From 8f3dac7d2bb727fe05577f74acefaf5fea1e5123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 28 Sep 2022 08:53:22 -0700 Subject: [PATCH 001/700] Update dependencies --- sass-embedded.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 70180109..7c44bfd0 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.required_ruby_version = '>= 2.6.0' - spec.add_runtime_dependency 'google-protobuf', '~> 3.19' + spec.add_runtime_dependency 'google-protobuf', '~> 3.21' if ENV.key?('gem_platform') spec.add_development_dependency 'rake', '>= 10.0.0' @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.36.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.13.1' + spec.add_development_dependency 'rubocop-rspec', '~> 2.13.2' end From 6b70d1532ebae772d98f7c25bc9bf2f230f29229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 30 Sep 2022 20:22:14 -0700 Subject: [PATCH 002/700] Refactor send_message --- lib/sass/embedded/channel.rb | 4 +- lib/sass/embedded/dispatcher.rb | 6 +-- lib/sass/embedded/host.rb | 74 ++++++++++++++------------------- 3 files changed, 36 insertions(+), 48 deletions(-) diff --git a/lib/sass/embedded/channel.rb b/lib/sass/embedded/channel.rb index e68fbb25..d5e743a0 100644 --- a/lib/sass/embedded/channel.rb +++ b/lib/sass/embedded/channel.rb @@ -48,8 +48,8 @@ def disconnect @dispatcher.unsubscribe(id) end - def send_message(message) - @dispatcher.send_message(message) + def send_message(**kwargs) + @dispatcher.send_message(**kwargs) end end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index fdebdf38..dd183ece 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -16,7 +16,7 @@ def initialize Thread.new do loop do - receive_message EmbeddedProtocol::OutboundMessage.decode @compiler.read + receive_message(EmbeddedProtocol::OutboundMessage.decode(@compiler.read)) rescue IOError, Errno::EBADF => e @mutex.synchronize do @id = PROTOCOL_ERROR_ID @@ -56,8 +56,8 @@ def closed? @compiler.closed? end - def send_message(inbound_message) - @compiler.write(inbound_message.to_proto) + def send_message(**kwargs) + @compiler.write(EmbeddedProtocol::InboundMessage.new(**kwargs).to_proto) end private diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 8df7626f..4b1e8310 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -19,8 +19,8 @@ def id @connection.id end - def send_message(message) - @connection.send_message(message) + def send_message(**kwargs) + @connection.send_message(**kwargs) end def compile_request(path:, @@ -47,40 +47,36 @@ def compile_request(path:, @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color: alert_color) @logger_registry = LoggerRegistry.new(logger) - send_message EmbeddedProtocol::InboundMessage.new( - compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( - id: id, - string: unless source.nil? - EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( - source: source, - url: url&.to_s, - syntax: Protofier.to_proto_syntax(syntax), - importer: (@importer_registry.register(importer) unless importer.nil?) - ) - end, - path: (File.absolute_path(path) unless path.nil?), - style: Protofier.to_proto_output_style(style), - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - importers: @importer_registry.importers, - global_functions: @function_registry.global_functions, - alert_ascii: alert_ascii, - alert_color: alert_color, - quiet_deps: quiet_deps, - verbose: verbose - ) - ) + send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( + id: id, + string: unless source.nil? + EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( + source: source, + url: url&.to_s, + syntax: Protofier.to_proto_syntax(syntax), + importer: (@importer_registry.register(importer) unless importer.nil?) + ) + end, + path: (File.absolute_path(path) unless path.nil?), + style: Protofier.to_proto_output_style(style), + charset: charset, + source_map: source_map, + source_map_include_sources: source_map_include_sources, + importers: @importer_registry.importers, + global_functions: @function_registry.global_functions, + alert_ascii: alert_ascii, + alert_color: alert_color, + quiet_deps: quiet_deps, + verbose: verbose + )) end end def version_request await do - send_message EmbeddedProtocol::InboundMessage.new( - version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( - id: id - ) - ) + send_message(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( + id: id + )) end end @@ -97,27 +93,19 @@ def version_response(message) end def canonicalize_request(message) - send_message EmbeddedProtocol::InboundMessage.new( - canonicalize_response: @importer_registry.canonicalize(message) - ) + send_message(canonicalize_response: @importer_registry.canonicalize(message)) end def import_request(message) - send_message EmbeddedProtocol::InboundMessage.new( - import_response: @importer_registry.import(message) - ) + send_message(import_response: @importer_registry.import(message)) end def file_import_request(message) - send_message EmbeddedProtocol::InboundMessage.new( - file_import_response: @importer_registry.file_import(message) - ) + send_message(file_import_response: @importer_registry.file_import(message)) end def function_call_request(message) - send_message EmbeddedProtocol::InboundMessage.new( - function_call_response: @function_registry.function_call(message) - ) + send_message(function_call_response: @function_registry.function_call(message)) end def error(message) From e6d59f1fa3375ec0c7997b1bfad4786fea85dc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 3 Oct 2022 01:15:04 -0700 Subject: [PATCH 003/700] Refactor receive_message --- lib/sass/embedded/dispatcher.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index dd183ece..bfc489ec 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -16,7 +16,7 @@ def initialize Thread.new do loop do - receive_message(EmbeddedProtocol::OutboundMessage.decode(@compiler.read)) + receive_message rescue IOError, Errno::EBADF => e @mutex.synchronize do @id = PROTOCOL_ERROR_ID @@ -62,7 +62,8 @@ def send_message(**kwargs) private - def receive_message(outbound_message) + def receive_message + outbound_message = EmbeddedProtocol::OutboundMessage.decode(@compiler.read) oneof = outbound_message.message message = outbound_message.public_send(oneof) case oneof From bc9e4a312931d97e03e6abad15b694169ddc3dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 6 Oct 2022 08:53:35 -0700 Subject: [PATCH 004/700] Set required_rubygems_version >= 3.3.22 for linux-gnu gems --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 7c44bfd0..5c242ec9 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA if ENV.key?('gem_platform') spec.files += Dir['ext/sass/*.rb'] + Dir['ext/sass/sass_embedded/**/*'] spec.platform = ENV['gem_platform'] - spec.required_rubygems_version = '>= 3.3.21' if ENV['gem_platform'].include?('-linux-') + spec.required_rubygems_version = '>= 3.3.22' if ENV['gem_platform'].include?('-linux-') else spec.extensions = ['ext/sass/Rakefile'] spec.files += Dir['ext/sass/*_pb.rb'] + [ From 67bd0fa53def20553d6ddf6f8576daef41dccec3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:18:35 +0000 Subject: [PATCH 005/700] Update rubocop requirement from ~> 1.36.0 to ~> 1.37.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.36.0...v1.37.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 5c242ec9..43675b07 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.11.0' - spec.add_development_dependency 'rubocop', '~> 1.36.0' + spec.add_development_dependency 'rubocop', '~> 1.37.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.13.2' From 5f9152a66a6fb4c445ce41cd941d647271d1ddd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:53:58 +0000 Subject: [PATCH 006/700] Update rubocop-rspec requirement from ~> 2.13.2 to ~> 2.14.1 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.13.2...v2.14.1) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 43675b07..7f0dd47e 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.37.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.13.2' + spec.add_development_dependency 'rubocop-rspec', '~> 2.14.1' end From 1cf4bfae40dad05ab39db029828963e7361fefc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Oct 2022 17:58:23 -0700 Subject: [PATCH 007/700] Update rubocop-rspec requirement from ~> 2.14.1 to ~> 2.14.2 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 7f0dd47e..756fbec1 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.37.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.14.1' + spec.add_development_dependency 'rubocop-rspec', '~> 2.14.2' end From 355e90845a07c398378a90b79548db16320a250e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Oct 2022 20:03:00 -0700 Subject: [PATCH 008/700] Update rubocop requirement from ~> 1.37.0 to ~> 1.37.1 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 756fbec1..91ba7a60 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.11.0' - spec.add_development_dependency 'rubocop', '~> 1.37.0' + spec.add_development_dependency 'rubocop', '~> 1.37.1' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.14.2' From ebcae5efead1d6eedb0371b82b062d28304e5a4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 16:17:08 +0000 Subject: [PATCH 009/700] Update rspec requirement from ~> 3.11.0 to ~> 3.12.0 Updates the requirements on [rspec](https://github.com/rspec/rspec-metagem) to permit the latest version. - [Release notes](https://github.com/rspec/rspec-metagem/releases) - [Commits](https://github.com/rspec/rspec-metagem/compare/v3.11.0...v3.12.0) --- updated-dependencies: - dependency-name: rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 91ba7a60..940455c4 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_runtime_dependency 'rake', '>= 10.0.0' end - spec.add_development_dependency 'rspec', '~> 3.11.0' + spec.add_development_dependency 'rspec', '~> 3.12.0' spec.add_development_dependency 'rubocop', '~> 1.37.1' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' From b6ce0098e94ca5695f30ba081ffac5a3af334c2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Nov 2022 15:42:55 +0000 Subject: [PATCH 010/700] Update rubocop requirement from ~> 1.37.1 to ~> 1.38.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.37.1...v1.38.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 940455c4..71208af7 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.37.1' + spec.add_development_dependency 'rubocop', '~> 1.38.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.14.2' From 4666900114db996e4d7e03773374f68eb5137372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 3 Nov 2022 16:26:54 -0700 Subject: [PATCH 011/700] Update build.yml --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b9772e8..891716c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] ruby-version: ['2.6', '2.7', '3.0', 'ruby', 'jruby', 'truffleruby', 'truffleruby+graalvm'] @@ -55,6 +56,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] ruby-version: ['2.6', '2.7', '3.0', 'ruby', 'jruby', 'truffleruby', 'truffleruby+graalvm'] From 15a1da9f4fae55ee3ba56f845fc87fde5d5adceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 3 Nov 2022 16:27:21 -0700 Subject: [PATCH 012/700] Update release.yml --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ff59a64..38c9a2e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,6 +40,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: include: - os: macos-latest From 98055fae27e2f755b0392abd97148b5f402d1a94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:11:29 +0000 Subject: [PATCH 013/700] Update rubocop-rspec requirement from ~> 2.14.2 to ~> 2.15.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.14.2...v2.15.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 71208af7..330bfed6 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.38.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.14.2' + spec.add_development_dependency 'rubocop-rspec', '~> 2.15.0' end From ff19d3c8ff79c01f5b436a3514aea14867bbe44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 9 Nov 2022 06:42:58 +0000 Subject: [PATCH 014/700] Do not broadcast :PARAMS type ProtocolError so that CompileError will be received --- lib/sass/embedded/dispatcher.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index bfc489ec..be056e28 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -70,7 +70,13 @@ def receive_message when :error @mutex.synchronize do @id = PROTOCOL_ERROR_ID - message.id == PROTOCOL_ERROR_ID ? @observers.values : [@observers[message.id]] + if message.type == :PARAMS + [] + elsif message.id == PROTOCOL_ERROR_ID + @observers.values + else + [@observers[message.id]] + end end.each do |observer| observer.public_send(oneof, message) end From c7d7062068f58b80f431752c9f1c3ccb3378ff49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 3 Nov 2022 22:48:58 -0700 Subject: [PATCH 015/700] Test invalid contents for importer results --- spec/sass_importer_spec.rb | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 7adc8f56..5e510329 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -652,4 +652,49 @@ def expect_from_import(canonicalize, expected) end end end + + describe 'when importer does not return string contents' do + it 'throws an error in sync mode' do + expect do + described_class.compile_string( + '@import "other";', + importers: [{ + canonicalize: ->(url, **) { "u:#{url}" }, + load: lambda { |*| + return { + contents: StringIO.new('not a string'), + syntax: 'scss' + } + } + }] + ) + end.to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.span.start.line).to eq(0) + expect(error.message).to include("Invalid argument for string field 'contents' (given StringIO)") + end + end + end + + it 'throws an ArgumentError when the result source_map_url is missing a scheme' do + expect do + described_class.compile_string( + '@import "other";', + importers: [{ + canonicalize: ->(url, **) { "u:#{url}" }, + load: lambda { |*| + return { + contents: '', + syntax: 'scss', + source_map_url: {} + } + } + }] + ) + end.to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.span.start.line).to eq(0) + expect(error.message).to include('ImportResponse.success.source_map_url must be absolute') + end + end end From 2bb6634256a645eb68316a6a05f6be316f45a5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 9 Nov 2022 09:49:33 -0800 Subject: [PATCH 016/700] Bump sass-embedded from 1.55.0 to 1.56.1 in /ext/sass --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index cf834056..99c74276 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.55.0" + "sass-embedded": "1.56.1" } } From b477a95ac4c6525d14df66081525c6ee1500cdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 9 Nov 2022 18:14:27 -0800 Subject: [PATCH 017/700] v1.56.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 0995a78e..a7bfdaa0 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.55.0' + VERSION = '1.56.1' end end From bf7761034163fc2439df738d093fb0943218e610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 10 Nov 2022 16:59:40 -0800 Subject: [PATCH 018/700] Mark host methods as private --- lib/sass/embedded/host.rb | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 4b1e8310..c16e0973 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -15,14 +15,6 @@ def initialize(channel) @channel = channel end - def id - @connection.id - end - - def send_message(**kwargs) - @connection.send_message(**kwargs) - end - def compile_request(path:, source:, importer:, @@ -85,11 +77,11 @@ def log_event(message) end def compile_response(message) - @async.resolve(message) + resolve(message) end def version_response(message) - @async.resolve(message) + resolve(message) end def canonicalize_request(message) @@ -109,7 +101,7 @@ def function_call_request(message) end def error(message) - @async.reject(CompileError.new(message.message, nil, nil, nil)) + reject(CompileError.new(message.message, nil, nil, nil)) end private @@ -122,6 +114,22 @@ def await ensure @connection&.disconnect end + + def resolve(value) + @async.resolve(value) + end + + def reject(reason) + @async.reject(reason) + end + + def id + @connection.id + end + + def send_message(**kwargs) + @connection.send_message(**kwargs) + end end private_constant :Host From f5f33b264e863a41f025eead9f937275fd3e0e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 11 Nov 2022 02:55:47 +0000 Subject: [PATCH 019/700] Remove unused code --- lib/sass/embedded/async.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/sass/embedded/async.rb b/lib/sass/embedded/async.rb index 9de80e29..a73c0ae8 100644 --- a/lib/sass/embedded/async.rb +++ b/lib/sass/embedded/async.rb @@ -21,12 +21,6 @@ def initialize @condition_variable = ConditionVariable.new @mutex = Mutex.new - - begin - yield if block_given? - rescue StandardError => e - reject e - end end def resolve(value) From 9460230b213a3e8c6e7453bd0465199b9065411c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 11 Nov 2022 13:07:35 -0800 Subject: [PATCH 020/700] Update async.rb --- lib/sass/embedded/async.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/sass/embedded/async.rb b/lib/sass/embedded/async.rb index a73c0ae8..78a07f5e 100644 --- a/lib/sass/embedded/async.rb +++ b/lib/sass/embedded/async.rb @@ -15,7 +15,6 @@ module State private_constant :State def initialize - @error = nil @result = nil @state = State::PENDING @@ -38,7 +37,7 @@ def reject(reason) return unless @state == State::PENDING @state = State::REJECTED - @error = reason + @result = reason @condition_variable.broadcast end end @@ -47,7 +46,7 @@ def await @mutex.synchronize do @condition_variable.wait(@mutex) if @state == State::PENDING - raise @error if @state == State::REJECTED + raise @result if @state == State::REJECTED @result end From 052c0a0e1c77214ad975b374e679b040688f7f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 11 Nov 2022 13:08:34 -0800 Subject: [PATCH 021/700] Update async.rb --- lib/sass/embedded/async.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/embedded/async.rb b/lib/sass/embedded/async.rb index 78a07f5e..51bc3869 100644 --- a/lib/sass/embedded/async.rb +++ b/lib/sass/embedded/async.rb @@ -26,8 +26,8 @@ def resolve(value) @mutex.synchronize do return unless @state == State::PENDING - @state = State::FULFILLED @result = value + @state = State::FULFILLED @condition_variable.broadcast end end @@ -36,8 +36,8 @@ def reject(reason) @mutex.synchronize do return unless @state == State::PENDING - @state = State::REJECTED @result = reason + @state = State::REJECTED @condition_variable.broadcast end end From 1a47f57c8682fd257762289310823d823055d98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 13 Nov 2022 09:34:31 -0800 Subject: [PATCH 022/700] Fix old versions of powershell - Closes #79 --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index cb0aa9a0..572f4a59 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -105,7 +105,7 @@ module FileUtils if RUBY_PLATFORM == 'java' junzip archive, dest elsif Gem.win_platform? - powershell 'expand-archive.ps1', '-Force', '-LiteralPath', archive, '-DestinationPath', dest, '-PassThru' + powershell 'expand-archive.ps1', '-Force', '-LiteralPath', archive, '-DestinationPath', dest else sh 'unzip', '-od', dest, archive end From 4f12f0f6ee9a0615016cd796d2d73635363243f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 15:45:53 +0000 Subject: [PATCH 023/700] Update rubocop requirement from ~> 1.38.0 to ~> 1.39.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.38.0...v1.39.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 330bfed6..f4f5acf4 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.38.0' + spec.add_development_dependency 'rubocop', '~> 1.39.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.15.0' From d243475b32a34c835daf10c513501e454e98c4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 17 Nov 2022 21:09:06 -0800 Subject: [PATCH 024/700] Make function name parsing consistent with compiler --- lib/sass/embedded/host/function_registry.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/sass/embedded/host/function_registry.rb b/lib/sass/embedded/host/function_registry.rb index 9b97c3a4..ec2b79b9 100644 --- a/lib/sass/embedded/host/function_registry.rb +++ b/lib/sass/embedded/host/function_registry.rb @@ -14,12 +14,11 @@ def initialize(functions, alert_color:) @global_functions = functions.keys @functions_by_name = functions.transform_keys do |signature| - signature = signature.chomp index = signature.index('(') if index - signature.slice(0, index) + signature.slice(0, index).chomp else - signature + signature.chomp end end From 098e971a2fd2f3f3a68cdcb5a24bcfcb4ec2c2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 20 Nov 2022 00:14:31 -0800 Subject: [PATCH 025/700] Update value_protofier.rb --- lib/sass/embedded/host/value_protofier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index fc724a41..bf2684d9 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -180,7 +180,7 @@ def from_proto(proto) when :compiler_function Sass::Value::Function.new(obj.id) when :host_function - raise ProtocolError, 'The compiler may not send Value.host_function to host' + raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :singleton case obj when :TRUE From 6e6d7a75ec38af4c0519aaafadb18de269f10cb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Dec 2022 16:04:05 +0000 Subject: [PATCH 026/700] Update rubocop requirement from ~> 1.39.0 to ~> 1.40.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.39.0...v1.40.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index f4f5acf4..33e1d1b9 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.39.0' + spec.add_development_dependency 'rubocop', '~> 1.40.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.15.0' From e94895e6d0b364020761ce9839398ef03f5d95d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 8 Dec 2022 15:06:27 -0800 Subject: [PATCH 027/700] Bump sass-embedded from 1.56.1 to 1.56.2 in /ext/sass --- ext/sass/package.json | 2 +- lib/sass/embedded/dispatcher.rb | 8 +------- spec/sass_importer_spec.rb | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 99c74276..ee59b3f4 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.56.1" + "sass-embedded": "1.56.2" } } diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index be056e28..bfc489ec 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -70,13 +70,7 @@ def receive_message when :error @mutex.synchronize do @id = PROTOCOL_ERROR_ID - if message.type == :PARAMS - [] - elsif message.id == PROTOCOL_ERROR_ID - @observers.values - else - [@observers[message.id]] - end + message.id == PROTOCOL_ERROR_ID ? @observers.values : [@observers[message.id]] end.each do |observer| observer.public_send(oneof, message) end diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 5e510329..a1bb0959 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -694,7 +694,7 @@ def expect_from_import(canonicalize, expected) end.to raise_error do |error| expect(error).to be_a(Sass::CompileError) expect(error.span.start.line).to eq(0) - expect(error.message).to include('ImportResponse.success.source_map_url must be absolute') + expect(error.message).to include('The importer must return an absolute URL') end end end From 5d643fbbc924cbe69837ba98c8f720a1163f9911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 8 Dec 2022 15:28:07 -0800 Subject: [PATCH 028/700] Leverage compiler side validation --- lib/sass/embedded/host/importer_registry.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/sass/embedded/host/importer_registry.rb b/lib/sass/embedded/host/importer_registry.rb index ac1b1aa1..18276f3e 100644 --- a/lib/sass/embedded/host/importer_registry.rb +++ b/lib/sass/embedded/host/importer_registry.rb @@ -86,10 +86,6 @@ def file_import(file_import_request) importer = @importers_by_id[file_import_request.importer_id] file_url = importer.find_file_url(file_import_request.url, from_import: file_import_request.from_import)&.to_s - if !file_url.nil? && !file_url.start_with?('file:') - raise "file_url must be a file: URL, was #{file_url.inspect}" - end - EmbeddedProtocol::InboundMessage::FileImportResponse.new( id: file_import_request.id, file_url: file_url From 3166fc9febff50c1e5f01744f4e046927bdc4d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 8 Dec 2022 15:43:23 -0800 Subject: [PATCH 029/700] v1.56.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index a7bfdaa0..69d8dc35 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.56.1' + VERSION = '1.56.2' end end From c00b132dd33835055283d13c17c8836782f84cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Dec 2022 10:28:59 -0800 Subject: [PATCH 030/700] Make sure umask is applied for tar extraction --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 572f4a59..a04be844 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -100,7 +100,7 @@ module FileUtils case archive.downcase when ->(name) { name.include?('.tar.') || name.end_with?('.tar') } mkdir_p dest - sh 'tar', '-vxC', dest, '-f', archive + sh 'tar', '-vxC', dest, '-f', archive, '--no-same-permissions' when ->(name) { name.end_with?('.zip') } if RUBY_PLATFORM == 'java' junzip archive, dest From 22f6b1181ce91121d22b0fd956efe8a86b0cff48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Dec 2022 11:07:21 -0800 Subject: [PATCH 031/700] Update Rakefile --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index a04be844..7ae755c2 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -100,7 +100,7 @@ module FileUtils case archive.downcase when ->(name) { name.include?('.tar.') || name.end_with?('.tar') } mkdir_p dest - sh 'tar', '-vxC', dest, '-f', archive, '--no-same-permissions' + sh 'tar', '-vxC', dest, '-f', archive, '--no-same-owner', '--no-same-permissions' when ->(name) { name.end_with?('.zip') } if RUBY_PLATFORM == 'java' junzip archive, dest From 846e162d3f00a8385276b8a373e529e56eda0dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 12 Dec 2022 00:06:18 -0800 Subject: [PATCH 032/700] Update function_registry.rb --- lib/sass/embedded/host/function_registry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/host/function_registry.rb b/lib/sass/embedded/host/function_registry.rb index ec2b79b9..7627a33a 100644 --- a/lib/sass/embedded/host/function_registry.rb +++ b/lib/sass/embedded/host/function_registry.rb @@ -18,7 +18,7 @@ def initialize(functions, alert_color:) if index signature.slice(0, index).chomp else - signature.chomp + signature end end From 0dd4d3fed5ffc101ed70045963bf5c4bcc98754a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 12 Dec 2022 18:15:14 -0800 Subject: [PATCH 033/700] Fix function name parsing with whitespace --- lib/sass/embedded/host/function_registry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/host/function_registry.rb b/lib/sass/embedded/host/function_registry.rb index 7627a33a..ac2d869f 100644 --- a/lib/sass/embedded/host/function_registry.rb +++ b/lib/sass/embedded/host/function_registry.rb @@ -16,7 +16,7 @@ def initialize(functions, alert_color:) @functions_by_name = functions.transform_keys do |signature| index = signature.index('(') if index - signature.slice(0, index).chomp + signature.slice(0, index).rstrip else signature end From e6651b48f4b03dff97dfa0f1e3130f5365a6683c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Dec 2022 16:08:01 +0000 Subject: [PATCH 034/700] Update rubocop-rspec requirement from ~> 2.15.0 to ~> 2.16.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.15.0...v2.16.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 33e1d1b9..dfd2cdd8 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.40.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.15.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0' end From 55a52e205554911498a0c6527d9c22408ba73df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 13 Dec 2022 21:43:33 -0800 Subject: [PATCH 035/700] Update function_registry.rb --- lib/sass/embedded/host/function_registry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/host/function_registry.rb b/lib/sass/embedded/host/function_registry.rb index ac2d869f..9ec2c973 100644 --- a/lib/sass/embedded/host/function_registry.rb +++ b/lib/sass/embedded/host/function_registry.rb @@ -16,7 +16,7 @@ def initialize(functions, alert_color:) @functions_by_name = functions.transform_keys do |signature| index = signature.index('(') if index - signature.slice(0, index).rstrip + signature.slice(0, index) else signature end From 35f6a8f330e418a2c7ede103f1582a25562477d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Dec 2022 01:43:44 +0000 Subject: [PATCH 036/700] Bump sass-embedded from 1.56.2 to 1.57.1 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.56.2 to 1.57.1. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.56.2...1.57.1) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index ee59b3f4..c7d9e84d 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.56.2" + "sass-embedded": "1.57.1" } } From 516fe6feb61fc38d9b1fc8ed1b0b503ef1ebea14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 12 Dec 2022 20:29:29 -0800 Subject: [PATCH 037/700] Test function signature parsing with whitespace --- spec/sass_function_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index 1e53be31..559d73e2 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -198,5 +198,23 @@ described_class.compile_string('', functions: { '$foo()': -> { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end + + it 'has whitespace before the signature' do + expect do + described_class.compile_string('', functions: { ' foo()': -> { Sass::Value::Null::NULL } }) + end.to raise_error(Sass::CompileError) + end + + it 'has whitespace after the signature' do + expect do + described_class.compile_string('', functions: { 'foo() ': -> { Sass::Value::Null::NULL } }) + end.to raise_error(Sass::CompileError) + end + + it 'has whitespace between the identifier and the arguments' do + expect do + described_class.compile_string('', functions: { 'foo ()': -> { Sass::Value::Null::NULL } }) + end.to raise_error(Sass::CompileError) + end end end From 37b18531e454525954707e3fbdd402dd27aad0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 19 Dec 2022 18:30:58 -0800 Subject: [PATCH 038/700] v1.57.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 69d8dc35..c14f55a5 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.56.2' + VERSION = '1.57.1' end end From 20b40b20c5ee4f95cd3c95c0cb3d2ef2b0d62d9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Dec 2022 15:37:20 +0000 Subject: [PATCH 039/700] Update rubocop requirement from ~> 1.40.0 to ~> 1.41.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.40.0...v1.41.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index dfd2cdd8..6d6b7738 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.40.0' + spec.add_development_dependency 'rubocop', '~> 1.41.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0' From e87a1b7bf54b76228e6871879617a3d902c5baba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 20 Dec 2022 16:40:29 -0800 Subject: [PATCH 040/700] Reset id when no requests are pending --- lib/sass/embedded/dispatcher.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index bfc489ec..62490c6d 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -44,7 +44,13 @@ def unsubscribe(id) @mutex.synchronize do @observers.delete(id) - close if @id == PROTOCOL_ERROR_ID && @observers.empty? + return unless @observers.empty? + + if @id == PROTOCOL_ERROR_ID + close + else + @id = 0 + end end end From 53f41a9422a32ea2cafad7f5579f5ebdabd50265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 22 Dec 2022 02:59:08 -0800 Subject: [PATCH 041/700] Update build.yml --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 891716c3..8add0bd0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,8 +27,18 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - ruby-version: ['2.6', '2.7', '3.0', 'ruby', 'jruby', 'truffleruby', 'truffleruby+graalvm'] + os: + - macos-latest + - ubuntu-latest + - windows-latest + ruby-version: + - '2.6' + - '2.7' + - '3.0' + - '3.1' + - jruby + - truffleruby + - truffleruby+graalvm exclude: - os: windows-latest ruby-version: truffleruby @@ -58,8 +68,18 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - ruby-version: ['2.6', '2.7', '3.0', 'ruby', 'jruby', 'truffleruby', 'truffleruby+graalvm'] + os: + - macos-latest + - ubuntu-latest + - windows-latest + ruby-version: + - '2.6' + - '2.7' + - '3.0' + - '3.1' + - jruby + - truffleruby + - truffleruby+graalvm exclude: - os: windows-latest ruby-version: truffleruby From 253f1750dce25a7fad73e61dca082a4c4001d405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 23 Dec 2022 12:31:53 -0800 Subject: [PATCH 042/700] Synchronize singleton instance construction --- lib/sass/embedded.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 78a707b1..31e91e9c 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -28,6 +28,11 @@ # @example # Sass.compile_string('h1 { font-size: 40px; }') module Sass + instance_eval do + @instance = nil + @mutex = Mutex.new + end + class << self # Compiles the Sass file at +path+ to CSS. # @param (see Embedded#compile) @@ -58,14 +63,17 @@ def info private def instance - if defined? @instance - @instance = Embedded.new if @instance.closed? - else + return @instance if @instance + + @mutex.synchronize do + return @instance if @instance + @instance = Embedded.new at_exit do @instance.close end end + @instance end end From ecc135fb0fa74c1a7bf53e607ef57059905bbbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 24 Dec 2022 01:13:52 -0800 Subject: [PATCH 043/700] Update embedded.rb --- lib/sass/embedded.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 31e91e9c..2e001c93 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -28,10 +28,8 @@ # @example # Sass.compile_string('h1 { font-size: 40px; }') module Sass - instance_eval do - @instance = nil - @mutex = Mutex.new - end + @instance = nil + @mutex = Mutex.new class << self # Compiles the Sass file at +path+ to CSS. From b2ec76a9f50eae29efb8039686858d41eb400e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 25 Dec 2022 21:44:54 -0800 Subject: [PATCH 044/700] Test ruby 3.2 --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8add0bd0..93b344f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,10 +36,13 @@ jobs: - '2.7' - '3.0' - '3.1' + - '3.2' - jruby - truffleruby - truffleruby+graalvm exclude: + - os: windows-latest + ruby-version: '3.2' - os: windows-latest ruby-version: truffleruby - os: windows-latest @@ -77,10 +80,13 @@ jobs: - '2.7' - '3.0' - '3.1' + - '3.2' - jruby - truffleruby - truffleruby+graalvm exclude: + - os: windows-latest + ruby-version: '3.2' - os: windows-latest ruby-version: truffleruby - os: windows-latest From bb2636e896be6a75130ad29044b93f27a54dc958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 26 Dec 2022 12:12:43 -0800 Subject: [PATCH 045/700] Update dispatcher.rb --- lib/sass/embedded/dispatcher.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 62490c6d..fc8f6761 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -63,7 +63,8 @@ def closed? end def send_message(**kwargs) - @compiler.write(EmbeddedProtocol::InboundMessage.new(**kwargs).to_proto) + inbound_message = EmbeddedProtocol::InboundMessage.new(**kwargs) + @compiler.write(inbound_message.to_proto) end private From d89435e4994b1ab56cadd4987e044fcbf183e63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 30 Dec 2022 23:19:46 -0800 Subject: [PATCH 046/700] Test ruby 3.2 on windows --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93b344f4..cc3cf4dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,8 +41,6 @@ jobs: - truffleruby - truffleruby+graalvm exclude: - - os: windows-latest - ruby-version: '3.2' - os: windows-latest ruby-version: truffleruby - os: windows-latest @@ -85,8 +83,6 @@ jobs: - truffleruby - truffleruby+graalvm exclude: - - os: windows-latest - ruby-version: '3.2' - os: windows-latest ruby-version: truffleruby - os: windows-latest From 2c2e12a8e6c5d97c3963bfc15784701458c57a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 1 Jan 2023 22:01:24 -0800 Subject: [PATCH 047/700] Make ArgumentList#clone and ArgumentList#dup return a host value --- lib/sass/value/argument_list.rb | 7 +++++++ lib/sass/value/number.rb | 2 +- spec/sass_proto_spec.rb | 5 +---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 8723125a..61b63106 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -25,6 +25,13 @@ def keywords @keywords_accessed = true @keywords end + + private + + def initialize_copy(orig) + super + @id = 0 + end end end end diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index 0bc6c5b3..a0182299 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -253,7 +253,7 @@ def assert_number(_name = nil) self end - protected + private def single_unit? numerator_units.length == 1 && denominator_units.empty? diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 8596f8da..563387af 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -6,10 +6,7 @@ def remote_eq(lhs, rhs) to_host_value = lambda { |value| if value.is_a? Sass::Value::ArgumentList - value.dup.instance_eval do - @id = 0 - self - end + value.dup else value end From e14de4a89c8f8d11f42f8cc372370feca81274e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Jan 2023 10:42:34 -0800 Subject: [PATCH 048/700] Update rubocop requirement from ~> 1.41.0 to ~> 1.42.0 (#90) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.41.0 to ~> 1.42.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Fix lint issues Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- lib/sass/embedded/varint.rb | 2 +- lib/sass/value/color.rb | 12 ++++++------ lib/sass/value/number/unit.rb | 4 ++-- sass-embedded.gemspec | 2 +- spec/sass/value/number_spec.rb | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/sass/embedded/varint.rb b/lib/sass/embedded/varint.rb index 2c63cbbd..3373bc9b 100644 --- a/lib/sass/embedded/varint.rb +++ b/lib/sass/embedded/varint.rb @@ -22,7 +22,7 @@ def read(readable) def write(writeable, value) bytes = [] until value < 0x80 - bytes << (0x80 | (value & 0x7f)) + bytes << ((value & 0x7f) | 0x80) value >>= 7 end bytes << value diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 48eaab6f..04c233f7 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -178,21 +178,21 @@ def rgb_to_hsl if max == min @hue = 0 elsif max == scaled_red - @hue = (60 * (scaled_green - scaled_blue) / delta) % 360 + @hue = ((scaled_green - scaled_blue) * 60 / delta) % 360 elsif max == scaled_green - @hue = (120 + (60 * (scaled_blue - scaled_red) / delta)) % 360 + @hue = (((scaled_blue - scaled_red) * 60 / delta) + 120) % 360 elsif max == scaled_blue - @hue = (240 + (60 * (scaled_red - scaled_green) / delta)) % 360 + @hue = (((scaled_red - scaled_green) * 60 / delta) + 240) % 360 end - lightness = @lightness = 50 * (max + min) + lightness = @lightness = (max + min) * 50 @saturation = if max == min 0 elsif lightness < 50 - 100 * delta / (max + min) + delta * 100 / (max + min) else - 100 * delta / (2 - max - min) + delta * 100 / (2 - max - min) end end diff --git a/lib/sass/value/number/unit.rb b/lib/sass/value/number/unit.rb index ba3f385e..bb0a418a 100644 --- a/lib/sass/value/number/unit.rb +++ b/lib/sass/value/number/unit.rb @@ -88,12 +88,12 @@ module Unit 'deg' => Rational(Math::PI, 180), 'grad' => Rational(Math::PI, 200), 'rad' => Rational(1), - 'turn' => Rational(2 * Math::PI) + 'turn' => Rational(Math::PI * 2) }, 'turn' => { 'deg' => Rational(1, 360), 'grad' => Rational(1, 400), - 'rad' => Rational(1, 2 * Math::PI), + 'rad' => Rational(1, Math::PI * 2), 'turn' => Rational(1) }, diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 6d6b7738..2958a75a 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.41.0' + spec.add_development_dependency 'rubocop', '~> 1.42.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0' diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 5861dcdb..9ed540f6 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -70,14 +70,14 @@ end it 'equals the same number within precision tolerance' do - expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) + expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) # rubocop:disable Style/YodaExpression expect(number).to eq(described_class.new(123 - 10.pow(-precision - 2))) end it "doesn't equal a different number" do expect(number).not_to eq(described_class.new(122)) expect(number).not_to eq(described_class.new(124)) - expect(number).not_to eq(described_class.new(123 + 10.pow(-precision - 1))) + expect(number).not_to eq(described_class.new(123 + 10.pow(-precision - 1))) # rubocop:disable Style/YodaExpression expect(number).not_to eq(described_class.new(123 - 10.pow(-precision - 1))) end @@ -191,7 +191,7 @@ end it 'equals the same number' do - expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) + expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) # rubocop:disable Style/YodaExpression end it 'equals the same number within precision tolerance' do From 5349a62c584f5d600314586f51db821efdddb36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 6 Jan 2023 13:59:44 -0800 Subject: [PATCH 049/700] Optimize dart aot runtime launch speed --- Rakefile | 2 +- ext/sass/Rakefile | 27 +++++++++++++++++++++------ lib/sass/embedded/compiler.rb | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index f64444cb..f259295f 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,7 @@ require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' -task default: %i[rubocop compile spec] +task default: %i[compile rubocop spec] desc 'Compile all the extensions' task :compile do diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 7ae755c2..358568f9 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -24,10 +24,25 @@ file 'sass_embedded' do |t| end file 'embedded.rb' => %w[sass_embedded] do |t| - path = 'sass_embedded/dart-sass-embedded' - path = "#{path}#{['.exe', '.bat'].find { |ext| File.exist? "#{path}#{ext}" }}" unless File.exist? path - - raise "#{path} not found" unless File.exist? path + exe = 'sass_embedded/dart-sass-embedded' + exe = "#{exe}#{['.exe', '.bat'].find { |ext| File.exist?("#{exe}#{ext}") }}" unless File.exist?(exe) + + raise "#{exe} not found" unless File.exist?(exe) + + runtime = 'sass_embedded/src/dart' + runtime = "#{runtime}#{['.exe', '.bat'].find { |ext| File.exist?("#{runtime}#{ext}") }}" unless File.exist?(runtime) + snapshot = 'sass_embedded/src/dart-sass-embedded.snapshot' + + command = if File.exist?(runtime) && File.exist?(snapshot) + " + File.absolute_path('#{runtime}', __dir__).freeze, + File.absolute_path('#{snapshot}', __dir__).freeze + " + else + " + File.absolute_path('#{exe}', __dir__).freeze + " + end File.write(t.name, <<~EMBEDDED_RB) # frozen_string_literal: true @@ -35,7 +50,7 @@ file 'embedded.rb' => %w[sass_embedded] do |t| module Sass class Embedded class Compiler - PATH = File.absolute_path('#{path}', __dir__) + COMMAND = [#{command}].freeze end end end @@ -285,7 +300,7 @@ module Configuration require 'open3' require_relative 'embedded' - stdout, stderr, status = Open3.capture3(Sass::Embedded::Compiler::PATH, '--version') + stdout, stderr, status = Open3.capture3(*Sass::Embedded::Compiler::COMMAND, '--version') raise stderr unless status.success? diff --git a/lib/sass/embedded/compiler.rb b/lib/sass/embedded/compiler.rb index ac48e089..ed0f3ba7 100644 --- a/lib/sass/embedded/compiler.rb +++ b/lib/sass/embedded/compiler.rb @@ -9,7 +9,7 @@ class Embedded # It runs the `dart-sass-embedded` process. class Compiler def initialize - @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(PATH, chdir: __dir__) + @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(*COMMAND, chdir: __dir__) @stdin.binmode @stdout.binmode @stdin_mutex = Mutex.new From 1d986f0883bdad9b21bd5e051b5c7dcd946cb2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 6 Jan 2023 18:10:10 -0800 Subject: [PATCH 050/700] Update Rakefile --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 358568f9..3c2b385f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -30,7 +30,7 @@ file 'embedded.rb' => %w[sass_embedded] do |t| raise "#{exe} not found" unless File.exist?(exe) runtime = 'sass_embedded/src/dart' - runtime = "#{runtime}#{['.exe', '.bat'].find { |ext| File.exist?("#{runtime}#{ext}") }}" unless File.exist?(runtime) + runtime = "#{runtime}#{['.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}" unless File.exist?(runtime) snapshot = 'sass_embedded/src/dart-sass-embedded.snapshot' command = if File.exist?(runtime) && File.exist?(snapshot) From 4af14a23804901212b3507cc23e69179ae2b054e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 6 Jan 2023 22:06:16 -0800 Subject: [PATCH 051/700] Update Rakefile --- ext/sass/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 3c2b385f..b75d4adc 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -25,12 +25,12 @@ end file 'embedded.rb' => %w[sass_embedded] do |t| exe = 'sass_embedded/dart-sass-embedded' - exe = "#{exe}#{['.exe', '.bat'].find { |ext| File.exist?("#{exe}#{ext}") }}" unless File.exist?(exe) + exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" raise "#{exe} not found" unless File.exist?(exe) runtime = 'sass_embedded/src/dart' - runtime = "#{runtime}#{['.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}" unless File.exist?(runtime) + runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}" snapshot = 'sass_embedded/src/dart-sass-embedded.snapshot' command = if File.exist?(runtime) && File.exist?(snapshot) From f08525077596f20655d0cad54d20e168827ce3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 7 Jan 2023 09:51:55 +0000 Subject: [PATCH 052/700] Update Rakefile --- ext/sass/Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index b75d4adc..815e36c3 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -35,12 +35,12 @@ file 'embedded.rb' => %w[sass_embedded] do |t| command = if File.exist?(runtime) && File.exist?(snapshot) " - File.absolute_path('#{runtime}', __dir__).freeze, - File.absolute_path('#{snapshot}', __dir__).freeze + File.absolute_path('#{runtime}', __dir__), + File.absolute_path('#{snapshot}', __dir__) " else " - File.absolute_path('#{exe}', __dir__).freeze + File.absolute_path('#{exe}', __dir__) " end From fee2d2132e2c8d72d3e34522cc1c63c1d7068fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 7 Jan 2023 20:26:13 +0000 Subject: [PATCH 053/700] Encapsulate host logic --- lib/sass/embedded.rb | 78 +++++++++++++++++++-------------------- lib/sass/embedded/host.rb | 8 +++- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 2e001c93..621ec0e7 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -135,26 +135,24 @@ def compile(path, verbose: false) raise ArgumentError, 'path must be set' if path.nil? - Protofier.from_proto_compile_response( - Host.new(@channel).compile_request( - path: path, - source: nil, - importer: nil, - load_paths: load_paths, - syntax: nil, - url: nil, - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - style: style, - functions: functions, - importers: importers, - alert_color: alert_color, - alert_ascii: alert_ascii, - logger: logger, - quiet_deps: quiet_deps, - verbose: verbose - ) + Host.new(@channel).compile_request( + path: path, + source: nil, + importer: nil, + load_paths: load_paths, + syntax: nil, + url: nil, + charset: charset, + source_map: source_map, + source_map_include_sources: source_map_include_sources, + style: style, + functions: functions, + importers: importers, + alert_color: alert_color, + alert_ascii: alert_ascii, + logger: logger, + quiet_deps: quiet_deps, + verbose: verbose ) end @@ -211,33 +209,31 @@ def compile_string(source, verbose: false) raise ArgumentError, 'source must be set' if source.nil? - Protofier.from_proto_compile_response( - Host.new(@channel).compile_request( - path: nil, - source: source, - importer: importer, - load_paths: load_paths, - syntax: syntax, - url: url, - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - style: style, - functions: functions, - importers: importers, - alert_color: alert_color, - alert_ascii: alert_ascii, - logger: logger, - quiet_deps: quiet_deps, - verbose: verbose - ) + Host.new(@channel).compile_request( + path: nil, + source: source, + importer: importer, + load_paths: load_paths, + syntax: syntax, + url: url, + charset: charset, + source_map: source_map, + source_map_include_sources: source_map_include_sources, + style: style, + functions: functions, + importers: importers, + alert_color: alert_color, + alert_ascii: alert_ascii, + logger: logger, + quiet_deps: quiet_deps, + verbose: verbose ) end # @return [String] Information about the Sass implementation. # @see https://sass-lang.com/documentation/js-api/modules#info def info - @info ||= "sass-embedded\t#{Host.new(@channel).version_request.implementation_version}" + @info ||= Host.new(@channel).version_request end def close diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index c16e0973..5dbdd41c 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -32,7 +32,7 @@ def compile_request(path:, logger:, quiet_deps:, verbose:) - await do + compile_response = await do alert_color = $stderr.tty? if alert_color.nil? @function_registry = FunctionRegistry.new(functions, alert_color: alert_color) @@ -62,14 +62,18 @@ def compile_request(path:, verbose: verbose )) end + + Protofier.from_proto_compile_response(compile_response) end def version_request - await do + version_response = await do send_message(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( id: id )) end + + "sass-embedded\t#{version_response.implementation_version}" end def log_event(message) From fb97977323c9050933387e4f7c13c7c15d476e88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 09:09:28 -0800 Subject: [PATCH 054/700] Update rubocop requirement from ~> 1.42.0 to ~> 1.43.0 (#92) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.42.0 to ~> 1.43.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.42.0...v1.43.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Fix lint errors Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- sass-embedded.gemspec | 2 +- spec/sass/value/number_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 2958a75a..43549b76 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.42.0' + spec.add_development_dependency 'rubocop', '~> 1.43.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0' diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 9ed540f6..5861dcdb 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -70,14 +70,14 @@ end it 'equals the same number within precision tolerance' do - expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) # rubocop:disable Style/YodaExpression + expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) expect(number).to eq(described_class.new(123 - 10.pow(-precision - 2))) end it "doesn't equal a different number" do expect(number).not_to eq(described_class.new(122)) expect(number).not_to eq(described_class.new(124)) - expect(number).not_to eq(described_class.new(123 + 10.pow(-precision - 1))) # rubocop:disable Style/YodaExpression + expect(number).not_to eq(described_class.new(123 + 10.pow(-precision - 1))) expect(number).not_to eq(described_class.new(123 - 10.pow(-precision - 1))) end @@ -191,7 +191,7 @@ end it 'equals the same number' do - expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) # rubocop:disable Style/YodaExpression + expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) end it 'equals the same number within precision tolerance' do From 346b1e8b690395911131c5da8221bfc8f62e48d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 10 Jan 2023 10:57:58 -0800 Subject: [PATCH 055/700] Improve documentation for top level methods --- lib/sass/embedded.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 621ec0e7..72a0478c 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -31,8 +31,10 @@ module Sass @instance = nil @mutex = Mutex.new + # rubocop:disable Layout/LineLength class << self # Compiles the Sass file at +path+ to CSS. + # @overload compile(path, load_paths: [], charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, logger: nil, quiet_deps: false, verbose: false) # @param (see Embedded#compile) # @return (see Embedded#compile) # @raise (see Embedded#compile) @@ -42,6 +44,7 @@ def compile(path, **kwargs) end # Compiles a stylesheet whose contents is +source+ to CSS. + # @overload compile_string(source, importer: nil, load_paths: [], syntax: :scss, url: nil, charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, logger: nil, quiet_deps: false, verbose: false) # @param (see Embedded#compile_string) # @return (see Embedded#compile_string) # @raise (see Embedded#compile_string) @@ -75,6 +78,7 @@ def instance @instance end end + # rubocop:enable Layout/LineLength # The {Embedded} host for using dart-sass-embedded. Each instance creates # its own communication {Channel} with a dedicated compiler process. From dc3b8eb6ef9acb09847a4c8c29fa25ce6486bad5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Jan 2023 16:03:41 +0000 Subject: [PATCH 056/700] Update rubocop-rspec requirement from ~> 2.16.0 to ~> 2.17.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.16.0...v2.17.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 43549b76..5044effa 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.43.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.16.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.17.0' end From 42818b910c0b2073e66567049d979e0323fb69b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 16:16:42 +0000 Subject: [PATCH 057/700] Update rubocop-rspec requirement from ~> 2.17.0 to ~> 2.18.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.17.0...v2.18.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 5044effa..8c0f3762 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.43.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.17.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' end From e838dce0dec63559579a2f07dd6bb25b9b468bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Jan 2023 02:52:55 -0800 Subject: [PATCH 058/700] Support musl --- ext/sass/Rakefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 815e36c3..f8d7ec02 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -235,6 +235,9 @@ module Configuration 'macos' when 'linux' 'linux' + when 'linux-musl' + repo = 'https://github.com/dart-musl/dart-sass-embedded' + 'linux' when 'windows' 'windows' else From e9672fff873ca3a4a9321cdc581bafc6ed852070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Jan 2023 03:10:24 -0800 Subject: [PATCH 059/700] Add musl releases --- .github/workflows/release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38c9a2e4..20019dce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,14 @@ jobs: platform: x86-linux-gnu - os: ubuntu-latest platform: x86_64-linux-gnu + - os: ubuntu-latest + platform: aarch64-linux-musl + - os: ubuntu-latest + platform: arm-linux-musleabihf + - os: ubuntu-latest + platform: x86-linux-musl + - os: ubuntu-latest + platform: x86_64-linux-musl - os: windows-latest platform: x64-mingw-ucrt - os: windows-latest From d5330a9f7c83bb9a85e1cb3cb3fd86a15fd0b2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Jan 2023 14:39:48 -0800 Subject: [PATCH 060/700] Test musl --- .github/workflows/build.yml | 87 ++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc3cf4dc..b61a26fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,6 +62,47 @@ jobs: - name: Spec run: bundle exec rake spec + spec-musl: + + name: spec (alpine-latest, ${{ matrix.ruby-version }}) + + runs-on: ubuntu-latest + + container: + image: docker.io/library/ruby:${{ matrix.ruby-version }}-alpine + + env: + PROTOC_BIN: /usr/bin/protoc + + strategy: + fail-fast: false + matrix: + ruby-version: + - '2.6' + - '2.7' + - '3.0' + - '3.1' + - '3.2' + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install dependencies + run: apk add alpine-sdk protoc + + - name: Update RubyGems + run: gem update --system + + - name: Bundle + run: bundle install + + - name: Compile + run: bundle exec rake compile + + - name: Spec + run: bundle exec rake spec + install: runs-on: ${{ matrix.os }} @@ -107,11 +148,55 @@ jobs: - name: Install run: rake -f -r bundler/gem_tasks install + install-musl: + + name: install (alpine-latest, ${{ matrix.ruby-version }}) + + runs-on: ubuntu-latest + + container: + image: docker.io/library/ruby:${{ matrix.ruby-version }}-alpine + + env: + PROTOC_BIN: /usr/bin/protoc + + strategy: + fail-fast: false + matrix: + ruby-version: + - '2.6' + - '2.7' + - '3.0' + - '3.1' + - '3.2' + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install dependencies + run: apk add alpine-sdk protoc + + - name: Update RubyGems + run: gem update --system + + - name: Bundle + run: bundle install + + - name: Install + run: rake -f -r bundler/gem_tasks install + + - name: Compile + run: bundle exec rake compile + + - name: Install + run: rake -f -r bundler/gem_tasks install + release: if: github.event.repository.fork == false && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - needs: [lint, spec, install] + needs: [lint, spec, spec-musl, install, install-musl] runs-on: ubuntu-latest From 0b4a8754707006942f8551a65deab80f06012e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 10 Jan 2023 01:32:56 +0000 Subject: [PATCH 061/700] Support NixOS (require dart-sass-embedded snapshot) --- ext/sass/Rakefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index f8d7ec02..6192719f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -21,6 +21,12 @@ file 'sass_embedded' do |t| archive = fetch(ENV.fetch(t.name.upcase) { Configuration.default_sass_embedded }) unarchive archive rm archive + + if ENV.key?('NIX_BINTOOLS') + sh 'patchelf', + '--set-interpreter', File.read("#{ENV.fetch('NIX_BINTOOLS')}/nix-support/dynamic-linker").chomp, + (['sass_embedded/src/dart', 'sass_embedded/dart-sass-embedded'].find { |exe| File.exist?(exe) }) + end end file 'embedded.rb' => %w[sass_embedded] do |t| From 5d751c76c57c5dd03620d48121c435863321d0b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jan 2023 16:08:33 +0000 Subject: [PATCH 062/700] Update rubocop requirement from ~> 1.43.0 to ~> 1.44.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.43.0...v1.44.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 8c0f3762..9ed03e18 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.43.0' + spec.add_development_dependency 'rubocop', '~> 1.44.0' spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' From 6b9525b6441ddee0a051fc8c3b31c1059f2ff893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 1 Feb 2023 16:38:34 -0800 Subject: [PATCH 063/700] Bump sass-embedded from 1.57.1 to 1.58.0 in /ext/sass --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index c7d9e84d..37646af1 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.57.1" + "sass-embedded": "1.58.0" } } From b473492aa28b79201f4120066682259f80b0f812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 1 Feb 2023 16:52:04 -0800 Subject: [PATCH 064/700] v1.58.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index c14f55a5..81df9ce3 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.57.1' + VERSION = '1.58.0' end end From efe09d3430cf08c588941d717bb5f06bf9562abf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 16:05:38 +0000 Subject: [PATCH 065/700] Update rubocop-performance requirement from ~> 1.15.0 to ~> 1.16.0 Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.15.0...v1.16.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 9ed03e18..d0ff810b 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -44,7 +44,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rspec', '~> 3.12.0' spec.add_development_dependency 'rubocop', '~> 1.44.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.15.0' + spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' end From 11c1a39a5804db2b0e6ea8857f394a5802d998b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:15:37 +0000 Subject: [PATCH 066/700] Update rubocop requirement from ~> 1.44.0 to ~> 1.45.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.44.0...v1.45.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index d0ff810b..c9e5fbc4 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.44.0' + spec.add_development_dependency 'rubocop', '~> 1.45.1' spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' From 30b3fce474c399da475079b6e7bff669615e3579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 11 Feb 2023 09:06:40 -0800 Subject: [PATCH 067/700] Detect linux-android (bionic) --- ext/sass/Rakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 6192719f..cfba3226 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -188,6 +188,8 @@ module Configuration OS = case RbConfig::CONFIG['host_os'].downcase when /darwin/ 'darwin' + when /linux-android/ + 'linux-android' when /linux-musl/ 'linux-musl' when /linux-uclibc/ From 3364b0a848a0c329e127cc93ebd0596d91d93c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 13 Feb 2023 17:19:01 -0800 Subject: [PATCH 068/700] Bump sass-embedded from 1.58.0 to 1.58.1 in /ext/sass --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 37646af1..3c99f30c 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.58.0" + "sass-embedded": "1.58.1" } } From 5be7125ce99384dc21fd02db1ef1646cf728bbd1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Feb 2023 02:14:22 +0000 Subject: [PATCH 069/700] Update sass-embedded requirement from 1.58.1 to 1.58.2 in /ext/sass Updates the requirements on [sass-embedded](https://github.com/sass/embedded-host-node) to permit the latest version. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/commits/1.58.2) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 3c99f30c..70ec4802 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.58.1" + "sass-embedded": "1.58.2" } } From 1e5b3bdb71e4de512989f1f14484d7f9ec9e0b39 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 18:30:46 -0800 Subject: [PATCH 070/700] v1.58.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 81df9ce3..05d43dfd 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.58.0' + VERSION = '1.58.2' end end From e3ac2a3ac32f5dcc97fc7f5a84ec1ae6376356e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 18 Feb 2023 04:41:44 +0000 Subject: [PATCH 071/700] Bump sass-embedded from 1.58.2 to 1.58.3 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.58.2 to 1.58.3. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.58.2...1.58.3) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 70ec4802..7d3263b4 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.58.2" + "sass-embedded": "1.58.3" } } From 310b40a4eb20d0813bb348b56e4c5983e7f005e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 18 Feb 2023 03:42:26 -0800 Subject: [PATCH 072/700] Support Android --- ext/sass/Rakefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index cfba3226..77ced01f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -243,6 +243,9 @@ module Configuration 'macos' when 'linux' 'linux' + when 'linux-android' + repo = 'https://github.com/dart-android/dart-sass-embedded' + 'android' when 'linux-musl' repo = 'https://github.com/dart-musl/dart-sass-embedded' 'linux' From 49f4f76b00aab3b8fa29d8813bb408ccc8b8acfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 18 Feb 2023 04:01:14 -0800 Subject: [PATCH 073/700] Support Android --- .github/workflows/release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 20019dce..185ad10b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,6 +47,14 @@ jobs: platform: arm64-darwin - os: macos-latest platform: x86_64-darwin + - os: ubuntu-latest + platform: aarch64-linux-android + - os: ubuntu-latest + platform: arm-linux-androideabi + - os: ubuntu-latest + platform: x86-linux-android + - os: ubuntu-latest + platform: x86_64-linux-android - os: ubuntu-latest platform: aarch64-linux-gnu - os: ubuntu-latest From 7a99e556f4a50a6a29e419a3e7ddb77be468829a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 18 Feb 2023 04:12:31 -0800 Subject: [PATCH 074/700] v1.58.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 05d43dfd..1622175c 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.58.2' + VERSION = '1.58.3' end end From dc18304165bf36fdc5565c8739834294e347626b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 16:59:13 +0000 Subject: [PATCH 075/700] Update rubocop requirement from ~> 1.45.1 to ~> 1.46.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.45.1...v1.46.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index c9e5fbc4..003a76a9 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.45.1' + spec.add_development_dependency 'rubocop', '~> 1.46.0' spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' From b00dbc0d365c5a88352508c997bf1f29536f649d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 24 Feb 2023 00:44:52 -0800 Subject: [PATCH 076/700] Optimize Sass::Value::Map --- lib/sass/value/map.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/value/map.rb b/lib/sass/value/map.rb index c15e7fc2..71f0a274 100644 --- a/lib/sass/value/map.rb +++ b/lib/sass/value/map.rb @@ -32,8 +32,8 @@ def ==(other) def at(index) if index.is_a? Numeric index = index.floor - index = to_a.length + index if index.negative? - return nil if index.negative? || index >= to_a.length + index = to_a_length + index if index.negative? + return nil if index.negative? || index >= to_a_length to_a[index] else @@ -48,7 +48,7 @@ def hash # @return [Array>] def to_a - contents.to_a.map { |entry| Sass::Value::List.new(entry, separator: ' ') } + contents.map { |key, value| Sass::Value::List.new([key, value], separator: ' ') } end # @return [Map] From 33e6af74c060be1468c00db638045176bbcf5a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 24 Feb 2023 00:51:45 -0800 Subject: [PATCH 077/700] Optimize Sass::Value::Map --- lib/sass/value/map.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/map.rb b/lib/sass/value/map.rb index 71f0a274..f42b3483 100644 --- a/lib/sass/value/map.rb +++ b/lib/sass/value/map.rb @@ -35,7 +35,7 @@ def at(index) index = to_a_length + index if index.negative? return nil if index.negative? || index >= to_a_length - to_a[index] + Sass::Value::List.new(contents.to_a[index], separator: ' ') else contents[index] end From 9bee4713142cc7217334b01467286933162f5764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 27 Feb 2023 09:31:04 -0800 Subject: [PATCH 078/700] Drop Ruby 2.6 --- .github/workflows/build.yml | 4 ---- .rubocop.yml | 2 +- lib/sass/embedded/structifier.rb | 6 +----- sass-embedded.gemspec | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b61a26fa..e8a62394 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,6 @@ jobs: - ubuntu-latest - windows-latest ruby-version: - - '2.6' - '2.7' - '3.0' - '3.1' @@ -78,7 +77,6 @@ jobs: fail-fast: false matrix: ruby-version: - - '2.6' - '2.7' - '3.0' - '3.1' @@ -115,7 +113,6 @@ jobs: - ubuntu-latest - windows-latest ruby-version: - - '2.6' - '2.7' - '3.0' - '3.1' @@ -164,7 +161,6 @@ jobs: fail-fast: false matrix: ruby-version: - - '2.6' - '2.7' - '3.0' - '3.1' diff --git a/.rubocop.yml b/.rubocop.yml index 75a8508d..269d1d6f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ AllCops: - '**/*_pb.rb' - 'vendor/**/*' - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 NewCops: enable diff --git a/lib/sass/embedded/structifier.rb b/lib/sass/embedded/structifier.rb index 66bf2d31..4a75fc4d 100644 --- a/lib/sass/embedded/structifier.rb +++ b/lib/sass/embedded/structifier.rb @@ -18,11 +18,7 @@ def to_struct(obj, *symbols) value = obj[key] if value.respond_to? :call struct.define_singleton_method key do |*args, **kwargs| - if kwargs.empty? - value.call(*args) - else - value.call(*args, **kwargs) - end + value.call(*args, **kwargs) end else struct.define_singleton_method key do diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 003a76a9..853bef9e 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA ] end - spec.required_ruby_version = '>= 2.6.0' + spec.required_ruby_version = '>= 2.7.0' spec.add_runtime_dependency 'google-protobuf', '~> 3.21' From 26dee965e70129307b75297e8f1d6dda9d02280f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:03:08 +0000 Subject: [PATCH 079/700] Update rubocop requirement from ~> 1.46.0 to ~> 1.47.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.46.0...v1.47.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 853bef9e..62192c84 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.46.0' + spec.add_development_dependency 'rubocop', '~> 1.47.0' spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' From 1ee65ba23b0fc37a073ae148a60980c3a3fbff6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 1 Mar 2023 17:03:38 -0800 Subject: [PATCH 080/700] Use Ruby 2.7's ... syntax for delegation --- lib/sass/compile_error.rb | 4 ++-- lib/sass/embedded.rb | 8 ++++---- lib/sass/embedded/channel.rb | 4 ++-- lib/sass/embedded/dispatcher.rb | 4 ++-- lib/sass/embedded/host.rb | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 13d3a7f0..096ec2c4 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -17,9 +17,9 @@ def initialize(message, full_message, sass_stack, span) end # @return [String] - def full_message(*args, **kwargs) + def full_message(...) if @full_message.nil? - super(*args, **kwargs) + super(...) else @full_message end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 72a0478c..aaa06c5b 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -39,8 +39,8 @@ class << self # @return (see Embedded#compile) # @raise (see Embedded#compile) # @see Embedded#compile - def compile(path, **kwargs) - instance.compile(path, **kwargs) + def compile(...) + instance.compile(...) end # Compiles a stylesheet whose contents is +source+ to CSS. @@ -49,8 +49,8 @@ def compile(path, **kwargs) # @return (see Embedded#compile_string) # @raise (see Embedded#compile_string) # @see Embedded#compile_string - def compile_string(source, **kwargs) - instance.compile_string(source, **kwargs) + def compile_string(...) + instance.compile_string(...) end # @param (see Embedded#info) diff --git a/lib/sass/embedded/channel.rb b/lib/sass/embedded/channel.rb index d5e743a0..fe6de32c 100644 --- a/lib/sass/embedded/channel.rb +++ b/lib/sass/embedded/channel.rb @@ -48,8 +48,8 @@ def disconnect @dispatcher.unsubscribe(id) end - def send_message(**kwargs) - @dispatcher.send_message(**kwargs) + def send_message(...) + @dispatcher.send_message(...) end end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index fc8f6761..817aaa44 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -62,8 +62,8 @@ def closed? @compiler.closed? end - def send_message(**kwargs) - inbound_message = EmbeddedProtocol::InboundMessage.new(**kwargs) + def send_message(...) + inbound_message = EmbeddedProtocol::InboundMessage.new(...) @compiler.write(inbound_message.to_proto) end diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 5dbdd41c..c4fee2d4 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -131,8 +131,8 @@ def id @connection.id end - def send_message(**kwargs) - @connection.send_message(**kwargs) + def send_message(...) + @connection.send_message(...) end end From ece3d53bfe77e901936dbfe76fac36e9dacbca64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 17:02:18 +0000 Subject: [PATCH 081/700] Update rubocop-rspec requirement from ~> 2.18.0 to ~> 2.19.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.18.0...v2.19.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 62192c84..bd3ebb0a 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.47.0' spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.18.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' end From d8c7713f1078931ebfe0a4fe8168e5467c3391f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 18:14:30 +0000 Subject: [PATCH 082/700] Update rubocop requirement from ~> 1.47.0 to ~> 1.48.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.47.0...v1.48.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index bd3ebb0a..e8d71879 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.47.0' + spec.add_development_dependency 'rubocop', '~> 1.48.0' spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' From 5b48a947e50090ceba87fd6b70ffc11797b14711 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Mar 2023 18:24:18 -0800 Subject: [PATCH 083/700] Bump sass-embedded from 1.58.3 to 1.59.2 in /ext/sass (#111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump sass-embedded from 1.58.3 to 1.59.2 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.58.3 to 1.59.2. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.58.3...1.59.2) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update spec for https://github.com/sass/sass-spec/pull/1887 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- ext/sass/package.json | 2 +- spec/sass_logger_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 7d3263b4..e2fc86e5 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.58.3" + "sass-embedded": "1.59.2" } } diff --git a/spec/sass_logger_spec.rb b/spec/sass_logger_spec.rb index 9dc66622..5ccfc872 100644 --- a/spec/sass_logger_spec.rb +++ b/spec/sass_logger_spec.rb @@ -22,7 +22,7 @@ expect(span.start.line).to be(0) expect(span.start.column).to be(0) expect(span.end.line).to be(0) - expect(span.end.column).to be(4) + expect(span.end.column).to be(3) } } ) From f3327491a2b4ce45aefbca360bf1befccded48a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 10 Mar 2023 18:32:05 -0800 Subject: [PATCH 084/700] v1.59.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 1622175c..9f61956f 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.58.3' + VERSION = '1.59.2' end end From 527b36033ba219dc0b2336e7bb3ac052418b62bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 22:03:56 +0000 Subject: [PATCH 085/700] Bump sass-embedded from 1.59.2 to 1.59.3 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.59.2 to 1.59.3. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.59.2...1.59.3) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index e2fc86e5..27658001 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.59.2" + "sass-embedded": "1.59.3" } } From 47ab0c6dd3e2254b277e1cb7c44b96d59c36b92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 14 Mar 2023 15:23:19 -0700 Subject: [PATCH 086/700] v1.59.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 9f61956f..68fe3c87 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.59.2' + VERSION = '1.59.3' end end From 89555223406decbac75510bb8b86b33e99573570 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 00:54:49 +0000 Subject: [PATCH 087/700] Bump sass-embedded from 1.59.3 to 1.60.0 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.59.3 to 1.60.0. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.59.3...1.60.0) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 27658001..d7972985 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.59.3" + "sass-embedded": "1.60.0" } } From ebbd31ee0112fa4a30532068c3c1960bb1047185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 23 Mar 2023 18:20:11 -0700 Subject: [PATCH 088/700] v1.60.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 68fe3c87..c99c7ec7 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.59.3' + VERSION = '1.60.0' end end From 9b22e80e2249a44762730422e580b963fcb64c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 24 Mar 2023 10:47:27 -0700 Subject: [PATCH 089/700] Mark Sass::EmbeddedProtocol as private constant --- lib/sass/embedded.rb | 2 + lib/sass/embedded/host/value_protofier.rb | 46 +++++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index aaa06c5b..c8231ece 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -248,4 +248,6 @@ def closed? @channel.closed? end end + + private_constant :EmbeddedProtocol end diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index bf2684d9..49042e22 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -14,15 +14,15 @@ def initialize(function_registry) def to_proto(obj) case obj when Sass::Value::String - Sass::EmbeddedProtocol::Value.new( - string: Sass::EmbeddedProtocol::Value::String.new( + EmbeddedProtocol::Value.new( + string: EmbeddedProtocol::Value::String.new( text: obj.text, quoted: obj.quoted? ) ) when Sass::Value::Number - Sass::EmbeddedProtocol::Value.new( - number: Sass::EmbeddedProtocol::Value::Number.new( + EmbeddedProtocol::Value.new( + number: EmbeddedProtocol::Value::Number.new( value: obj.value.to_f, numerators: obj.numerator_units, denominators: obj.denominator_units @@ -30,8 +30,8 @@ def to_proto(obj) ) when Sass::Value::Color if obj.instance_eval { !defined?(@hue) } - Sass::EmbeddedProtocol::Value.new( - rgb_color: Sass::EmbeddedProtocol::Value::RgbColor.new( + EmbeddedProtocol::Value.new( + rgb_color: EmbeddedProtocol::Value::RgbColor.new( red: obj.red, green: obj.green, blue: obj.blue, @@ -39,8 +39,8 @@ def to_proto(obj) ) ) elsif obj.instance_eval { !defined?(@saturation) } - Sass::EmbeddedProtocol::Value.new( - hwb_color: Sass::EmbeddedProtocol::Value::HwbColor.new( + EmbeddedProtocol::Value.new( + hwb_color: EmbeddedProtocol::Value::HwbColor.new( hue: obj.hue.to_f, whiteness: obj.whiteness.to_f, blackness: obj.blackness.to_f, @@ -48,8 +48,8 @@ def to_proto(obj) ) ) else - Sass::EmbeddedProtocol::Value.new( - hsl_color: Sass::EmbeddedProtocol::Value::HslColor.new( + EmbeddedProtocol::Value.new( + hsl_color: EmbeddedProtocol::Value::HslColor.new( hue: obj.hue.to_f, saturation: obj.saturation.to_f, lightness: obj.lightness.to_f, @@ -58,8 +58,8 @@ def to_proto(obj) ) end when Sass::Value::ArgumentList - Sass::EmbeddedProtocol::Value.new( - argument_list: Sass::EmbeddedProtocol::Value::ArgumentList.new( + EmbeddedProtocol::Value.new( + argument_list: EmbeddedProtocol::Value::ArgumentList.new( id: obj.instance_eval { @id }, contents: obj.contents.map { |element| to_proto(element) }, keywords: obj.keywords.transform_values { |value| to_proto(value) }, @@ -67,18 +67,18 @@ def to_proto(obj) ) ) when Sass::Value::List - Sass::EmbeddedProtocol::Value.new( - list: Sass::EmbeddedProtocol::Value::List.new( + EmbeddedProtocol::Value.new( + list: EmbeddedProtocol::Value::List.new( contents: obj.contents.map { |element| to_proto(element) }, separator: ListSeparator.to_proto(obj.separator), has_brackets: obj.bracketed? ) ) when Sass::Value::Map - Sass::EmbeddedProtocol::Value.new( - map: Sass::EmbeddedProtocol::Value::Map.new( + EmbeddedProtocol::Value.new( + map: EmbeddedProtocol::Value::Map.new( entries: obj.contents.map do |key, value| - Sass::EmbeddedProtocol::Value::Map::Entry.new( + EmbeddedProtocol::Value::Map::Entry.new( key: to_proto(key), value: to_proto(value) ) @@ -87,25 +87,25 @@ def to_proto(obj) ) when Sass::Value::Function if obj.id - Sass::EmbeddedProtocol::Value.new( - compiler_function: Sass::EmbeddedProtocol::Value::CompilerFunction.new( + EmbeddedProtocol::Value.new( + compiler_function: EmbeddedProtocol::Value::CompilerFunction.new( id: obj.id ) ) else - Sass::EmbeddedProtocol::Value.new( - host_function: Sass::EmbeddedProtocol::Value::HostFunction.new( + EmbeddedProtocol::Value.new( + host_function: EmbeddedProtocol::Value::HostFunction.new( id: @function_registry.register(obj.callback), signature: obj.signature ) ) end when Sass::Value::Boolean - Sass::EmbeddedProtocol::Value.new( + EmbeddedProtocol::Value.new( singleton: obj.value ? :TRUE : :FALSE ) when Sass::Value::Null - Sass::EmbeddedProtocol::Value.new( + EmbeddedProtocol::Value.new( singleton: :NULL ) else From c6783834772a5b3ab353daf9a3ba37c195aa8dad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:06:54 +0000 Subject: [PATCH 090/700] Update rubocop requirement from ~> 1.48.0 to ~> 1.49.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.48.0...v1.49.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index e8d71879..a8c7ee06 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.48.0' + spec.add_development_dependency 'rubocop', '~> 1.49.0' spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' From c24f77c99106b04e924de35c9678e801c44d9e18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 22:42:16 +0000 Subject: [PATCH 091/700] Bump sass-embedded from 1.60.0 to 1.61.0 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.60.0 to 1.61.0. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.60.0...1.61.0) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index d7972985..264c7073 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.60.0" + "sass-embedded": "1.61.0" } } From a0328ddc1e6c6ead575a37f0406243cdcc60a93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 6 Apr 2023 16:35:07 -0700 Subject: [PATCH 092/700] v1.61.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index c99c7ec7..ec129523 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.60.0' + VERSION = '1.61.0' end end From 8aa72aac19ee524f08004e09eca20a0289e560c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:16:39 +0000 Subject: [PATCH 093/700] Update rubocop-performance requirement from ~> 1.16.0 to ~> 1.17.1 Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.16.0...v1.17.1) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index a8c7ee06..bf0e88a8 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -44,7 +44,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rspec', '~> 3.12.0' spec.add_development_dependency 'rubocop', '~> 1.49.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' + spec.add_development_dependency 'rubocop-performance', '~> 1.17.1' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' end From 653a9e4daf00a5da0e9a048e31847f8dce2a5f35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 15:38:59 +0000 Subject: [PATCH 094/700] Update rubocop requirement from ~> 1.49.0 to ~> 1.50.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.49.0...v1.50.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index bf0e88a8..4822ddc7 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA end spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.49.0' + spec.add_development_dependency 'rubocop', '~> 1.50.0' spec.add_development_dependency 'rubocop-performance', '~> 1.17.1' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' From d1006e3dcccef1937531c1a6e4300aaa433f5c53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 23:27:35 +0000 Subject: [PATCH 095/700] Bump sass-embedded from 1.61.0 to 1.62.0 in /ext/sass Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.61.0 to 1.62.0. - [Release notes](https://github.com/sass/embedded-host-node/releases) - [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/embedded-host-node/compare/1.61.0...1.62.0) --- updated-dependencies: - dependency-name: sass-embedded dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 264c7073..57d307e0 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.61.0" + "sass-embedded": "1.62.0" } } From d66710b8eb99516170fa545b7ce4a00b5a83befe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 11 Apr 2023 16:51:14 -0700 Subject: [PATCH 096/700] v1.62.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index ec129523..8c2d39ff 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.61.0' + VERSION = '1.62.0' end end From 985f4e2cade4c5cbe4e7cfb2a9d3289c6993bd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 14 Apr 2023 15:24:32 -0700 Subject: [PATCH 097/700] Support NixOS/Guix by invoking ELF interpreter --- ext/sass/Rakefile | 6 - lib/sass/embedded/compiler.rb | 11 +- lib/sass/embedded/elf.rb | 275 ++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+), 7 deletions(-) create mode 100644 lib/sass/embedded/elf.rb diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 77ced01f..226adcc2 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -21,12 +21,6 @@ file 'sass_embedded' do |t| archive = fetch(ENV.fetch(t.name.upcase) { Configuration.default_sass_embedded }) unarchive archive rm archive - - if ENV.key?('NIX_BINTOOLS') - sh 'patchelf', - '--set-interpreter', File.read("#{ENV.fetch('NIX_BINTOOLS')}/nix-support/dynamic-linker").chomp, - (['sass_embedded/src/dart', 'sass_embedded/dart-sass-embedded'].find { |exe| File.exist?(exe) }) - end end file 'embedded.rb' => %w[sass_embedded] do |t| diff --git a/lib/sass/embedded/compiler.rb b/lib/sass/embedded/compiler.rb index ed0f3ba7..af354a1a 100644 --- a/lib/sass/embedded/compiler.rb +++ b/lib/sass/embedded/compiler.rb @@ -9,7 +9,16 @@ class Embedded # It runs the `dart-sass-embedded` process. class Compiler def initialize - @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(*COMMAND, chdir: __dir__) + @stdin, @stdout, @stderr, @wait_thread = begin + Open3.popen3(*COMMAND, chdir: __dir__) + rescue Errno::ENOENT + require_relative 'elf' + + raise if ELF::INTERPRETER.nil? + + Open3.popen3(ELF::INTERPRETER, *COMMAND, chdir: __dir__) + end + @stdin.binmode @stdout.binmode @stdin_mutex = Mutex.new diff --git a/lib/sass/embedded/elf.rb b/lib/sass/embedded/elf.rb new file mode 100644 index 00000000..bfaa9b07 --- /dev/null +++ b/lib/sass/embedded/elf.rb @@ -0,0 +1,275 @@ +# frozen_string_literal: true + +module Sass + class Embedded + # The {ELF} class. + # + # It parses ELF header to extract interpreter. + # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h + # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c + class ELF + # rubocop:disable Naming/ConstantName + + # 32-bit ELF base types. + Elf32_Addr = :__u32 + Elf32_Half = :__u16 + Elf32_Off = :__u32 + Elf32_Sword = :__s32 + Elf32_Word = :__u32 + + # 64-bit ELF base types. + Elf64_Addr = :__u64 + Elf64_Half = :__u16 + Elf64_SHalf = :__s16 + Elf64_Off = :__u64 + Elf64_Sword = :__s32 + Elf64_Word = :__u32 + Elf64_Xword = :__u64 + Elf64_Sxword = :__s64 + + # rubocop:enable Naming/ConstantName + + # These constants are for the segment types stored in the image headers + PT_NULL = 0 + PT_LOAD = 1 + PT_DYNAMIC = 2 + PT_INTERP = 3 + PT_NOTE = 4 + PT_SHLIB = 5 + PT_PHDR = 6 + PT_TLS = 7 + PT_LOOS = 0x60000000 + PT_HIOS = 0x6fffffff + PT_LOPROC = 0x70000000 + PT_HIPROC = 0x7fffffff + PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550) + PT_GNU_STACK = (PT_LOOS + 0x474e551) + PT_GNU_RELRO = (PT_LOOS + 0x474e552) + PT_GNU_PROPERTY = (PT_LOOS + 0x474e553) + + # These constants define the different elf file types + ET_NONE = 0 + ET_REL = 1 + ET_EXEC = 2 + ET_DYN = 3 + ET_CORE = 4 + ET_LOPROC = 0xff00 + ET_HIPROC = 0xffff + + EI_NIDENT = 16 + + # rubocop:disable Naming/ConstantName + + Elf32_Ehdr = [ + [:unsigned_char, :e_ident, EI_NIDENT], + [Elf32_Half, :e_type], + [Elf32_Half, :e_machine], + [Elf32_Word, :e_version], + [Elf32_Addr, :e_entry], + [Elf32_Off, :e_phoff], + [Elf32_Off, :e_shoff], + [Elf32_Word, :e_flags], + [Elf32_Half, :e_ehsize], + [Elf32_Half, :e_phentsize], + [Elf32_Half, :e_phnum], + [Elf32_Half, :e_shentsize], + [Elf32_Half, :e_shnum], + [Elf32_Half, :e_shstrndx] + ].freeze + + Elf64_Ehdr = [ + [:unsigned_char, :e_ident, EI_NIDENT], + [Elf64_Half, :e_type], + [Elf64_Half, :e_machine], + [Elf64_Word, :e_version], + [Elf64_Addr, :e_entry], + [Elf64_Off, :e_phoff], + [Elf64_Off, :e_shoff], + [Elf64_Word, :e_flags], + [Elf64_Half, :e_ehsize], + [Elf64_Half, :e_phentsize], + [Elf64_Half, :e_phnum], + [Elf64_Half, :e_shentsize], + [Elf64_Half, :e_shnum], + [Elf64_Half, :e_shstrndx] + ].freeze + + Elf32_Phdr = [ + [Elf32_Word, :p_type], + [Elf32_Off, :p_offset], + [Elf32_Addr, :p_vaddr], + [Elf32_Addr, :p_paddr], + [Elf32_Word, :p_filesz], + [Elf32_Word, :p_memsz], + [Elf32_Word, :p_flags], + [Elf32_Word, :p_align] + ].freeze + + Elf64_Phdr = [ + [Elf64_Word, :p_type], + [Elf64_Word, :p_flags], + [Elf64_Off, :p_offset], + [Elf64_Addr, :p_vaddr], + [Elf64_Addr, :p_paddr], + [Elf64_Xword, :p_filesz], + [Elf64_Xword, :p_memsz], + [Elf64_Xword, :p_align] + ].freeze + + # rubocop:enable Naming/ConstantName + + # e_ident[] indexes + EI_MAG0 = 0 + EI_MAG1 = 1 + EI_MAG2 = 2 + EI_MAG3 = 3 + EI_CLASS = 4 + EI_DATA = 5 + EI_VERSION = 6 + EI_OSABI = 7 + EI_PAD = 8 + + # EI_MAG + ELFMAG0 = 0x7f + ELFMAG1 = 'E'.ord + ELFMAG2 = 'L'.ord + ELFMAG3 = 'F'.ord + ELFMAG = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3].pack('C*') + SELFMAG = 4 + + # e_ident[EI_CLASS] + ELFCLASSNONE = 0 + ELFCLASS32 = 1 + ELFCLASS64 = 2 + ELFCLASSNUM = 3 + + # e_ident[EI_DATA] + ELFDATANONE = 0 + ELFDATA2LSB = 1 + ELFDATA2MSB = 2 + + def initialize(buffer) + @buffer = buffer + @ehdr = read_ehdr + @buffer.seek(@ehdr[:e_phoff], :SET) + @proghdrs = Array.new(@ehdr[:e_phnum]) do + read_phdr + end + end + + def relocatable? + @ehdr[:e_type] == ET_REL + end + + def executable? + @ehdr[:e_type] == ET_EXEC + end + + def shared_object? + @ehdr[:e_type] == ET_DYN + end + + def core? + @ehdr[:e_type] == ET_CORE + end + + def interpreter + phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP } + return if phdr.nil? + + @buffer.seek(phdr[:p_offset], :SET) + interpreter = @buffer.read(phdr[:p_filesz]) + raise ArgumentError unless interpreter.end_with?("\0") + + interpreter.chomp("\0") + end + + private + + def file_class + @ehdr[:e_ident][EI_CLASS] + end + + def data_encoding + @ehdr[:e_ident][EI_DATA] + end + + def read_ehdr + @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') } + raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG + + case file_class + when ELFCLASS32 + Elf32_Ehdr + when ELFCLASS64 + Elf64_Ehdr + else + raise ArgumentError + end.drop(1).to_h do |field| + [field[1], read1(field[0])] + end.merge!(@ehdr) + end + + def read_phdr + case file_class + when ELFCLASS32 + Elf32_Phdr + when ELFCLASS64 + Elf64_Phdr + else + raise ArgumentError + end.to_h do |field| + [field[1], read1(field[0])] + end + end + + def read1(type) + case data_encoding + when ELFDATA2LSB + case type + when :__u16 + @buffer.read(2).unpack1('v*') + when :__u32 + @buffer.read(4).unpack1('V*') + when :__u64 + buffer = @buffer.read(8).unpack('V*') + (buffer[1] << 32) | buffer[0] + else + raise ArgumentError + end + when ELFDATA2MSB + case type + when :__u16 + @buffer.read(2).unpack1('n*') + when :__u32 + @buffer.read(4).unpack1('N*') + when :__u64 + buffer = @buffer.read(8).unpack('N*') + (buffer[0] << 32) | buffer[1] + else + raise ArgumentError + end + else + raise ArgumentError + end + end + + INTERPRETER = proc do + proc_self_exe = '/proc/self/exe' + if File.exist?(proc_self_exe) + File.open(proc_self_exe, 'rb') do |exe| + elf = ELF.new(exe) + interpreter = elf.interpreter + if interpreter.nil? && elf.shared_object? + File.readlink(proc_self_exe) + else + interpreter + end + end + end + end.call + end + + private_constant :ELF + end +end From 7640a934f4439e19517714be39a190f94d7323f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:58:22 +0000 Subject: [PATCH 098/700] Update rubocop-rspec requirement from ~> 2.19.0 to ~> 2.20.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.19.0...v2.20.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 4822ddc7..7f136b34 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.50.0' spec.add_development_dependency 'rubocop-performance', '~> 1.17.1' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.20.0' end From 2667b4c6e9e4ac27bcb10dcd265baf243813dc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Apr 2023 17:03:55 -0700 Subject: [PATCH 099/700] Bump sass-embedded from 1.62.0 to 1.62.1 in /ext/sass --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 57d307e0..e92c1b62 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.62.0" + "sass-embedded": "1.62.1" } } From 3b7b5e3fde64b7319e682057f6e7e69797959b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Apr 2023 17:24:02 -0700 Subject: [PATCH 100/700] v1.62.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 8c2d39ff..b2be0b90 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.62.0' + VERSION = '1.62.1' end end From 0bdf097968d4949ed24c875bf998b30d47b5fa7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Apr 2023 21:28:24 -0700 Subject: [PATCH 101/700] Improve ELF parser --- lib/sass/embedded/elf.rb | 49 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/sass/embedded/elf.rb b/lib/sass/embedded/elf.rb index bfaa9b07..16dc6a82 100644 --- a/lib/sass/embedded/elf.rb +++ b/lib/sass/embedded/elf.rb @@ -223,32 +223,35 @@ def read_phdr end end - def read1(type) + def explicit_endian case data_encoding when ELFDATA2LSB - case type - when :__u16 - @buffer.read(2).unpack1('v*') - when :__u32 - @buffer.read(4).unpack1('V*') - when :__u64 - buffer = @buffer.read(8).unpack('V*') - (buffer[1] << 32) | buffer[0] - else - raise ArgumentError - end + '<' when ELFDATA2MSB - case type - when :__u16 - @buffer.read(2).unpack1('n*') - when :__u32 - @buffer.read(4).unpack1('N*') - when :__u64 - buffer = @buffer.read(8).unpack('N*') - (buffer[0] << 32) | buffer[1] - else - raise ArgumentError - end + '>' + else + raise ArgumentError + end + end + + def read1(type) + case type + when :__u8 + @buffer.read(1).unpack1('C') + when :__u16 + @buffer.read(2).unpack1("S#{explicit_endian}") + when :__u32 + @buffer.read(4).unpack1("L#{explicit_endian}") + when :__u64 + @buffer.read(8).unpack1("Q#{explicit_endian}") + when :__s8 + @buffer.read(1).unpack1('c') + when :__s16 + @buffer.read(2).unpack1("s#{explicit_endian}") + when :__s32 + @buffer.read(4).unpack1("l#{explicit_endian}") + when :__s64 + @buffer.read(8).unpack1("q#{explicit_endian}") else raise ArgumentError end From 77fa992a7c14212c0b44df9dbf436aa45094e645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Apr 2023 21:59:30 -0700 Subject: [PATCH 102/700] Test ruby on musl with default rubygems --- .github/workflows/build.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8a62394..5e026b65 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,9 +89,6 @@ jobs: - name: Install dependencies run: apk add alpine-sdk protoc - - name: Update RubyGems - run: gem update --system - - name: Bundle run: bundle install @@ -173,9 +170,6 @@ jobs: - name: Install dependencies run: apk add alpine-sdk protoc - - name: Update RubyGems - run: gem update --system - - name: Bundle run: bundle install From f6ca1c9fe5b635979fff3888e3ec2d19ca9a06fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Apr 2023 22:56:40 -0700 Subject: [PATCH 103/700] Update elf.rb --- lib/sass/embedded/elf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/embedded/elf.rb b/lib/sass/embedded/elf.rb index 16dc6a82..9b59e45a 100644 --- a/lib/sass/embedded/elf.rb +++ b/lib/sass/embedded/elf.rb @@ -260,8 +260,8 @@ def read1(type) INTERPRETER = proc do proc_self_exe = '/proc/self/exe' if File.exist?(proc_self_exe) - File.open(proc_self_exe, 'rb') do |exe| - elf = ELF.new(exe) + File.open(proc_self_exe, 'rb') do |file| + elf = ELF.new(file) interpreter = elf.interpreter if interpreter.nil? && elf.shared_object? File.readlink(proc_self_exe) From 86fa84fd39672789b530eb078f57c7b0cd85c7da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 May 2023 16:58:20 +0000 Subject: [PATCH 104/700] Update rubocop-rspec requirement from ~> 2.20.0 to ~> 2.21.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.20.0...v2.21.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 7f136b34..c103816e 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.50.0' spec.add_development_dependency 'rubocop-performance', '~> 1.17.1' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.20.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.21.0' end From 33c87f59e684daee499bb88744cb6dbaa4c94445 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 16:09:33 +0000 Subject: [PATCH 105/700] Update rubocop-rspec requirement from ~> 2.21.0 to ~> 2.22.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.21.0...v2.22.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index c103816e..d631b61e 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -46,5 +46,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.add_development_dependency 'rubocop', '~> 1.50.0' spec.add_development_dependency 'rubocop-performance', '~> 1.17.1' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.21.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.22.0' end From 71bfd4e9bb72400bf81a8fae62c07d7f96ebde0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 13 May 2023 10:39:12 -0700 Subject: [PATCH 106/700] Update elf.rb --- lib/sass/embedded/elf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/elf.rb b/lib/sass/embedded/elf.rb index 9b59e45a..ab531da9 100644 --- a/lib/sass/embedded/elf.rb +++ b/lib/sass/embedded/elf.rb @@ -181,7 +181,7 @@ def interpreter interpreter = @buffer.read(phdr[:p_filesz]) raise ArgumentError unless interpreter.end_with?("\0") - interpreter.chomp("\0") + interpreter.chomp!("\0") end private From 3bc78c6d43bf235f705a6e0848f9bddcf5495f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 May 2023 16:48:34 -0700 Subject: [PATCH 107/700] Let dependabot check sass instead of sass-embedded --- ext/sass/Rakefile | 4 ++-- ext/sass/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 226adcc2..f318ab11 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -228,9 +228,9 @@ module Configuration spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__))) - tag_name = spec['dependencies']['sass-embedded'] + tag_name = spec['dependencies']['sass'] - message = "sass_embedded for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}" + message = "sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}" os = case Platform::OS when 'darwin' diff --git a/ext/sass/package.json b/ext/sass/package.json index e92c1b62..f51890ef 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass-embedded": "1.62.1" + "sass": "1.62.1" } } From 9f4bad62aadd59b516bd79918460254e41fe22ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 May 2023 16:27:47 -0700 Subject: [PATCH 108/700] Expose sass executable --- bin/sass | 18 ++++++++++++++++++ lib/sass/embedded.rb | 4 ++-- sass-embedded.gemspec | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100755 bin/sass diff --git a/bin/sass b/bin/sass new file mode 100755 index 00000000..85e6e419 --- /dev/null +++ b/bin/sass @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative '../ext/sass/embedded' + +module Sass + class Embedded # rubocop:disable Style/Documentation + begin + exec(*Compiler::COMMAND, *ARGV) + rescue Errno::ENOENT + require_relative '../lib/sass/embedded/elf' + + raise if ELF::INTERPRETER.nil? + + exec(ELF::INTERPRETER, *Compiler::COMMAND, *ARGV) + end + end +end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index c8231ece..0c6b38a9 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -80,8 +80,8 @@ def instance end # rubocop:enable Layout/LineLength - # The {Embedded} host for using dart-sass-embedded. Each instance creates - # its own communication {Channel} with a dedicated compiler process. + # The {Embedded} host for using dart-sass. Each instance creates its own + # communication {Channel} with a dedicated compiler process. # # @example # embedded = Sass::Embedded.new diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index d631b61e..41103db5 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -17,7 +17,8 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA 'funding_uri' => 'https://github.com/sponsors/ntkme' } - spec.files = Dir['lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.executables = ['sass'] + spec.files = Dir['bin/**/*'] + Dir['lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') spec.files += Dir['ext/sass/*.rb'] + Dir['ext/sass/sass_embedded/**/*'] From be874cc564aa8cfec356a69b362345195ad593fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 13 May 2023 17:54:14 -0700 Subject: [PATCH 109/700] Set gemspec's bindir to exe --- {bin => exe}/sass | 0 sass-embedded.gemspec | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename {bin => exe}/sass (100%) diff --git a/bin/sass b/exe/sass similarity index 100% rename from bin/sass rename to exe/sass diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 41103db5..d7336c2a 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -17,8 +17,9 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA 'funding_uri' => 'https://github.com/sponsors/ntkme' } + spec.bindir = 'exe' spec.executables = ['sass'] - spec.files = Dir['bin/**/*'] + Dir['lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.files = Dir['exe/**/*'] + Dir['lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') spec.files += Dir['ext/sass/*.rb'] + Dir['ext/sass/sass_embedded/**/*'] From fdffda81d3f28ab88dae74d062e920577f972722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 13 May 2023 21:23:24 -0700 Subject: [PATCH 110/700] Use exe/sass in Rakefile --- ext/sass/Rakefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index f318ab11..402f483c 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -306,9 +306,8 @@ module Configuration def default_sass_embedded_protocol require 'json' require 'open3' - require_relative 'embedded' - stdout, stderr, status = Open3.capture3(*Sass::Embedded::Compiler::COMMAND, '--version') + stdout, stderr, status = Open3.capture3(RbConfig.ruby, File.absolute_path('../../exe/sass', __dir__), '--version') raise stderr unless status.success? From 69387a1e789674a21a7529a5627a7af81bbfdb8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 15 May 2023 08:39:32 -0700 Subject: [PATCH 111/700] Move development dependency to Gemfile --- Gemfile | 10 ++++++++++ sass-embedded.gemspec | 13 +------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 5f10ba8c..3647497f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,14 @@ # frozen_string_literal: true source 'https://rubygems.org' + gemspec + +group :development do + gem 'rake', '>= 10.0.0' + gem 'rspec', '~> 3.12.0' + gem 'rubocop', '~> 1.50.0' + gem 'rubocop-performance', '~> 1.17.1' + gem 'rubocop-rake', '~> 0.6.0' + gem 'rubocop-rspec', '~> 2.22.0' +end diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index d7336c2a..f9785eae 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -37,16 +37,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.required_ruby_version = '>= 2.7.0' spec.add_runtime_dependency 'google-protobuf', '~> 3.21' - - if ENV.key?('gem_platform') - spec.add_development_dependency 'rake', '>= 10.0.0' - else - spec.add_runtime_dependency 'rake', '>= 10.0.0' - end - - spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rubocop', '~> 1.50.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.17.1' - spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.22.0' + spec.add_runtime_dependency 'rake', '>= 10.0.0' unless ENV.key?('gem_platform') end From 9c1eea5061e23a8bdf7cc17b601c1135b6ce4ff5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 15:42:18 +0000 Subject: [PATCH 112/700] Update rubocop requirement from ~> 1.50.0 to ~> 1.51.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.50.0...v1.51.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3647497f..3e6599d7 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 10.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.50.0' + gem 'rubocop', '~> 1.51.0' gem 'rubocop-performance', '~> 1.17.1' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.22.0' From 53ac09f4e64014ea5e275e413e87d804a7425427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 16 May 2023 19:18:27 -0700 Subject: [PATCH 113/700] Use the embedded protocol from the Sass language repo --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 402f483c..e639272f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -313,6 +313,6 @@ module Configuration tag_name = JSON.parse(stdout)['protocolVersion'] - "https://github.com/sass/embedded-protocol/raw/#{tag_name}/embedded_sass.proto" + "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto" end end From fcf59a793b49e4d33f94247a11629f670c6b08fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 18 May 2023 08:59:42 -0700 Subject: [PATCH 114/700] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index bcd491ed..72d5b2bb 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ require 'sass-embedded' result = Sass.compile('style.scss') puts result.css + +compressed = Sass.compile('style.scss', style: :compressed) +puts compressed.css ``` - `Sass.compile_string` takes a string that represents the contents of a Sass file and return the result of compiling that file to CSS. @@ -33,6 +36,9 @@ require 'sass-embedded' result = Sass.compile_string('h1 { font-size: 40px; }') puts result.css + +compressed = Sass.compile_string('h1 { font-size: 40px; }', style: :compressed) +puts compressed.css ``` See [rubydoc.info/gems/sass-embedded](https://rubydoc.info/gems/sass-embedded) for full API documentation. From 98742acf3c3c1f5b4d3614ba6a81a2ab45b2a92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 18 May 2023 19:47:42 -0700 Subject: [PATCH 115/700] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72d5b2bb..af6db62b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ compressed = Sass.compile_string('h1 { font-size: 40px; }', style: :compressed) puts compressed.css ``` -See [rubydoc.info/gems/sass-embedded](https://rubydoc.info/gems/sass-embedded) for full API documentation. +See [rubydoc.info/gems/sass-embedded/Sass](https://rubydoc.info/gems/sass-embedded/Sass) for full API documentation. --- From de3482e6f1f3570eab1728696c57ce222172a474 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 16:59:26 +0000 Subject: [PATCH 116/700] Update rubocop-performance requirement from ~> 1.17.1 to ~> 1.18.0 Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.17.1...v1.18.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3e6599d7..aa76fd02 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ group :development do gem 'rake', '>= 10.0.0' gem 'rspec', '~> 3.12.0' gem 'rubocop', '~> 1.51.0' - gem 'rubocop-performance', '~> 1.17.1' + gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.22.0' end From 493503a7e160c694a86e7b77716a07fd08a82bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 24 May 2023 18:23:40 -0700 Subject: [PATCH 117/700] Rename Sass::Embedded::ELF to Sass::ELF --- exe/sass | 2 +- lib/sass/elf.rb | 276 +++++++++++++++++++++++++++++++++ lib/sass/embedded/compiler.rb | 2 +- lib/sass/embedded/elf.rb | 278 ---------------------------------- 4 files changed, 278 insertions(+), 280 deletions(-) create mode 100644 lib/sass/elf.rb delete mode 100644 lib/sass/embedded/elf.rb diff --git a/exe/sass b/exe/sass index 85e6e419..736537fa 100755 --- a/exe/sass +++ b/exe/sass @@ -8,7 +8,7 @@ module Sass begin exec(*Compiler::COMMAND, *ARGV) rescue Errno::ENOENT - require_relative '../lib/sass/embedded/elf' + require_relative '../lib/sass/elf' raise if ELF::INTERPRETER.nil? diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb new file mode 100644 index 00000000..673ea5d0 --- /dev/null +++ b/lib/sass/elf.rb @@ -0,0 +1,276 @@ +# frozen_string_literal: true + +module Sass + # The {ELF} class. + # + # It parses ELF header to extract interpreter. + # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h + # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c + class ELF + # rubocop:disable Naming/ConstantName + + # 32-bit ELF base types. + Elf32_Addr = :__u32 + Elf32_Half = :__u16 + Elf32_Off = :__u32 + Elf32_Sword = :__s32 + Elf32_Word = :__u32 + + # 64-bit ELF base types. + Elf64_Addr = :__u64 + Elf64_Half = :__u16 + Elf64_SHalf = :__s16 + Elf64_Off = :__u64 + Elf64_Sword = :__s32 + Elf64_Word = :__u32 + Elf64_Xword = :__u64 + Elf64_Sxword = :__s64 + + # rubocop:enable Naming/ConstantName + + # These constants are for the segment types stored in the image headers + PT_NULL = 0 + PT_LOAD = 1 + PT_DYNAMIC = 2 + PT_INTERP = 3 + PT_NOTE = 4 + PT_SHLIB = 5 + PT_PHDR = 6 + PT_TLS = 7 + PT_LOOS = 0x60000000 + PT_HIOS = 0x6fffffff + PT_LOPROC = 0x70000000 + PT_HIPROC = 0x7fffffff + PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550) + PT_GNU_STACK = (PT_LOOS + 0x474e551) + PT_GNU_RELRO = (PT_LOOS + 0x474e552) + PT_GNU_PROPERTY = (PT_LOOS + 0x474e553) + + # These constants define the different elf file types + ET_NONE = 0 + ET_REL = 1 + ET_EXEC = 2 + ET_DYN = 3 + ET_CORE = 4 + ET_LOPROC = 0xff00 + ET_HIPROC = 0xffff + + EI_NIDENT = 16 + + # rubocop:disable Naming/ConstantName + + Elf32_Ehdr = [ + [:unsigned_char, :e_ident, EI_NIDENT], + [Elf32_Half, :e_type], + [Elf32_Half, :e_machine], + [Elf32_Word, :e_version], + [Elf32_Addr, :e_entry], + [Elf32_Off, :e_phoff], + [Elf32_Off, :e_shoff], + [Elf32_Word, :e_flags], + [Elf32_Half, :e_ehsize], + [Elf32_Half, :e_phentsize], + [Elf32_Half, :e_phnum], + [Elf32_Half, :e_shentsize], + [Elf32_Half, :e_shnum], + [Elf32_Half, :e_shstrndx] + ].freeze + + Elf64_Ehdr = [ + [:unsigned_char, :e_ident, EI_NIDENT], + [Elf64_Half, :e_type], + [Elf64_Half, :e_machine], + [Elf64_Word, :e_version], + [Elf64_Addr, :e_entry], + [Elf64_Off, :e_phoff], + [Elf64_Off, :e_shoff], + [Elf64_Word, :e_flags], + [Elf64_Half, :e_ehsize], + [Elf64_Half, :e_phentsize], + [Elf64_Half, :e_phnum], + [Elf64_Half, :e_shentsize], + [Elf64_Half, :e_shnum], + [Elf64_Half, :e_shstrndx] + ].freeze + + Elf32_Phdr = [ + [Elf32_Word, :p_type], + [Elf32_Off, :p_offset], + [Elf32_Addr, :p_vaddr], + [Elf32_Addr, :p_paddr], + [Elf32_Word, :p_filesz], + [Elf32_Word, :p_memsz], + [Elf32_Word, :p_flags], + [Elf32_Word, :p_align] + ].freeze + + Elf64_Phdr = [ + [Elf64_Word, :p_type], + [Elf64_Word, :p_flags], + [Elf64_Off, :p_offset], + [Elf64_Addr, :p_vaddr], + [Elf64_Addr, :p_paddr], + [Elf64_Xword, :p_filesz], + [Elf64_Xword, :p_memsz], + [Elf64_Xword, :p_align] + ].freeze + + # rubocop:enable Naming/ConstantName + + # e_ident[] indexes + EI_MAG0 = 0 + EI_MAG1 = 1 + EI_MAG2 = 2 + EI_MAG3 = 3 + EI_CLASS = 4 + EI_DATA = 5 + EI_VERSION = 6 + EI_OSABI = 7 + EI_PAD = 8 + + # EI_MAG + ELFMAG0 = 0x7f + ELFMAG1 = 'E'.ord + ELFMAG2 = 'L'.ord + ELFMAG3 = 'F'.ord + ELFMAG = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3].pack('C*') + SELFMAG = 4 + + # e_ident[EI_CLASS] + ELFCLASSNONE = 0 + ELFCLASS32 = 1 + ELFCLASS64 = 2 + ELFCLASSNUM = 3 + + # e_ident[EI_DATA] + ELFDATANONE = 0 + ELFDATA2LSB = 1 + ELFDATA2MSB = 2 + + def initialize(buffer) + @buffer = buffer + @ehdr = read_ehdr + @buffer.seek(@ehdr[:e_phoff], :SET) + @proghdrs = Array.new(@ehdr[:e_phnum]) do + read_phdr + end + end + + def relocatable? + @ehdr[:e_type] == ET_REL + end + + def executable? + @ehdr[:e_type] == ET_EXEC + end + + def shared_object? + @ehdr[:e_type] == ET_DYN + end + + def core? + @ehdr[:e_type] == ET_CORE + end + + def interpreter + phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP } + return if phdr.nil? + + @buffer.seek(phdr[:p_offset], :SET) + interpreter = @buffer.read(phdr[:p_filesz]) + raise ArgumentError unless interpreter.end_with?("\0") + + interpreter.chomp!("\0") + end + + private + + def file_class + @ehdr[:e_ident][EI_CLASS] + end + + def data_encoding + @ehdr[:e_ident][EI_DATA] + end + + def read_ehdr + @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') } + raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG + + case file_class + when ELFCLASS32 + Elf32_Ehdr + when ELFCLASS64 + Elf64_Ehdr + else + raise ArgumentError + end.drop(1).to_h do |field| + [field[1], read1(field[0])] + end.merge!(@ehdr) + end + + def read_phdr + case file_class + when ELFCLASS32 + Elf32_Phdr + when ELFCLASS64 + Elf64_Phdr + else + raise ArgumentError + end.to_h do |field| + [field[1], read1(field[0])] + end + end + + def explicit_endian + case data_encoding + when ELFDATA2LSB + '<' + when ELFDATA2MSB + '>' + else + raise ArgumentError + end + end + + def read1(type) + case type + when :__u8 + @buffer.read(1).unpack1('C') + when :__u16 + @buffer.read(2).unpack1("S#{explicit_endian}") + when :__u32 + @buffer.read(4).unpack1("L#{explicit_endian}") + when :__u64 + @buffer.read(8).unpack1("Q#{explicit_endian}") + when :__s8 + @buffer.read(1).unpack1('c') + when :__s16 + @buffer.read(2).unpack1("s#{explicit_endian}") + when :__s32 + @buffer.read(4).unpack1("l#{explicit_endian}") + when :__s64 + @buffer.read(8).unpack1("q#{explicit_endian}") + else + raise ArgumentError + end + end + + INTERPRETER = proc do + proc_self_exe = '/proc/self/exe' + if File.exist?(proc_self_exe) + File.open(proc_self_exe, 'rb') do |file| + elf = ELF.new(file) + interpreter = elf.interpreter + if interpreter.nil? && elf.shared_object? + File.readlink(proc_self_exe) + else + interpreter + end + end + end + end.call + end + + private_constant :ELF +end diff --git a/lib/sass/embedded/compiler.rb b/lib/sass/embedded/compiler.rb index af354a1a..0c73d179 100644 --- a/lib/sass/embedded/compiler.rb +++ b/lib/sass/embedded/compiler.rb @@ -12,7 +12,7 @@ def initialize @stdin, @stdout, @stderr, @wait_thread = begin Open3.popen3(*COMMAND, chdir: __dir__) rescue Errno::ENOENT - require_relative 'elf' + require_relative '../elf' raise if ELF::INTERPRETER.nil? diff --git a/lib/sass/embedded/elf.rb b/lib/sass/embedded/elf.rb deleted file mode 100644 index ab531da9..00000000 --- a/lib/sass/embedded/elf.rb +++ /dev/null @@ -1,278 +0,0 @@ -# frozen_string_literal: true - -module Sass - class Embedded - # The {ELF} class. - # - # It parses ELF header to extract interpreter. - # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h - # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c - class ELF - # rubocop:disable Naming/ConstantName - - # 32-bit ELF base types. - Elf32_Addr = :__u32 - Elf32_Half = :__u16 - Elf32_Off = :__u32 - Elf32_Sword = :__s32 - Elf32_Word = :__u32 - - # 64-bit ELF base types. - Elf64_Addr = :__u64 - Elf64_Half = :__u16 - Elf64_SHalf = :__s16 - Elf64_Off = :__u64 - Elf64_Sword = :__s32 - Elf64_Word = :__u32 - Elf64_Xword = :__u64 - Elf64_Sxword = :__s64 - - # rubocop:enable Naming/ConstantName - - # These constants are for the segment types stored in the image headers - PT_NULL = 0 - PT_LOAD = 1 - PT_DYNAMIC = 2 - PT_INTERP = 3 - PT_NOTE = 4 - PT_SHLIB = 5 - PT_PHDR = 6 - PT_TLS = 7 - PT_LOOS = 0x60000000 - PT_HIOS = 0x6fffffff - PT_LOPROC = 0x70000000 - PT_HIPROC = 0x7fffffff - PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550) - PT_GNU_STACK = (PT_LOOS + 0x474e551) - PT_GNU_RELRO = (PT_LOOS + 0x474e552) - PT_GNU_PROPERTY = (PT_LOOS + 0x474e553) - - # These constants define the different elf file types - ET_NONE = 0 - ET_REL = 1 - ET_EXEC = 2 - ET_DYN = 3 - ET_CORE = 4 - ET_LOPROC = 0xff00 - ET_HIPROC = 0xffff - - EI_NIDENT = 16 - - # rubocop:disable Naming/ConstantName - - Elf32_Ehdr = [ - [:unsigned_char, :e_ident, EI_NIDENT], - [Elf32_Half, :e_type], - [Elf32_Half, :e_machine], - [Elf32_Word, :e_version], - [Elf32_Addr, :e_entry], - [Elf32_Off, :e_phoff], - [Elf32_Off, :e_shoff], - [Elf32_Word, :e_flags], - [Elf32_Half, :e_ehsize], - [Elf32_Half, :e_phentsize], - [Elf32_Half, :e_phnum], - [Elf32_Half, :e_shentsize], - [Elf32_Half, :e_shnum], - [Elf32_Half, :e_shstrndx] - ].freeze - - Elf64_Ehdr = [ - [:unsigned_char, :e_ident, EI_NIDENT], - [Elf64_Half, :e_type], - [Elf64_Half, :e_machine], - [Elf64_Word, :e_version], - [Elf64_Addr, :e_entry], - [Elf64_Off, :e_phoff], - [Elf64_Off, :e_shoff], - [Elf64_Word, :e_flags], - [Elf64_Half, :e_ehsize], - [Elf64_Half, :e_phentsize], - [Elf64_Half, :e_phnum], - [Elf64_Half, :e_shentsize], - [Elf64_Half, :e_shnum], - [Elf64_Half, :e_shstrndx] - ].freeze - - Elf32_Phdr = [ - [Elf32_Word, :p_type], - [Elf32_Off, :p_offset], - [Elf32_Addr, :p_vaddr], - [Elf32_Addr, :p_paddr], - [Elf32_Word, :p_filesz], - [Elf32_Word, :p_memsz], - [Elf32_Word, :p_flags], - [Elf32_Word, :p_align] - ].freeze - - Elf64_Phdr = [ - [Elf64_Word, :p_type], - [Elf64_Word, :p_flags], - [Elf64_Off, :p_offset], - [Elf64_Addr, :p_vaddr], - [Elf64_Addr, :p_paddr], - [Elf64_Xword, :p_filesz], - [Elf64_Xword, :p_memsz], - [Elf64_Xword, :p_align] - ].freeze - - # rubocop:enable Naming/ConstantName - - # e_ident[] indexes - EI_MAG0 = 0 - EI_MAG1 = 1 - EI_MAG2 = 2 - EI_MAG3 = 3 - EI_CLASS = 4 - EI_DATA = 5 - EI_VERSION = 6 - EI_OSABI = 7 - EI_PAD = 8 - - # EI_MAG - ELFMAG0 = 0x7f - ELFMAG1 = 'E'.ord - ELFMAG2 = 'L'.ord - ELFMAG3 = 'F'.ord - ELFMAG = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3].pack('C*') - SELFMAG = 4 - - # e_ident[EI_CLASS] - ELFCLASSNONE = 0 - ELFCLASS32 = 1 - ELFCLASS64 = 2 - ELFCLASSNUM = 3 - - # e_ident[EI_DATA] - ELFDATANONE = 0 - ELFDATA2LSB = 1 - ELFDATA2MSB = 2 - - def initialize(buffer) - @buffer = buffer - @ehdr = read_ehdr - @buffer.seek(@ehdr[:e_phoff], :SET) - @proghdrs = Array.new(@ehdr[:e_phnum]) do - read_phdr - end - end - - def relocatable? - @ehdr[:e_type] == ET_REL - end - - def executable? - @ehdr[:e_type] == ET_EXEC - end - - def shared_object? - @ehdr[:e_type] == ET_DYN - end - - def core? - @ehdr[:e_type] == ET_CORE - end - - def interpreter - phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP } - return if phdr.nil? - - @buffer.seek(phdr[:p_offset], :SET) - interpreter = @buffer.read(phdr[:p_filesz]) - raise ArgumentError unless interpreter.end_with?("\0") - - interpreter.chomp!("\0") - end - - private - - def file_class - @ehdr[:e_ident][EI_CLASS] - end - - def data_encoding - @ehdr[:e_ident][EI_DATA] - end - - def read_ehdr - @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') } - raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG - - case file_class - when ELFCLASS32 - Elf32_Ehdr - when ELFCLASS64 - Elf64_Ehdr - else - raise ArgumentError - end.drop(1).to_h do |field| - [field[1], read1(field[0])] - end.merge!(@ehdr) - end - - def read_phdr - case file_class - when ELFCLASS32 - Elf32_Phdr - when ELFCLASS64 - Elf64_Phdr - else - raise ArgumentError - end.to_h do |field| - [field[1], read1(field[0])] - end - end - - def explicit_endian - case data_encoding - when ELFDATA2LSB - '<' - when ELFDATA2MSB - '>' - else - raise ArgumentError - end - end - - def read1(type) - case type - when :__u8 - @buffer.read(1).unpack1('C') - when :__u16 - @buffer.read(2).unpack1("S#{explicit_endian}") - when :__u32 - @buffer.read(4).unpack1("L#{explicit_endian}") - when :__u64 - @buffer.read(8).unpack1("Q#{explicit_endian}") - when :__s8 - @buffer.read(1).unpack1('c') - when :__s16 - @buffer.read(2).unpack1("s#{explicit_endian}") - when :__s32 - @buffer.read(4).unpack1("l#{explicit_endian}") - when :__s64 - @buffer.read(8).unpack1("q#{explicit_endian}") - else - raise ArgumentError - end - end - - INTERPRETER = proc do - proc_self_exe = '/proc/self/exe' - if File.exist?(proc_self_exe) - File.open(proc_self_exe, 'rb') do |file| - elf = ELF.new(file) - interpreter = elf.interpreter - if interpreter.nil? && elf.shared_object? - File.readlink(proc_self_exe) - else - interpreter - end - end - end - end.call - end - - private_constant :ELF - end -end From de476c3796b0c9f7c62b0437faa86e14221b8fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 24 May 2023 18:26:21 -0700 Subject: [PATCH 118/700] Use begin instead of proc --- lib/sass/elf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index 673ea5d0..d3c422fb 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -256,7 +256,7 @@ def read1(type) end end - INTERPRETER = proc do + INTERPRETER = begin proc_self_exe = '/proc/self/exe' if File.exist?(proc_self_exe) File.open(proc_self_exe, 'rb') do |file| @@ -269,7 +269,7 @@ def read1(type) end end end - end.call + end end private_constant :ELF From 5d6a5c2a997bb7df749478a685ffb5aa2e833ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 25 May 2023 14:47:12 -0700 Subject: [PATCH 119/700] Add Varint.length(value) --- lib/sass/embedded/varint.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/sass/embedded/varint.rb b/lib/sass/embedded/varint.rb index 3373bc9b..5a170b2a 100644 --- a/lib/sass/embedded/varint.rb +++ b/lib/sass/embedded/varint.rb @@ -8,6 +8,12 @@ class Embedded module Varint module_function + def length(value) + return 1 if value < 128 + + (value.bit_length + 6) / 7 + end + def read(readable) value = bits = 0 loop do From 073f0d21b379662d8b50e72c160ec4924eace117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 28 May 2023 21:56:29 -0700 Subject: [PATCH 120/700] Defer thread creation for logger --- lib/sass/embedded/dispatcher.rb | 4 +++- lib/sass/embedded/host.rb | 16 +++++++------- lib/sass/embedded/host/logger_registry.rb | 26 ++++++++++++++--------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 817aaa44..9abb9ffc 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -83,7 +83,9 @@ def receive_message end when :compile_response, :version_response @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) - when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request + when :log_event + @mutex.synchronize { @observers[message.compilation_id] }.public_send(oneof, message) + when :canonicalize_request, :import_request, :file_import_request, :function_call_request Thread.new(@mutex.synchronize { @observers[message.compilation_id] }) do |observer| observer.public_send(oneof, message) end diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index c4fee2d4..f4861ac9 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -76,10 +76,6 @@ def version_request "sass-embedded\t#{version_response.implementation_version}" end - def log_event(message) - @logger_registry.log(message) - end - def compile_response(message) resolve(message) end @@ -88,6 +84,14 @@ def version_response(message) resolve(message) end + def error(message) + reject(CompileError.new(message.message, nil, nil, nil)) + end + + def log_event(message) + @logger_registry.log(message) + end + def canonicalize_request(message) send_message(canonicalize_response: @importer_registry.canonicalize(message)) end @@ -104,10 +108,6 @@ def function_call_request(message) send_message(function_call_response: @function_registry.function_call(message)) end - def error(message) - reject(CompileError.new(message.message, nil, nil, nil)) - end - private def await diff --git a/lib/sass/embedded/host/logger_registry.rb b/lib/sass/embedded/host/logger_registry.rb index c40d51df..2ec4ade0 100644 --- a/lib/sass/embedded/host/logger_registry.rb +++ b/lib/sass/embedded/host/logger_registry.rb @@ -17,26 +17,32 @@ def log(event) case event.type when :DEBUG if logger.respond_to? :debug - logger.debug(event.message, - span: Protofier.from_proto_source_span(event.span)) + Thread.new do + logger.debug(event.message, + span: Protofier.from_proto_source_span(event.span)) + end else warn(event.formatted) end when :DEPRECATION_WARNING if logger.respond_to? :warn - logger.warn(event.message, - deprecation: true, - span: Protofier.from_proto_source_span(event.span), - stack: event.stack_trace) + Thread.new do + logger.warn(event.message, + deprecation: true, + span: Protofier.from_proto_source_span(event.span), + stack: event.stack_trace) + end else warn(event.formatted) end when :WARNING if logger.respond_to? :warn - logger.warn(event.message, - deprecation: false, - span: Protofier.from_proto_source_span(event.span), - stack: event.stack_trace) + Thread.new do + logger.warn(event.message, + deprecation: false, + span: Protofier.from_proto_source_span(event.span), + stack: event.stack_trace) + end else warn(event.formatted) end From 5b0de471e3154b392542c0c2233acd50cb70f273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 28 May 2023 23:34:14 -0700 Subject: [PATCH 121/700] Optimize LoggerRegistry --- lib/sass/embedded/host/logger_registry.rb | 49 +++++++++++------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/sass/embedded/host/logger_registry.rb b/lib/sass/embedded/host/logger_registry.rb index 2ec4ade0..8f014e26 100644 --- a/lib/sass/embedded/host/logger_registry.rb +++ b/lib/sass/embedded/host/logger_registry.rb @@ -7,45 +7,44 @@ class Host # # It stores logger and handles log events. class LoggerRegistry - attr_reader :logger - def initialize(logger) - @logger = Structifier.to_struct(logger, :debug, :warn) - end + logger = Structifier.to_struct(logger, :debug, :warn) - def log(event) - case event.type - when :DEBUG - if logger.respond_to? :debug + if logger.respond_to?(:debug) + define_singleton_method(:debug) do |event| Thread.new do logger.debug(event.message, span: Protofier.from_proto_source_span(event.span)) end - else - warn(event.formatted) end - when :DEPRECATION_WARNING - if logger.respond_to? :warn - Thread.new do - logger.warn(event.message, - deprecation: true, - span: Protofier.from_proto_source_span(event.span), - stack: event.stack_trace) - end - else - warn(event.formatted) + else + define_singleton_method(:debug) do |event| + Kernel.warn(event.formatted) end - when :WARNING - if logger.respond_to? :warn + end + + if logger.respond_to?(:warn) + define_singleton_method(:warn) do |event| Thread.new do logger.warn(event.message, - deprecation: false, + deprecation: event.type == :DEPRECATION_WARNING, span: Protofier.from_proto_source_span(event.span), stack: event.stack_trace) end - else - warn(event.formatted) end + else + define_singleton_method(:warn) do |event| + Kernel.warn(event.formatted) + end + end + end + + def log(event) + case event.type + when :DEBUG + debug(event) + when :DEPRECATION_WARNING, :WARNING + warn(event) end end end From e588033207fa68bb660fe72260bc47eb5667c75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 29 May 2023 00:18:49 -0700 Subject: [PATCH 122/700] Optimize LoggerRegistry --- lib/sass/embedded/host/logger_registry.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/sass/embedded/host/logger_registry.rb b/lib/sass/embedded/host/logger_registry.rb index 8f014e26..a81896e3 100644 --- a/lib/sass/embedded/host/logger_registry.rb +++ b/lib/sass/embedded/host/logger_registry.rb @@ -17,13 +17,9 @@ def initialize(logger) span: Protofier.from_proto_source_span(event.span)) end end - else - define_singleton_method(:debug) do |event| - Kernel.warn(event.formatted) - end end - if logger.respond_to?(:warn) + if logger.respond_to?(:warn) # rubocop:disable Style/GuardClause define_singleton_method(:warn) do |event| Thread.new do logger.warn(event.message, @@ -32,10 +28,6 @@ def initialize(logger) stack: event.stack_trace) end end - else - define_singleton_method(:warn) do |event| - Kernel.warn(event.formatted) - end end end @@ -47,6 +39,16 @@ def log(event) warn(event) end end + + private + + def debug(event) + Kernel.warn(event.formatted) + end + + def warn(event) + Kernel.warn(event.formatted) + end end private_constant :LoggerRegistry From 8c47d19eea81f759c2dd95ee6e43639a6cf24817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 31 May 2023 18:18:31 -0700 Subject: [PATCH 123/700] Move empty string to nil conversion to protofier --- lib/sass/compile_error.rb | 16 +++++++--------- lib/sass/compile_result.rb | 2 +- lib/sass/embedded/protofier.rb | 10 +++++----- lib/sass/logger/source_span.rb | 4 ++-- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 096ec2c4..cdff8225 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -4,25 +4,23 @@ module Sass # An exception thrown because a Sass compilation failed. class CompileError < StandardError # @return [String, nil] - attr_accessor :sass_stack + attr_reader :sass_stack # @return [Logger::SourceSpan, nil] - attr_accessor :span + attr_reader :span def initialize(message, full_message, sass_stack, span) super(message) - @full_message = full_message == '' ? nil : full_message.dup - @sass_stack = sass_stack == '' ? nil : sass_stack + @full_message = full_message + @sass_stack = sass_stack @span = span end # @return [String] def full_message(...) - if @full_message.nil? - super(...) - else - @full_message - end + return @full_message unless @full_message.nil? + + super(...) end end end diff --git a/lib/sass/compile_result.rb b/lib/sass/compile_result.rb index 70858355..c211b2e3 100644 --- a/lib/sass/compile_result.rb +++ b/lib/sass/compile_result.rb @@ -16,7 +16,7 @@ class CompileResult def initialize(css, source_map, loaded_urls) @css = css - @source_map = source_map == '' ? nil : source_map + @source_map = source_map @loaded_urls = loaded_urls end end diff --git a/lib/sass/embedded/protofier.rb b/lib/sass/embedded/protofier.rb index 504942da..73f8d30b 100644 --- a/lib/sass/embedded/protofier.rb +++ b/lib/sass/embedded/protofier.rb @@ -15,14 +15,14 @@ def from_proto_compile_response(compile_response) when :failure raise CompileError.new( result.message, - result.formatted, - result.stack_trace, + result.formatted == '' ? nil : +result.formatted, + result.stack_trace == '' ? nil : result.stack_trace, from_proto_source_span(result.span) ) when :success CompileResult.new( result.css, - result.source_map, + result.source_map == '' ? nil : result.source_map, result.loaded_urls ) else @@ -36,8 +36,8 @@ def from_proto_source_span(source_span) Logger::SourceSpan.new(from_proto_source_location(source_span.start), from_proto_source_location(source_span.end), source_span.text, - source_span.url, - source_span.context) + source_span.url == '' ? nil : source_span.url, + source_span.context == '' ? nil : source_span.context) end def from_proto_source_location(source_location) diff --git a/lib/sass/logger/source_span.rb b/lib/sass/logger/source_span.rb index 23c505f2..090781a6 100644 --- a/lib/sass/logger/source_span.rb +++ b/lib/sass/logger/source_span.rb @@ -19,8 +19,8 @@ def initialize(start, end_, text, url, context) @start = start @end = end_ @text = text - @url = url == '' ? nil : url - @context = context == '' ? nil : context + @url = url + @context = context end end end From 3afbd3dd823a188de100eec3dc5b1801c2af347f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 1 Jun 2023 08:38:32 -0700 Subject: [PATCH 124/700] Lazily unfreeze full_message --- lib/sass/compile_error.rb | 4 ++-- lib/sass/embedded/protofier.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index cdff8225..463b05b4 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -18,9 +18,9 @@ def initialize(message, full_message, sass_stack, span) # @return [String] def full_message(...) - return @full_message unless @full_message.nil? + return super(...) if @full_message.nil? - super(...) + @full_message = +@full_message end end end diff --git a/lib/sass/embedded/protofier.rb b/lib/sass/embedded/protofier.rb index 73f8d30b..f8fddc66 100644 --- a/lib/sass/embedded/protofier.rb +++ b/lib/sass/embedded/protofier.rb @@ -15,7 +15,7 @@ def from_proto_compile_response(compile_response) when :failure raise CompileError.new( result.message, - result.formatted == '' ? nil : +result.formatted, + result.formatted == '' ? nil : result.formatted, result.stack_trace == '' ? nil : result.stack_trace, from_proto_source_span(result.span) ) From 5ebcc06052b8088b872bffaf548f09e7b24925a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:58:06 +0000 Subject: [PATCH 125/700] Update rubocop requirement from ~> 1.51.0 to ~> 1.52.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.51.0...v1.52.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index aa76fd02..88768035 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 10.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.51.0' + gem 'rubocop', '~> 1.52.0' gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.22.0' From 348b2f8555ef8dc259c1c905ff727fefc455d84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 3 Jun 2023 14:22:14 -0700 Subject: [PATCH 126/700] Rename ext/sass/embedded.rb to ext/sass/cli.rb --- Rakefile | 4 ++-- exe/sass | 11 +++++++---- ext/sass/.gitignore | 2 +- ext/sass/Rakefile | 30 +++++++++++++++--------------- lib/sass/embedded.rb | 2 +- lib/sass/embedded/compiler.rb | 4 ++-- sass-embedded.gemspec | 4 ++-- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Rakefile b/Rakefile index f259295f..185aaa74 100644 --- a/Rakefile +++ b/Rakefile @@ -13,11 +13,11 @@ task :compile do if ENV.key?('ext_platform') host_cpu, host_os = ENV['ext_platform'].split('-', 2) - rm 'ext/sass/embedded.rb' + rm 'ext/sass/cli.rb' rm_rf 'ext/sass/sass_embedded' sh 'rake', '-C', 'ext/sass', - '-E', "RbConfig::CONFIG.merge!({ 'host_cpu' => #{host_cpu.dump}, 'host_os' => #{host_os.dump} })", 'embedded.rb' + '-E', "RbConfig::CONFIG.merge!({ 'host_cpu' => #{host_cpu.dump}, 'host_os' => #{host_os.dump} })", 'cli.rb' end end diff --git a/exe/sass b/exe/sass index 736537fa..58b15a55 100755 --- a/exe/sass +++ b/exe/sass @@ -1,18 +1,21 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require_relative '../ext/sass/embedded' +require_relative '../ext/sass/cli' module Sass - class Embedded # rubocop:disable Style/Documentation + # The `sass` command line interface + class CLI begin - exec(*Compiler::COMMAND, *ARGV) + exec(*COMMAND, *ARGV) rescue Errno::ENOENT require_relative '../lib/sass/elf' raise if ELF::INTERPRETER.nil? - exec(ELF::INTERPRETER, *Compiler::COMMAND, *ARGV) + exec(ELF::INTERPRETER, *COMMAND, *ARGV) end end + + private_constant :CLI end diff --git a/ext/sass/.gitignore b/ext/sass/.gitignore index 198cc4bd..4e1b8cb6 100644 --- a/ext/sass/.gitignore +++ b/ext/sass/.gitignore @@ -1,6 +1,6 @@ /*.tar.gz /*.zip -/embedded.rb +/cli.rb /embedded_sass.proto /embedded_sass_pb.rb /protoc.exe diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index e639272f..961103b0 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -4,13 +4,13 @@ require 'rake/clean' task default: %i[install clean] -task install: %w[embedded.rb] do +task install: %w[cli.rb] do Rake::Task['embedded_sass_pb.rb'].invoke unless File.exist?('embedded_sass_pb.rb') end CLEAN.include %w[protoc.exe *.proto *.tar.gz *.zip] -CLOBBER.include %w[sass_embedded embedded.rb embedded_sass_pb.rb] +CLOBBER.include %w[sass_embedded cli.rb embedded_sass_pb.rb] file 'protoc.exe' do |t| fetch(ENV.fetch('PROTOC_BIN') { Configuration.default_protoc }, t.name) @@ -23,7 +23,7 @@ file 'sass_embedded' do |t| rm archive end -file 'embedded.rb' => %w[sass_embedded] do |t| +file 'cli.rb' => %w[sass_embedded] do |t| exe = 'sass_embedded/dart-sass-embedded' exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" @@ -35,29 +35,29 @@ file 'embedded.rb' => %w[sass_embedded] do |t| command = if File.exist?(runtime) && File.exist?(snapshot) " - File.absolute_path('#{runtime}', __dir__), - File.absolute_path('#{snapshot}', __dir__) - " + File.absolute_path('#{runtime}', __dir__), + File.absolute_path('#{snapshot}', __dir__) + " else " - File.absolute_path('#{exe}', __dir__) - " + File.absolute_path('#{exe}', __dir__) + " end - File.write(t.name, <<~EMBEDDED_RB) + File.write(t.name, <<~CLI_RB) # frozen_string_literal: true module Sass - class Embedded - class Compiler - COMMAND = [#{command}].freeze - end + class CLI + COMMAND = [#{command}].freeze end + + private_constant :CLI end - EMBEDDED_RB + CLI_RB end -file 'embedded_sass.proto' => %w[embedded.rb] do |t| +file 'embedded_sass.proto' => %w[cli.rb] do |t| fetch(ENV.fetch('SASS_EMBEDDED_PROTOCOL') { Configuration.default_sass_embedded_protocol }, t.name) end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 0c6b38a9..eaa9be62 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../ext/sass/embedded' +require_relative '../../ext/sass/cli' require_relative '../../ext/sass/embedded_sass_pb' require_relative 'compile_error' require_relative 'compile_result' diff --git a/lib/sass/embedded/compiler.rb b/lib/sass/embedded/compiler.rb index 0c73d179..33e432d7 100644 --- a/lib/sass/embedded/compiler.rb +++ b/lib/sass/embedded/compiler.rb @@ -10,13 +10,13 @@ class Embedded class Compiler def initialize @stdin, @stdout, @stderr, @wait_thread = begin - Open3.popen3(*COMMAND, chdir: __dir__) + Open3.popen3(*CLI::COMMAND, chdir: __dir__) rescue Errno::ENOENT require_relative '../elf' raise if ELF::INTERPRETER.nil? - Open3.popen3(ELF::INTERPRETER, *COMMAND, chdir: __dir__) + Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, chdir: __dir__) end @stdin.binmode diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index f9785eae..2cb36a22 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -19,10 +19,10 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.bindir = 'exe' spec.executables = ['sass'] - spec.files = Dir['exe/**/*'] + Dir['lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.files = Dir['exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') - spec.files += Dir['ext/sass/*.rb'] + Dir['ext/sass/sass_embedded/**/*'] + spec.files += Dir['ext/sass/*.rb', 'ext/sass/sass_embedded/**/*'] spec.platform = ENV['gem_platform'] spec.required_rubygems_version = '>= 3.3.22' if ENV['gem_platform'].include?('-linux-') else From 4c79087391c319f10061b59d31ddb2a894e351a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 3 Jun 2023 15:57:36 -0700 Subject: [PATCH 127/700] Update google-protobuf requirement from ~> 3.21 to ~> 3.23 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 2cb36a22..e3da3ef7 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -36,6 +36,6 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.required_ruby_version = '>= 2.7.0' - spec.add_runtime_dependency 'google-protobuf', '~> 3.21' + spec.add_runtime_dependency 'google-protobuf', '~> 3.23' spec.add_runtime_dependency 'rake', '>= 10.0.0' unless ENV.key?('gem_platform') end From 7bbe3ac2f2716ad8e17490d33fb1254a8eea9061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 4 Jun 2023 14:13:44 -0700 Subject: [PATCH 128/700] Use Errno::EBUSY internally --- lib/sass/embedded/channel.rb | 2 +- lib/sass/embedded/dispatcher.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/embedded/channel.rb b/lib/sass/embedded/channel.rb index fe6de32c..d7d46a72 100644 --- a/lib/sass/embedded/channel.rb +++ b/lib/sass/embedded/channel.rb @@ -27,7 +27,7 @@ def connect(observer) @mutex.synchronize do begin id = @dispatcher.subscribe(observer) - rescue EOFError + rescue Errno::EBUSY @dispatcher = Dispatcher.new id = @dispatcher.subscribe(observer) end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 9abb9ffc..400f9f6b 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -31,7 +31,7 @@ def initialize def subscribe(observer) @mutex.synchronize do - raise EOFError if @id == PROTOCOL_ERROR_ID + raise Errno::EBUSY if @id == PROTOCOL_ERROR_ID id = @id @id = id.next From 3223c7e0be1cf72d2328916117ad76349883544d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 4 Jun 2023 14:14:57 -0700 Subject: [PATCH 129/700] Rename PROTOCOL_ERROR_ID to UINT_MAX --- lib/sass/embedded/dispatcher.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 400f9f6b..64a00f11 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -6,7 +6,7 @@ class Embedded # # It dispatches messages between mutliple instances of {Host} and a single {Compiler}. class Dispatcher - PROTOCOL_ERROR_ID = 0xffffffff + UINT_MAX = 0xffffffff def initialize @compiler = Compiler.new @@ -19,7 +19,7 @@ def initialize receive_message rescue IOError, Errno::EBADF => e @mutex.synchronize do - @id = PROTOCOL_ERROR_ID + @id = UINT_MAX @observers.values end.each do |observer| observer.error e @@ -31,7 +31,7 @@ def initialize def subscribe(observer) @mutex.synchronize do - raise Errno::EBUSY if @id == PROTOCOL_ERROR_ID + raise Errno::EBUSY if @id == UINT_MAX id = @id @id = id.next @@ -46,7 +46,7 @@ def unsubscribe(id) return unless @observers.empty? - if @id == PROTOCOL_ERROR_ID + if @id == UINT_MAX close else @id = 0 @@ -76,8 +76,8 @@ def receive_message case oneof when :error @mutex.synchronize do - @id = PROTOCOL_ERROR_ID - message.id == PROTOCOL_ERROR_ID ? @observers.values : [@observers[message.id]] + @id = UINT_MAX + message.id == UINT_MAX ? @observers.values : [@observers[message.id]] end.each do |observer| observer.public_send(oneof, message) end From 7372bf25f5fbae07a2089678631082d74beda54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 5 Jun 2023 15:38:43 -0700 Subject: [PATCH 130/700] Rename SASS_EMBEDDED_PROTOCOL to EMBEDDED_SASS_PROTOCOL --- ext/sass/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 961103b0..8853bf7f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -58,7 +58,7 @@ file 'cli.rb' => %w[sass_embedded] do |t| end file 'embedded_sass.proto' => %w[cli.rb] do |t| - fetch(ENV.fetch('SASS_EMBEDDED_PROTOCOL') { Configuration.default_sass_embedded_protocol }, t.name) + fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') { Configuration.default_embedded_sass_protocol }, t.name) end rule '_pb.rb' => %w[.proto protoc.exe] do |t| @@ -303,7 +303,7 @@ module Configuration "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe" end - def default_sass_embedded_protocol + def default_embedded_sass_protocol require 'json' require 'open3' From 3c0fdd83cb8671cb20aa1fe3d30bb5278765cad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 13 May 2023 22:10:01 -0700 Subject: [PATCH 131/700] Bump sass from 1.62.1 to 1.63.0 in /ext/sass --- Rakefile | 2 +- ext/sass/.gitignore | 2 +- ext/sass/Rakefile | 31 ++++++------ ext/sass/package.json | 2 +- lib/sass/compile_error.rb | 6 ++- lib/sass/embedded.rb | 1 - lib/sass/embedded/async.rb | 58 ---------------------- lib/sass/embedded/channel.rb | 4 +- lib/sass/embedded/compiler.rb | 17 ++++--- lib/sass/embedded/dispatcher.rb | 45 +++++++++-------- lib/sass/embedded/host.rb | 60 +++++++++++++++++------ lib/sass/embedded/host/logger_registry.rb | 16 +++--- lib/sass/embedded/protofier.rb | 5 +- sass-embedded.gemspec | 2 +- spec/console.rb | 6 --- 15 files changed, 114 insertions(+), 143 deletions(-) delete mode 100644 lib/sass/embedded/async.rb diff --git a/Rakefile b/Rakefile index 185aaa74..4d17d81e 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ task :compile do host_cpu, host_os = ENV['ext_platform'].split('-', 2) rm 'ext/sass/cli.rb' - rm_rf 'ext/sass/sass_embedded' + rm_rf 'ext/sass/dart-sass' sh 'rake', '-C', 'ext/sass', '-E', "RbConfig::CONFIG.merge!({ 'host_cpu' => #{host_cpu.dump}, 'host_os' => #{host_os.dump} })", 'cli.rb' diff --git a/ext/sass/.gitignore b/ext/sass/.gitignore index 4e1b8cb6..9e8b2514 100644 --- a/ext/sass/.gitignore +++ b/ext/sass/.gitignore @@ -1,7 +1,7 @@ /*.tar.gz /*.zip /cli.rb +/dart-sass /embedded_sass.proto /embedded_sass_pb.rb /protoc.exe -/sass_embedded diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 8853bf7f..1424f8aa 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -10,28 +10,28 @@ end CLEAN.include %w[protoc.exe *.proto *.tar.gz *.zip] -CLOBBER.include %w[sass_embedded cli.rb embedded_sass_pb.rb] +CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb] file 'protoc.exe' do |t| fetch(ENV.fetch('PROTOC_BIN') { Configuration.default_protoc }, t.name) chmod 'a+x', t.name end -file 'sass_embedded' do |t| - archive = fetch(ENV.fetch(t.name.upcase) { Configuration.default_sass_embedded }) +file 'dart-sass' do |t| + archive = fetch(ENV.fetch(t.name.tr('-', '_').upcase) { Configuration.default_dart_sass }) unarchive archive rm archive end -file 'cli.rb' => %w[sass_embedded] do |t| - exe = 'sass_embedded/dart-sass-embedded' +file 'cli.rb' => %w[dart-sass] do |t| + exe = 'dart-sass/sass' exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" raise "#{exe} not found" unless File.exist?(exe) - runtime = 'sass_embedded/src/dart' + runtime = 'dart-sass/src/dart' runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}" - snapshot = 'sass_embedded/src/dart-sass-embedded.snapshot' + snapshot = 'dart-sass/src/sass.snapshot' command = if File.exist?(runtime) && File.exist?(snapshot) " @@ -221,16 +221,16 @@ module Configuration module_function - def default_sass_embedded + def default_dart_sass require 'json' - repo = 'https://github.com/sass/dart-sass-embedded' + repo = 'https://github.com/sass/dart-sass' spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__))) tag_name = spec['dependencies']['sass'] - message = "sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}" + message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}" os = case Platform::OS when 'darwin' @@ -238,10 +238,10 @@ module Configuration when 'linux' 'linux' when 'linux-android' - repo = 'https://github.com/dart-android/dart-sass-embedded' + repo = 'https://github.com/dart-android/dart-sass' 'android' when 'linux-musl' - repo = 'https://github.com/dart-musl/dart-sass-embedded' + repo = 'https://github.com/dart-musl/dart-sass' 'linux' when 'windows' 'windows' @@ -264,7 +264,7 @@ module Configuration ext = Platform::OS == 'windows' ? 'zip' : 'tar.gz' - "#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{cpu}.#{ext}" + "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}.#{ext}" end def default_protoc @@ -307,7 +307,10 @@ module Configuration require 'json' require 'open3' - stdout, stderr, status = Open3.capture3(RbConfig.ruby, File.absolute_path('../../exe/sass', __dir__), '--version') + stdout, stderr, status = Open3.capture3(RbConfig.ruby, + File.absolute_path('../../exe/sass', __dir__), + '--embedded', + '--version') raise stderr unless status.success? diff --git a/ext/sass/package.json b/ext/sass/package.json index f51890ef..9bc19c86 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.62.1" + "sass": "1.63.0" } } diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 463b05b4..c3537cc5 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -9,11 +9,15 @@ class CompileError < StandardError # @return [Logger::SourceSpan, nil] attr_reader :span - def initialize(message, full_message, sass_stack, span) + # @return [Array] + attr_reader :loaded_urls + + def initialize(message, full_message, sass_stack, span, loaded_urls) super(message) @full_message = full_message @sass_stack = sass_stack @span = span + @loaded_urls = loaded_urls end # @return [String] diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index eaa9be62..ce94ac81 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -4,7 +4,6 @@ require_relative '../../ext/sass/embedded_sass_pb' require_relative 'compile_error' require_relative 'compile_result' -require_relative 'embedded/async' require_relative 'embedded/channel' require_relative 'embedded/compiler' require_relative 'embedded/dispatcher' diff --git a/lib/sass/embedded/async.rb b/lib/sass/embedded/async.rb deleted file mode 100644 index 51bc3869..00000000 --- a/lib/sass/embedded/async.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -module Sass - class Embedded - # The {Async} class. - # - # It awaits until the promise is resolved or rejected. - class Async - module State - PENDING = 0 - FULFILLED = 1 - REJECTED = 2 - end - - private_constant :State - - def initialize - @result = nil - @state = State::PENDING - - @condition_variable = ConditionVariable.new - @mutex = Mutex.new - end - - def resolve(value) - @mutex.synchronize do - return unless @state == State::PENDING - - @result = value - @state = State::FULFILLED - @condition_variable.broadcast - end - end - - def reject(reason) - @mutex.synchronize do - return unless @state == State::PENDING - - @result = reason - @state = State::REJECTED - @condition_variable.broadcast - end - end - - def await - @mutex.synchronize do - @condition_variable.wait(@mutex) if @state == State::PENDING - - raise @result if @state == State::REJECTED - - @result - end - end - end - - private_constant :Async - end -end diff --git a/lib/sass/embedded/channel.rb b/lib/sass/embedded/channel.rb index d7d46a72..a3eaed01 100644 --- a/lib/sass/embedded/channel.rb +++ b/lib/sass/embedded/channel.rb @@ -48,8 +48,8 @@ def disconnect @dispatcher.unsubscribe(id) end - def send_message(...) - @dispatcher.send_message(...) + def send_proto(...) + @dispatcher.send_proto(...) end end diff --git a/lib/sass/embedded/compiler.rb b/lib/sass/embedded/compiler.rb index 33e432d7..4508e9a9 100644 --- a/lib/sass/embedded/compiler.rb +++ b/lib/sass/embedded/compiler.rb @@ -6,17 +6,17 @@ module Sass class Embedded # The {Compiler} class. # - # It runs the `dart-sass-embedded` process. + # It runs the `sass --embedded` process. class Compiler def initialize @stdin, @stdout, @stderr, @wait_thread = begin - Open3.popen3(*CLI::COMMAND, chdir: __dir__) + Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) rescue Errno::ENOENT require_relative '../elf' raise if ELF::INTERPRETER.nil? - Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, chdir: __dir__) + Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) end @stdin.binmode @@ -49,17 +49,20 @@ def closed? end end - def write(payload) + def write(id, proto) @stdin_mutex.synchronize do - Varint.write(@stdin, payload.length) - @stdin.write(payload) + Varint.write(@stdin, Varint.length(id) + proto.length) + Varint.write(@stdin, id) + @stdin.write(proto) end end def read @stdout_mutex.synchronize do length = Varint.read(@stdout) - @stdout.read(length) + id = Varint.read(@stdout) + proto = @stdout.read(length - Varint.length(id)) + return id, proto end end end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 64a00f11..ef0bbd2f 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -11,18 +11,18 @@ class Dispatcher def initialize @compiler = Compiler.new @observers = {} - @id = 0 + @id = 1 @mutex = Mutex.new Thread.new do loop do - receive_message + receive_proto rescue IOError, Errno::EBADF => e @mutex.synchronize do @id = UINT_MAX @observers.values end.each do |observer| - observer.error e + observer.error(e) end break end @@ -49,7 +49,7 @@ def unsubscribe(id) if @id == UINT_MAX close else - @id = 0 + @id = 1 end end end @@ -62,35 +62,34 @@ def closed? @compiler.closed? end - def send_message(...) - inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @compiler.write(inbound_message.to_proto) + def send_proto(...) + @compiler.write(...) end private - def receive_message - outbound_message = EmbeddedProtocol::OutboundMessage.decode(@compiler.read) - oneof = outbound_message.message - message = outbound_message.public_send(oneof) - case oneof - when :error + def receive_proto + id, proto = @compiler.read + case id + when 1...UINT_MAX + @mutex.synchronize { @observers[id] }.receive_proto(proto) + when 0 + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) + when UINT_MAX + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) @mutex.synchronize do @id = UINT_MAX message.id == UINT_MAX ? @observers.values : [@observers[message.id]] end.each do |observer| - observer.public_send(oneof, message) - end - when :compile_response, :version_response - @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) - when :log_event - @mutex.synchronize { @observers[message.compilation_id] }.public_send(oneof, message) - when :canonicalize_request, :import_request, :file_import_request, :function_call_request - Thread.new(@mutex.synchronize { @observers[message.compilation_id] }) do |observer| - observer.public_send(oneof, message) + observer.public_send(oneof, Errno::EPROTO.new(message.message)) end else - raise ArgumentError, "Unknown OutboundMessage.message #{message}" + raise ArgumentError end end end diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index f4861ac9..826a7455 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -40,7 +40,6 @@ def compile_request(path:, @logger_registry = LoggerRegistry.new(logger) send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( - id: id, string: unless source.nil? EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( source: source, @@ -67,8 +66,8 @@ def compile_request(path:, end def version_request - version_response = await do - send_message(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( + version_response = await0 do + send_message0(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( id: id )) end @@ -77,15 +76,18 @@ def version_request end def compile_response(message) - resolve(message) + @result = message + @queue.close end def version_response(message) - resolve(message) + @result = message + @queue.close end def error(message) - reject(CompileError.new(message.message, nil, nil, nil)) + @error = message + @queue.close end def log_event(message) @@ -108,31 +110,59 @@ def function_call_request(message) send_message(function_call_response: @function_registry.function_call(message)) end + def receive_proto(proto) + @queue.push(proto) + end + private - def await + def await0 @connection = @channel.connect(self) - @async = Async.new + @queue = Queue.new + yield - @async.await + + @queue.pop + + raise @error if @error + + @result ensure @connection&.disconnect end - def resolve(value) - @async.resolve(value) - end + def await + @connection = @channel.connect(self) + @queue = Queue.new - def reject(reason) - @async.reject(reason) + yield + + while (proto = @queue.pop) + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + public_send(oneof, message) + end + + raise @error if @error + + @result + ensure + @connection&.disconnect end def id @connection.id end + def send_message0(...) + inbound_message = EmbeddedProtocol::InboundMessage.new(...) + @connection.send_proto(0, inbound_message.to_proto) + end + def send_message(...) - @connection.send_message(...) + inbound_message = EmbeddedProtocol::InboundMessage.new(...) + @connection.send_proto(id, inbound_message.to_proto) end end diff --git a/lib/sass/embedded/host/logger_registry.rb b/lib/sass/embedded/host/logger_registry.rb index a81896e3..46c0e67c 100644 --- a/lib/sass/embedded/host/logger_registry.rb +++ b/lib/sass/embedded/host/logger_registry.rb @@ -12,21 +12,17 @@ def initialize(logger) if logger.respond_to?(:debug) define_singleton_method(:debug) do |event| - Thread.new do - logger.debug(event.message, - span: Protofier.from_proto_source_span(event.span)) - end + logger.debug(event.message, + span: Protofier.from_proto_source_span(event.span)) end end if logger.respond_to?(:warn) # rubocop:disable Style/GuardClause define_singleton_method(:warn) do |event| - Thread.new do - logger.warn(event.message, - deprecation: event.type == :DEPRECATION_WARNING, - span: Protofier.from_proto_source_span(event.span), - stack: event.stack_trace) - end + logger.warn(event.message, + deprecation: event.type == :DEPRECATION_WARNING, + span: Protofier.from_proto_source_span(event.span), + stack: event.stack_trace) end end end diff --git a/lib/sass/embedded/protofier.rb b/lib/sass/embedded/protofier.rb index f8fddc66..4e3a4ed6 100644 --- a/lib/sass/embedded/protofier.rb +++ b/lib/sass/embedded/protofier.rb @@ -17,13 +17,14 @@ def from_proto_compile_response(compile_response) result.message, result.formatted == '' ? nil : result.formatted, result.stack_trace == '' ? nil : result.stack_trace, - from_proto_source_span(result.span) + from_proto_source_span(result.span), + compile_response.loaded_urls ) when :success CompileResult.new( result.css, result.source_map == '' ? nil : result.source_map, - result.loaded_urls + compile_response.loaded_urls ) else raise ArgumentError, "Unknown CompileResponse.result #{result}" diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index e3da3ef7..def74572 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.files = Dir['exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') - spec.files += Dir['ext/sass/*.rb', 'ext/sass/sass_embedded/**/*'] + spec.files += Dir['ext/sass/*.rb', 'ext/sass/dart-sass/**/*'] spec.platform = ENV['gem_platform'] spec.required_rubygems_version = '>= 3.3.22' if ENV['gem_platform'].include?('-linux-') else diff --git a/spec/console.rb b/spec/console.rb index 1eeddfa1..2fe50205 100644 --- a/spec/console.rb +++ b/spec/console.rb @@ -9,14 +9,8 @@ def capture_stdio stderr = $stderr $stderr = StringIO.new - thread_list = Thread.list - yield - Thread.list.each do |thread| - thread.join unless thread_list.include? thread - end - ConsoleOutput.new $stdout.string, $stderr.string ensure $stdout = stdout From 00846e1ed27366442f8d6c2dde853fe7c19e020f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 7 Jun 2023 16:30:18 -0700 Subject: [PATCH 132/700] Simplify protocol error handling --- lib/sass/embedded/dispatcher.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index ef0bbd2f..839e7734 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -17,7 +17,7 @@ def initialize Thread.new do loop do receive_proto - rescue IOError, Errno::EBADF => e + rescue IOError, Errno::EBADF, Errno::EPROTO => e @mutex.synchronize do @id = UINT_MAX @observers.values @@ -82,14 +82,9 @@ def receive_proto outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) oneof = outbound_message.message message = outbound_message.public_send(oneof) - @mutex.synchronize do - @id = UINT_MAX - message.id == UINT_MAX ? @observers.values : [@observers[message.id]] - end.each do |observer| - observer.public_send(oneof, Errno::EPROTO.new(message.message)) - end + raise Errno::EPROTO, message.message else - raise ArgumentError + raise Errno::EPROTO end end end From 32c93f914fd69cad7da4371ad734d08e5ad38571 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 00:48:22 +0000 Subject: [PATCH 133/700] Bump sass from 1.63.0 to 1.63.1 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.0 to 1.63.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.0...1.63.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 9bc19c86..1aaea09e 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.0" + "sass": "1.63.1" } } From 122bf518457892f9738ba71aefd4853760134556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 7 Jun 2023 18:44:42 -0700 Subject: [PATCH 134/700] v1.63.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index b2be0b90..4ff73e90 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.62.1' + VERSION = '1.63.1' end end From 337eb82175f307cbeb1a01c8c15a7f326b8529ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 03:28:15 +0000 Subject: [PATCH 135/700] Bump sass from 1.63.1 to 1.63.2 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.1 to 1.63.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.1...1.63.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 1aaea09e..b33b8c81 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.1" + "sass": "1.63.2" } } From bcb7e2577564f871822ab4fbb456ea08307945ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 7 Jun 2023 21:01:04 -0700 Subject: [PATCH 136/700] v1.63.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 4ff73e90..359bb006 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.63.1' + VERSION = '1.63.2' end end From 5daff96893ac023a08b59d5fb9fcf99ff2102ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 8 Jun 2023 16:12:54 -0700 Subject: [PATCH 137/700] Work around race condition bug in dart-sass compiler --- lib/sass/embedded/dispatcher.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 839e7734..9f61ac92 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -46,11 +46,15 @@ def unsubscribe(id) return unless @observers.empty? - if @id == UINT_MAX - close - else - @id = 1 - end + # if @id == UINT_MAX + # close + # else + # @id = 1 + # end + + # Resetting @id can cause a race condition in compiler + # See: https://github.com/sass/dart-sass/issues/2004 + close if @id == UINT_MAX end end From e1829690651b549bed3a42518fed2881d3e61731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Jun 2023 09:00:00 -0700 Subject: [PATCH 138/700] Enable RSpec color mode in GitHub Actions --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9787b047..b7e275ed 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,6 +7,7 @@ require_relative './sandbox' RSpec.configure do |config| + config.color_mode = :on if ENV.key?('GITHUB_ACTIONS') config.formatter = :documentation config.include Console From 8bc40cfa8b3874fd072bde8b4a3a9d0a9477d17b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Jun 2023 16:05:03 +0000 Subject: [PATCH 139/700] Bump sass from 1.63.2 to 1.63.3 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.2 to 1.63.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.2...1.63.3) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index b33b8c81..b32d5be8 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.2" + "sass": "1.63.3" } } From 1e875169039290c7ae576d3cb466b16b1e27a6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Jun 2023 09:39:53 -0700 Subject: [PATCH 140/700] v1.63.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 359bb006..f61a0c92 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.63.2' + VERSION = '1.63.3' end end From d5e2775debaa6def15d76aac3d8b0795fee100f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 11 Jun 2023 10:57:54 -0700 Subject: [PATCH 141/700] Update rake requirement from >= 10.0.0 to >= 13.0.0 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index def74572..8e02c0ee 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -37,5 +37,5 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.required_ruby_version = '>= 2.7.0' spec.add_runtime_dependency 'google-protobuf', '~> 3.23' - spec.add_runtime_dependency 'rake', '>= 10.0.0' unless ENV.key?('gem_platform') + spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') end From fbc9b86c88b460929ce194b8950806961d71bb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 11 Jun 2023 15:46:30 -0700 Subject: [PATCH 142/700] Update rake requirement from >= 10.0.0 to >= 13.0.0 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 88768035..7eee0066 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'https://rubygems.org' gemspec group :development do - gem 'rake', '>= 10.0.0' + gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' gem 'rubocop', '~> 1.52.0' gem 'rubocop-performance', '~> 1.18.0' From 874da814fa74f0ac225de8cf0f058d51a9f56ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 12 Jun 2023 23:03:13 -0700 Subject: [PATCH 143/700] Move conneciton class --- lib/sass/embedded/channel.rb | 31 ++++--------------------------- lib/sass/embedded/dispatcher.rb | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/lib/sass/embedded/channel.rb b/lib/sass/embedded/channel.rb index a3eaed01..20e0d733 100644 --- a/lib/sass/embedded/channel.rb +++ b/lib/sass/embedded/channel.rb @@ -25,35 +25,12 @@ def closed? def connect(observer) @mutex.synchronize do - begin - id = @dispatcher.subscribe(observer) - rescue Errno::EBUSY - @dispatcher = Dispatcher.new - id = @dispatcher.subscribe(observer) - end - Connection.new(@dispatcher, id) + @dispatcher.connect(observer) + rescue Errno::EBUSY + @dispatcher = Dispatcher.new + @dispatcher.connect(observer) end end - - # The {Connection} between {Host} to {Dispatcher}. - class Connection - attr_reader :id - - def initialize(dispatcher, id) - @dispatcher = dispatcher - @id = id - end - - def disconnect - @dispatcher.unsubscribe(id) - end - - def send_proto(...) - @dispatcher.send_proto(...) - end - end - - private_constant :Connection end private_constant :Channel diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 9f61ac92..358270cb 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -58,6 +58,10 @@ def unsubscribe(id) end end + def connect(host) + Connection.new(self, subscribe(host)) + end + def close @compiler.close end @@ -91,6 +95,26 @@ def receive_proto raise Errno::EPROTO end end + + # The {Connection} between {Host} to {Dispatcher}. + class Connection + attr_reader :id + + def initialize(dispatcher, id) + @dispatcher = dispatcher + @id = id + end + + def disconnect + @dispatcher.unsubscribe(id) + end + + def send_proto(...) + @dispatcher.send_proto(...) + end + end + + private_constant :Connection end private_constant :Dispatcher From 8052a4a8a99f16d65ffcf364b766ba339ea4e655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 12 Jun 2023 23:44:47 -0700 Subject: [PATCH 144/700] Rename Channel to ResilientDispatcher --- lib/sass/embedded.rb | 16 ++++++++-------- lib/sass/embedded/dispatcher.rb | 8 ++++---- lib/sass/embedded/host.rb | 8 ++++---- .../{channel.rb => resilient_dispatcher.rb} | 14 +++++++------- 4 files changed, 23 insertions(+), 23 deletions(-) rename lib/sass/embedded/{channel.rb => resilient_dispatcher.rb} (65%) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index ce94ac81..9c0564e8 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -4,11 +4,11 @@ require_relative '../../ext/sass/embedded_sass_pb' require_relative 'compile_error' require_relative 'compile_result' -require_relative 'embedded/channel' require_relative 'embedded/compiler' require_relative 'embedded/dispatcher' require_relative 'embedded/host' require_relative 'embedded/protofier' +require_relative 'embedded/resilient_dispatcher' require_relative 'embedded/structifier' require_relative 'embedded/varint' require_relative 'embedded/version' @@ -80,7 +80,7 @@ def instance # rubocop:enable Layout/LineLength # The {Embedded} host for using dart-sass. Each instance creates its own - # communication {Channel} with a dedicated compiler process. + # communication {Dispatcher} with a dedicated compiler process. # # @example # embedded = Sass::Embedded.new @@ -89,7 +89,7 @@ def instance # embedded.close class Embedded def initialize - @channel = Channel.new + @dispatcher = ResilientDispatcher.new end # Compiles the Sass file at +path+ to CSS. @@ -138,7 +138,7 @@ def compile(path, verbose: false) raise ArgumentError, 'path must be set' if path.nil? - Host.new(@channel).compile_request( + Host.new(@dispatcher).compile_request( path: path, source: nil, importer: nil, @@ -212,7 +212,7 @@ def compile_string(source, verbose: false) raise ArgumentError, 'source must be set' if source.nil? - Host.new(@channel).compile_request( + Host.new(@dispatcher).compile_request( path: nil, source: source, importer: importer, @@ -236,15 +236,15 @@ def compile_string(source, # @return [String] Information about the Sass implementation. # @see https://sass-lang.com/documentation/js-api/modules#info def info - @info ||= Host.new(@channel).version_request + @info ||= Host.new(@dispatcher).version_request end def close - @channel.close + @dispatcher.close end def closed? - @channel.closed? + @dispatcher.closed? end end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 358270cb..7a13a36e 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -59,7 +59,7 @@ def unsubscribe(id) end def connect(host) - Connection.new(self, subscribe(host)) + Connection.new(self, host) end def close @@ -96,13 +96,13 @@ def receive_proto end end - # The {Connection} between {Host} to {Dispatcher}. + # The {Connection} between {Dispatcher} and {Host}. class Connection attr_reader :id - def initialize(dispatcher, id) + def initialize(dispatcher, host) @dispatcher = dispatcher - @id = id + @id = @dispatcher.subscribe(host) end def disconnect diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 826a7455..1cdd8626 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -11,8 +11,8 @@ class Embedded # # It communicates with {Dispatcher} and handles the host logic. class Host - def initialize(channel) - @channel = channel + def initialize(dispatcher) + @dispatcher = dispatcher end def compile_request(path:, @@ -117,7 +117,7 @@ def receive_proto(proto) private def await0 - @connection = @channel.connect(self) + @connection = @dispatcher.connect(self) @queue = Queue.new yield @@ -132,7 +132,7 @@ def await0 end def await - @connection = @channel.connect(self) + @connection = @dispatcher.connect(self) @queue = Queue.new yield diff --git a/lib/sass/embedded/channel.rb b/lib/sass/embedded/resilient_dispatcher.rb similarity index 65% rename from lib/sass/embedded/channel.rb rename to lib/sass/embedded/resilient_dispatcher.rb index 20e0d733..aada9749 100644 --- a/lib/sass/embedded/channel.rb +++ b/lib/sass/embedded/resilient_dispatcher.rb @@ -2,10 +2,10 @@ module Sass class Embedded - # The {Channel} class. + # The {ResilientDispatcher} class. # - # It establishes connection between {Host} and {Dispatcher}. - class Channel + # It recovers from failures and continues to function. + class ResilientDispatcher def initialize @dispatcher = Dispatcher.new @mutex = Mutex.new @@ -23,16 +23,16 @@ def closed? end end - def connect(observer) + def connect(host) @mutex.synchronize do - @dispatcher.connect(observer) + @dispatcher.connect(host) rescue Errno::EBUSY @dispatcher = Dispatcher.new - @dispatcher.connect(observer) + @dispatcher.connect(host) end end end - private_constant :Channel + private_constant :ResilientDispatcher end end From 5de93c7ce1310898254b4e7552b8f260ce57e877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 13 Jun 2023 00:05:06 -0700 Subject: [PATCH 145/700] Rename Connection to Channel --- lib/sass/embedded/dispatcher.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 7a13a36e..5d1640ae 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -59,7 +59,7 @@ def unsubscribe(id) end def connect(host) - Connection.new(self, host) + Channel.new(self, host) end def close @@ -96,8 +96,8 @@ def receive_proto end end - # The {Connection} between {Dispatcher} and {Host}. - class Connection + # The {Channel} between {Dispatcher} and {Host}. + class Channel attr_reader :id def initialize(dispatcher, host) @@ -114,7 +114,7 @@ def send_proto(...) end end - private_constant :Connection + private_constant :Channel end private_constant :Dispatcher From 36cf3e74b05b9f3c3ff1a9927c88237c1c629442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 13 Jun 2023 00:12:42 -0700 Subject: [PATCH 146/700] Rename Compiler to Connection --- lib/sass/embedded.rb | 2 +- lib/sass/embedded/{compiler.rb => connection.rb} | 8 ++++---- lib/sass/embedded/dispatcher.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) rename lib/sass/embedded/{compiler.rb => connection.rb} (89%) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 9c0564e8..e1317e1e 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -4,7 +4,7 @@ require_relative '../../ext/sass/embedded_sass_pb' require_relative 'compile_error' require_relative 'compile_result' -require_relative 'embedded/compiler' +require_relative 'embedded/connection' require_relative 'embedded/dispatcher' require_relative 'embedded/host' require_relative 'embedded/protofier' diff --git a/lib/sass/embedded/compiler.rb b/lib/sass/embedded/connection.rb similarity index 89% rename from lib/sass/embedded/compiler.rb rename to lib/sass/embedded/connection.rb index 4508e9a9..509a1c90 100644 --- a/lib/sass/embedded/compiler.rb +++ b/lib/sass/embedded/connection.rb @@ -4,10 +4,10 @@ module Sass class Embedded - # The {Compiler} class. + # The stdio based {Connection} between the {Dispatcher} and the compiler. # - # It runs the `sass --embedded` process. - class Compiler + # It runs the `sass --embedded` command. + class Connection def initialize @stdin, @stdout, @stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) @@ -67,6 +67,6 @@ def read end end - private_constant :Compiler + private_constant :Connection end end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 5d1640ae..86ae37fd 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -4,12 +4,12 @@ module Sass class Embedded # The {Dispatcher} class. # - # It dispatches messages between mutliple instances of {Host} and a single {Compiler}. + # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler. class Dispatcher UINT_MAX = 0xffffffff def initialize - @compiler = Compiler.new + @connection = Connection.new @observers = {} @id = 1 @mutex = Mutex.new @@ -63,21 +63,21 @@ def connect(host) end def close - @compiler.close + @connection.close end def closed? - @compiler.closed? + @connection.closed? end def send_proto(...) - @compiler.write(...) + @connection.write(...) end private def receive_proto - id, proto = @compiler.read + id, proto = @connection.read case id when 1...UINT_MAX @mutex.synchronize { @observers[id] }.receive_proto(proto) From c66cb1294dfb1cdd0e7a9aae0c7615cd5c5df80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 13 Jun 2023 00:17:09 -0700 Subject: [PATCH 147/700] Rename `@connection` to `@channel` --- lib/sass/embedded/host.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 1cdd8626..8a4695c0 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -117,7 +117,7 @@ def receive_proto(proto) private def await0 - @connection = @dispatcher.connect(self) + @channel = @dispatcher.connect(self) @queue = Queue.new yield @@ -128,11 +128,11 @@ def await0 @result ensure - @connection&.disconnect + @channel&.disconnect end def await - @connection = @dispatcher.connect(self) + @channel = @dispatcher.connect(self) @queue = Queue.new yield @@ -148,21 +148,21 @@ def await @result ensure - @connection&.disconnect + @channel&.disconnect end def id - @connection.id + @channel.id end def send_message0(...) inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @connection.send_proto(0, inbound_message.to_proto) + @channel.send_proto(0, inbound_message.to_proto) end def send_message(...) inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @connection.send_proto(id, inbound_message.to_proto) + @channel.send_proto(id, inbound_message.to_proto) end end From cd3a498424f2ba99a61675b3c261880ca2352370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 14 Jun 2023 06:03:10 -0700 Subject: [PATCH 148/700] Fallback to older version of protoc --- ext/sass/Rakefile | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 1424f8aa..ea84ec51 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -268,9 +268,13 @@ module Configuration end def default_protoc + require 'rubygems/remote_fetcher' + repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc' - version = Gem::Dependency.new('google-protobuf').to_spec.version + spec = Gem::Dependency.new('google-protobuf').to_spec + + version = spec.version message = "protoc for #{Platform::ARCH} not available at #{repo}/#{version}" @@ -300,7 +304,25 @@ module Configuration raise NotImplementedError, message end - "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe" + path = URI.parse("#{repo}/#{version}/") + + Gem::RemoteFetcher.fetcher.fetch_https(path) + + path + "protoc-#{version}-#{os}-#{cpu}.exe" + rescue Gem::RemoteFetcher::FetchError => e + Gem::SpecFetcher.fetcher.detect do |name_tuple| + name_tuple.name == spec.name && name_tuple.platform == 'ruby' + end.reverse_each do |name_tuple, _| + path = URI.parse("#{repo}/#{name_tuple.version}/") + + Gem::RemoteFetcher.fetcher.fetch_https(path) + + return path + "protoc-#{name_tuple.version}-#{os}-#{cpu}.exe" + rescue Gem::RemoteFetcher::FetchError + next + end + + raise e end def default_embedded_sass_protocol From b37724690a7251569067f007aedf1a76d48c0dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 13 Jun 2023 21:17:31 -0700 Subject: [PATCH 149/700] Reduce locking --- lib/sass/embedded/resilient_dispatcher.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sass/embedded/resilient_dispatcher.rb b/lib/sass/embedded/resilient_dispatcher.rb index aada9749..c264b20e 100644 --- a/lib/sass/embedded/resilient_dispatcher.rb +++ b/lib/sass/embedded/resilient_dispatcher.rb @@ -24,6 +24,8 @@ def closed? end def connect(host) + @dispatcher.connect(host) + rescue Errno::EBUSY @mutex.synchronize do @dispatcher.connect(host) rescue Errno::EBUSY From 252712530f23548a854b500064af191546efefbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 14 Jun 2023 06:19:53 -0700 Subject: [PATCH 150/700] Simplify CI tests --- .github/workflows/build.yml | 90 +++---------------------------------- 1 file changed, 6 insertions(+), 84 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e026b65..cffbd6ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,6 +58,9 @@ jobs: - name: Compile run: bundle exec rake compile + - name: Install + run: rake -f -r bundler/gem_tasks install + - name: Spec run: bundle exec rake spec @@ -95,98 +98,17 @@ jobs: - name: Compile run: bundle exec rake compile - - name: Spec - run: bundle exec rake spec - - install: - - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - ruby-version: - - '2.7' - - '3.0' - - '3.1' - - '3.2' - - jruby - - truffleruby - - truffleruby+graalvm - exclude: - - os: windows-latest - ruby-version: truffleruby - - os: windows-latest - ruby-version: truffleruby+graalvm - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true - - name: Install run: rake -f -r bundler/gem_tasks install - - name: Compile - run: bundle exec rake compile - - - name: Install - run: rake -f -r bundler/gem_tasks install - - install-musl: - - name: install (alpine-latest, ${{ matrix.ruby-version }}) - - runs-on: ubuntu-latest - - container: - image: docker.io/library/ruby:${{ matrix.ruby-version }}-alpine - - env: - PROTOC_BIN: /usr/bin/protoc - - strategy: - fail-fast: false - matrix: - ruby-version: - - '2.7' - - '3.0' - - '3.1' - - '3.2' - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install dependencies - run: apk add alpine-sdk protoc - - - name: Bundle - run: bundle install - - - name: Install - run: rake -f -r bundler/gem_tasks install - - - name: Compile - run: bundle exec rake compile - - - name: Install - run: rake -f -r bundler/gem_tasks install + - name: Spec + run: bundle exec rake spec release: if: github.event.repository.fork == false && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - needs: [lint, spec, spec-musl, install, install-musl] + needs: [lint, spec, spec-musl] runs-on: ubuntu-latest From 1280aebb4d810935a23325e52c0e6a8b2a188eb2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 13:10:01 +0000 Subject: [PATCH 151/700] Bump sass from 1.63.3 to 1.63.4 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.3 to 1.63.4. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.3...1.63.4) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index b32d5be8..aaa39ad4 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.3" + "sass": "1.63.4" } } From 7fb116b07e445bdd23bfb72f9f119ef4145046e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 14 Jun 2023 22:18:33 -0700 Subject: [PATCH 152/700] Improve protoc fallback logic --- ext/sass/Rakefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ea84ec51..e90e4d17 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -304,25 +304,25 @@ module Configuration raise NotImplementedError, message end - path = URI.parse("#{repo}/#{version}/") + uri = "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe" - Gem::RemoteFetcher.fetcher.fetch_https(path) + Gem::RemoteFetcher.fetcher.fetch_https(URI.parse("#{uri}.sha1")) - path + "protoc-#{version}-#{os}-#{cpu}.exe" - rescue Gem::RemoteFetcher::FetchError => e + uri + rescue Gem::RemoteFetcher::FetchError Gem::SpecFetcher.fetcher.detect do |name_tuple| name_tuple.name == spec.name && name_tuple.platform == 'ruby' end.reverse_each do |name_tuple, _| - path = URI.parse("#{repo}/#{name_tuple.version}/") + uri = "#{repo}/#{name_tuple.version}/protoc-#{name_tuple.version}-#{os}-#{cpu}.exe" - Gem::RemoteFetcher.fetcher.fetch_https(path) + Gem::RemoteFetcher.fetcher.fetch_https(URI.parse("#{uri}.sha1")) - return path + "protoc-#{name_tuple.version}-#{os}-#{cpu}.exe" + return uri rescue Gem::RemoteFetcher::FetchError next end - raise e + raise NotImplementedError, message end def default_embedded_sass_protocol From 280ca402434912dc935fd406e559d4f4408add65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 14 Jun 2023 22:39:14 -0700 Subject: [PATCH 153/700] v1.63.4 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index f61a0c92..152b0b3a 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.63.3' + VERSION = '1.63.4' end end From a1b31ccc88b07f1d26dc4079ef1f5072061a2f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 16 Jun 2023 09:24:32 -0700 Subject: [PATCH 154/700] Test ruby 3.3-rc --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cffbd6ee..344cd05f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,10 +36,13 @@ jobs: - '3.0' - '3.1' - '3.2' + - '3.3' - jruby - truffleruby - truffleruby+graalvm exclude: + - os: windows-latest + ruby-version: '3.3' - os: windows-latest ruby-version: truffleruby - os: windows-latest @@ -84,6 +87,7 @@ jobs: - '3.0' - '3.1' - '3.2' + - '3.3-rc' steps: - name: Checkout From f47aeea8922b495aaa0c535149b3fca0dd25fcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Jun 2023 20:09:22 -0700 Subject: [PATCH 155/700] Add .yardopts --- .yardopts | 1 + 1 file changed, 1 insertion(+) create mode 100644 .yardopts diff --git a/.yardopts b/.yardopts new file mode 100644 index 00000000..8f8f5a1a --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +lib/**/*.rb From c2333e1c6647021cb8fc462610cad7c708fb3531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 16 Jun 2023 21:41:09 -0700 Subject: [PATCH 156/700] Detect x86/x64 emulation for Windows on Arm --- ext/sass/Rakefile | 38 +++++++++++- ext/sass/win32_api.rb | 135 ++++++++++++++++++++++++++++++++++++++++++ sass-embedded.gemspec | 1 + 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 ext/sass/win32_api.rb diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index e90e4d17..544cf4fe 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -255,7 +255,24 @@ module Configuration when 'x86_64' 'x64' when 'aarch64' - 'arm64' + if Platform::OS == 'windows' + begin + require_relative 'win32_api' + + if Win32API.x64? + 'x64' + elsif Win32API.x86? + 'ia32' + else + raise NotImplementedError, message + end + rescue LoadError + # TODO: remove begin/rescue once jruby/jffi support windows aarch64 + 'ia32' + end + else + 'arm64' + end when 'arm' 'arm' else @@ -295,7 +312,24 @@ module Configuration when 'x86_64' 'x86_64' when 'aarch64' - 'aarch_64' + if Platform::OS == 'windows' + begin + require_relative 'win32_api' + + if Win32API.x64? + 'x86_64' + elsif Win32API.x86? + 'x86_32' + else + raise NotImplementedError, message + end + rescue LoadError + # TODO: remove begin/rescue once jruby/jffi support windows aarch64 + 'x86_32' + end + else + 'aarch_64' + end when 'powerpc64le' 'ppcle_64' when 's390x' diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb new file mode 100644 index 00000000..f9ec3536 --- /dev/null +++ b/ext/sass/win32_api.rb @@ -0,0 +1,135 @@ +# frozen_string_literal: true + +require 'fiddle' + +# @see https://learn.microsoft.com/en-us/windows/win32/api/ +module Win32API + Kernel32 = Fiddle.dlopen('Kernel32.dll') + + # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants + module ImageFileMachineConstants + IMAGE_FILE_MACHINE_I386 = 0x014c + IMAGE_FILE_MACHINE_ARMNT = 0x01c4 + IMAGE_FILE_MACHINE_AMD64 = 0x8664 + IMAGE_FILE_MACHINE_ARM64 = 0xAA64 + end + + private_constant :ImageFileMachineConstants + + # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes + module MachineAttributes + USER_ENABLED = 0x00000001 + KERNEL_ENABLED = 0x00000002 + WOW64_CONTAINER = 0x00000004 + end + + private_constant :MachineAttributes + + # Specifies the ways in which an architecture of code can run on a host operating system. + class MachineTypeAttributes + def initialize(machine_type_attributes) + @machine_type_attributes = machine_type_attributes + end + + # The specified architecture of code can run in user mode. + def user_enabled? + @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED + end + + # The specified architecture of code can run in kernel mode. + def kernel_enabled? + @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED + end + + # The specified architecture of code runs on WOW64. + def wow64_container? + @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER + end + end + + private_constant :MachineTypeAttributes + + class << self + def x86? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled? + end + + def arm? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled? + end + + def x64? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled? + end + + def arm64? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled? + end + + private + + begin + # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes + GetMachineTypeAttributes = Fiddle::Function.new( + Kernel32['GetMachineTypeAttributes'], + [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], + Fiddle::TYPE_LONG + ) + + def get_machine_type_attributes(machine) + p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE) + raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero? + + MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i')) + end + rescue Fiddle::DLError + # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess + GetCurrentProcess = Fiddle::Function.new( + Kernel32['GetCurrentProcess'], + [], + Fiddle::TYPE_VOIDP + ) + + # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2 + IsWow64Process2 = Fiddle::Function.new( + Kernel32['IsWow64Process2'], + [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], + Fiddle::TYPE_CHAR + ) + + # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported + IsWow64GuestMachineSupported = Fiddle::Function.new( + Kernel32['IsWow64GuestMachineSupported'], + [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], + Fiddle::TYPE_LONG + ) + + def get_machine_type_attributes(machine) + h_process = GetCurrentProcess.call + p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) + p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) + raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero? + + if p_native_machine.to_str.unpack1('S!') == machine + return MachineTypeAttributes.new( + MachineAttributes::USER_ENABLED | + MachineAttributes::KERNEL_ENABLED | + MachineAttributes::WOW64_CONTAINER + ) + end + + p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE) + raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero? + + if p_machine_is_supported.to_str.unpack1('c').zero? + MachineTypeAttributes.new(0) + else + MachineTypeAttributes.new( + MachineAttributes::USER_ENABLED | + MachineAttributes::WOW64_CONTAINER + ) + end + end + end + end +end diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 8e02c0ee..55c1badf 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -30,6 +30,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.files += Dir['ext/sass/*_pb.rb'] + [ 'ext/sass/expand-archive.ps1', 'ext/sass/package.json', + 'ext/sass/win32_api.rb', 'ext/sass/Rakefile' ] end From 9bcd7a8138665b2a824d5f99581c384af0749fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 18 Jun 2023 10:40:00 -0700 Subject: [PATCH 157/700] Add .yardopts to gemspec --- sass-embedded.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 55c1badf..f6dc8ff0 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.bindir = 'exe' spec.executables = ['sass'] - spec.files = Dir['exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.files = Dir['.yardopts*', 'exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') spec.files += Dir['ext/sass/*.rb', 'ext/sass/dart-sass/**/*'] @@ -28,10 +28,10 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA else spec.extensions = ['ext/sass/Rakefile'] spec.files += Dir['ext/sass/*_pb.rb'] + [ + 'ext/sass/Rakefile', 'ext/sass/expand-archive.ps1', 'ext/sass/package.json', - 'ext/sass/win32_api.rb', - 'ext/sass/Rakefile' + 'ext/sass/win32_api.rb' ] end From 3ef6be2b6dfc5550ad0ffd92d25789f47edb6f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 18 Jun 2023 11:10:48 -0700 Subject: [PATCH 158/700] Fix a yard warning --- lib/sass/embedded.rb | 4 +--- lib/sass/embedded_protocol.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 lib/sass/embedded_protocol.rb diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index e1317e1e..096052ca 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative '../../ext/sass/cli' -require_relative '../../ext/sass/embedded_sass_pb' require_relative 'compile_error' require_relative 'compile_result' require_relative 'embedded/connection' @@ -12,6 +11,7 @@ require_relative 'embedded/structifier' require_relative 'embedded/varint' require_relative 'embedded/version' +require_relative 'embedded_protocol' require_relative 'logger/silent' require_relative 'logger/source_location' require_relative 'logger/source_span' @@ -247,6 +247,4 @@ def closed? @dispatcher.closed? end end - - private_constant :EmbeddedProtocol end diff --git a/lib/sass/embedded_protocol.rb b/lib/sass/embedded_protocol.rb new file mode 100644 index 00000000..1031afb0 --- /dev/null +++ b/lib/sass/embedded_protocol.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Sass + # @see https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md + module EmbeddedProtocol + require_relative '../../ext/sass/embedded_sass_pb' + end + + private_constant :EmbeddedProtocol +end From 9619088d520ccd78e34968e281604c67fd0464a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 18 Jun 2023 11:54:20 -0700 Subject: [PATCH 159/700] Update x86 emulation detection --- ext/sass/win32_api.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb index f9ec3536..7262068f 100644 --- a/ext/sass/win32_api.rb +++ b/ext/sass/win32_api.rb @@ -11,7 +11,7 @@ module ImageFileMachineConstants IMAGE_FILE_MACHINE_I386 = 0x014c IMAGE_FILE_MACHINE_ARMNT = 0x01c4 IMAGE_FILE_MACHINE_AMD64 = 0x8664 - IMAGE_FILE_MACHINE_ARM64 = 0xAA64 + IMAGE_FILE_MACHINE_ARM64 = 0xaa64 end private_constant :ImageFileMachineConstants @@ -111,11 +111,7 @@ def get_machine_type_attributes(machine) raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero? if p_native_machine.to_str.unpack1('S!') == machine - return MachineTypeAttributes.new( - MachineAttributes::USER_ENABLED | - MachineAttributes::KERNEL_ENABLED | - MachineAttributes::WOW64_CONTAINER - ) + return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED) end p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE) @@ -124,10 +120,7 @@ def get_machine_type_attributes(machine) if p_machine_is_supported.to_str.unpack1('c').zero? MachineTypeAttributes.new(0) else - MachineTypeAttributes.new( - MachineAttributes::USER_ENABLED | - MachineAttributes::WOW64_CONTAINER - ) + MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER) end end end From 2f978d277df742fb1b85654861d4625f89f7c8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 18 Jun 2023 12:08:36 -0700 Subject: [PATCH 160/700] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af6db62b..6f9d663e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![build](https://github.com/ntkme/sass-embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ntkme/sass-embedded-host-ruby/actions/workflows/build.yml) [![gem](https://badge.fury.io/rb/sass-embedded.svg)](https://rubygems.org/gems/sass-embedded) -This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/embedded-protocol). +This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md). It exposes a Ruby API for Sass that's backed by a native [Dart Sass](https://sass-lang.com/dart-sass) executable. From bce9ed6c5481ba47654f0f27ccc36e7e5e4cde9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 20 Jun 2023 18:54:34 -0700 Subject: [PATCH 161/700] Revert "Work around race condition bug in dart-sass compiler" This reverts commit 5daff96893ac023a08b59d5fb9fcf99ff2102ca9. --- lib/sass/embedded/dispatcher.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 86ae37fd..f0efd6cc 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -46,15 +46,11 @@ def unsubscribe(id) return unless @observers.empty? - # if @id == UINT_MAX - # close - # else - # @id = 1 - # end - - # Resetting @id can cause a race condition in compiler - # See: https://github.com/sass/dart-sass/issues/2004 - close if @id == UINT_MAX + if @id == UINT_MAX + close + else + @id = 1 + end end end From 6f636c1930d2c0e20a8d381b3d958c936abbd265 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 01:59:24 +0000 Subject: [PATCH 162/700] Bump sass from 1.63.4 to 1.63.5 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.4 to 1.63.5. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.4...1.63.5) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index aaa39ad4..ba8b0cc6 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.4" + "sass": "1.63.5" } } From 036783361fb073ffb3b6cc5e0a4adc1cb1603a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 20 Jun 2023 20:27:03 -0700 Subject: [PATCH 163/700] Mark windows helper module as private --- .yardopts | 1 - ext/sass/win32_api.rb | 1 + sass-embedded.gemspec | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 .yardopts diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 8f8f5a1a..00000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ -lib/**/*.rb diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb index 7262068f..4a99fb2a 100644 --- a/ext/sass/win32_api.rb +++ b/ext/sass/win32_api.rb @@ -2,6 +2,7 @@ require 'fiddle' +# @!visibility private # @see https://learn.microsoft.com/en-us/windows/win32/api/ module Win32API Kernel32 = Fiddle.dlopen('Kernel32.dll') diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index f6dc8ff0..924a325e 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.bindir = 'exe' spec.executables = ['sass'] - spec.files = Dir['.yardopts*', 'exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.files = Dir['exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') spec.files += Dir['ext/sass/*.rb', 'ext/sass/dart-sass/**/*'] From 5dd1178234f2f3d8bc0c9ecebfa7b0fc36fccbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 20 Jun 2023 20:44:01 -0700 Subject: [PATCH 164/700] v1.63.5 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 152b0b3a..f33a7fbb 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.63.4' + VERSION = '1.63.5' end end From 1cc20df400b6c13a33c99c508a164f9d08961d56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 22:27:23 +0000 Subject: [PATCH 165/700] Bump sass from 1.63.5 to 1.63.6 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.5 to 1.63.6. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.5...1.63.6) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index ba8b0cc6..d60ca212 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.5" + "sass": "1.63.6" } } From 629bfcbff9544f1dc4aada19b7ec7a68920f3cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 21 Jun 2023 15:53:23 -0700 Subject: [PATCH 166/700] v1.63.6 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index f33a7fbb..43008587 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.63.5' + VERSION = '1.63.6' end end From 63fdafe0d6b32943234b28b8cea80b0865840cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 23 Jun 2023 08:15:51 -0700 Subject: [PATCH 167/700] Update spec_helper.rb --- spec/spec_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b7e275ed..e3e0877f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,8 +3,8 @@ require 'sass-embedded' require 'json' -require_relative './console' -require_relative './sandbox' +require_relative 'console' +require_relative 'sandbox' RSpec.configure do |config| config.color_mode = :on if ENV.key?('GITHUB_ACTIONS') From 31e636abc22d035ee3e68d758be7da04f9d1f4b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 15:17:12 +0000 Subject: [PATCH 168/700] Update rubocop requirement from ~> 1.52.0 to ~> 1.53.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.52.0...v1.53.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7eee0066..7b2604bd 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.52.0' + gem 'rubocop', '~> 1.53.0' gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.22.0' From 6d56eaf06c9b1a67e87a7502c55f83e3cd6dbe29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 25 Jun 2023 05:07:17 -0700 Subject: [PATCH 169/700] Avoid naming conflict on jruby --- ext/sass/win32_api.rb | 207 +++++++++++++++++++++--------------------- 1 file changed, 105 insertions(+), 102 deletions(-) diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb index 4a99fb2a..de0e49dc 100644 --- a/ext/sass/win32_api.rb +++ b/ext/sass/win32_api.rb @@ -2,128 +2,131 @@ require 'fiddle' -# @!visibility private -# @see https://learn.microsoft.com/en-us/windows/win32/api/ -module Win32API - Kernel32 = Fiddle.dlopen('Kernel32.dll') - - # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants - module ImageFileMachineConstants - IMAGE_FILE_MACHINE_I386 = 0x014c - IMAGE_FILE_MACHINE_ARMNT = 0x01c4 - IMAGE_FILE_MACHINE_AMD64 = 0x8664 - IMAGE_FILE_MACHINE_ARM64 = 0xaa64 - end - - private_constant :ImageFileMachineConstants - - # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes - module MachineAttributes - USER_ENABLED = 0x00000001 - KERNEL_ENABLED = 0x00000002 - WOW64_CONTAINER = 0x00000004 - end - - private_constant :MachineAttributes - - # Specifies the ways in which an architecture of code can run on a host operating system. - class MachineTypeAttributes - def initialize(machine_type_attributes) - @machine_type_attributes = machine_type_attributes +module Configuration + # @see https://learn.microsoft.com/en-us/windows/win32/api/ + module Win32API + Kernel32 = Fiddle.dlopen('Kernel32.dll') + + # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants + module ImageFileMachineConstants + IMAGE_FILE_MACHINE_I386 = 0x014c + IMAGE_FILE_MACHINE_ARMNT = 0x01c4 + IMAGE_FILE_MACHINE_AMD64 = 0x8664 + IMAGE_FILE_MACHINE_ARM64 = 0xaa64 end - # The specified architecture of code can run in user mode. - def user_enabled? - @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED - end + private_constant :ImageFileMachineConstants - # The specified architecture of code can run in kernel mode. - def kernel_enabled? - @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED + # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes + module MachineAttributes + USER_ENABLED = 0x00000001 + KERNEL_ENABLED = 0x00000002 + WOW64_CONTAINER = 0x00000004 end - # The specified architecture of code runs on WOW64. - def wow64_container? - @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER - end - end + private_constant :MachineAttributes - private_constant :MachineTypeAttributes + # Specifies the ways in which an architecture of code can run on a host operating system. + class MachineTypeAttributes + def initialize(machine_type_attributes) + @machine_type_attributes = machine_type_attributes + end - class << self - def x86? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled? - end + # The specified architecture of code can run in user mode. + def user_enabled? + @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED + end - def arm? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled? - end + # The specified architecture of code can run in kernel mode. + def kernel_enabled? + @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED + end - def x64? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled? + # The specified architecture of code runs on WOW64. + def wow64_container? + @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER + end end - def arm64? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled? - end + private_constant :MachineTypeAttributes - private + class << self + def x86? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled? + end - begin - # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes - GetMachineTypeAttributes = Fiddle::Function.new( - Kernel32['GetMachineTypeAttributes'], - [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_LONG - ) + def arm? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled? + end - def get_machine_type_attributes(machine) - p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE) - raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero? + def x64? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled? + end - MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i')) + def arm64? + get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled? end - rescue Fiddle::DLError - # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess - GetCurrentProcess = Fiddle::Function.new( - Kernel32['GetCurrentProcess'], - [], - Fiddle::TYPE_VOIDP - ) - - # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2 - IsWow64Process2 = Fiddle::Function.new( - Kernel32['IsWow64Process2'], - [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_CHAR - ) - - # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported - IsWow64GuestMachineSupported = Fiddle::Function.new( - Kernel32['IsWow64GuestMachineSupported'], - [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_LONG - ) - - def get_machine_type_attributes(machine) - h_process = GetCurrentProcess.call - p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) - p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) - raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero? - - if p_native_machine.to_str.unpack1('S!') == machine - return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED) - end - p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE) - raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero? + private + + begin + # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes + GetMachineTypeAttributes = Fiddle::Function.new( + Kernel32['GetMachineTypeAttributes'], + [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], + Fiddle::TYPE_LONG + ) - if p_machine_is_supported.to_str.unpack1('c').zero? - MachineTypeAttributes.new(0) - else - MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER) + def get_machine_type_attributes(machine) + p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE) + raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero? + + MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i')) + end + rescue Fiddle::DLError + # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess + GetCurrentProcess = Fiddle::Function.new( + Kernel32['GetCurrentProcess'], + [], + Fiddle::TYPE_VOIDP + ) + + # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2 + IsWow64Process2 = Fiddle::Function.new( + Kernel32['IsWow64Process2'], + [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], + Fiddle::TYPE_CHAR + ) + + # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported + IsWow64GuestMachineSupported = Fiddle::Function.new( + Kernel32['IsWow64GuestMachineSupported'], + [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], + Fiddle::TYPE_LONG + ) + + def get_machine_type_attributes(machine) + h_process = GetCurrentProcess.call + p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) + p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) + raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero? + + if p_native_machine.to_str.unpack1('S!') == machine + return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED) + end + + p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE) + raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero? + + if p_machine_is_supported.to_str.unpack1('c').zero? + MachineTypeAttributes.new(0) + else + MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER) + end end end end end + + private_constant :Win32API end From 8043c13e85a3ba9208d49ad8d6d0a4bde9fc0a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 28 Jun 2023 23:06:12 -0700 Subject: [PATCH 170/700] Use Enumerable#filter_map --- lib/sass/embedded/host/function_registry.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/sass/embedded/host/function_registry.rb b/lib/sass/embedded/host/function_registry.rb index 9ec2c973..aca89006 100644 --- a/lib/sass/embedded/host/function_registry.rb +++ b/lib/sass/embedded/host/function_registry.rb @@ -47,13 +47,11 @@ def function_call(function_call_request) end success = value_protofier.to_proto(get(function_call_request).call(arguments)) - accessed_argument_lists = arguments - .select do |argument| - argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval do - @keywords_accessed - end - end - .map { |argument| argument.instance_eval { @id } } + accessed_argument_lists = arguments.filter_map do |argument| + if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed } + argument.instance_eval { @id } + end + end EmbeddedProtocol::InboundMessage::FunctionCallResponse.new( id: function_call_request.id, From 2c79885bc2901eca358a26dd0b6a64251e08832b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 1 Jul 2023 08:38:41 -0700 Subject: [PATCH 171/700] Update Rakefile --- ext/sass/Rakefile | 10 +++++----- ext/sass/win32_api.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 544cf4fe..29850f72 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -13,12 +13,12 @@ CLEAN.include %w[protoc.exe *.proto *.tar.gz *.zip] CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb] file 'protoc.exe' do |t| - fetch(ENV.fetch('PROTOC_BIN') { Configuration.default_protoc }, t.name) + fetch(ENV.fetch('PROTOC_BIN') { SassConfig.default_protoc }, t.name) chmod 'a+x', t.name end file 'dart-sass' do |t| - archive = fetch(ENV.fetch(t.name.tr('-', '_').upcase) { Configuration.default_dart_sass }) + archive = fetch(ENV.fetch(t.name.tr('-', '_').upcase) { SassConfig.default_dart_sass }) unarchive archive rm archive end @@ -58,7 +58,7 @@ file 'cli.rb' => %w[dart-sass] do |t| end file 'embedded_sass.proto' => %w[cli.rb] do |t| - fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') { Configuration.default_embedded_sass_protocol }, t.name) + fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') { SassConfig.default_embedded_sass_protocol }, t.name) end rule '_pb.rb' => %w[.proto protoc.exe] do |t| @@ -176,8 +176,8 @@ module FileUtils end end -# The {Configuration} module. -module Configuration +# The {SassConfig} module. +module SassConfig module Platform OS = case RbConfig::CONFIG['host_os'].downcase when /darwin/ diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb index de0e49dc..246bfc71 100644 --- a/ext/sass/win32_api.rb +++ b/ext/sass/win32_api.rb @@ -2,7 +2,7 @@ require 'fiddle' -module Configuration +module SassConfig # @see https://learn.microsoft.com/en-us/windows/win32/api/ module Win32API Kernel32 = Fiddle.dlopen('Kernel32.dll') From 2e28affb608491e0b0018f8753bd6d3f2dc63781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 1 Jul 2023 09:07:49 -0700 Subject: [PATCH 172/700] Update sass-embedded.gemspec --- sass-embedded.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 924a325e..fbbe785f 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -19,15 +19,15 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.bindir = 'exe' spec.executables = ['sass'] - spec.files = Dir['exe/**/*', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.files = Dir['exe/**/*', 'ext/**/*_pb.rb', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] if ENV.key?('gem_platform') - spec.files += Dir['ext/sass/*.rb', 'ext/sass/dart-sass/**/*'] + spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] spec.platform = ENV['gem_platform'] spec.required_rubygems_version = '>= 3.3.22' if ENV['gem_platform'].include?('-linux-') else spec.extensions = ['ext/sass/Rakefile'] - spec.files += Dir['ext/sass/*_pb.rb'] + [ + spec.files += [ 'ext/sass/Rakefile', 'ext/sass/expand-archive.ps1', 'ext/sass/package.json', From 3fd8fff608a1b5356415b0a0bc2542738feb0dd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:12:22 +0000 Subject: [PATCH 173/700] Update rubocop requirement from ~> 1.53.0 to ~> 1.54.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.53.0...v1.54.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7b2604bd..4640838e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.53.0' + gem 'rubocop', '~> 1.54.0' gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.22.0' From 1c049edeb4f0df436da6be698650193743d77a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 5 Jul 2023 00:26:03 -0700 Subject: [PATCH 174/700] Attempt to download dart-sass from rubygems --- ext/sass/.gitignore | 3 +- ext/sass/Rakefile | 100 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 90 insertions(+), 13 deletions(-) diff --git a/ext/sass/.gitignore b/ext/sass/.gitignore index 9e8b2514..23f2a2c0 100644 --- a/ext/sass/.gitignore +++ b/ext/sass/.gitignore @@ -1,7 +1,8 @@ /*.tar.gz /*.zip /cli.rb -/dart-sass +/dart-sass/ /embedded_sass.proto /embedded_sass_pb.rb /protoc.exe +/ruby/ diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 29850f72..1b616034 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'rake/clean' +require 'rubygems/remote_fetcher' task default: %i[install clean] @@ -8,7 +9,7 @@ task install: %w[cli.rb] do Rake::Task['embedded_sass_pb.rb'].invoke unless File.exist?('embedded_sass_pb.rb') end -CLEAN.include %w[protoc.exe *.proto *.tar.gz *.zip] +CLEAN.include %w[protoc.exe ruby *.proto *.tar.gz *.zip] CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb] @@ -18,9 +19,21 @@ file 'protoc.exe' do |t| end file 'dart-sass' do |t| - archive = fetch(ENV.fetch(t.name.tr('-', '_').upcase) { SassConfig.default_dart_sass }) - unarchive archive - rm archive + if ENV.key?('DART_SASS') + archive = fetch(ENV.fetch('DART_SASS')) + unarchive archive + rm archive + else + begin + gem_install 'sass-embedded', SassConfig.dart_sass_version, SassConfig.normalized_gem_platform do |dir| + cp_r File.absolute_path("ext/sass/#{t.name}", dir), t.name + end + rescue StandardError + archive = fetch(SassConfig.default_dart_sass) + unarchive archive + rm archive + end + end end file 'cli.rb' => %w[dart-sass] do |t| @@ -130,8 +143,6 @@ module FileUtils end def fetch(source_uri, dest_path = nil) - require 'rubygems/remote_fetcher' - unless source_uri.is_a?(URI::Generic) begin source_uri = URI.parse(source_uri) @@ -174,6 +185,44 @@ module FileUtils dest_path end + + def gem_install(name, version, platform) + install_dir = File.absolute_path('ruby', __dir__) + + if Rake::FileUtilsExt.verbose_flag + Rake.rake_output_message [ + 'gem', 'install', + '--force', + '--install-dir', install_dir, + '--no-document', '--ignore-dependencies', + '--platform', platform, + '--version', version, + 'sass-embedded' + ].join(' ') + end + + dependency = Gem::Dependency.new(name, version) + + specs_and_sources, _errors = Gem::SpecFetcher.fetcher.spec_for_dependency(dependency, false) + + spec, source = specs_and_sources.find do |s, _| + s.platform == platform + end + + raise if spec.nil? || source.nil? + + if Rake::FileUtilsExt.nowrite_flag + installer = Gem::Installer.for_spec(spec, { force: true, install_dir: install_dir }) + else + path = source.download(spec, install_dir) + installer = Gem::Installer.at(path, { force: true, install_dir: install_dir }) + installer.install + end + + yield installer.dir + ensure + rm_rf install_dir + end end # The {SassConfig} module. @@ -221,14 +270,18 @@ module SassConfig module_function - def default_dart_sass + def dart_sass_version require 'json' - repo = 'https://github.com/sass/dart-sass' - spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__))) - tag_name = spec['dependencies']['sass'] + spec['dependencies']['sass'] + end + + def default_dart_sass + repo = 'https://github.com/sass/dart-sass' + + tag_name = dart_sass_version message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}" @@ -285,8 +338,6 @@ module SassConfig end def default_protoc - require 'rubygems/remote_fetcher' - repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc' spec = Gem::Dependency.new('google-protobuf').to_spec @@ -374,4 +425,29 @@ module SassConfig "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto" end + + def normalized_gem_platform + platform = Gem::Platform.new("#{RbConfig::CONFIG['host_cpu']}-#{RbConfig::CONFIG['host_os']}") + case Platform::OS + when 'darwin' + Gem::Platform.new([platform.cpu, platform.os]) + when 'linux' + if platform.version&.start_with?('gnu') + platform + else + Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"]) + end + when 'windows' + case Platform::CPU + when 'x86_64' + Gem::Platform.new('x64-mingw32') + when 'i386' + Gem::Platform.new('x86-mingw32') + else + Gem::Platform.new([platform.cpu, 'mingw32']) + end + else + platform + end + end end From c2f2817802f60e5e3ab67f86b010713834768537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 6 Jul 2023 17:08:38 -0700 Subject: [PATCH 175/700] Drop ruby 2.7 (eol) --- .github/workflows/build.yml | 2 -- .rubocop.yml | 2 +- ext/sass/Rakefile | 5 ++--- sass-embedded.gemspec | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 344cd05f..1064ebb6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,6 @@ jobs: - ubuntu-latest - windows-latest ruby-version: - - '2.7' - '3.0' - '3.1' - '3.2' @@ -83,7 +82,6 @@ jobs: fail-fast: false matrix: ruby-version: - - '2.7' - '3.0' - '3.1' - '3.2' diff --git a/.rubocop.yml b/.rubocop.yml index 269d1d6f..f3937e0f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ AllCops: - '**/*_pb.rb' - 'vendor/**/*' - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 NewCops: enable diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 1b616034..aba97e27 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -253,8 +253,7 @@ module SassConfig when /arm64|aarch64/ 'aarch64' when /arm/ - # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin - OS == 'darwin' ? 'aarch64' : 'arm' + 'arm' when /ppc64le|powerpc64le/ 'powerpc64le' when /s390x/ @@ -263,7 +262,7 @@ module SassConfig RbConfig::CONFIG['host_cpu'] end - ARCH = "#{CPU}-#{OS}" + ARCH = "#{CPU}-#{OS}".freeze end private_constant :Platform diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index fbbe785f..49a55f37 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA ] end - spec.required_ruby_version = '>= 2.7.0' + spec.required_ruby_version = '>= 3.0.0' spec.add_runtime_dependency 'google-protobuf', '~> 3.23' spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') From 71dc80538c0eca15500199373efbfe4943853485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 7 Jul 2023 02:11:05 -0700 Subject: [PATCH 176/700] Use dart-sass version as gem version in development --- ext/sass/Rakefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index aba97e27..64baad31 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -25,7 +25,7 @@ file 'dart-sass' do |t| rm archive else begin - gem_install 'sass-embedded', SassConfig.dart_sass_version, SassConfig.normalized_gem_platform do |dir| + gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| cp_r File.absolute_path("ext/sass/#{t.name}", dir), t.name end rescue StandardError @@ -425,7 +425,17 @@ module SassConfig "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto" end - def normalized_gem_platform + def development? + File.exist?('../../Gemfile') + end + + def gem_version + require_relative '../../lib/sass/embedded/version' + + development? ? dart_sass_version : Sass::Embedded::VERSION + end + + def gem_platform platform = Gem::Platform.new("#{RbConfig::CONFIG['host_cpu']}-#{RbConfig::CONFIG['host_os']}") case Platform::OS when 'darwin' From 7547ea7bb833e5de74bffef89a83325aecfe886b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 7 Jul 2023 02:14:05 -0700 Subject: [PATCH 177/700] Update Rakefile --- ext/sass/Rakefile | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 64baad31..c34ae490 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -19,21 +19,15 @@ file 'protoc.exe' do |t| end file 'dart-sass' do |t| - if ENV.key?('DART_SASS') - archive = fetch(ENV.fetch('DART_SASS')) - unarchive archive - rm archive - else - begin - gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| - cp_r File.absolute_path("ext/sass/#{t.name}", dir), t.name - end - rescue StandardError - archive = fetch(SassConfig.default_dart_sass) - unarchive archive - rm archive - end + raise if ENV.key?('DART_SASS') + + gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| + cp_r File.absolute_path("ext/sass/#{t.name}", dir), t.name end +rescue StandardError + archive = fetch(ENV.fetch('DART_SASS') { SassConfig.default_dart_sass }) + unarchive archive + rm archive end file 'cli.rb' => %w[dart-sass] do |t| From 24293bb916ba590cb011f905dbdee609c990d5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 7 Jul 2023 02:48:29 -0700 Subject: [PATCH 178/700] Update Rakefile --- ext/sass/Rakefile | 58 ++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index c34ae490..d965ec5d 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -257,6 +257,20 @@ module SassConfig end ARCH = "#{CPU}-#{OS}".freeze + + EMULATION = if ARCH == 'aarch64-windows' + begin + require_relative 'win32_api' + + if Win32API.x64? + 'x86_64' + elsif Win32API.x86? + 'i386' + end + rescue LoadError + 'i386' + end + end end private_constant :Platform @@ -295,30 +309,13 @@ module SassConfig raise NotImplementedError, message end - cpu = case Platform::CPU + cpu = case Platform::EMULATION || Platform::CPU when 'i386' 'ia32' when 'x86_64' 'x64' when 'aarch64' - if Platform::OS == 'windows' - begin - require_relative 'win32_api' - - if Win32API.x64? - 'x64' - elsif Win32API.x86? - 'ia32' - else - raise NotImplementedError, message - end - rescue LoadError - # TODO: remove begin/rescue once jruby/jffi support windows aarch64 - 'ia32' - end - else - 'arm64' - end + 'arm64' when 'arm' 'arm' else @@ -350,30 +347,13 @@ module SassConfig raise NotImplementedError, message end - cpu = case Platform::CPU + cpu = case Platform::EMULATION || Platform::CPU when 'i386' 'x86_32' when 'x86_64' 'x86_64' when 'aarch64' - if Platform::OS == 'windows' - begin - require_relative 'win32_api' - - if Win32API.x64? - 'x86_64' - elsif Win32API.x86? - 'x86_32' - else - raise NotImplementedError, message - end - rescue LoadError - # TODO: remove begin/rescue once jruby/jffi support windows aarch64 - 'x86_32' - end - else - 'aarch_64' - end + 'aarch_64' when 'powerpc64le' 'ppcle_64' when 's390x' @@ -441,7 +421,7 @@ module SassConfig Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"]) end when 'windows' - case Platform::CPU + case Platform::EMULATION || Platform::CPU when 'x86_64' Gem::Platform.new('x64-mingw32') when 'i386' From 4b895810e3ae55e1531235a9b9dc8003b7ea634f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 7 Jul 2023 03:03:04 -0700 Subject: [PATCH 179/700] Update Rakefile --- ext/sass/Rakefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index d965ec5d..873fbe69 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'rake/clean' -require 'rubygems/remote_fetcher' task default: %i[install clean] @@ -137,6 +136,8 @@ module FileUtils end def fetch(source_uri, dest_path = nil) + require 'rubygems/remote_fetcher' + unless source_uri.is_a?(URI::Generic) begin source_uri = URI.parse(source_uri) @@ -328,6 +329,8 @@ module SassConfig end def default_protoc + require 'rubygems/remote_fetcher' + repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc' spec = Gem::Dependency.new('google-protobuf').to_spec From e0d27574806458a2bbf0b18f5c9046965f39f8c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 00:29:46 +0000 Subject: [PATCH 180/700] Bump sass from 1.63.6 to 1.64.0 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.63.6 to 1.64.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.63.6...1.64.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index d60ca212..2f764312 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.63.6" + "sass": "1.64.0" } } From a0a69310373064bbb175a70c735742f4c4f01b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Jun 2023 11:48:35 -0700 Subject: [PATCH 181/700] Add support for SassCalculation --- ext/sass/win32_api.rb | 1 + lib/sass/calculation_value.rb | 17 + .../calculation_interpolation.rb | 31 ++ .../calculation_operation.rb | 52 +++ lib/sass/compile_result.rb | 2 +- lib/sass/embedded.rb | 14 +- lib/sass/embedded/host.rb | 8 +- lib/sass/embedded/host/value_protofier.rb | 191 ++++++++- lib/sass/logger/silent.rb | 4 +- lib/sass/logger/source_location.rb | 2 +- lib/sass/logger/source_span.rb | 2 +- lib/sass/value.rb | 11 +- lib/sass/value/argument_list.rb | 2 +- lib/sass/value/boolean.rb | 2 +- lib/sass/value/calculation.rb | 90 ++++ lib/sass/value/color.rb | 2 +- lib/sass/value/function.rb | 2 +- lib/sass/value/list.rb | 2 +- lib/sass/value/map.rb | 2 +- lib/sass/value/null.rb | 2 +- lib/sass/value/number.rb | 3 +- lib/sass/value/string.rb | 11 +- spec/sass/value/argument_list_spec.rb | 1 + spec/sass/value/boolean_spec.rb | 2 + spec/sass/value/calculation_spec.rb | 402 ++++++++++++++++++ spec/sass/value/color_spec.rb | 1 + spec/sass/value/list_spec.rb | 1 + spec/sass/value/map_spec.rb | 1 + spec/sass/value/null_spec.rb | 1 + spec/sass/value/number_spec.rb | 1 + spec/sass/value/string_spec.rb | 1 + spec/sass_function_spec.rb | 60 ++- spec/sass_proto_spec.rb | 15 + 33 files changed, 884 insertions(+), 55 deletions(-) create mode 100644 lib/sass/calculation_value.rb create mode 100644 lib/sass/calculation_value/calculation_interpolation.rb create mode 100644 lib/sass/calculation_value/calculation_operation.rb create mode 100644 lib/sass/value/calculation.rb create mode 100644 spec/sass/value/calculation_spec.rb diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb index 246bfc71..792e477f 100644 --- a/ext/sass/win32_api.rb +++ b/ext/sass/win32_api.rb @@ -2,6 +2,7 @@ require 'fiddle' +# @!visibility private module SassConfig # @see https://learn.microsoft.com/en-us/windows/win32/api/ module Win32API diff --git a/lib/sass/calculation_value.rb b/lib/sass/calculation_value.rb new file mode 100644 index 00000000..3541d14f --- /dev/null +++ b/lib/sass/calculation_value.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Sass + # The type of values that can be arguments to a SassCalculation. + # + # @see https://sass-lang.com/documentation/js-api/types/calculationvalue/ + module CalculationValue + # @return [CalculationValue] + # @raise [ScriptError] + def assert_calculation_value(_name = nil) + self + end + end +end + +require_relative 'calculation_value/calculation_interpolation' +require_relative 'calculation_value/calculation_operation' diff --git a/lib/sass/calculation_value/calculation_interpolation.rb b/lib/sass/calculation_value/calculation_interpolation.rb new file mode 100644 index 00000000..a43b72c0 --- /dev/null +++ b/lib/sass/calculation_value/calculation_interpolation.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Sass + module CalculationValue + # A string injected into a SassCalculation using interpolation. + # + # @see https://sass-lang.com/documentation/js-api/classes/calculationinterpolation/ + class CalculationInterpolation + include CalculationValue + + # @param value [::String] + def initialize(value) + @value = value + end + + # @return [::String] + attr_reader :value + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::CalculationValue::CalculationInterpolation) && + other.value == value + end + + # @return [Integer] + def hash + @hash ||= value.hash + end + end + end +end diff --git a/lib/sass/calculation_value/calculation_operation.rb b/lib/sass/calculation_value/calculation_operation.rb new file mode 100644 index 00000000..2ffd53c3 --- /dev/null +++ b/lib/sass/calculation_value/calculation_operation.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Sass + module CalculationValue + # A binary operation that can appear in a SassCalculation. + # + # @see https://sass-lang.com/documentation/js-api/classes/calculationoperation/ + class CalculationOperation + include CalculationValue + + OPERATORS = ['+', '-', '*', '/'].freeze + + private_constant :OPERATORS + + # @param operator [::String] + # @param left [CalculationValue] + # @param right [CalculationValue] + def initialize(operator, left, right) + raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator) + + left.assert_calculation_value + right.assert_calculation_value + + @operator = operator.freeze + @left = left.freeze + @right = right.freeze + end + + # @return [::String] + attr_reader :operator + + # @return [CalculationValue] + attr_reader :left + + # @return [CalculationValue] + attr_reader :right + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::CalculationValue::CalculationOperation) && + other.operator == operator && + other.left == left && + other.right == right + end + + # @return [Integer] + def hash + @hash ||= [operator, left, right].hash + end + end + end +end diff --git a/lib/sass/compile_result.rb b/lib/sass/compile_result.rb index c211b2e3..af48d9b7 100644 --- a/lib/sass/compile_result.rb +++ b/lib/sass/compile_result.rb @@ -3,7 +3,7 @@ module Sass # The result of compiling Sass to CSS. Returned by {Sass.compile} and {Sass.compile_string}. # - # @see https://sass-lang.com/documentation/js-api/interfaces/CompileResult + # @see https://sass-lang.com/documentation/js-api/interfaces/compileresult/ class CompileResult # @return [String] attr_reader :css diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 096052ca..ff008083 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -95,7 +95,7 @@ def initialize # Compiles the Sass file at +path+ to CSS. # @param path [String] # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import]. + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. @@ -104,7 +104,7 @@ def initialize # @param style [String, Symbol] The OutputStyle of the compiled CSS. # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. # @param importers [Array] Custom importers that control how Sass resolves loads from rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import]. + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and @@ -119,7 +119,7 @@ def initialize # deprecation warning it encounters. # @return [CompileResult] # @raise [CompileError] - # @see https://sass-lang.com/documentation/js-api/modules#compile + # @see https://sass-lang.com/documentation/js-api/functions/compile/ def compile(path, load_paths: [], @@ -163,7 +163,7 @@ def compile(path, # @param source [String] # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet. # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import]. + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. # @param syntax [String, Symbol] The Syntax to use to parse the entrypoint stylesheet. # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's # used to resolve relative loads in the entrypoint stylesheet. @@ -175,7 +175,7 @@ def compile(path, # @param style [String, Symbol] The OutputStyle of the compiled CSS. # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. # @param importers [Array] Custom importers that control how Sass resolves loads from rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import]. + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and @@ -190,7 +190,7 @@ def compile(path, # deprecation warning it encounters. # @return [CompileResult] # @raise [CompileError] - # @see https://sass-lang.com/documentation/js-api/modules#compileString + # @see https://sass-lang.com/documentation/js-api/functions/compilestring/ def compile_string(source, importer: nil, load_paths: [], @@ -234,7 +234,7 @@ def compile_string(source, end # @return [String] Information about the Sass implementation. - # @see https://sass-lang.com/documentation/js-api/modules#info + # @see https://sass-lang.com/documentation/js-api/variables/info/ def info @info ||= Host.new(@dispatcher).version_request end diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 8a4695c0..bbac4d35 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -86,7 +86,13 @@ def version_response(message) end def error(message) - @error = message + if message.is_a?(EmbeddedProtocol::ProtocolError) + return if message.id != id + + @error = Errno::EPROTO.new(message.message) + else + @error = message + end @queue.close end diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index 49042e22..49dcd0e2 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -22,11 +22,7 @@ def to_proto(obj) ) when Sass::Value::Number EmbeddedProtocol::Value.new( - number: EmbeddedProtocol::Value::Number.new( - value: obj.value.to_f, - numerators: obj.numerator_units, - denominators: obj.denominator_units - ) + number: Number.to_proto(obj) ) when Sass::Value::Color if obj.instance_eval { !defined?(@hue) } @@ -100,6 +96,10 @@ def to_proto(obj) ) ) end + when Sass::Value::Calculation + EmbeddedProtocol::Value.new( + calculation: Calculation.to_proto(obj) + ) when Sass::Value::Boolean EmbeddedProtocol::Value.new( singleton: obj.value ? :TRUE : :FALSE @@ -123,12 +123,7 @@ def from_proto(proto) quoted: obj.quoted ) when :number - Sass::Value::Number.new( - obj.value, { - numerator_units: obj.numerators.to_a, - denominator_units: obj.denominators.to_a - } - ) + Number.from_proto(obj) when :rgb_color Sass::Value::Color.new( red: obj.red, @@ -181,6 +176,8 @@ def from_proto(proto) Sass::Value::Function.new(obj.id) when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' + when :calculation + Calculation.from_proto(obj) when :singleton case obj when :TRUE @@ -197,6 +194,178 @@ def from_proto(proto) end end + # The {Number} Protofier. + module Number + module_function + + def to_proto(obj) + EmbeddedProtocol::Value::Number.new( + value: obj.value.to_f, + numerators: obj.numerator_units, + denominators: obj.denominator_units + ) + end + + def from_proto(obj) + Sass::Value::Number.new( + obj.value, { + numerator_units: obj.numerators.to_a, + denominator_units: obj.denominators.to_a + } + ) + end + end + + private_constant :Number + + # The {Calculation} Protofier. + module Calculation + module_function + + def to_proto(obj) + EmbeddedProtocol::Value::Calculation.new( + name: obj.name, + arguments: obj.arguments.map { |argument| CalculationValue.to_proto(argument) } + ) + end + + def from_proto(obj) + case obj.name + when 'calc' + if obj.arguments.length != 1 + raise Sass::ScriptError, + 'Value.Calculation.arguments must have exactly one argument for calc().' + end + + Sass::Value::Calculation.calc(*obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) + when 'clamp' + if obj.arguments.length != 3 + raise Sass::ScriptError, + 'Value.Calculation.arguments must have exactly 3 arguments for clamp().' + end + + Sass::Value::Calculation.clamp(*obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) + when 'min' + if obj.arguments.empty? + raise Sass::ScriptError, + 'Value.Calculation.arguments must have at least 1 argument for min().' + end + + Sass::Value::Calculation.min(obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) + when 'max' + if obj.arguments.empty? + raise Sass::ScriptError, + 'Value.Calculation.arguments must have at least 1 argument for max().' + end + + Sass::Value::Calculation.max(obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) + else + raise Sass::ScriptError, + "Value.Calculation.name #{calculation.name.inspect} is not a recognized calculation type." + end + end + end + + private_constant :Calculation + + # The {CalculationValue} Protofier. + module CalculationValue + module_function + + def to_proto(value) + case value + when Sass::Value::Number + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + number: Number.to_proto(value) + ) + when Sass::Value::Calculation + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + calculation: Calculation.to_proto(value) + ) + when Sass::Value::String + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + string: value.text + ) + when Sass::CalculationValue::CalculationOperation + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + operation: EmbeddedProtocol::Value::Calculation::CalculationOperation.new( + operator: CalculationOperator.to_proto(value.operator), + left: to_proto(value.left), + right: to_proto(value.right) + ) + ) + when Sass::CalculationValue::CalculationInterpolation + EmbeddedProtocol::Value::Calculation::CalculationValue.new( + interpolation: value.value + ) + else + raise Sass::ScriptError, "Unknown CalculationValue #{value}" + end + end + + def from_proto(value) + oneof = value.value + obj = value.public_send(oneof) + case oneof + when :number + Number.from_proto(obj) + when :calculation + Calculation.from_proto(obj) + when :string + Sass::Value::String.new(obj, quoted: false) + when :operation + Sass::CalculationValue::CalculationOperation.new( + CalculationOperator.from_proto(obj.operator), + from_proto(obj.left), + from_proto(obj.right) + ) + when :interpolation + Sass::CalculationValue::CalculationInterpolation.new(obj) + else + raise Sass::ScriptError, "Unknown CalculationValue #{value}" + end + end + end + + private_constant :CalculationValue + + # The {CalculationOperator} Protofier. + module CalculationOperator + module_function + + def to_proto(operator) + case operator + when '+' + :PLUS + when '-' + :MINUS + when '*' + :TIMES + when '/' + :DIVIDE + else + raise Sass::ScriptError, "Unknown CalculationOperator #{separator}" + end + end + + def from_proto(operator) + case operator + when :PLUS + '+' + when :MINUS + '-' + when :TIMES + '*' + when :DIVIDE + '/' + else + raise Sass::ScriptError, "Unknown CalculationOperator #{separator}" + end + end + end + + private_constant :CalculationOperator + # The {ListSeparator} Protofier. module ListSeparator module_function diff --git a/lib/sass/logger/silent.rb b/lib/sass/logger/silent.rb index 1014fd0f..ac06b756 100644 --- a/lib/sass/logger/silent.rb +++ b/lib/sass/logger/silent.rb @@ -3,11 +3,13 @@ module Sass # A namespace for built-in Loggers. # - # @see https://sass-lang.com/documentation/js-api/modules/Logger + # @see https://sass-lang.com/documentation/js-api/modules/logger/ module Logger module_function # A Logger that silently ignores all warnings and debug messages. + # + # @see https://sass-lang.com/documentation/js-api/variables/logger.silent/ def silent Silent end diff --git a/lib/sass/logger/source_location.rb b/lib/sass/logger/source_location.rb index c4949664..7181461f 100644 --- a/lib/sass/logger/source_location.rb +++ b/lib/sass/logger/source_location.rb @@ -6,7 +6,7 @@ module Logger # # This is always associated with a {SourceSpan} which indicates which file it refers to. # - # @see https://sass-lang.com/documentation/js-api/interfaces/SourceLocation + # @see https://sass-lang.com/documentation/js-api/interfaces/sourcelocation/ class SourceLocation # @return [Integer] attr_reader :offset, :line, :column diff --git a/lib/sass/logger/source_span.rb b/lib/sass/logger/source_span.rb index 090781a6..6e8ee08c 100644 --- a/lib/sass/logger/source_span.rb +++ b/lib/sass/logger/source_span.rb @@ -4,7 +4,7 @@ module Sass module Logger # A span of text within a source file. # - # @see https://sass-lang.com/documentation/js-api/interfaces/SourceSpan + # @see https://sass-lang.com/documentation/js-api/interfaces/sourcespan/ class SourceSpan # @return [SourceLocation] attr_reader :start, :end diff --git a/lib/sass/value.rb b/lib/sass/value.rb index 0507926f..24909366 100644 --- a/lib/sass/value.rb +++ b/lib/sass/value.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true +require_relative 'calculation_value' require_relative 'script_error' module Sass # The abstract base class of Sass's value types. # - # @see https://sass-lang.com/documentation/js-api/classes/Value + # @see https://sass-lang.com/documentation/js-api/classes/value/ module Value # @return [::String, nil] def separator @@ -60,11 +61,18 @@ def assert_boolean(name = nil) raise Sass::ScriptError.new("#{self} is not a boolean", name) end + # @return [Calculation] # @raise [ScriptError] def assert_calculation(name = nil) raise Sass::ScriptError.new("#{self} is not a calculation", name) end + # @return [CalculationValue] + # @raise [ScriptError] + def assert_calculation_value(name = nil) + raise Sass::ScriptError.new("#{self} is not a calculation value", name) + end + # @return [Color] # @raise [ScriptError] def assert_color(name = nil) @@ -119,6 +127,7 @@ def to_a_length require_relative 'value/list' require_relative 'value/argument_list' require_relative 'value/boolean' +require_relative 'value/calculation' require_relative 'value/color' require_relative 'value/function' require_relative 'value/fuzzy_math' diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 61b63106..018fed38 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -7,7 +7,7 @@ module Value # An argument list comes from a rest argument. It's distinct from a normal {List} in that it may contain a keyword # map as well as the positional arguments. # - # @see https://sass-lang.com/documentation/js-api/classes/SassArgumentList + # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/ class ArgumentList < Value::List # @param contents [Array] # @param keywords [Hash<::String, Value>] diff --git a/lib/sass/value/boolean.rb b/lib/sass/value/boolean.rb index bad569bb..ea4d418e 100644 --- a/lib/sass/value/boolean.rb +++ b/lib/sass/value/boolean.rb @@ -4,7 +4,7 @@ module Sass module Value # Sass's boolean type. # - # @see https://sass-lang.com/documentation/js-api/classes/SassBoolean + # @see https://sass-lang.com/documentation/js-api/classes/sassboolean/ class Boolean include Value diff --git a/lib/sass/value/calculation.rb b/lib/sass/value/calculation.rb new file mode 100644 index 00000000..4f0e0dad --- /dev/null +++ b/lib/sass/value/calculation.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's calculation type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sasscalculation/ + class Calculation + include Value + include CalculationValue + + def initialize(name, arguments) + @name = name.freeze + @arguments = arguments.freeze + end + + # @return [::String] + attr_reader :name + + # @return [Array] + attr_reader :arguments + + private_class_method :new + + class << self + # @param argument [CalculationValue] + # @return [Calculation] + def calc(argument) + argument.assert_calculation_value + new('calc', [argument]) + end + + # @param arguments [Array] + # @return [Calculation] + def min(arguments) + arguments.each(&:assert_calculation_value) + new('min', arguments) + end + + # @param arguments [Array] + # @return [Calculation] + def max(arguments) + arguments.each(&:assert_calculation_value) + new('max', arguments) + end + + # @param min [CalculationValue] + # @param value [CalculationValue] + # @param max [CalculationValue] + # @return [Calculation] + def clamp(min, value = nil, max = nil) + if (value.nil? && !valid_clamp_arg?(min)) || + (max.nil? && [min, value].none? { |x| x && valid_clamp_arg?(x) }) + raise Sass::ScriptError, 'Argument must be an unquoted SassString or CalculationInterpolation.' + end + + arguments = [min] + arguments.push(value) unless value.nil? + arguments.push(max) unless max.nil? + arguments.each(&:assert_calculation_value) + new('clamp', arguments) + end + + private + + def valid_clamp_arg?(value) + value.is_a?(Sass::CalculationValue::CalculationInterpolation) || + (value.is_a?(Sass::Value::String) && !value.quoted?) + end + end + + # @return [Calculation] + def assert_calculation(_name = nil) + self + end + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Calculation) && + other.name == name && + other.arguments == arguments + end + + # @return [Integer] + def hash + @hash ||= [name, *arguments].hash + end + end + end +end diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 04c233f7..6844148c 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -6,7 +6,7 @@ module Value # # No matter what representation was originally used to create this color, all of its channels are accessible. # - # @see https://sass-lang.com/documentation/js-api/classes/SassColor + # @see https://sass-lang.com/documentation/js-api/classes/sasscolor/ class Color include Value diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index dc7b91fc..3d412c92 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -4,7 +4,7 @@ module Sass module Value # Sass's function type. # - # @see https://sass-lang.com/documentation/js-api/classes/SassFunction + # @see https://sass-lang.com/documentation/js-api/classes/sassfunction/ class Function include Value diff --git a/lib/sass/value/list.rb b/lib/sass/value/list.rb index cb9802c9..c3269e39 100644 --- a/lib/sass/value/list.rb +++ b/lib/sass/value/list.rb @@ -4,7 +4,7 @@ module Sass module Value # Sass's list type. # - # @see https://sass-lang.com/documentation/js-api/classes/SassList + # @see https://sass-lang.com/documentation/js-api/classes/sasslist/ class List include Value diff --git a/lib/sass/value/map.rb b/lib/sass/value/map.rb index f42b3483..03c3b9f7 100644 --- a/lib/sass/value/map.rb +++ b/lib/sass/value/map.rb @@ -4,7 +4,7 @@ module Sass module Value # Sass's map type. # - # @see https://sass-lang.com/documentation/js-api/classes/SassMap + # @see https://sass-lang.com/documentation/js-api/classes/sassmap/ class Map include Value diff --git a/lib/sass/value/null.rb b/lib/sass/value/null.rb index 7c95a612..c680a300 100644 --- a/lib/sass/value/null.rb +++ b/lib/sass/value/null.rb @@ -4,7 +4,7 @@ module Sass module Value # Sass's null type. # - # @see https://sass-lang.com/documentation/js-api/modules#sassNull + # @see https://sass-lang.com/documentation/js-api/variables/sassnull/ class Null include Value diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index a0182299..bdca78ed 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -6,9 +6,10 @@ module Sass module Value # Sass's number type. # - # @see https://sass-lang.com/documentation/js-api/classes/SassNumber + # @see https://sass-lang.com/documentation/js-api/classes/sassnumber/ class Number include Value + include CalculationValue # @param value [Numeric] # @param unit [::String, Hash] diff --git a/lib/sass/value/string.rb b/lib/sass/value/string.rb index d1eb9907..f7176542 100644 --- a/lib/sass/value/string.rb +++ b/lib/sass/value/string.rb @@ -4,9 +4,10 @@ module Sass module Value # Sass's string type. # - # @see https://sass-lang.com/documentation/js-api/classes/SassString + # @see https://sass-lang.com/documentation/js-api/classes/sassstring/ class String include Value + include CalculationValue # @param text [::String] # @param quoted [::Boolean] @@ -38,6 +39,14 @@ def assert_string(_name = nil) self end + # @return [CalculationValue] + # @raise [ScriptError] + def assert_calculation_value(_name = nil) + raise Sass::ScriptError, "Expected #{self} to be an unquoted string." if quoted? + + self + end + # @param sass_index [Number] # @return [Integer] def sass_index_to_string_index(sass_index, name = nil) diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index 5b6dae72..46f031bc 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -96,6 +96,7 @@ it "isn't any other type" do expect { list.assert_boolean }.to raise_error(Sass::ScriptError) + expect { list.assert_calculation }.to raise_error(Sass::ScriptError) expect { list.assert_color }.to raise_error(Sass::ScriptError) expect { list.assert_function }.to raise_error(Sass::ScriptError) expect { list.assert_map }.to raise_error(Sass::ScriptError) diff --git a/spec/sass/value/boolean_spec.rb b/spec/sass/value/boolean_spec.rb index ab66326a..ce1a7ca5 100644 --- a/spec/sass/value/boolean_spec.rb +++ b/spec/sass/value/boolean_spec.rb @@ -23,6 +23,7 @@ end it "isn't any other type" do + expect { value.assert_calculation }.to raise_error(Sass::ScriptError) expect { value.assert_color }.to raise_error(Sass::ScriptError) expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) @@ -52,6 +53,7 @@ end it "isn't any other type" do + expect { value.assert_calculation }.to raise_error(Sass::ScriptError) expect { value.assert_color }.to raise_error(Sass::ScriptError) expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb new file mode 100644 index 00000000..717cac45 --- /dev/null +++ b/spec/sass/value/calculation_spec.rb @@ -0,0 +1,402 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Sass::Value::Calculation do + valid_calculation_values = [ + Sass::Value::Number.new(1), + Sass::Value::String.new('1', quoted: false), + described_class.calc(Sass::Value::Number.new(1)), + Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), Sass::Value::Number.new(1)), + Sass::CalculationValue::CalculationInterpolation.new('') + ] + invalid_calculation_values = [Sass::Value::String.new('1', quoted: true)] + + describe 'construction' do + calculation = nil + before do + calculation = described_class.calc(Sass::Value::Number.new(1)) + end + + it 'is a value' do + expect(calculation).to be_a(Sass::Value) + end + + it 'is a calculation' do + expect(calculation).to be_a(described_class) + expect(calculation.assert_calculation).to be(calculation) + end + + it "isn't any other type" do + expect { calculation.assert_boolean }.to raise_error(Sass::ScriptError) + expect { calculation.assert_color }.to raise_error(Sass::ScriptError) + expect { calculation.assert_function }.to raise_error(Sass::ScriptError) + expect { calculation.assert_map }.to raise_error(Sass::ScriptError) + expect(calculation.to_map).to be_nil + expect { calculation.assert_number }.to raise_error(Sass::ScriptError) + expect { calculation.assert_string }.to raise_error(Sass::ScriptError) + end + end + + describe 'calc' do + it 'correctly stores name and arguments' do + result = described_class.calc(Sass::Value::Number.new(1)) + expect(result.name).to be('calc') + expect(result.arguments).to eq([Sass::Value::Number.new(1)]) + end + + it 'rejects invalid arguments' do + invalid_calculation_values.each do |value| + expect { described_class.calc(value) }.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid arguments' do + valid_calculation_values.each do |value| + expect { described_class.calc(value) }.not_to raise_error + end + end + end + + describe 'min' do + it 'correctly stores name and arguments' do + result = described_class.min([ + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ]) + expect(result.name).to be('min') + expect(result.arguments).to eq([ + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ]) + end + + it 'rejects invalid arguments' do + invalid_calculation_values.each do |value| + expect { described_class.min([value, Sass::Value::Number.new(2)]) }.to raise_error(Sass::ScriptError) + expect { described_class.min([Sass::Value::Number.new(1), value]) }.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid arguments' do + valid_calculation_values.each do |value| + expect { described_class.min([value, Sass::Value::Number.new(2)]) }.not_to raise_error + expect { described_class.min([Sass::Value::Number.new(1), value]) }.not_to raise_error + end + end + end + + describe 'max' do + it 'correctly stores name and arguments' do + result = described_class.max([ + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ]) + expect(result.name).to be('max') + expect(result.arguments).to eq([ + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ]) + end + + it 'rejects invalid arguments' do + invalid_calculation_values.each do |value| + expect { described_class.max([value, Sass::Value::Number.new(2)]) }.to raise_error(Sass::ScriptError) + expect { described_class.max([Sass::Value::Number.new(1), value]) }.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid arguments' do + valid_calculation_values.each do |value| + expect { described_class.max([value, Sass::Value::Number.new(2)]) }.not_to raise_error + expect { described_class.max([Sass::Value::Number.new(1), value]) }.not_to raise_error + end + end + end + + describe 'clamp' do + it 'correctly stores name and arguments' do + result = described_class.clamp( + Sass::Value::Number.new(1), + Sass::Value::Number.new(2), + Sass::Value::Number.new(3) + ) + expect(result.name).to be('clamp') + expect(result.arguments).to eq([ + Sass::Value::Number.new(1), + Sass::Value::Number.new(2), + Sass::Value::Number.new(3) + ]) + end + + it 'rejects invalid arguments' do + invalid_calculation_values.each do |value| + expect do + described_class.clamp(value, Sass::Value::Number.new(2), + Sass::Value::Number.new(3)) + end.to raise_error(Sass::ScriptError) + expect do + described_class.clamp(Sass::Value::Number.new(1), value, + Sass::Value::Number.new(3)) + end.to raise_error(Sass::ScriptError) + expect do + described_class.clamp(Sass::Value::Number.new(1), Sass::Value::Number.new(2), + value) + end.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid arguments' do + valid_calculation_values.each do |value| + expect do + described_class.clamp(value, Sass::Value::Number.new(2), Sass::Value::Number.new(3)) + end.not_to raise_error + expect do + described_class.clamp(Sass::Value::Number.new(1), value, Sass::Value::Number.new(3)) + end.not_to raise_error + expect do + described_class.clamp(Sass::Value::Number.new(1), Sass::Value::Number.new(2), value) + end.not_to raise_error + end + end + + # When `clamp()` is called with less than three arguments, the list of + # accepted values is much narrower + valid_clamp_values = [ + Sass::Value::String.new('1', quoted: false), + Sass::CalculationValue::CalculationInterpolation.new('1') + ] + invalid_clamp_values = [ + Sass::Value::Number.new(1), + Sass::Value::String.new('1', quoted: true) + ] + + it 'rejects invalid values for one argument' do + invalid_clamp_values.each do |value| + expect { described_class.clamp(value) }.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid values for one argument' do + valid_clamp_values.each do |value| + expect { described_class.clamp(value) }.not_to raise_error + end + end + + it 'rejects invalid values for two arguments' do + invalid_clamp_values.each do |value| + expect { described_class.clamp(value, value) }.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid values for two arguments' do + valid_clamp_values.each do |value| + expect { described_class.clamp(value, value) }.not_to raise_error + end + end + end + + describe 'simplifies' do + it 'calc()' do + fn = lambda do |_args| + described_class.calc( + Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), Sass::Value::Number.new(2)) + ) + end + + expect( + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + ).to eq("a {\n b: 3;\n}") + end + + it 'clamp()' do + fn = lambda do |_args| + described_class.clamp( + Sass::Value::Number.new(1), + Sass::Value::Number.new(2), + Sass::Value::Number.new(3) + ) + end + + expect( + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + ).to eq("a {\n b: 2;\n}") + end + + it 'min()' do + fn = lambda do |_args| + described_class.min([Sass::Value::Number.new(1), Sass::Value::Number.new(2)]) + end + + expect( + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + ).to eq("a {\n b: 1;\n}") + end + + it 'max()' do + fn = lambda do |_args| + described_class.max([Sass::Value::Number.new(1), Sass::Value::Number.new(2)]) + end + + expect( + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + ).to eq("a {\n b: 2;\n}") + end + + it 'operations' do + fn = lambda do |_args| + described_class.calc( + Sass::CalculationValue::CalculationOperation.new( + '+', + described_class.min([Sass::Value::Number.new(3), Sass::Value::Number.new(4)]), + Sass::CalculationValue::CalculationOperation.new( + '*', + described_class.max([Sass::Value::Number.new(5), Sass::Value::Number.new(6)]), + Sass::CalculationValue::CalculationOperation.new( + '-', + Sass::Value::Number.new(3), + Sass::CalculationValue::CalculationOperation.new( + '/', + Sass::Value::Number.new(4), + Sass::Value::Number.new(5) + ) + ) + ) + ) + ) + end + + expect( + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + ).to eq("a {\n b: 16.2;\n}") + end + end + + describe 'throws when simplifying' do + it 'calc() with more than one argument' do + fn = lambda do |_args| + described_class.calc(Sass::Value::Number.new(1), Sass::Value::Number.new(2)) + end + + expect do + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + end.to raise_error(Sass::CompileError) + end + + it 'clamp() with the wrong number of arguments' do + fn = lambda do |_args| + described_class.clamp(Sass::CalculationValue::CalculationInterpolation.new('1')) + end + + expect do + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + end.to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.full_message).to match(/exactly 3 arguments/) + end + end + + it 'an unknown calculation function' do + fn = lambda do |_args| + described_class.send(:new, 'foo', [Sass::Value::Number.new(1)]) + end + + expect do + Sass.compile_string('a {b: foo()}', + functions: { 'foo()': fn }).css + end.to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.full_message).to match(/"foo" is not a recognized calculation type/) + end + end + end + + describe 'CalculationOperation' do + valid_operators = ['+', '-', '*', '/'] + invalid_operators = ['||', '&&', 'plus', 'minus', ''] + + describe 'construction' do + it 'rejects invalid operators' do + invalid_operators.each do |operator| + expect do + Sass::CalculationValue::CalculationOperation.new( + operator, + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ) + end.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid operators' do + valid_operators.each do |operator| + expect do + Sass::CalculationValue::CalculationOperation.new( + operator, + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ) + end.not_to raise_error + end + end + end + + it 'rejects invalid operands' do + invalid_calculation_values.each do |operand| + expect do + Sass::CalculationValue::CalculationOperation.new('+', operand, Sass::Value::Number.new(1)) + end.to raise_error(Sass::ScriptError) + expect do + Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), operand) + end.to raise_error(Sass::ScriptError) + end + end + + it 'accepts valid operands' do + valid_calculation_values.each do |operand| + expect do + Sass::CalculationValue::CalculationOperation.new('+', operand, Sass::Value::Number.new(1)) + end.not_to raise_error + expect do + Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), operand) + end.not_to raise_error + end + end + + describe 'stores' do + operation = nil + before do + operation = Sass::CalculationValue::CalculationOperation.new( + '+', + Sass::Value::Number.new(1), + Sass::Value::Number.new(2) + ) + end + + it 'operator' do + expect(operation.operator).to eq('+') + end + + it 'left' do + expect(operation.left).to eq(Sass::Value::Number.new(1)) + end + + it 'right' do + expect(operation.right).to eq(Sass::Value::Number.new(2)) + end + end + end + + describe 'CalculationInterpolation' do + it 'stores value' do + expect(Sass::CalculationValue::CalculationInterpolation.new('1').value).to eq('1') + end + end +end diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb index 04d25809..652503fd 100644 --- a/spec/sass/value/color_spec.rb +++ b/spec/sass/value/color_spec.rb @@ -33,6 +33,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) it "isn't any other type" do expect { color.assert_boolean }.to raise_error(Sass::ScriptError) + expect { color.assert_calculation }.to raise_error(Sass::ScriptError) expect { color.assert_function }.to raise_error(Sass::ScriptError) expect { color.assert_map }.to raise_error(Sass::ScriptError) expect(color.to_map).to be_nil diff --git a/spec/sass/value/list_spec.rb b/spec/sass/value/list_spec.rb index ecbeacdf..485f3754 100644 --- a/spec/sass/value/list_spec.rb +++ b/spec/sass/value/list_spec.rb @@ -18,6 +18,7 @@ it "isn't any other type" do expect { list.assert_boolean }.to raise_error(Sass::ScriptError) + expect { list.assert_calculation }.to raise_error(Sass::ScriptError) expect { list.assert_color }.to raise_error(Sass::ScriptError) expect { list.assert_function }.to raise_error(Sass::ScriptError) expect { list.assert_map }.to raise_error(Sass::ScriptError) diff --git a/spec/sass/value/map_spec.rb b/spec/sass/value/map_spec.rb index 21e42994..3c30ecff 100644 --- a/spec/sass/value/map_spec.rb +++ b/spec/sass/value/map_spec.rb @@ -24,6 +24,7 @@ it "isn't any other type" do expect { map.assert_boolean }.to raise_error(Sass::ScriptError) + expect { map.assert_calculation }.to raise_error(Sass::ScriptError) expect { map.assert_color }.to raise_error(Sass::ScriptError) expect { map.assert_function }.to raise_error(Sass::ScriptError) expect { map.assert_number }.to raise_error(Sass::ScriptError) diff --git a/spec/sass/value/null_spec.rb b/spec/sass/value/null_spec.rb index ed89516a..12fd7643 100644 --- a/spec/sass/value/null_spec.rb +++ b/spec/sass/value/null_spec.rb @@ -23,6 +23,7 @@ it "isn't any type" do expect { value.assert_boolean }.to raise_error(Sass::ScriptError) + expect { value.assert_calculation }.to raise_error(Sass::ScriptError) expect { value.assert_color }.to raise_error(Sass::ScriptError) expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 5861dcdb..5c606f16 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -33,6 +33,7 @@ it "isn't any other type" do expect { number.assert_boolean }.to raise_error(Sass::ScriptError) + expect { number.assert_calculation }.to raise_error(Sass::ScriptError) expect { number.assert_color }.to raise_error(Sass::ScriptError) expect { number.assert_function }.to raise_error(Sass::ScriptError) expect { number.assert_map }.to raise_error(Sass::ScriptError) diff --git a/spec/sass/value/string_spec.rb b/spec/sass/value/string_spec.rb index 9feee2e6..71259386 100644 --- a/spec/sass/value/string_spec.rb +++ b/spec/sass/value/string_spec.rb @@ -52,6 +52,7 @@ it "isn't any other type" do value = described_class.new('nb') expect { value.assert_boolean }.to raise_error(Sass::ScriptError) + expect { value.assert_calculation }.to raise_error(Sass::ScriptError) expect { value.assert_color }.to raise_error(Sass::ScriptError) expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index 559d73e2..e2cb3ad0 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -90,7 +90,7 @@ described_class.compile_string( 'a {b: foo()}', functions: { - 'foo()': -> { raise 'heck' } + 'foo()': ->(_args) { raise 'heck' } } ) end.to raise_error do |error| @@ -104,7 +104,7 @@ described_class.compile_string( 'a {b: foo()}', functions: { - 'foo()': -> {} + 'foo()': ->(_args) {} } ) end.to raise_error do |error| @@ -113,17 +113,33 @@ end end - it 'returning a non-Value' do - expect do - described_class.compile_string( - 'a {b: foo()}', - functions: { - 'foo()': -> { 'wrong' } - } - ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) + describe 'returning a non-Value' do + it 'directly' do + expect do + described_class.compile_string( + 'a {b: foo()}', + functions: { + 'foo()': ->(_args) { 'wrong' } + } + ) + end.to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.span.start.line).to eq(0) + end + end + + it 'in a calculation' do + expect do + described_class.compile_string( + 'a {b: foo()}', + functions: { + 'foo()': ->(_args) { Sass::Value::Calculation.calc('wrong') } + } + ) + end.to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.span.start.line).to eq(0) + end end end end @@ -165,55 +181,55 @@ describe 'rejects a function signature that' do it 'is empty' do expect do - described_class.compile_string('', functions: { '': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { '': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has no name' do expect do - described_class.compile_string('', functions: { '()': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { '()': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has no arguments' do expect do - described_class.compile_string('', functions: { foo: -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { foo: ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has invalid arguments' do expect do - described_class.compile_string('', functions: { 'foo(arg)': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { 'foo(arg)': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has no closing parentheses' do expect do - described_class.compile_string('', functions: { 'foo(': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { 'foo(': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has a non-identifier name' do expect do - described_class.compile_string('', functions: { '$foo()': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { '$foo()': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has whitespace before the signature' do expect do - described_class.compile_string('', functions: { ' foo()': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { ' foo()': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has whitespace after the signature' do expect do - described_class.compile_string('', functions: { 'foo() ': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { 'foo() ': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end it 'has whitespace between the identifier and the arguments' do expect do - described_class.compile_string('', functions: { 'foo ()': -> { Sass::Value::Null::NULL } }) + described_class.compile_string('', functions: { 'foo ()': ->(_args) { Sass::Value::Null::NULL } }) end.to raise_error(Sass::CompileError) end end diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 563387af..940205b8 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -39,6 +39,21 @@ def remote_eq(lhs, rhs) __LINE__ => Sass::Value::Number.new(Math::PI), __LINE__ => Sass::Value::Number.new(42, 'px'), __LINE__ => Sass::Value::Number.new(42, { numerator_units: ['px'], denominator_units: ['ms'] }), + __LINE__ => Sass::Value::Calculation.calc( + Sass::CalculationValue::CalculationOperation.new( + '+', + Sass::Value::Number.new(1, 'em'), + Sass::Value::Number.new(42, 'px') + ) + ), + __LINE__ => Sass::Value::Calculation.min([ + Sass::Value::Number.new(1, 'em'), + Sass::Value::Number.new(42, 'px') + ]), + __LINE__ => Sass::Value::Calculation.max([ + Sass::Value::Number.new(1, 'em'), + Sass::Value::Number.new(42, 'px') + ]), __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, whiteness: 0, blackness: 0, alpha: 1), From a9943a0ac7155025c1ed7d94345b6ddeb31a44af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Jul 2023 02:09:54 -0700 Subject: [PATCH 182/700] Update sass_proto_spec.rb --- spec/sass_proto_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 940205b8..7c5f949b 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -48,11 +48,16 @@ def remote_eq(lhs, rhs) ), __LINE__ => Sass::Value::Calculation.min([ Sass::Value::Number.new(1, 'em'), - Sass::Value::Number.new(42, 'px') + Sass::Value::Number.new(42, 'px'), + Sass::Value::Calculation.max([ + Sass::Value::Number.new(1, 'rem'), + Sass::Value::Number.new(42, 'pt') + ]) ]), __LINE__ => Sass::Value::Calculation.max([ - Sass::Value::Number.new(1, 'em'), - Sass::Value::Number.new(42, 'px') + Sass::Value::String.new('1', quoted: false), + Sass::Value::Number.new(42, 'px'), + Sass::CalculationValue::CalculationInterpolation.new('1em') ]), __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), From 37a3724eb91d1feadf67479ca049de5c1151b214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Jul 2023 02:17:16 -0700 Subject: [PATCH 183/700] v1.64.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 43008587..4e5c6689 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.63.6' + VERSION = '1.64.0' end end From edab924c26464b80f021a84a54ea84a0145f8e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Jul 2023 09:23:05 -0700 Subject: [PATCH 184/700] Use normalized cpu in normalized gem platform --- ext/sass/Rakefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 873fbe69..4ca11d4f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -413,10 +413,10 @@ module SassConfig end def gem_platform - platform = Gem::Platform.new("#{RbConfig::CONFIG['host_cpu']}-#{RbConfig::CONFIG['host_os']}") + platform = Gem::Platform.new("#{Platform::EMULATION || Platform::CPU}-#{RbConfig::CONFIG['host_os']}") case Platform::OS when 'darwin' - Gem::Platform.new([platform.cpu, platform.os]) + Gem::Platform.new([RbConfig::CONFIG['host_cpu'], platform.os]) when 'linux' if platform.version&.start_with?('gnu') platform @@ -424,11 +424,9 @@ module SassConfig Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"]) end when 'windows' - case Platform::EMULATION || Platform::CPU + case platform.cpu when 'x86_64' Gem::Platform.new('x64-mingw32') - when 'i386' - Gem::Platform.new('x86-mingw32') else Gem::Platform.new([platform.cpu, 'mingw32']) end From b909a2c30af32c1a6c8cfd8c6dafa6a64ce937f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Jul 2023 16:36:07 -0700 Subject: [PATCH 185/700] Skip validation of Calculation arguments from compiler --- lib/sass/embedded/host/value_protofier.rb | 36 ++--------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index 49dcd0e2..fe622763 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -230,39 +230,9 @@ def to_proto(obj) end def from_proto(obj) - case obj.name - when 'calc' - if obj.arguments.length != 1 - raise Sass::ScriptError, - 'Value.Calculation.arguments must have exactly one argument for calc().' - end - - Sass::Value::Calculation.calc(*obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) - when 'clamp' - if obj.arguments.length != 3 - raise Sass::ScriptError, - 'Value.Calculation.arguments must have exactly 3 arguments for clamp().' - end - - Sass::Value::Calculation.clamp(*obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) - when 'min' - if obj.arguments.empty? - raise Sass::ScriptError, - 'Value.Calculation.arguments must have at least 1 argument for min().' - end - - Sass::Value::Calculation.min(obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) - when 'max' - if obj.arguments.empty? - raise Sass::ScriptError, - 'Value.Calculation.arguments must have at least 1 argument for max().' - end - - Sass::Value::Calculation.max(obj.arguments.map { |argument| CalculationValue.from_proto(argument) }) - else - raise Sass::ScriptError, - "Value.Calculation.name #{calculation.name.inspect} is not a recognized calculation type." - end + Sass::Value::Calculation.send(:new, obj.name, obj.arguments.map do |argument| + CalculationValue.from_proto(argument) + end) end end From fd48f3a6af4becfbb30210c384de3108c3b506f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Jul 2023 16:48:28 -0700 Subject: [PATCH 186/700] Format --- lib/sass/embedded/host/value_protofier.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index fe622763..2efdc0b1 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -230,9 +230,11 @@ def to_proto(obj) end def from_proto(obj) - Sass::Value::Calculation.send(:new, obj.name, obj.arguments.map do |argument| - CalculationValue.from_proto(argument) - end) + Sass::Value::Calculation.send( + :new, + obj.name, + obj.arguments.map { |argument| CalculationValue.from_proto(argument) } + ) end end From 283aa90e627929f205d7f836c69007cca877f60e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 18:32:54 -0700 Subject: [PATCH 187/700] Bump sass from 1.64.0 to 1.64.1 in /ext/sass (#141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump sass from 1.64.0 to 1.64.1 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.64.0 to 1.64.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.64.0...1.64.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Fix spec --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- ext/sass/package.json | 2 +- spec/sass/value/calculation_spec.rb | 6 +++--- spec/sass_proto_spec.rb | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 2f764312..0d659f31 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.64.0" + "sass": "1.64.1" } } diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 717cac45..129e4538 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -289,9 +289,9 @@ end.to raise_error(Sass::CompileError) end - it 'clamp() with the wrong number of arguments' do + it 'clamp() with the wrong argument' do fn = lambda do |_args| - described_class.clamp(Sass::CalculationValue::CalculationInterpolation.new('1')) + described_class.clamp(Sass::Value::Number.new('1')) end expect do @@ -299,7 +299,7 @@ functions: { 'foo()': fn }).css end.to raise_error do |error| expect(error).to be_a(Sass::CompileError) - expect(error.full_message).to match(/exactly 3 arguments/) + expect(error.full_message).to match(/SassString or CalculationInterpolation/) end end diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 7c5f949b..0130de46 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -59,6 +59,8 @@ def remote_eq(lhs, rhs) Sass::Value::Number.new(42, 'px'), Sass::CalculationValue::CalculationInterpolation.new('1em') ]), + __LINE__ => Sass::Value::Calculation.clamp(Sass::CalculationValue::CalculationInterpolation.new('var(--clamp)')), + __LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)), __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, whiteness: 0, blackness: 0, alpha: 1), From a8c174a964e6c4a24a632c6df685e5962c29e9a2 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 18:45:44 -0700 Subject: [PATCH 188/700] v1.64.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 4e5c6689..09f29af3 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.64.0' + VERSION = '1.64.1' end end From 53e0d337a3a6db37007df9cf6460b8822906b879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 22 Jul 2023 01:25:23 -0700 Subject: [PATCH 189/700] Optimize Calculation implementation --- lib/sass/value/calculation.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/sass/value/calculation.rb b/lib/sass/value/calculation.rb index 4f0e0dad..891658d5 100644 --- a/lib/sass/value/calculation.rb +++ b/lib/sass/value/calculation.rb @@ -10,6 +10,8 @@ class Calculation include CalculationValue def initialize(name, arguments) + arguments.each(&:assert_calculation_value) + @name = name.freeze @arguments = arguments.freeze end @@ -26,21 +28,18 @@ class << self # @param argument [CalculationValue] # @return [Calculation] def calc(argument) - argument.assert_calculation_value new('calc', [argument]) end # @param arguments [Array] # @return [Calculation] def min(arguments) - arguments.each(&:assert_calculation_value) new('min', arguments) end # @param arguments [Array] # @return [Calculation] def max(arguments) - arguments.each(&:assert_calculation_value) new('max', arguments) end @@ -54,11 +53,7 @@ def clamp(min, value = nil, max = nil) raise Sass::ScriptError, 'Argument must be an unquoted SassString or CalculationInterpolation.' end - arguments = [min] - arguments.push(value) unless value.nil? - arguments.push(max) unless max.nil? - arguments.each(&:assert_calculation_value) - new('clamp', arguments) + new('clamp', [min, value, max].compact) end private From 25688e07232dc679778528e1699b76c093907671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 22 Jul 2023 01:40:04 -0700 Subject: [PATCH 190/700] Update calculation.rb --- lib/sass/value/calculation.rb | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/sass/value/calculation.rb b/lib/sass/value/calculation.rb index 891658d5..dc1f957c 100644 --- a/lib/sass/value/calculation.rb +++ b/lib/sass/value/calculation.rb @@ -9,22 +9,9 @@ class Calculation include Value include CalculationValue - def initialize(name, arguments) - arguments.each(&:assert_calculation_value) - - @name = name.freeze - @arguments = arguments.freeze - end - - # @return [::String] - attr_reader :name - - # @return [Array] - attr_reader :arguments - - private_class_method :new - class << self + private :new + # @param argument [CalculationValue] # @return [Calculation] def calc(argument) @@ -64,6 +51,23 @@ def valid_clamp_arg?(value) end end + protected + + def initialize(name, arguments) + arguments.each(&:assert_calculation_value) + + @name = name.freeze + @arguments = arguments.freeze + end + + public + + # @return [::String] + attr_reader :name + + # @return [Array] + attr_reader :arguments + # @return [Calculation] def assert_calculation(_name = nil) self From a69a0a891cc48765a432de06e0fca2a3498e62a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 22 Jul 2023 01:47:15 -0700 Subject: [PATCH 191/700] Update argument_list.rb --- lib/sass/value/argument_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 018fed38..71cda0b6 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -26,7 +26,7 @@ def keywords @keywords end - private + protected def initialize_copy(orig) super From a6aeacb96c24192df016874daf460ec7569acab1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:34:56 +0000 Subject: [PATCH 192/700] Update rubocop requirement from ~> 1.54.0 to ~> 1.55.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.54.0...v1.55.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4640838e..65862646 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.54.0' + gem 'rubocop', '~> 1.55.0' gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.22.0' From 5188b71b766a37b24cb9122b9742ec84a96b0879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Jul 2023 10:31:41 -0700 Subject: [PATCH 193/700] Use private instead of protected --- lib/sass/value/argument_list.rb | 2 +- lib/sass/value/calculation.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 71cda0b6..018fed38 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -26,7 +26,7 @@ def keywords @keywords end - protected + private def initialize_copy(orig) super diff --git a/lib/sass/value/calculation.rb b/lib/sass/value/calculation.rb index dc1f957c..034b2aff 100644 --- a/lib/sass/value/calculation.rb +++ b/lib/sass/value/calculation.rb @@ -51,7 +51,7 @@ def valid_clamp_arg?(value) end end - protected + private def initialize(name, arguments) arguments.each(&:assert_calculation_value) From d2bea299df98ed394f615326c77ec6743a469680 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:44:17 +0000 Subject: [PATCH 194/700] Update rubocop-rspec requirement from ~> 2.22.0 to ~> 2.23.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.22.0...v2.23.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 65862646..c358d7e0 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.55.0' gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.22.0' + gem 'rubocop-rspec', '~> 2.23.0' end From ee2b2a8ad2a9a0cada493ec33a61131daf9c907f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 31 Jul 2023 16:16:54 -0700 Subject: [PATCH 195/700] Improve error message --- lib/sass/value/string.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/string.rb b/lib/sass/value/string.rb index f7176542..ef67381e 100644 --- a/lib/sass/value/string.rb +++ b/lib/sass/value/string.rb @@ -41,8 +41,8 @@ def assert_string(_name = nil) # @return [CalculationValue] # @raise [ScriptError] - def assert_calculation_value(_name = nil) - raise Sass::ScriptError, "Expected #{self} to be an unquoted string." if quoted? + def assert_calculation_value(name = nil) + raise Sass::ScriptError.new("Expected #{self} to be an unquoted string.", name) if quoted? self end From 45275d3b99b18dc649977cace6f98cd62e6f3e3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 23:52:46 +0000 Subject: [PATCH 196/700] Bump sass from 1.64.1 to 1.64.2 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.64.1 to 1.64.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.64.1...1.64.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 0d659f31..6a720e3e 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.64.1" + "sass": "1.64.2" } } From 87fe599a009a30dfd96d25ffa9d0fac9889e2df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 31 Jul 2023 17:23:58 -0700 Subject: [PATCH 197/700] v1.64.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 09f29af3..6394a9e9 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.64.1' + VERSION = '1.64.2' end end From 4e9176b9ee4c93a9c1ec430e7e25e8b406895ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 4 Aug 2023 18:19:56 -0700 Subject: [PATCH 198/700] Prepare for null-alpha deprecation --- lib/sass/value/color.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 6844148c..07f44351 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -27,7 +27,7 @@ def initialize(red: nil, lightness: nil, whiteness: nil, blackness: nil, - alpha: nil) + alpha: 1) @alpha = alpha.nil? ? 1 : FuzzyMath.assert_between(alpha, 0, 1, 'alpha') if red && green && blue @red = FuzzyMath.assert_between(FuzzyMath.round(red), 0, 255, 'red') From 798796251fe1823c72301bb91c6f1504f0002bd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:42:48 +0000 Subject: [PATCH 199/700] Update rubocop requirement from ~> 1.55.0 to ~> 1.56.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.55.0...v1.56.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c358d7e0..1baa5736 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.55.0' + gem 'rubocop', '~> 1.56.0' gem 'rubocop-performance', '~> 1.18.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.23.0' From 2490187cd1300a43f94c0ffc5b589eebb60e83a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 22:00:15 +0000 Subject: [PATCH 200/700] Bump sass from 1.64.2 to 1.65.0 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.64.2 to 1.65.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.64.2...1.65.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 6a720e3e..d2e5d79c 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.64.2" + "sass": "1.65.0" } } From f9591db4178e39478a89058000108b3f5e24ef28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:59:26 +0000 Subject: [PATCH 201/700] Update rubocop-performance requirement from ~> 1.18.0 to ~> 1.19.0 Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.18.0...v1.19.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1baa5736..c9b35dd4 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' gem 'rubocop', '~> 1.56.0' - gem 'rubocop-performance', '~> 1.18.0' + gem 'rubocop-performance', '~> 1.19.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.23.0' end From a7451473bfe787f74425f121c0b0fd9f6d5367b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 23:02:42 +0000 Subject: [PATCH 202/700] Bump sass from 1.65.0 to 1.65.1 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.65.0 to 1.65.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.65.0...1.65.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index d2e5d79c..23ce19c4 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.65.0" + "sass": "1.65.1" } } From 84f304cd349e3855ae5df646c3dd5236b7a2d5b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:38:25 +0000 Subject: [PATCH 203/700] Bump sass from 1.65.1 to 1.66.0 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.65.1 to 1.66.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.65.1...1.66.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 23ce19c4..afbc07b0 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.65.1" + "sass": "1.66.0" } } From bee80a7730a98fb9b1eadb4c8a72752f1df95fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 17 Aug 2023 12:50:55 -0700 Subject: [PATCH 204/700] v1.66.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 6394a9e9..b1c649f6 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.64.2' + VERSION = '1.66.0' end end From 76e6a4a43763966bf89bc6b32a5c3f0c375807ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:05:35 +0000 Subject: [PATCH 205/700] Bump sass from 1.66.0 to 1.66.1 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.66.0 to 1.66.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.66.0...1.66.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index afbc07b0..6a30356f 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.66.0" + "sass": "1.66.1" } } From 374f2c5ee4913749dd8b6bd877ba39f496af431a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 18 Aug 2023 15:21:49 -0700 Subject: [PATCH 206/700] v1.66.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index b1c649f6..104b59d0 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.66.0' + VERSION = '1.66.1' end end From 3480cb2667819dce94f09b0e5132ac662c34044e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 16:15:11 +0000 Subject: [PATCH 207/700] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 8 ++++---- .github/workflows/release.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1064ebb6..329088be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup ruby uses: ruby/setup-ruby@v1 @@ -49,7 +49,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup ruby uses: ruby/setup-ruby@v1 @@ -89,7 +89,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: apk add alpine-sdk protoc @@ -116,7 +116,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 ssh-key: ${{ secrets.DEPLOY_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 185ad10b..69fed6cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup ruby uses: ruby/setup-ruby@v1 @@ -80,7 +80,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup ruby uses: ruby/setup-ruby@v1 From b0cd132bf07d4d0a9d60b76d2da7523cd3fdd343 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:42:53 +0000 Subject: [PATCH 208/700] Update rubocop-rspec requirement from ~> 2.23.0 to ~> 2.24.0 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.23.0...v2.24.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c9b35dd4..6fd0bcf7 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.56.0' gem 'rubocop-performance', '~> 1.19.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.23.0' + gem 'rubocop-rspec', '~> 2.24.0' end From 3b864c888373415d25d1c9170d469ab05db75dc4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:57:17 +0000 Subject: [PATCH 209/700] Bump sass from 1.66.1 to 1.67.0 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.66.1 to 1.67.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.66.1...1.67.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 6a30356f..83cf329f 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.66.1" + "sass": "1.67.0" } } From 3d34597bfb6a5cdc60659cf1c9ede730ea2b1603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 6 Sep 2023 13:27:26 -0700 Subject: [PATCH 210/700] Update spec --- spec/sass_importer_spec.rb | 180 +++++++++++++++++++++++++++++++------ 1 file changed, 155 insertions(+), 25 deletions(-) diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index a1bb0959..baa745d4 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -226,31 +226,6 @@ end end - it 'prefers a relative importer load to an importer' do - result = described_class.compile_string( - '@import "other";', - importers: [{ - canonicalize: lambda { |*| - raise 'canonicalize() should not be called' - }, - load: lambda { |*| - raise 'load() should not be called' - } - }], - url: 'o:style.scss', - importer: { - canonicalize: ->(url, **) { url }, - load: lambda { |*| - return { - contents: 'a {from: relative}', - syntax: 'scss' - } - } - } - ) - expect(result.css).to eq("a {\n from: relative;\n}") - end - it 'prefers an importer to a load path' do sandbox do |dir| dir.write({ @@ -337,6 +312,161 @@ end end + describe "compile_string()'s importer option" do + it 'loads relative imports from the entrypoint' do + result = described_class.compile_string( + '@import "orange";', + importer: { + canonicalize: lambda { |url, **| + expect(url).to eq('u:orange') + url + }, + load: lambda { |url| + color = url.split(':')[1] + return { + contents: ".#{color} {color: #{color}}", + syntax: 'scss' + } + } + }, + url: 'u:entrypoint' + ) + + expect(result.css).to eq(".orange {\n color: orange;\n}") + end + + it 'takes precedence over the importer list for relative URLs' do + result = described_class.compile_string( + '@import "other";', + importer: { + canonicalize: lambda { |url, **| + url + }, + load: lambda { |_url| + return { + contents: 'a {from: relative}', + syntax: 'scss' + } + } + }, + importers: [{ + canonicalize: lambda { |*| + raise 'canonicalize() should not be called' + }, + load: lambda { |*| + raise 'load() should not be called' + } + }], + url: 'o:style.scss' + ) + + expect(result.css).to eq("a {\n from: relative;\n}") + end + + it "doesn't load absolute imports" do + result = described_class.compile_string( + '@import "u:orange";', + importer: { + canonicalize: lambda { |*| + raise 'canonicalize() should not be called' + }, + load: lambda { |*| + raise 'load() should not be called' + } + }, + importers: [{ + canonicalize: lambda { |url, **| + expect(url).to eq('u:orange') + url + }, + load: lambda { |url| + color = url.split(':')[1] + return { + contents: ".#{color} {color: #{color}}", + syntax: 'scss' + } + } + }], + url: 'x:entrypoint' + ) + + expect(result.css).to eq(".orange {\n color: orange;\n}") + end + + it "doesn't load from other importers" do + result = described_class.compile_string( + '@import "u:midstream";', + importer: { + canonicalize: lambda { |*| + raise 'canonicalize() should not be called' + }, + load: lambda { |*| + raise 'load() should not be called' + } + }, + importers: [{ + canonicalize: lambda { |url, **| + url + }, + load: lambda { |url| + pathname = url.split(':')[1] + if pathname == 'midstream' + return { + contents: "@import 'orange';", + syntax: 'scss' + } + else + color = pathname + return { + contents: ".#{color} {color: #{color}}", + syntax: 'scss' + } + end + } + }], + url: 'x:entrypoint' + ) + + expect(result.css).to eq(".orange {\n color: orange;\n}") + end + + it 'importer order is preserved for absolute imports' do + # The second importer should only be invoked once, because when the + # "first:other" import is resolved it should be passed to the first + # importer first despite being in the second importer's file. + second_called = false + result = described_class.compile_string( + '@import "second:other";', + importers: [{ + canonicalize: lambda { |url, **| + url if url.start_with?('first:') + }, + load: lambda { |*| + return { + contents: 'a {from: first}', + syntax: 'scss' + } + } + }, { + canonicalize: lambda { |url, **| + raise 'Second importer should only be called once.' if second_called + + second_called = true + url if url.start_with?('second:') + }, + load: lambda { |*| + return { + contents: '@import "first:other";', + syntax: 'scss' + } + } + }] + ) + + expect(result.css).to eq("a {\n from: first;\n}") + end + end + describe 'from_import is' do def expect_from_import(canonicalize, expected) allow(canonicalize).to receive(:call) { |url, from_import:| From 004143cf1b76eb7e3eac4a07209cfa433841b7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Sep 2023 16:57:22 -0700 Subject: [PATCH 211/700] Update handling of ProtocolError --- lib/sass/embedded/host.rb | 12 +++++------- spec/sass/value/calculation_spec.rb | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index bbac4d35..1cf35a2b 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -86,13 +86,11 @@ def version_response(message) end def error(message) - if message.is_a?(EmbeddedProtocol::ProtocolError) - return if message.id != id - - @error = Errno::EPROTO.new(message.message) - else - @error = message - end + @error = if message.is_a?(EmbeddedProtocol::ProtocolError) + Errno::EPROTO.new(message.message) + else + message + end @queue.close end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 129e4538..cebe907b 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -312,7 +312,6 @@ Sass.compile_string('a {b: foo()}', functions: { 'foo()': fn }).css end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) expect(error.full_message).to match(/"foo" is not a recognized calculation type/) end end From 174bb0dfdfea4dcbbebcf5d6195168d2c847ca11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Sep 2023 18:07:15 -0700 Subject: [PATCH 212/700] Interprolation in Calculation is more strict --- spec/sass_proto_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 0130de46..089c0a14 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -57,9 +57,11 @@ def remote_eq(lhs, rhs) __LINE__ => Sass::Value::Calculation.max([ Sass::Value::String.new('1', quoted: false), Sass::Value::Number.new(42, 'px'), - Sass::CalculationValue::CalculationInterpolation.new('1em') + Sass::Value::Calculation.min([ + Sass::Value::Number.new(1, 'rem'), + Sass::Value::Number.new(42, 'pt') + ]) ]), - __LINE__ => Sass::Value::Calculation.clamp(Sass::CalculationValue::CalculationInterpolation.new('var(--clamp)')), __LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)), __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), From 38aed329b3cc806faa42004da4b02c42cfc36261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Sep 2023 18:23:06 -0700 Subject: [PATCH 213/700] v1.67.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 104b59d0..1416d6f6 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.66.1' + VERSION = '1.67.0' end end From fc74588a3e04c52246699da6efdc8183d395d67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 19 Sep 2023 17:33:33 -0700 Subject: [PATCH 214/700] Enable rubocop Style/MultilineBlockChain --- .rubocop.yml | 3 - ext/sass/Rakefile | 6 +- lib/sass/embedded.rb | 4 +- lib/sass/embedded/dispatcher.rb | 5 +- spec/sass/value/argument_list_spec.rb | 9 ++- spec/sass/value/calculation_spec.rb | 9 +-- spec/sass/value/function_spec.rb | 9 ++- spec/sass_compile_spec.rb | 81 ++++++++++++--------------- spec/sass_function_spec.rb | 28 ++++----- spec/sass_importer_spec.rb | 77 ++++++++++++------------- 10 files changed, 102 insertions(+), 129 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f3937e0f..d6d29e92 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,3 @@ RSpec/MultipleExpectations: RSpec/NestedGroups: Enabled: false - -Style/MultilineBlockChain: - Enabled: false diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 4ca11d4f..e2efd33a 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -371,9 +371,11 @@ module SassConfig uri rescue Gem::RemoteFetcher::FetchError - Gem::SpecFetcher.fetcher.detect do |name_tuple| + tuples = Gem::SpecFetcher.fetcher.detect(:released) do |name_tuple| name_tuple.name == spec.name && name_tuple.platform == 'ruby' - end.reverse_each do |name_tuple, _| + end + + tuples.sort.reverse_each do |name_tuple, _source| uri = "#{repo}/#{name_tuple.version}/protoc-#{name_tuple.version}-#{os}-#{cpu}.exe" Gem::RemoteFetcher.fetcher.fetch_https(URI.parse("#{uri}.sha1")) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index ff008083..672c550e 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -118,7 +118,7 @@ def initialize # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every # deprecation warning it encounters. # @return [CompileResult] - # @raise [CompileError] + # @raise [ArgumentError, CompileError] # @see https://sass-lang.com/documentation/js-api/functions/compile/ def compile(path, load_paths: [], @@ -189,7 +189,7 @@ def compile(path, # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every # deprecation warning it encounters. # @return [CompileResult] - # @raise [CompileError] + # @raise [ArgumentError, CompileError] # @see https://sass-lang.com/documentation/js-api/functions/compilestring/ def compile_string(source, importer: nil, diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index f0efd6cc..3bd17965 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -18,10 +18,11 @@ def initialize loop do receive_proto rescue IOError, Errno::EBADF, Errno::EPROTO => e - @mutex.synchronize do + values = @mutex.synchronize do @id = UINT_MAX @observers.values - end.each do |observer| + end + values.each do |observer| observer.error(e) end break diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index 46f031bc..b50152d3 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -68,11 +68,10 @@ 'foo($arg...)': fn } ).css - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to be_nil - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: nil)) + )) expect(fn).to have_received(:call) end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index cebe907b..b4625fe5 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -297,10 +297,7 @@ expect do Sass.compile_string('a {b: foo()}', functions: { 'foo()': fn }).css - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.full_message).to match(/SassString or CalculationInterpolation/) - end + end.to raise_error(Sass::CompileError, /SassString or CalculationInterpolation/) end it 'an unknown calculation function' do @@ -311,9 +308,7 @@ expect do Sass.compile_string('a {b: foo()}', functions: { 'foo()': fn }).css - end.to raise_error do |error| - expect(error.full_message).to match(/"foo" is not a recognized calculation type/) - end + end.to raise_error(/"foo" is not a recognized calculation type/) end end diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index 50a501d5..b6d29497 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -83,11 +83,10 @@ 'foo()': fn } ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to be_nil - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: nil)) + )) expect(fn).to have_received(:call) end diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 67a06af1..773ca320 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -228,22 +228,20 @@ describe 'error' do it 'requires plain CSS with explicit syntax' do expect { described_class.compile_string('$a: b; c {d: $a}', syntax: 'css') } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to be_nil - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: nil)) + )) end it 'relative loads fail without a URL' do sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) expect { described_class.compile_string("@use \"#{dir.relative_url('other')}\";") } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to be_nil - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: nil)) + )) end end @@ -251,11 +249,10 @@ sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) expect { described_class.compile_string("@use \"#{dir.relative_url('other')}\";", url: 'unknown:style.scss') } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq('unknown:style.scss') - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: 'unknown:style.scss')) + )) end end @@ -264,11 +261,10 @@ sandbox do |dir| url = dir.url('foo.scss') expect { described_class.compile_string('a {b:', url: url) } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(url) - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: url)) + )) end end @@ -276,11 +272,10 @@ sandbox do |dir| url = dir.url('foo.scss') expect { described_class.compile_string('@error "oh no"', url: url) } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(url) - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: url)) + )) end end @@ -288,11 +283,10 @@ sandbox do |dir| url = dir.url('foo.scss') expect { described_class.compile_string('@use "sass:math"; @use "sass:math"', url: url) } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(url) - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: url)) + )) end end end @@ -428,11 +422,10 @@ sandbox do |dir| dir.write({ 'input.css' => '$a: b; c {d: $a}' }) expect { described_class.compile(dir.path('input.css')) } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(dir.url('input.css')) - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: dir.url('input.css'))) + )) end end @@ -441,11 +434,10 @@ sandbox do |dir| dir.write({ 'input.scss' => 'a {b:' }) expect { described_class.compile(dir.path('input.scss')) } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(dir.url('input.scss')) - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: dir.url('input.scss'))) + )) end end @@ -453,11 +445,10 @@ sandbox do |dir| dir.write({ 'input.scss' => '@error "oh no"' }) expect { described_class.compile(dir.path('input.scss')) } - .to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(dir.url('input.scss')) - end + .to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: dir.url('input.scss'))) + )) end end end diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index e2cb3ad0..0e9c56f8 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -93,10 +93,9 @@ 'foo()': ->(_args) { raise 'heck' } } ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end it 'not returning' do @@ -107,10 +106,9 @@ 'foo()': ->(_args) {} } ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end describe 'returning a non-Value' do @@ -122,10 +120,9 @@ 'foo()': ->(_args) { 'wrong' } } ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end it 'in a calculation' do @@ -136,10 +133,9 @@ 'foo()': ->(_args) { Sass::Value::Calculation.calc('wrong') } } ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end end end diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index baa745d4..59a61c46 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -139,10 +139,9 @@ } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end it 'wraps an error in load()' do @@ -158,10 +157,9 @@ } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end it 'avoids importer when canonicalize() returns nil' do @@ -197,10 +195,9 @@ }], load_paths: [dir.path('dir')] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end end @@ -305,10 +302,9 @@ } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end end @@ -650,10 +646,9 @@ def expect_from_import(canonicalize, expected) } ] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end it 'rejects a non-file URL' do @@ -662,10 +657,9 @@ def expect_from_import(canonicalize, expected) '@import "other";', importers: [{ find_file_url: ->(*) { 'u:other.scss' } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0))) + )) end describe 'when the resolved file has extension' do @@ -714,11 +708,10 @@ def expect_from_import(canonicalize, expected) '@import "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.span.url).to eq(dir.url('_other.css')) - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0), + url: dir.url('_other.css'))) + )) end end end @@ -777,9 +770,7 @@ def expect_from_import(canonicalize, expected) } }] ) - end.to raise_error do |error| - expect(error).not_to be_a(Sass::CompileError) - end + end.to raise_error(ArgumentError) end end @@ -798,11 +789,12 @@ def expect_from_import(canonicalize, expected) } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.message).to include("Invalid argument for string field 'contents' (given StringIO)") - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0)), + message: include( + "Invalid argument for string field 'contents' (given StringIO)" + )) + )) end end @@ -821,10 +813,11 @@ def expect_from_import(canonicalize, expected) } }] ) - end.to raise_error do |error| - expect(error).to be_a(Sass::CompileError) - expect(error.span.start.line).to eq(0) - expect(error.message).to include('The importer must return an absolute URL') - end + end.to raise_error(an_instance_of(Sass::CompileError).and( + having_attributes(span: having_attributes(start: having_attributes(line: 0)), + message: include( + 'The importer must return an absolute URL' + )) + )) end end From f99eaa687a58b116d2844bef69aa0b5cc3dd32f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 20 Sep 2023 17:00:24 -0700 Subject: [PATCH 215/700] Use custom rspec matcher --- spec/sass/value/argument_list_spec.rb | 5 +-- spec/sass/value/calculation_spec.rb | 4 +-- spec/sass/value/function_spec.rb | 5 +-- spec/sass_compile_spec.rb | 45 +++++-------------------- spec/sass_function_spec.rb | 34 ++++++++----------- spec/sass_importer_spec.rb | 47 ++++++++------------------- spec/spec_helper.rb | 30 +++++++++++++++++ 7 files changed, 69 insertions(+), 101 deletions(-) diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index b50152d3..39907253 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -68,10 +68,7 @@ 'foo($arg...)': fn } ).css - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: nil)) - )) + end.to raise_sass_compile_error.with_line(0).without_url expect(fn).to have_received(:call) end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index b4625fe5..0769b8fc 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -286,7 +286,7 @@ expect do Sass.compile_string('a {b: foo()}', functions: { 'foo()': fn }).css - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'clamp() with the wrong argument' do @@ -297,7 +297,7 @@ expect do Sass.compile_string('a {b: foo()}', functions: { 'foo()': fn }).css - end.to raise_error(Sass::CompileError, /SassString or CalculationInterpolation/) + end.to raise_sass_compile_error.with_message('SassString or CalculationInterpolation') end it 'an unknown calculation function' do diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index b6d29497..8214e491 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -83,10 +83,7 @@ 'foo()': fn } ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: nil)) - )) + end.to raise_sass_compile_error.with_line(0).without_url expect(fn).to have_received(:call) end diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 773ca320..ff9f2893 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -228,20 +228,14 @@ describe 'error' do it 'requires plain CSS with explicit syntax' do expect { described_class.compile_string('$a: b; c {d: $a}', syntax: 'css') } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: nil)) - )) + .to raise_sass_compile_error.with_line(0).without_url end it 'relative loads fail without a URL' do sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) expect { described_class.compile_string("@use \"#{dir.relative_url('other')}\";") } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: nil)) - )) + .to raise_sass_compile_error.with_line(0).without_url end end @@ -249,10 +243,7 @@ sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) expect { described_class.compile_string("@use \"#{dir.relative_url('other')}\";", url: 'unknown:style.scss') } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: 'unknown:style.scss')) - )) + .to raise_sass_compile_error.with_line(0).with_url('unknown:style.scss') end end @@ -261,10 +252,7 @@ sandbox do |dir| url = dir.url('foo.scss') expect { described_class.compile_string('a {b:', url: url) } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: url)) - )) + .to raise_sass_compile_error.with_line(0).with_url(url) end end @@ -272,10 +260,7 @@ sandbox do |dir| url = dir.url('foo.scss') expect { described_class.compile_string('@error "oh no"', url: url) } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: url)) - )) + .to raise_sass_compile_error.with_line(0).with_url(url) end end @@ -283,10 +268,7 @@ sandbox do |dir| url = dir.url('foo.scss') expect { described_class.compile_string('@use "sass:math"; @use "sass:math"', url: url) } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: url)) - )) + .to raise_sass_compile_error.with_line(0).with_url(url) end end end @@ -422,10 +404,7 @@ sandbox do |dir| dir.write({ 'input.css' => '$a: b; c {d: $a}' }) expect { described_class.compile(dir.path('input.css')) } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: dir.url('input.css'))) - )) + .to raise_sass_compile_error.with_line(0).with_url(dir.url('input.css')) end end @@ -434,10 +413,7 @@ sandbox do |dir| dir.write({ 'input.scss' => 'a {b:' }) expect { described_class.compile(dir.path('input.scss')) } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: dir.url('input.scss'))) - )) + .to raise_sass_compile_error.with_line(0).with_url(dir.url('input.scss')) end end @@ -445,10 +421,7 @@ sandbox do |dir| dir.write({ 'input.scss' => '@error "oh no"' }) expect { described_class.compile(dir.path('input.scss')) } - .to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: dir.url('input.scss'))) - )) + .to raise_sass_compile_error.with_line(0).with_url(dir.url('input.scss')) end end end diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index 0e9c56f8..533df55e 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -93,9 +93,7 @@ 'foo()': ->(_args) { raise 'heck' } } ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end it 'not returning' do @@ -106,9 +104,7 @@ 'foo()': ->(_args) {} } ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end describe 'returning a non-Value' do @@ -120,9 +116,7 @@ 'foo()': ->(_args) { 'wrong' } } ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end it 'in a calculation' do @@ -133,9 +127,7 @@ 'foo()': ->(_args) { Sass::Value::Calculation.calc('wrong') } } ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end end end @@ -178,55 +170,55 @@ it 'is empty' do expect do described_class.compile_string('', functions: { '': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has no name' do expect do described_class.compile_string('', functions: { '()': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has no arguments' do expect do described_class.compile_string('', functions: { foo: ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has invalid arguments' do expect do described_class.compile_string('', functions: { 'foo(arg)': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has no closing parentheses' do expect do described_class.compile_string('', functions: { 'foo(': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has a non-identifier name' do expect do described_class.compile_string('', functions: { '$foo()': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has whitespace before the signature' do expect do described_class.compile_string('', functions: { ' foo()': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has whitespace after the signature' do expect do described_class.compile_string('', functions: { 'foo() ': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end it 'has whitespace between the identifier and the arguments' do expect do described_class.compile_string('', functions: { 'foo ()': ->(_args) { Sass::Value::Null::NULL } }) - end.to raise_error(Sass::CompileError) + end.to raise_sass_compile_error end end end diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 59a61c46..051a6a1f 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -139,9 +139,7 @@ } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end it 'wraps an error in load()' do @@ -157,9 +155,7 @@ } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end it 'avoids importer when canonicalize() returns nil' do @@ -195,9 +191,7 @@ }], load_paths: [dir.path('dir')] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end end @@ -302,9 +296,7 @@ } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end end @@ -646,9 +638,7 @@ def expect_from_import(canonicalize, expected) } ] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end it 'rejects a non-file URL' do @@ -657,9 +647,7 @@ def expect_from_import(canonicalize, expected) '@import "other";', importers: [{ find_file_url: ->(*) { 'u:other.scss' } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0))) - )) + end.to raise_sass_compile_error.with_line(0) end describe 'when the resolved file has extension' do @@ -708,10 +696,7 @@ def expect_from_import(canonicalize, expected) '@import "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0), - url: dir.url('_other.css'))) - )) + end.to raise_sass_compile_error.with_line(0).with_url(dir.url('_other.css')) end end end @@ -789,12 +774,9 @@ def expect_from_import(canonicalize, expected) } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0)), - message: include( - "Invalid argument for string field 'contents' (given StringIO)" - )) - )) + end.to raise_sass_compile_error.with_line(0).with_message( + "Invalid argument for string field 'contents' (given StringIO)" + ) end end @@ -813,11 +795,8 @@ def expect_from_import(canonicalize, expected) } }] ) - end.to raise_error(an_instance_of(Sass::CompileError).and( - having_attributes(span: having_attributes(start: having_attributes(line: 0)), - message: include( - 'The importer must return an absolute URL' - )) - )) + end.to raise_sass_compile_error.with_line(0).with_message( + 'The importer must return an absolute URL' + ) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e3e0877f..078f5f82 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,3 +13,33 @@ config.include Console config.include Sandbox end + +RSpec::Matchers.matcher :raise_sass_compile_error do + match do |actual| + expect { actual.call } + .to raise_error do |error| + expect(error).to be_a(Sass::CompileError) + expect(error.span.start.line).to eq(@line) if defined?(@line) + expect(error.span.url).to eq(@url) if defined?(@url) + expect(error.message).to include(@message) if defined?(@message) + end + end + + chain :with_message do |message| + @message = message + end + + chain :with_line do |line| + @line = line + end + + chain :with_url do |url| + @url = url + end + + chain :without_url do + @url = nil + end + + supports_block_expectations +end From 4744bd167458dead1919f64ff5854883c507ab41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 01:10:04 +0000 Subject: [PATCH 216/700] Bump sass from 1.67.0 to 1.68.0 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.67.0 to 1.68.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.67.0...1.68.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 83cf329f..cacd3716 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.67.0" + "sass": "1.68.0" } } From efbc7a80947a4b4010da7da92f5f16e23a0d9ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 20 Sep 2023 17:07:23 -0700 Subject: [PATCH 217/700] Breaking change on importer function signature --- lib/sass/canonicalize_context.rb | 20 ++ lib/sass/embedded.rb | 1 + lib/sass/embedded/host/importer_registry.rb | 20 +- lib/sass/embedded/protofier.rb | 7 + spec/sass_importer_spec.rb | 354 ++++++++++++++++++-- 5 files changed, 376 insertions(+), 26 deletions(-) create mode 100644 lib/sass/canonicalize_context.rb diff --git a/lib/sass/canonicalize_context.rb b/lib/sass/canonicalize_context.rb new file mode 100644 index 00000000..42ecd4ca --- /dev/null +++ b/lib/sass/canonicalize_context.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Sass + # Contextual information passed to `canonicalize` and `find_file_url`. + # Not all importers will need this information to resolve loads, but some may find it useful. + # + # @see https://sass-lang.com/documentation/js-api/interfaces/canonicalizecontext/ + class CanonicalizeContext + # @return [String, nil] + attr_reader :containing_url + + # @return [Boolean] + attr_reader :from_import + + def initialize(containing_url, from_import) + @containing_url = containing_url + @from_import = from_import + end + end +end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 672c550e..d78043c1 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative '../../ext/sass/cli' +require_relative 'canonicalize_context' require_relative 'compile_error' require_relative 'compile_result' require_relative 'embedded/connection' diff --git a/lib/sass/embedded/host/importer_registry.rb b/lib/sass/embedded/host/importer_registry.rb index 18276f3e..51b39002 100644 --- a/lib/sass/embedded/host/importer_registry.rb +++ b/lib/sass/embedded/host/importer_registry.rb @@ -26,7 +26,7 @@ def initialize(importers, load_paths, alert_color:) end def register(importer) - importer = Structifier.to_struct(importer, :canonicalize, :load, :find_file_url) + importer = Structifier.to_struct(importer, :canonicalize, :load, :non_canonical_scheme, :find_file_url) is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load) is_file_importer = importer.respond_to?(:find_file_url) @@ -39,7 +39,17 @@ def register(importer) @importers_by_id[id] = importer if is_importer EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( - importer_id: id + importer_id: id, + non_canonical_scheme: if importer.respond_to?(:non_canonical_scheme) + non_canonical_scheme = importer.non_canonical_scheme + if non_canonical_scheme.is_a?(String) + [non_canonical_scheme] + else + non_canonical_scheme || [] + end + else + [] + end ) else EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( @@ -50,7 +60,8 @@ def register(importer) def canonicalize(canonicalize_request) importer = @importers_by_id[canonicalize_request.importer_id] - url = importer.canonicalize(canonicalize_request.url, from_import: canonicalize_request.from_import)&.to_s + url = importer.canonicalize(canonicalize_request.url, + Protofier.from_proto_canonicalize_context(canonicalize_request))&.to_s EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( id: canonicalize_request.id, @@ -84,7 +95,8 @@ def import(import_request) def file_import(file_import_request) importer = @importers_by_id[file_import_request.importer_id] - file_url = importer.find_file_url(file_import_request.url, from_import: file_import_request.from_import)&.to_s + file_url = importer.find_file_url(file_import_request.url, + Protofier.from_proto_canonicalize_context(file_import_request))&.to_s EmbeddedProtocol::InboundMessage::FileImportResponse.new( id: file_import_request.id, diff --git a/lib/sass/embedded/protofier.rb b/lib/sass/embedded/protofier.rb index 4e3a4ed6..2b6792ae 100644 --- a/lib/sass/embedded/protofier.rb +++ b/lib/sass/embedded/protofier.rb @@ -8,6 +8,13 @@ class Embedded module Protofier module_function + def from_proto_canonicalize_context(canonicalize_request) + CanonicalizeContext.new( + canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url, + canonicalize_request.from_import + ) + end + def from_proto_compile_response(compile_response) oneof = compile_response.result result = compile_response.public_send(oneof) diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 051a6a1f..1535606e 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -7,7 +7,7 @@ result = described_class.compile_string( '@import "orange";', importers: [{ - canonicalize: ->(url, **) { "u:#{url}" }, + canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |url| color = url.split(':')[1] return { @@ -67,7 +67,7 @@ result = described_class.compile_string( '@import "/orange";', importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| expect(url).to eq('/orange') "u:#{url}" }, @@ -87,7 +87,7 @@ result = described_class.compile_string( '@import "C:/orange";', importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| expect(url).to eq('file:///C:/orange') "u:#{url}" }, @@ -104,11 +104,269 @@ end end + describe 'the containing URL' do + it 'is nil for a potentially canonical scheme' do + result = described_class.compile_string( + '@import "u:orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to be_nil + url + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + } + }] + ) + + expect(result.css).to eq('@a;') + end + + describe 'for a non-canonical scheme' do + describe 'in a list' do + it 'is set to the original URL' do + result = described_class.compile_string( + '@import "u:orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to eq('x:original.scss') + url.gsub(/^u:/, 'x:') + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: ['u'] + }], + url: 'x:original.scss' + ) + + expect(result.css).to eq('@a;') + end + + it 'is nil if the original URL is nil' do + result = described_class.compile_string( + '@import "u:orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to be_nil + url.gsub(/^u:/, 'x:') + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: ['u'] + }] + ) + + expect(result.css).to eq('@a;') + end + end + + describe 'as a string' do + it 'is set to the original URL' do + result = described_class.compile_string( + '@import "u:orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to eq('x:original.scss') + url.gsub(/^u:/, 'x:') + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: 'u' + }], + url: 'x:original.scss' + ) + + expect(result.css).to eq('@a;') + end + + it 'is nil if the original URL is nil' do + result = described_class.compile_string( + '@import "u:orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to be_nil + url.gsub(/^u:/, 'x:') + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: 'u' + }] + ) + + expect(result.css).to eq('@a;') + end + end + end + + describe 'for a schemeless load' do + it 'is set to the original URL' do + result = described_class.compile_string( + '@import "orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to eq('x:original.scss') + "u:#{url}" + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + } + }], + url: 'x:original.scss' + ) + + expect(result.css).to eq('@a;') + end + + it 'is nil if the original URL is nil' do + result = described_class.compile_string( + '@import "orange"', + importers: [{ + canonicalize: lambda { |url, context| + expect(context.containing_url).to be_nil + "u:#{url}" + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + } + }] + ) + + expect(result.css).to eq('@a;') + end + end + end + + describe 'throws an error if the importer returns a canonical URL with a non-canonical scheme' do + it 'set as a list' do + expect do + described_class.compile_string( + '@import "orange"', + importers: [{ + canonicalize: lambda { |url, _context| + "u:#{url}" + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: ['u'] + }] + ) + end.to raise_sass_compile_error.with_line(0) + end + + it 'set as a string' do + expect do + described_class.compile_string( + '@import "orange"', + importers: [{ + canonicalize: lambda { |url, _context| + "u:#{url}" + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: 'u' + }] + ) + end.to raise_sass_compile_error.with_line(0) + end + end + + describe 'throws an error for an invalid scheme:' do + it 'empty' do + expect do + described_class.compile_string( + 'a {b: c}', + importers: [{ + canonicalize: lambda { |*| + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: '' + }] + ) + end.to raise_sass_compile_error + end + + it 'uppercase' do + expect do + described_class.compile_string( + 'a {b: c}', + importers: [{ + canonicalize: lambda { |*| + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: 'U' + }] + ) + end.to raise_sass_compile_error + end + + it 'colon' do + expect do + described_class.compile_string( + 'a {b: c}', + importers: [{ + canonicalize: lambda { |*| + }, + load: lambda { |*| + return { + contents: '@a', + syntax: 'scss' + } + }, + non_canonical_scheme: 'u:' + }] + ) + end.to raise_sass_compile_error + end + end + it "uses an importer's source map URL" do result = described_class.compile_string( '@import "orange";', importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| "u:#{url}" }, load: lambda { |url| @@ -147,7 +405,7 @@ described_class.compile_string( '@import "orange";', importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| "u:#{url}" }, load: lambda { |*| @@ -184,7 +442,7 @@ described_class.compile_string( '@import "other";', importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| "u:#{url}" }, load: ->(*) {} @@ -227,7 +485,7 @@ result = described_class.compile( dir.path('input.scss'), importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| "u:#{url}" }, load: lambda { |*| @@ -305,7 +563,7 @@ result = described_class.compile_string( '@import "orange";', importer: { - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| expect(url).to eq('u:orange') url }, @@ -327,7 +585,7 @@ result = described_class.compile_string( '@import "other";', importer: { - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| url }, load: lambda { |_url| @@ -363,7 +621,7 @@ } }, importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| expect(url).to eq('u:orange') url }, @@ -393,7 +651,7 @@ } }, importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| url }, load: lambda { |url| @@ -426,7 +684,7 @@ result = described_class.compile_string( '@import "second:other";', importers: [{ - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| url if url.start_with?('first:') }, load: lambda { |*| @@ -436,7 +694,7 @@ } } }, { - canonicalize: lambda { |url, **| + canonicalize: lambda { |url, _context| raise 'Second importer should only be called once.' if second_called second_called = true @@ -457,8 +715,8 @@ describe 'from_import is' do def expect_from_import(canonicalize, expected) - allow(canonicalize).to receive(:call) { |url, from_import:| - expect(from_import).to be(expected) + allow(canonicalize).to receive(:call) { |url, context| + expect(context.from_import).to be(expected) "u:#{url}" } { @@ -578,7 +836,7 @@ def expect_from_import(canonicalize, expected) result = described_class.compile_string( '@import "u:other";', importers: [{ - find_file_url: lambda { |url, **| + find_file_url: lambda { |url, _context| expect(url).to eq('u:other') dir.url('dir/other') } @@ -709,8 +967,8 @@ def expect_from_import(canonicalize, expected) described_class.compile_string( '@import "other";', importers: [{ - find_file_url: lambda { |*, from_import:| - expect(from_import).to be(true) + find_file_url: lambda { |_url, context| + expect(context.from_import).to be(true) dir.url('other') } }] @@ -725,8 +983,8 @@ def expect_from_import(canonicalize, expected) described_class.compile_string( '@use "other";', importers: [{ - find_file_url: lambda { |*, from_import:| - expect(from_import).to be(false) + find_file_url: lambda { |_url, context| + expect(context.from_import).to be(false) dir.url('other') } }] @@ -736,6 +994,58 @@ def expect_from_import(canonicalize, expected) end end + describe 'containing_url is' do + it 'set for a relative URL' do + sandbox do |dir| + dir.write({ '_other.scss' => 'a {b: c}' }) + result = described_class.compile_string( + '@import "other";', + importers: [{ + find_file_url: lambda { |_url, context| + expect(context.containing_url).to eq('x:original.scss') + dir.url('other') + } + }], + url: 'x:original.scss' + ) + expect(result.css).to eq("a {\n b: c;\n}") + end + end + + it 'set for an absolute URL' do + sandbox do |dir| + dir.write({ '_other.scss' => 'a {b: c}' }) + result = described_class.compile_string( + '@import "u:other";', + importers: [{ + find_file_url: lambda { |_url, context| + expect(context.containing_url).to eq('x:original.scss') + dir.url('other') + } + }], + url: 'x:original.scss' + ) + expect(result.css).to eq("a {\n b: c;\n}") + end + end + + it 'unset when the URL is unavailable' do + sandbox do |dir| + dir.write({ '_other.scss' => 'a {b: c}' }) + result = described_class.compile_string( + '@import "u:other";', + importers: [{ + find_file_url: lambda { |_url, context| + expect(context.containing_url).to be_nil + dir.url('other') + } + }] + ) + expect(result.css).to eq("a {\n b: c;\n}") + end + end + end + it "throws an error for an importer that's ambiguous between FileImporter and Importer" do sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) @@ -765,7 +1075,7 @@ def expect_from_import(canonicalize, expected) described_class.compile_string( '@import "other";', importers: [{ - canonicalize: ->(url, **) { "u:#{url}" }, + canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| return { contents: StringIO.new('not a string'), @@ -785,7 +1095,7 @@ def expect_from_import(canonicalize, expected) described_class.compile_string( '@import "other";', importers: [{ - canonicalize: ->(url, **) { "u:#{url}" }, + canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| return { contents: '', From df5d07f4cab485ea31bdb4c20109f4f70349ed50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 20 Sep 2023 19:37:25 -0700 Subject: [PATCH 218/700] v1.68.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 1416d6f6..cecd4601 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.67.0' + VERSION = '1.68.0' end end From 08262953a69ab57e87a79c1ea25e83bf6237c66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 21 Sep 2023 14:20:22 -0700 Subject: [PATCH 219/700] Deprecate Sass::CalculationValue::CalculationInterpolation --- lib/sass/calculation_value/calculation_interpolation.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sass/calculation_value/calculation_interpolation.rb b/lib/sass/calculation_value/calculation_interpolation.rb index a43b72c0..c104057e 100644 --- a/lib/sass/calculation_value/calculation_interpolation.rb +++ b/lib/sass/calculation_value/calculation_interpolation.rb @@ -4,6 +4,7 @@ module Sass module CalculationValue # A string injected into a SassCalculation using interpolation. # + # @deprecated Use unquoted {Sass::Value::String} instead. # @see https://sass-lang.com/documentation/js-api/classes/calculationinterpolation/ class CalculationInterpolation include CalculationValue From f0736522d281b7505ac56ec77a1ea0cc4c965d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 21 Sep 2023 14:30:07 -0700 Subject: [PATCH 220/700] Hide constructors from API docs --- lib/sass/canonicalize_context.rb | 1 + lib/sass/compile_error.rb | 1 + lib/sass/compile_result.rb | 1 + lib/sass/logger/source_location.rb | 1 + lib/sass/logger/source_span.rb | 1 + 5 files changed, 5 insertions(+) diff --git a/lib/sass/canonicalize_context.rb b/lib/sass/canonicalize_context.rb index 42ecd4ca..56bcc2b2 100644 --- a/lib/sass/canonicalize_context.rb +++ b/lib/sass/canonicalize_context.rb @@ -12,6 +12,7 @@ class CanonicalizeContext # @return [Boolean] attr_reader :from_import + # @!visibility private def initialize(containing_url, from_import) @containing_url = containing_url @from_import = from_import diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index c3537cc5..21ae1c96 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -12,6 +12,7 @@ class CompileError < StandardError # @return [Array] attr_reader :loaded_urls + # @!visibility private def initialize(message, full_message, sass_stack, span, loaded_urls) super(message) @full_message = full_message diff --git a/lib/sass/compile_result.rb b/lib/sass/compile_result.rb index af48d9b7..9ed7a929 100644 --- a/lib/sass/compile_result.rb +++ b/lib/sass/compile_result.rb @@ -14,6 +14,7 @@ class CompileResult # @return [Array] attr_reader :loaded_urls + # @!visibility private def initialize(css, source_map, loaded_urls) @css = css @source_map = source_map diff --git a/lib/sass/logger/source_location.rb b/lib/sass/logger/source_location.rb index 7181461f..59f872e5 100644 --- a/lib/sass/logger/source_location.rb +++ b/lib/sass/logger/source_location.rb @@ -11,6 +11,7 @@ class SourceLocation # @return [Integer] attr_reader :offset, :line, :column + # @!visibility private def initialize(offset, line, column) @offset = offset @line = line diff --git a/lib/sass/logger/source_span.rb b/lib/sass/logger/source_span.rb index 6e8ee08c..cdc31af2 100644 --- a/lib/sass/logger/source_span.rb +++ b/lib/sass/logger/source_span.rb @@ -15,6 +15,7 @@ class SourceSpan # @return [String, nil] attr_reader :url, :context + # @!visibility private def initialize(start, end_, text, url, context) @start = start @end = end_ From b6dd4dc922c9d921333bb4af5ff94bca47c558f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Sep 2023 10:02:17 -0700 Subject: [PATCH 221/700] Fix hash --- lib/sass/value/function.rb | 4 +--- lib/sass/value/fuzzy_math.rb | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 3d412c92..cad01b35 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -8,8 +8,6 @@ module Value class Function include Value - # @overload initialize(id) - # @param id [Numeric] # @overload initialize(signature, callback) # @param signature [::String] # @param callback [Proc] @@ -42,7 +40,7 @@ def ==(other) # @return [Integer] def hash - id.nil? ? signature.hash : id.hash + @hash ||= id.nil? ? signature.hash : id.hash end # @return [Function] diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index c3aa6e2a..5fc6bc63 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -67,11 +67,11 @@ def assert_between(number, min, max, name) end def hash(number) - @hash ||= if number.finite? - (number * INVERSE_EPSILON).round.hash - else - number.hash - end + if number.finite? + (number * INVERSE_EPSILON).round.hash + else + number.hash + end end end From 6478471007faa331f409adbd1464d516aed90599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Sep 2023 13:05:39 -0700 Subject: [PATCH 222/700] Fix a race condition on crashed compiler restart --- lib/sass/embedded/host.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 1cf35a2b..1d769625 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -121,8 +121,8 @@ def receive_proto(proto) private def await0 - @channel = @dispatcher.connect(self) @queue = Queue.new + @channel = @dispatcher.connect(self) yield @@ -136,8 +136,8 @@ def await0 end def await - @channel = @dispatcher.connect(self) @queue = Queue.new + @channel = @dispatcher.connect(self) yield From 035cc4b94a4822ef8d150c89bdc07dfc7d528bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Sep 2023 13:56:30 -0700 Subject: [PATCH 223/700] Ensure queue is closed if connection fails --- lib/sass/embedded/host.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 1d769625..b33bbbb9 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -133,6 +133,7 @@ def await0 @result ensure @channel&.disconnect + @queue&.close end def await @@ -153,6 +154,7 @@ def await @result ensure @channel&.disconnect + @queue&.close end def id From 0f1c714f443c577106da08dd9070c2d9f9427795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Sep 2023 14:21:38 -0700 Subject: [PATCH 224/700] Support first class mixins (#157) --- lib/sass/embedded/host/value_protofier.rb | 8 +++++ lib/sass/value.rb | 7 +++++ lib/sass/value/mixin.rb | 35 +++++++++++++++++++++ spec/sass/value/argument_list_spec.rb | 1 + spec/sass/value/boolean_spec.rb | 2 ++ spec/sass/value/calculation_spec.rb | 1 + spec/sass/value/color_spec.rb | 1 + spec/sass/value/list_spec.rb | 1 + spec/sass/value/map_spec.rb | 1 + spec/sass/value/mixin_spec.rb | 37 +++++++++++++++++++++++ spec/sass/value/null_spec.rb | 1 + spec/sass/value/number_spec.rb | 1 + spec/sass/value/string_spec.rb | 1 + 13 files changed, 97 insertions(+) create mode 100644 lib/sass/value/mixin.rb create mode 100644 spec/sass/value/mixin_spec.rb diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index 2efdc0b1..7e454df4 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -96,6 +96,12 @@ def to_proto(obj) ) ) end + when Sass::Value::Mixin + EmbeddedProtocol::Value.new( + compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new( + id: obj.id + ) + ) when Sass::Value::Calculation EmbeddedProtocol::Value.new( calculation: Calculation.to_proto(obj) @@ -176,6 +182,8 @@ def from_proto(proto) Sass::Value::Function.new(obj.id) when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' + when :compiler_mixin + Sass::Value::Mixin.new(obj.id) when :calculation Calculation.from_proto(obj) when :singleton diff --git a/lib/sass/value.rb b/lib/sass/value.rb index 24909366..3b686298 100644 --- a/lib/sass/value.rb +++ b/lib/sass/value.rb @@ -91,6 +91,12 @@ def assert_map(name = nil) raise Sass::ScriptError.new("#{self} is not a map", name) end + # @return [Mixin] + # @raise [ScriptError] + def assert_mixin(name = nil) + raise Sass::ScriptError.new("#{self} is not a mixin", name) + end + # @return [Number] # @raise [ScriptError] def assert_number(name = nil) @@ -132,6 +138,7 @@ def to_a_length require_relative 'value/function' require_relative 'value/fuzzy_math' require_relative 'value/map' +require_relative 'value/mixin' require_relative 'value/null' require_relative 'value/number' require_relative 'value/string' diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb new file mode 100644 index 00000000..1175b58a --- /dev/null +++ b/lib/sass/value/mixin.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Sass + module Value + # Sass's mixin type. + # + # @see https://sass-lang.com/documentation/js-api/classes/sassmixin/ + class Mixin + include Value + + # @!visibility private + def initialize(id) + @id = id + end + + # @return [Integer] + attr_reader :id + + # @return [::Boolean] + def ==(other) + other.is_a?(Sass::Value::Mixin) && other.id == id + end + + # @return [Integer] + def hash + @hash ||= id.hash + end + + # @return [Mixin] + def assert_mixin(_name = nil) + self + end + end + end +end diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index 39907253..5d1f7d0f 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -97,6 +97,7 @@ expect { list.assert_function }.to raise_error(Sass::ScriptError) expect { list.assert_map }.to raise_error(Sass::ScriptError) expect(list.to_map).to be_nil + expect { list.assert_mixin }.to raise_error(Sass::ScriptError) expect { list.assert_number }.to raise_error(Sass::ScriptError) expect { list.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/boolean_spec.rb b/spec/sass/value/boolean_spec.rb index ce1a7ca5..4979b5bf 100644 --- a/spec/sass/value/boolean_spec.rb +++ b/spec/sass/value/boolean_spec.rb @@ -28,6 +28,7 @@ expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) expect(value.to_map).to be_nil + expect { value.assert_mixin }.to raise_error(Sass::ScriptError) expect { value.assert_number }.to raise_error(Sass::ScriptError) expect { value.assert_string }.to raise_error(Sass::ScriptError) end @@ -58,6 +59,7 @@ expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) expect(value.to_map).to be_nil + expect { value.assert_mixin }.to raise_error(Sass::ScriptError) expect { value.assert_number }.to raise_error(Sass::ScriptError) expect { value.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 0769b8fc..629dd976 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -33,6 +33,7 @@ expect { calculation.assert_function }.to raise_error(Sass::ScriptError) expect { calculation.assert_map }.to raise_error(Sass::ScriptError) expect(calculation.to_map).to be_nil + expect { calculation.assert_mixin }.to raise_error(Sass::ScriptError) expect { calculation.assert_number }.to raise_error(Sass::ScriptError) expect { calculation.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb index 652503fd..779b21d4 100644 --- a/spec/sass/value/color_spec.rb +++ b/spec/sass/value/color_spec.rb @@ -37,6 +37,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) expect { color.assert_function }.to raise_error(Sass::ScriptError) expect { color.assert_map }.to raise_error(Sass::ScriptError) expect(color.to_map).to be_nil + expect { color.assert_mixin }.to raise_error(Sass::ScriptError) expect { color.assert_number }.to raise_error(Sass::ScriptError) expect { color.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/list_spec.rb b/spec/sass/value/list_spec.rb index 485f3754..c98d199e 100644 --- a/spec/sass/value/list_spec.rb +++ b/spec/sass/value/list_spec.rb @@ -23,6 +23,7 @@ expect { list.assert_function }.to raise_error(Sass::ScriptError) expect { list.assert_map }.to raise_error(Sass::ScriptError) expect(list.to_map).to be_nil + expect { list.assert_mixin }.to raise_error(Sass::ScriptError) expect { list.assert_number }.to raise_error(Sass::ScriptError) expect { list.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/map_spec.rb b/spec/sass/value/map_spec.rb index 3c30ecff..282928f1 100644 --- a/spec/sass/value/map_spec.rb +++ b/spec/sass/value/map_spec.rb @@ -27,6 +27,7 @@ expect { map.assert_calculation }.to raise_error(Sass::ScriptError) expect { map.assert_color }.to raise_error(Sass::ScriptError) expect { map.assert_function }.to raise_error(Sass::ScriptError) + expect { map.assert_mixin }.to raise_error(Sass::ScriptError) expect { map.assert_number }.to raise_error(Sass::ScriptError) expect { map.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/mixin_spec.rb b/spec/sass/value/mixin_spec.rb new file mode 100644 index 00000000..baf39bb8 --- /dev/null +++ b/spec/sass/value/mixin_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Sass::Value::Mixin do + it 'can round-trip a mixin reference from Sass' do + skip 'TODO: enable after dart-sass release' + + fn = double + allow(fn).to receive(:call) { |args| + expect(args.length).to eq(1) + expect(args[0]).to be_a(described_class) + args[0] + } + + expect( + Sass.compile_string( + " + @use 'sass:meta'; + + @mixin a() { + a { + b: c; + } + } + + @include meta.apply(foo(meta.get-mixin('a'))); + ", + functions: { + 'foo($arg)': fn + } + ).css + ).to eq("a {\n b: c;\n}") + + expect(fn).to have_received(:call) + end +end diff --git a/spec/sass/value/null_spec.rb b/spec/sass/value/null_spec.rb index 12fd7643..42d2b2ab 100644 --- a/spec/sass/value/null_spec.rb +++ b/spec/sass/value/null_spec.rb @@ -28,6 +28,7 @@ expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) expect(value.to_map).to be_nil + expect { value.assert_mixin }.to raise_error(Sass::ScriptError) expect { value.assert_number }.to raise_error(Sass::ScriptError) expect { value.assert_string }.to raise_error(Sass::ScriptError) end diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 5c606f16..6993c618 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -38,6 +38,7 @@ expect { number.assert_function }.to raise_error(Sass::ScriptError) expect { number.assert_map }.to raise_error(Sass::ScriptError) expect(number.to_map).to be_nil + expect { number.assert_mixin }.to raise_error(Sass::ScriptError) expect { number.assert_string }.to raise_error(Sass::ScriptError) end end diff --git a/spec/sass/value/string_spec.rb b/spec/sass/value/string_spec.rb index 71259386..a7e3b7db 100644 --- a/spec/sass/value/string_spec.rb +++ b/spec/sass/value/string_spec.rb @@ -57,6 +57,7 @@ expect { value.assert_function }.to raise_error(Sass::ScriptError) expect { value.assert_map }.to raise_error(Sass::ScriptError) expect(value.to_map).to be_nil + expect { value.assert_mixin }.to raise_error(Sass::ScriptError) expect { value.assert_number }.to raise_error(Sass::ScriptError) end end From 395d851962f4cf2a624ecd3c558a25187cab69b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 3 Oct 2023 11:48:02 -0700 Subject: [PATCH 225/700] Remove id from compiler function and mixin constructor --- lib/sass/embedded/host/value_protofier.rb | 16 +++++++++++----- lib/sass/value/function.rb | 17 ++++++----------- lib/sass/value/mixin.rb | 7 +------ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index 7e454df4..6c229a1f 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -82,10 +82,10 @@ def to_proto(obj) ) ) when Sass::Value::Function - if obj.id + if obj.instance_eval { @id } EmbeddedProtocol::Value.new( compiler_function: EmbeddedProtocol::Value::CompilerFunction.new( - id: obj.id + id: obj.instance_eval { @id } ) ) else @@ -99,7 +99,7 @@ def to_proto(obj) when Sass::Value::Mixin EmbeddedProtocol::Value.new( compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new( - id: obj.id + id: obj.instance_eval { @id } ) ) when Sass::Value::Calculation @@ -179,11 +179,17 @@ def from_proto(proto) end ) when :compiler_function - Sass::Value::Function.new(obj.id) + Sass::Value::Function.new(nil, nil).instance_eval do + @id = obj.id + self + end when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :compiler_mixin - Sass::Value::Mixin.new(obj.id) + Sass::Value::Mixin.new.instance_eval do + @id = obj.id + self + end when :calculation Calculation.from_proto(obj) when :singleton diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index cad01b35..9aff006e 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -8,20 +8,15 @@ module Value class Function include Value - # @overload initialize(signature, callback) - # @param signature [::String] - # @param callback [Proc] - def initialize(id_or_signature, callback = nil) - if id_or_signature.is_a? Numeric - @id = id_or_signature - else - @signature = id_or_signature - @callback = callback - end + # @param signature [::String] + # @param callback [Proc] + def initialize(signature, callback) + @signature = signature + @callback = callback end # @return [Integer, nil] - attr_reader :id + protected attr_reader :id # rubocop:disable Style/AccessModifierDeclarations # @return [::String, nil] attr_reader :signature diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index 1175b58a..338b1407 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -8,13 +8,8 @@ module Value class Mixin include Value - # @!visibility private - def initialize(id) - @id = id - end - # @return [Integer] - attr_reader :id + protected attr_reader :id # rubocop:disable Style/AccessModifierDeclarations # @return [::Boolean] def ==(other) From 21818b90f1580395054d6bd23833c44aba288b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 3 Oct 2023 23:22:20 -0700 Subject: [PATCH 226/700] Improve handling of compiler crash on protocol error --- lib/sass/embedded/connection.rb | 6 +++--- lib/sass/embedded/dispatcher.rb | 10 +++++++++- lib/sass/embedded/host.rb | 12 +++++++----- lib/sass/embedded/resilient_dispatcher.rb | 20 ++++++++++++-------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 509a1c90..e2869709 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -35,9 +35,9 @@ def initialize def close @stdin_mutex.synchronize do - @stdin.close unless @stdin.closed? - @stdout.close unless @stdout.closed? - @stderr.close unless @stderr.closed? + @stdin.close + @stdout.close + @stderr.close end @wait_thread.value diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 3bd17965..471fe9ce 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -48,7 +48,9 @@ def unsubscribe(id) return unless @observers.empty? if @id == UINT_MAX - close + Thread.new do + close + end else @id = 1 end @@ -67,6 +69,12 @@ def closed? @connection.closed? end + def error + @mutex.synchronize do + @id = UINT_MAX + end + end + def send_proto(...) @connection.write(...) end diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index b33bbbb9..2cd0a9e5 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -86,11 +86,13 @@ def version_response(message) end def error(message) - @error = if message.is_a?(EmbeddedProtocol::ProtocolError) - Errno::EPROTO.new(message.message) - else - message - end + case message + when EmbeddedProtocol::ProtocolError + @dispatcher.error + @error = Errno::EPROTO.new(message.message) + else + @error ||= message + end @queue.close end diff --git a/lib/sass/embedded/resilient_dispatcher.rb b/lib/sass/embedded/resilient_dispatcher.rb index c264b20e..ccea6478 100644 --- a/lib/sass/embedded/resilient_dispatcher.rb +++ b/lib/sass/embedded/resilient_dispatcher.rb @@ -11,28 +11,32 @@ def initialize @mutex = Mutex.new end - def close + def close(...) @mutex.synchronize do - @dispatcher.close + @dispatcher.close(...) end end - def closed? + def closed?(...) @mutex.synchronize do - @dispatcher.closed? + @dispatcher.closed?(...) end end - def connect(host) - @dispatcher.connect(host) + def connect(...) + @dispatcher.connect(...) rescue Errno::EBUSY @mutex.synchronize do - @dispatcher.connect(host) + @dispatcher.connect(...) rescue Errno::EBUSY @dispatcher = Dispatcher.new - @dispatcher.connect(host) + @dispatcher.connect(...) end end + + def error(...) + @dispatcher.error(...) + end end private_constant :ResilientDispatcher From f425c83d0024a159c7a323ab5a280e86f50f1c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 4 Oct 2023 10:01:03 -0700 Subject: [PATCH 227/700] Remove duplicate code --- lib/sass/embedded/host.rb | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 2cd0a9e5..4e8670e7 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -123,34 +123,32 @@ def receive_proto(proto) private def await0 - @queue = Queue.new - @channel = @dispatcher.connect(self) - - yield - - @queue.pop + listen do + yield - raise @error if @error - - @result - ensure - @channel&.disconnect - @queue&.close + @queue.pop + end end def await + listen do + yield + + while (proto = @queue.pop) + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + public_send(oneof, message) + end + end + end + + def listen @queue = Queue.new @channel = @dispatcher.connect(self) yield - while (proto = @queue.pop) - outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) - oneof = outbound_message.message - message = outbound_message.public_send(oneof) - public_send(oneof, message) - end - raise @error if @error @result From 064c17c9f6fa041d7f42869402a357e43453f6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 4 Oct 2023 15:17:38 -0700 Subject: [PATCH 228/700] Workaround rubocop Style/AccessModifierDeclarations --- lib/sass/value/function.rb | 4 +++- lib/sass/value/mixin.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 9aff006e..886887f0 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -16,7 +16,9 @@ def initialize(signature, callback) end # @return [Integer, nil] - protected attr_reader :id # rubocop:disable Style/AccessModifierDeclarations + attr_reader :id + + protected :id # @return [::String, nil] attr_reader :signature diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index 338b1407..cab8b6da 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -9,7 +9,9 @@ class Mixin include Value # @return [Integer] - protected attr_reader :id # rubocop:disable Style/AccessModifierDeclarations + attr_reader :id + + protected :id # @return [::Boolean] def ==(other) From 6280ecd23703571b7d249daad11e46c8adcde5ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 4 Oct 2023 16:43:02 -0700 Subject: [PATCH 229/700] Close compiler stdout and stderr pipe after shutdown --- lib/sass/embedded/connection.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index e2869709..6090369a 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -36,11 +36,10 @@ def initialize def close @stdin_mutex.synchronize do @stdin.close + @wait_thread.join @stdout.close @stderr.close end - - @wait_thread.value end def closed? From 8217c650390f032bb8faeb61a19e0403cf0a74ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 4 Oct 2023 19:31:19 -0700 Subject: [PATCH 230/700] Mark Mixin constructor as private --- lib/sass/embedded/host/value_protofier.rb | 2 +- lib/sass/value/mixin.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index 6c229a1f..f54e31ab 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -186,7 +186,7 @@ def from_proto(proto) when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :compiler_mixin - Sass::Value::Mixin.new.instance_eval do + Sass::Value::Mixin.send(:new).instance_eval do @id = obj.id self end diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index cab8b6da..6593f625 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -8,6 +8,10 @@ module Value class Mixin include Value + class << self + private :new + end + # @return [Integer] attr_reader :id From 952f10c599f40df18889fc3e0d1c04979a2d4b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 5 Oct 2023 09:39:25 -0700 Subject: [PATCH 231/700] Redirect CalculationInterpolation to String --- .../calculation_interpolation.rb | 21 ++++--------------- lib/sass/embedded/host/value_protofier.rb | 6 ------ spec/sass/value/calculation_spec.rb | 6 ------ spec/sass_proto_spec.rb | 1 + 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/lib/sass/calculation_value/calculation_interpolation.rb b/lib/sass/calculation_value/calculation_interpolation.rb index c104057e..7127d875 100644 --- a/lib/sass/calculation_value/calculation_interpolation.rb +++ b/lib/sass/calculation_value/calculation_interpolation.rb @@ -9,23 +9,10 @@ module CalculationValue class CalculationInterpolation include CalculationValue - # @param value [::String] - def initialize(value) - @value = value - end - - # @return [::String] - attr_reader :value - - # @return [::Boolean] - def ==(other) - other.is_a?(Sass::CalculationValue::CalculationInterpolation) && - other.value == value - end - - # @return [Integer] - def hash - @hash ||= value.hash + class << self + def new(value) + Sass::Value::String.new("(#{value})", quoted: false) + end end end end diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/embedded/host/value_protofier.rb index f54e31ab..be3be955 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/embedded/host/value_protofier.rb @@ -280,10 +280,6 @@ def to_proto(value) right: to_proto(value.right) ) ) - when Sass::CalculationValue::CalculationInterpolation - EmbeddedProtocol::Value::Calculation::CalculationValue.new( - interpolation: value.value - ) else raise Sass::ScriptError, "Unknown CalculationValue #{value}" end @@ -305,8 +301,6 @@ def from_proto(value) from_proto(obj.left), from_proto(obj.right) ) - when :interpolation - Sass::CalculationValue::CalculationInterpolation.new(obj) else raise Sass::ScriptError, "Unknown CalculationValue #{value}" end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 629dd976..b24dbfae 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -388,10 +388,4 @@ end end end - - describe 'CalculationInterpolation' do - it 'stores value' do - expect(Sass::CalculationValue::CalculationInterpolation.new('1').value).to eq('1') - end - end end diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 089c0a14..255d343d 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -63,6 +63,7 @@ def remote_eq(lhs, rhs) ]) ]), __LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)), + __LINE__ => Sass::Value::Calculation.clamp(Sass::CalculationValue::CalculationInterpolation.new('var(--clamp)')), __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, whiteness: 0, blackness: 0, alpha: 1), From 692f5b7d6624d7969edf0e6d37604eb04022d06a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:13:38 -0700 Subject: [PATCH 232/700] Bump sass from 1.68.0 to 1.69.1 in /ext/sass (#162) Bumps [sass](https://github.com/sass/dart-sass) from 1.68.0 to 1.69.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.68.0...1.69.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index cacd3716..4b3476cf 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.68.0" + "sass": "1.69.1" } } From aca2ae460569d235f6959a3947f2520942c79376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 9 Oct 2023 17:14:11 -0700 Subject: [PATCH 233/700] Enable mixin test --- spec/sass/value/mixin_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/sass/value/mixin_spec.rb b/spec/sass/value/mixin_spec.rb index baf39bb8..478c53d3 100644 --- a/spec/sass/value/mixin_spec.rb +++ b/spec/sass/value/mixin_spec.rb @@ -4,8 +4,6 @@ describe Sass::Value::Mixin do it 'can round-trip a mixin reference from Sass' do - skip 'TODO: enable after dart-sass release' - fn = double allow(fn).to receive(:call) { |args| expect(args.length).to eq(1) From 412d2a1d47c54372c74eff5b6c882ec82a4228d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 9 Oct 2023 17:28:22 -0700 Subject: [PATCH 234/700] Remove CalculationInterpolation (#161) --- lib/sass/calculation_value.rb | 1 - .../calculation_interpolation.rb | 19 ------------------- lib/sass/value/calculation.rb | 5 ++--- spec/sass/value/calculation_spec.rb | 8 +++----- spec/sass_proto_spec.rb | 1 - 5 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 lib/sass/calculation_value/calculation_interpolation.rb diff --git a/lib/sass/calculation_value.rb b/lib/sass/calculation_value.rb index 3541d14f..df589fe8 100644 --- a/lib/sass/calculation_value.rb +++ b/lib/sass/calculation_value.rb @@ -13,5 +13,4 @@ def assert_calculation_value(_name = nil) end end -require_relative 'calculation_value/calculation_interpolation' require_relative 'calculation_value/calculation_operation' diff --git a/lib/sass/calculation_value/calculation_interpolation.rb b/lib/sass/calculation_value/calculation_interpolation.rb deleted file mode 100644 index 7127d875..00000000 --- a/lib/sass/calculation_value/calculation_interpolation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -module Sass - module CalculationValue - # A string injected into a SassCalculation using interpolation. - # - # @deprecated Use unquoted {Sass::Value::String} instead. - # @see https://sass-lang.com/documentation/js-api/classes/calculationinterpolation/ - class CalculationInterpolation - include CalculationValue - - class << self - def new(value) - Sass::Value::String.new("(#{value})", quoted: false) - end - end - end - end -end diff --git a/lib/sass/value/calculation.rb b/lib/sass/value/calculation.rb index 034b2aff..efdf20f8 100644 --- a/lib/sass/value/calculation.rb +++ b/lib/sass/value/calculation.rb @@ -37,7 +37,7 @@ def max(arguments) def clamp(min, value = nil, max = nil) if (value.nil? && !valid_clamp_arg?(min)) || (max.nil? && [min, value].none? { |x| x && valid_clamp_arg?(x) }) - raise Sass::ScriptError, 'Argument must be an unquoted SassString or CalculationInterpolation.' + raise Sass::ScriptError, 'Argument must be an unquoted SassString.' end new('clamp', [min, value, max].compact) @@ -46,8 +46,7 @@ def clamp(min, value = nil, max = nil) private def valid_clamp_arg?(value) - value.is_a?(Sass::CalculationValue::CalculationInterpolation) || - (value.is_a?(Sass::Value::String) && !value.quoted?) + value.is_a?(Sass::Value::String) && !value.quoted? end end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index b24dbfae..77a9f3af 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -7,8 +7,7 @@ Sass::Value::Number.new(1), Sass::Value::String.new('1', quoted: false), described_class.calc(Sass::Value::Number.new(1)), - Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), Sass::Value::Number.new(1)), - Sass::CalculationValue::CalculationInterpolation.new('') + Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), Sass::Value::Number.new(1)) ] invalid_calculation_values = [Sass::Value::String.new('1', quoted: true)] @@ -164,8 +163,7 @@ # When `clamp()` is called with less than three arguments, the list of # accepted values is much narrower valid_clamp_values = [ - Sass::Value::String.new('1', quoted: false), - Sass::CalculationValue::CalculationInterpolation.new('1') + Sass::Value::String.new('1', quoted: false) ] invalid_clamp_values = [ Sass::Value::Number.new(1), @@ -298,7 +296,7 @@ expect do Sass.compile_string('a {b: foo()}', functions: { 'foo()': fn }).css - end.to raise_sass_compile_error.with_message('SassString or CalculationInterpolation') + end.to raise_sass_compile_error.with_message('SassString') end it 'an unknown calculation function' do diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 255d343d..089c0a14 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -63,7 +63,6 @@ def remote_eq(lhs, rhs) ]) ]), __LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)), - __LINE__ => Sass::Value::Calculation.clamp(Sass::CalculationValue::CalculationInterpolation.new('var(--clamp)')), __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), __LINE__ => Sass::Value::Color.new(hue: 0, whiteness: 0, blackness: 0, alpha: 1), From c21cbf66a6ce06f91741932a2d727986d954cb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 9 Oct 2023 17:27:53 -0700 Subject: [PATCH 235/700] v1.69.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index cecd4601..4aaf5798 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.68.0' + VERSION = '1.69.1' end end From 97b8cee3a130cda8abb58103e2886cf63095500d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 13:20:40 -0700 Subject: [PATCH 236/700] Bump sass from 1.69.1 to 1.69.2 in /ext/sass (#163) Bumps [sass](https://github.com/sass/dart-sass) from 1.69.1 to 1.69.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.1...1.69.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 4b3476cf..bb031388 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.1" + "sass": "1.69.2" } } From d5fe6dd660f2b91380ae910c4e4ac3fd9c852f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 10 Oct 2023 13:25:16 -0700 Subject: [PATCH 237/700] v1.69.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 4aaf5798..ff3343ef 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.69.1' + VERSION = '1.69.2' end end From d6daaaeae7010a9950b855eeb6cb69aa94debf20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 08:53:28 -0700 Subject: [PATCH 238/700] Update rubocop requirement from ~> 1.56.0 to ~> 1.57.0 (#164) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.56.0...v1.57.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6fd0bcf7..3aeca10f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.56.0' + gem 'rubocop', '~> 1.57.0' gem 'rubocop-performance', '~> 1.19.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.24.0' From b7528752e04102134ec52b5dc781ac67e58b0a45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 17:22:50 -0700 Subject: [PATCH 239/700] Bump sass from 1.69.2 to 1.69.3 in /ext/sass (#165) Bumps [sass](https://github.com/sass/dart-sass) from 1.69.2 to 1.69.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.2...1.69.3) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index bb031388..e729eb4b 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.2" + "sass": "1.69.3" } } From 2d45793e6a8434271613024221e25a581df3b418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 11 Oct 2023 17:37:57 -0700 Subject: [PATCH 240/700] v1.69.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index ff3343ef..20d01586 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.69.2' + VERSION = '1.69.3' end end From d494d848e28bc433de85c1701e97127ed3bc2ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 12 Oct 2023 14:40:24 -0700 Subject: [PATCH 241/700] Refactor dispatcher (#166) --- lib/sass/embedded/connection.rb | 35 +++++++++------- lib/sass/embedded/dispatcher.rb | 73 +++++++++++++-------------------- lib/sass/embedded/host.rb | 1 - 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 6090369a..72dda0b1 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -9,6 +9,7 @@ class Embedded # It runs the `sass --embedded` command. class Connection def initialize + @mutex = Mutex.new @stdin, @stdout, @stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) rescue Errno::ENOENT @@ -21,8 +22,6 @@ def initialize @stdin.binmode @stdout.binmode - @stdin_mutex = Mutex.new - @stdout_mutex = Mutex.new Thread.new do loop do @@ -31,10 +30,27 @@ def initialize break end end + + Thread.new do + loop do + length = Varint.read(@stdout) + id = Varint.read(@stdout) + proto = @stdout.read(length - Varint.length(id)) + yield id, proto + rescue IOError, Errno::EBADF => e + yield 0xffffffff, EmbeddedProtocol::OutboundMessage.new( + error: EmbeddedProtocol::ProtocolError.new( + type: :PARSE, + message: e.message + ) + ).to_proto + break + end + end end def close - @stdin_mutex.synchronize do + @mutex.synchronize do @stdin.close @wait_thread.join @stdout.close @@ -43,27 +59,18 @@ def close end def closed? - @stdin_mutex.synchronize do + @mutex.synchronize do @stdin.closed? end end def write(id, proto) - @stdin_mutex.synchronize do + @mutex.synchronize do Varint.write(@stdin, Varint.length(id) + proto.length) Varint.write(@stdin, id) @stdin.write(proto) end end - - def read - @stdout_mutex.synchronize do - length = Varint.read(@stdout) - id = Varint.read(@stdout) - proto = @stdout.read(length - Varint.length(id)) - return id, proto - end - end end private_constant :Connection diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 471fe9ce..8ed34ed4 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -6,33 +6,46 @@ class Embedded # # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler. class Dispatcher - UINT_MAX = 0xffffffff - def initialize - @connection = Connection.new - @observers = {} @id = 1 + @observers = {} @mutex = Mutex.new + @connection = Connection.new do |id, proto| + case id + when 1...0xffffffff + @mutex.synchronize { @observers[id] }.receive_proto(proto) + when 0 + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) + when 0xffffffff + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + raise Errno::EPROTO, message.message + else + raise Errno::EPROTO + end + rescue Errno::EPROTO => e + observers = @mutex.synchronize do + @id = 0xffffffff + @observers.values + end - Thread.new do - loop do - receive_proto - rescue IOError, Errno::EBADF, Errno::EPROTO => e - values = @mutex.synchronize do - @id = UINT_MAX - @observers.values - end - values.each do |observer| + if observers.empty? + close + else + observers.each do |observer| observer.error(e) end - break end end end def subscribe(observer) @mutex.synchronize do - raise Errno::EBUSY if @id == UINT_MAX + raise Errno::EBUSY if @id == 0xffffffff id = @id @id = id.next @@ -47,7 +60,7 @@ def unsubscribe(id) return unless @observers.empty? - if @id == UINT_MAX + if @id == 0xffffffff Thread.new do close end @@ -69,38 +82,10 @@ def closed? @connection.closed? end - def error - @mutex.synchronize do - @id = UINT_MAX - end - end - def send_proto(...) @connection.write(...) end - private - - def receive_proto - id, proto = @connection.read - case id - when 1...UINT_MAX - @mutex.synchronize { @observers[id] }.receive_proto(proto) - when 0 - outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) - oneof = outbound_message.message - message = outbound_message.public_send(oneof) - @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) - when UINT_MAX - outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) - oneof = outbound_message.message - message = outbound_message.public_send(oneof) - raise Errno::EPROTO, message.message - else - raise Errno::EPROTO - end - end - # The {Channel} between {Dispatcher} and {Host}. class Channel attr_reader :id diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 4e8670e7..78e7dbd4 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -88,7 +88,6 @@ def version_response(message) def error(message) case message when EmbeddedProtocol::ProtocolError - @dispatcher.error @error = Errno::EPROTO.new(message.message) else @error ||= message From d7e7abb73886613f652338df75548eeeef3a6bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 12 Oct 2023 20:07:15 -0700 Subject: [PATCH 242/700] Eagerly mark compiler as unavailable on protocol error --- lib/sass/embedded/dispatcher.rb | 70 ++++++++++++++++++++------------- lib/sass/embedded/host.rb | 1 + 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 8ed34ed4..331e1724 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -11,35 +11,9 @@ def initialize @observers = {} @mutex = Mutex.new @connection = Connection.new do |id, proto| - case id - when 1...0xffffffff - @mutex.synchronize { @observers[id] }.receive_proto(proto) - when 0 - outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) - oneof = outbound_message.message - message = outbound_message.public_send(oneof) - @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) - when 0xffffffff - outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) - oneof = outbound_message.message - message = outbound_message.public_send(oneof) - raise Errno::EPROTO, message.message - else - raise Errno::EPROTO - end + receive_proto(id, proto) rescue Errno::EPROTO => e - observers = @mutex.synchronize do - @id = 0xffffffff - @observers.values - end - - if observers.empty? - close - else - observers.each do |observer| - observer.error(e) - end - end + error(e) end end @@ -82,10 +56,46 @@ def closed? @connection.closed? end + def error(error) + observers = @mutex.synchronize do + @id = 0xffffffff + @observers.values + end + + if observers.empty? + close + else + observers.each do |observer| + observer.error(error) + end + end + end + def send_proto(...) @connection.write(...) end + private + + def receive_proto(id, proto) + case id + when 1...0xffffffff + @mutex.synchronize { @observers[id] }.receive_proto(proto) + when 0 + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) + when 0xffffffff + outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) + oneof = outbound_message.message + message = outbound_message.public_send(oneof) + raise Errno::EPROTO, message.message + else + raise Errno::EPROTO + end + end + # The {Channel} between {Dispatcher} and {Host}. class Channel attr_reader :id @@ -99,6 +109,10 @@ def disconnect @dispatcher.unsubscribe(id) end + def error(...) + @dispatcher.error(...) + end + def send_proto(...) @dispatcher.send_proto(...) end diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index 78e7dbd4..c6efca7b 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -89,6 +89,7 @@ def error(message) case message when EmbeddedProtocol::ProtocolError @error = Errno::EPROTO.new(message.message) + @channel.error(@error) else @error ||= message end From 693f3a98b3528250f495dc007a1f7a9c7f52d1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 12 Oct 2023 20:42:26 -0700 Subject: [PATCH 243/700] Refactor --- lib/sass/embedded/connection.rb | 13 ++++--------- lib/sass/embedded/dispatcher.rb | 16 +++++----------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 72dda0b1..347c5c15 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -8,7 +8,7 @@ class Embedded # # It runs the `sass --embedded` command. class Connection - def initialize + def initialize(dispatcher) @mutex = Mutex.new @stdin, @stdout, @stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) @@ -36,14 +36,9 @@ def initialize length = Varint.read(@stdout) id = Varint.read(@stdout) proto = @stdout.read(length - Varint.length(id)) - yield id, proto - rescue IOError, Errno::EBADF => e - yield 0xffffffff, EmbeddedProtocol::OutboundMessage.new( - error: EmbeddedProtocol::ProtocolError.new( - type: :PARSE, - message: e.message - ) - ).to_proto + dispatcher.receive_proto(id, proto) + rescue IOError, Errno::EBADF, Errno::EPROTO => e + dispatcher.error(e) break end end diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index 331e1724..cfc4d620 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -10,11 +10,7 @@ def initialize @id = 1 @observers = {} @mutex = Mutex.new - @connection = Connection.new do |id, proto| - receive_proto(id, proto) - rescue Errno::EPROTO => e - error(e) - end + @connection = Connection.new(self) end def subscribe(observer) @@ -71,12 +67,6 @@ def error(error) end end - def send_proto(...) - @connection.write(...) - end - - private - def receive_proto(id, proto) case id when 1...0xffffffff @@ -96,6 +86,10 @@ def receive_proto(id, proto) end end + def send_proto(...) + @connection.write(...) + end + # The {Channel} between {Dispatcher} and {Host}. class Channel attr_reader :id From f3274cf3287984466e9030c439c96f60991405f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 13 Oct 2023 11:22:55 -0700 Subject: [PATCH 244/700] Report error without blocking main thread --- lib/sass/embedded/dispatcher.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index cfc4d620..a177bbe0 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -104,7 +104,9 @@ def disconnect end def error(...) - @dispatcher.error(...) + Thread.new do + @dispatcher.error(...) + end end def send_proto(...) From f871483a46e2999b00b21da907fff0e764c3a157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 13 Oct 2023 13:59:03 -0700 Subject: [PATCH 245/700] Remove synchronization on closing compiler --- lib/sass/embedded/connection.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 347c5c15..86a79736 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -45,18 +45,14 @@ def initialize(dispatcher) end def close - @mutex.synchronize do - @stdin.close - @wait_thread.join - @stdout.close - @stderr.close - end + @stdin.close + @wait_thread.join + @stdout.close + @stderr.close end def closed? - @mutex.synchronize do - @stdin.closed? - end + @stdin.closed? && !@wait_thread.alive? end def write(id, proto) From 1d6ffa3b09bb11b5de130e667a17dd5e82587e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 13 Oct 2023 14:07:50 -0700 Subject: [PATCH 246/700] Close stdout and stderr on EOF --- lib/sass/embedded/connection.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 86a79736..9b49b58d 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -10,7 +10,7 @@ class Embedded class Connection def initialize(dispatcher) @mutex = Mutex.new - @stdin, @stdout, @stderr, @wait_thread = begin + @stdin, stdout, stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) rescue Errno::ENOENT require_relative '../elf' @@ -19,36 +19,35 @@ def initialize(dispatcher) Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) end - @stdin.binmode - @stdout.binmode Thread.new do loop do - warn(@stderr.readline, uplevel: 1) + warn(stderr.readline, uplevel: 1) rescue IOError, Errno::EBADF break end + stderr.close end Thread.new do + stdout.binmode loop do - length = Varint.read(@stdout) - id = Varint.read(@stdout) - proto = @stdout.read(length - Varint.length(id)) + length = Varint.read(stdout) + id = Varint.read(stdout) + proto = stdout.read(length - Varint.length(id)) dispatcher.receive_proto(id, proto) rescue IOError, Errno::EBADF, Errno::EPROTO => e dispatcher.error(e) break end + stdout.close end end def close @stdin.close @wait_thread.join - @stdout.close - @stderr.close end def closed? From bf05d896a4b7d4cbbd877b4256a11601cde0003d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 13 Oct 2023 18:57:19 -0700 Subject: [PATCH 247/700] Improve stdin throughput --- lib/sass/embedded/connection.rb | 10 ++++------ lib/sass/embedded/varint.rb | 6 ++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 9b49b58d..970a39fa 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -9,7 +9,6 @@ class Embedded # It runs the `sass --embedded` command. class Connection def initialize(dispatcher) - @mutex = Mutex.new @stdin, stdout, stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) rescue Errno::ENOENT @@ -55,11 +54,10 @@ def closed? end def write(id, proto) - @mutex.synchronize do - Varint.write(@stdin, Varint.length(id) + proto.length) - Varint.write(@stdin, id) - @stdin.write(proto) - end + buffer = [] + Varint.write(buffer, Varint.length(id) + proto.length) + Varint.write(buffer, id) + @stdin.write(buffer.pack('C*'), proto) end end diff --git a/lib/sass/embedded/varint.rb b/lib/sass/embedded/varint.rb index 5a170b2a..4787fdac 100644 --- a/lib/sass/embedded/varint.rb +++ b/lib/sass/embedded/varint.rb @@ -26,13 +26,11 @@ def read(readable) end def write(writeable, value) - bytes = [] until value < 0x80 - bytes << ((value & 0x7f) | 0x80) + writeable << ((value & 0x7f) | 0x80) value >>= 7 end - bytes << value - writeable.write bytes.pack('C*') + writeable << value end end From 53647b6fa8e71473e54944ca7ef42baeb34f1430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 13 Oct 2023 23:09:28 -0700 Subject: [PATCH 248/700] Refactor --- lib/sass/embedded.rb | 1 - lib/sass/embedded/connection.rb | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index d78043c1..37f9162e 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require_relative '../../ext/sass/cli' require_relative 'canonicalize_context' require_relative 'compile_error' require_relative 'compile_result' diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 970a39fa..80b2f5e6 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -2,6 +2,8 @@ require 'open3' +require_relative '../../../ext/sass/cli' + module Sass class Embedded # The stdio based {Connection} between the {Dispatcher} and the compiler. @@ -20,15 +22,6 @@ def initialize(dispatcher) end @stdin.binmode - Thread.new do - loop do - warn(stderr.readline, uplevel: 1) - rescue IOError, Errno::EBADF - break - end - stderr.close - end - Thread.new do stdout.binmode loop do @@ -42,6 +35,15 @@ def initialize(dispatcher) end stdout.close end + + Thread.new do + loop do + warn(stderr.readline, uplevel: 1) + rescue IOError, Errno::EBADF + break + end + stderr.close + end end def close From b1856eb3576f9c08d507af73ab45741f6f39b547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 16 Oct 2023 16:26:22 -0700 Subject: [PATCH 249/700] Remove unused method --- lib/sass/embedded/resilient_dispatcher.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/sass/embedded/resilient_dispatcher.rb b/lib/sass/embedded/resilient_dispatcher.rb index ccea6478..4fe6ad35 100644 --- a/lib/sass/embedded/resilient_dispatcher.rb +++ b/lib/sass/embedded/resilient_dispatcher.rb @@ -33,10 +33,6 @@ def connect(...) @dispatcher.connect(...) end end - - def error(...) - @dispatcher.error(...) - end end private_constant :ResilientDispatcher From a371a9d8a7ef529736ef893bc6b8d401b2614002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 16 Oct 2023 18:06:12 -0700 Subject: [PATCH 250/700] Create CONTRIBUTING.md --- CONTRIBUTING.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d882675e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Design Overview + +``` +┌─────────────┐ ┌────────────┐ ┌────────────┐ ┌─────────────────────┐ +│ ├───► │ │ ├───► │ +│ host thread │ │ │ │ │ │ compilation isolate │ +│ ◄───┤ │ write stdin │ ◄───┤ │ +└─────────────┘ │ ruby ├─────────────────────────────► dart │ └─────────────────────┘ + │ │ from host threads │ │ +┌─────────────┐ │ sass │ │ sass │ ┌─────────────────────┐ +│ ├───► │ │ ├───► │ +│ host thread │ │ embedded │ │ embedded │ │ compilation isolate │ +│ ◄───┤ │ │ ◄───┤ │ +└─────────────┘ │ host │ │ compiler │ └─────────────────────┘ + │ │ read stdout │ │ +┌─────────────┐ │ dispatcher ◄─────────────────────────────┤ dispatcher │ ┌─────────────────────┐ +│ ├───► │ on polling thread │ ├───► │ +│ host thread │ │ │ │ │ │ compilation isolate │ +│ ◄───┤ │ │ ◄───┤ │ +└─────────────┘ └────────────┘ │ │ └─────────────────────┘ + │ │ +┌─────────────┐ │ │ +│ │ read stderr │ │ +│ host stderr ◄──────────────────────────────────────────────┤ │ +│ │ on polling thread │ │ +└─────────────┘ └────────────┘ +``` From 2be0fe766964d64eee8dce53a0f0df794ebf3721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 16 Oct 2023 18:13:00 -0700 Subject: [PATCH 251/700] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d882675e..1618d623 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ │ │ ┌─────────────┐ │ │ │ │ read stderr │ │ -│ host stderr ◄──────────────────────────────────────────────┤ │ +│ ruby stderr ◄──────────────────────────────────────────────┤ │ │ │ on polling thread │ │ └─────────────┘ └────────────┘ ``` From d7b33c8021a568f65572721f731ebb3dfbd3675f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Oct 2023 12:36:07 -0700 Subject: [PATCH 252/700] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1618d623..7fa340b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ │ │ from host threads │ │ ┌─────────────┐ │ sass │ │ sass │ ┌─────────────────────┐ │ ├───► │ │ ├───► │ -│ host thread │ │ embedded │ │ embedded │ │ compilation isolate │ +│ ... │ │ embedded │ │ embedded │ │ ... │ │ ◄───┤ │ │ ◄───┤ │ └─────────────┘ │ host │ │ compiler │ └─────────────────────┘ │ │ read stdout │ │ From 8d670f65a9c676cd913f7e6e4de263475bea3ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Oct 2023 12:48:26 -0700 Subject: [PATCH 253/700] Move files --- lib/sass/embedded.rb | 2 - lib/sass/embedded/host.rb | 2 + lib/sass/embedded/host/protofier.rb | 88 +++++++++++++++++++++++++++ lib/sass/embedded/host/structifier.rb | 37 +++++++++++ lib/sass/embedded/protofier.rb | 86 -------------------------- lib/sass/embedded/structifier.rb | 35 ----------- 6 files changed, 127 insertions(+), 123 deletions(-) create mode 100644 lib/sass/embedded/host/protofier.rb create mode 100644 lib/sass/embedded/host/structifier.rb delete mode 100644 lib/sass/embedded/protofier.rb delete mode 100644 lib/sass/embedded/structifier.rb diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 37f9162e..1c05be37 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -6,9 +6,7 @@ require_relative 'embedded/connection' require_relative 'embedded/dispatcher' require_relative 'embedded/host' -require_relative 'embedded/protofier' require_relative 'embedded/resilient_dispatcher' -require_relative 'embedded/structifier' require_relative 'embedded/varint' require_relative 'embedded/version' require_relative 'embedded_protocol' diff --git a/lib/sass/embedded/host.rb b/lib/sass/embedded/host.rb index c6efca7b..dff5845b 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/embedded/host.rb @@ -3,6 +3,8 @@ require_relative 'host/function_registry' require_relative 'host/importer_registry' require_relative 'host/logger_registry' +require_relative 'host/protofier' +require_relative 'host/structifier' require_relative 'host/value_protofier' module Sass diff --git a/lib/sass/embedded/host/protofier.rb b/lib/sass/embedded/host/protofier.rb new file mode 100644 index 00000000..94b930de --- /dev/null +++ b/lib/sass/embedded/host/protofier.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +module Sass + class Embedded + class Host + # The {Protofier} module. + # + # It converts Pure Ruby types and Protobuf Ruby types. + module Protofier + module_function + + def from_proto_canonicalize_context(canonicalize_request) + CanonicalizeContext.new( + canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url, + canonicalize_request.from_import + ) + end + + def from_proto_compile_response(compile_response) + oneof = compile_response.result + result = compile_response.public_send(oneof) + case oneof + when :failure + raise CompileError.new( + result.message, + result.formatted == '' ? nil : result.formatted, + result.stack_trace == '' ? nil : result.stack_trace, + from_proto_source_span(result.span), + compile_response.loaded_urls + ) + when :success + CompileResult.new( + result.css, + result.source_map == '' ? nil : result.source_map, + compile_response.loaded_urls + ) + else + raise ArgumentError, "Unknown CompileResponse.result #{result}" + end + end + + def from_proto_source_span(source_span) + return if source_span.nil? + + Logger::SourceSpan.new(from_proto_source_location(source_span.start), + from_proto_source_location(source_span.end), + source_span.text, + source_span.url == '' ? nil : source_span.url, + source_span.context == '' ? nil : source_span.context) + end + + def from_proto_source_location(source_location) + return if source_location.nil? + + Logger::SourceLocation.new(source_location.offset, + source_location.line, + source_location.column) + end + + def to_proto_syntax(syntax) + case syntax&.to_sym + when :scss + EmbeddedProtocol::Syntax::SCSS + when :indented + EmbeddedProtocol::Syntax::INDENTED + when :css + EmbeddedProtocol::Syntax::CSS + else + raise ArgumentError, 'syntax must be one of :scss, :indented, :css' + end + end + + def to_proto_output_style(style) + case style&.to_sym + when :expanded + EmbeddedProtocol::OutputStyle::EXPANDED + when :compressed + EmbeddedProtocol::OutputStyle::COMPRESSED + else + raise ArgumentError, 'style must be one of :expanded, :compressed' + end + end + end + + private_constant :Protofier + end + end +end diff --git a/lib/sass/embedded/host/structifier.rb b/lib/sass/embedded/host/structifier.rb new file mode 100644 index 00000000..86559edc --- /dev/null +++ b/lib/sass/embedded/host/structifier.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Sass + class Embedded + class Host + # The {Structifier} module. + # + # It converts {::Hash} to {Struct}-like objects. + module Structifier + module_function + + def to_struct(obj, *symbols) + return obj unless obj.is_a? Hash + + struct = Object.new + symbols.each do |key| + next unless obj.key?(key) + + value = obj[key] + if value.respond_to? :call + struct.define_singleton_method key do |*args, **kwargs| + value.call(*args, **kwargs) + end + else + struct.define_singleton_method key do + value + end + end + end + struct + end + end + + private_constant :Structifier + end + end +end diff --git a/lib/sass/embedded/protofier.rb b/lib/sass/embedded/protofier.rb deleted file mode 100644 index 2b6792ae..00000000 --- a/lib/sass/embedded/protofier.rb +++ /dev/null @@ -1,86 +0,0 @@ -# frozen_string_literal: true - -module Sass - class Embedded - # The {Protofier} module. - # - # It converts Pure Ruby types and Protobuf Ruby types. - module Protofier - module_function - - def from_proto_canonicalize_context(canonicalize_request) - CanonicalizeContext.new( - canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url, - canonicalize_request.from_import - ) - end - - def from_proto_compile_response(compile_response) - oneof = compile_response.result - result = compile_response.public_send(oneof) - case oneof - when :failure - raise CompileError.new( - result.message, - result.formatted == '' ? nil : result.formatted, - result.stack_trace == '' ? nil : result.stack_trace, - from_proto_source_span(result.span), - compile_response.loaded_urls - ) - when :success - CompileResult.new( - result.css, - result.source_map == '' ? nil : result.source_map, - compile_response.loaded_urls - ) - else - raise ArgumentError, "Unknown CompileResponse.result #{result}" - end - end - - def from_proto_source_span(source_span) - return if source_span.nil? - - Logger::SourceSpan.new(from_proto_source_location(source_span.start), - from_proto_source_location(source_span.end), - source_span.text, - source_span.url == '' ? nil : source_span.url, - source_span.context == '' ? nil : source_span.context) - end - - def from_proto_source_location(source_location) - return if source_location.nil? - - Logger::SourceLocation.new(source_location.offset, - source_location.line, - source_location.column) - end - - def to_proto_syntax(syntax) - case syntax&.to_sym - when :scss - EmbeddedProtocol::Syntax::SCSS - when :indented - EmbeddedProtocol::Syntax::INDENTED - when :css - EmbeddedProtocol::Syntax::CSS - else - raise ArgumentError, 'syntax must be one of :scss, :indented, :css' - end - end - - def to_proto_output_style(style) - case style&.to_sym - when :expanded - EmbeddedProtocol::OutputStyle::EXPANDED - when :compressed - EmbeddedProtocol::OutputStyle::COMPRESSED - else - raise ArgumentError, 'style must be one of :expanded, :compressed' - end - end - end - - private_constant :Protofier - end -end diff --git a/lib/sass/embedded/structifier.rb b/lib/sass/embedded/structifier.rb deleted file mode 100644 index 4a75fc4d..00000000 --- a/lib/sass/embedded/structifier.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -module Sass - class Embedded - # The {Structifier} module. - # - # It converts {::Hash} to {Struct}-like objects. - module Structifier - module_function - - def to_struct(obj, *symbols) - return obj unless obj.is_a? Hash - - struct = Object.new - symbols.each do |key| - next unless obj.key?(key) - - value = obj[key] - if value.respond_to? :call - struct.define_singleton_method key do |*args, **kwargs| - value.call(*args, **kwargs) - end - else - struct.define_singleton_method key do - value - end - end - end - struct - end - end - - private_constant :Structifier - end -end From 82dbc867ea0033281059d5a76b7fd27980e3a6ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:02:57 -0700 Subject: [PATCH 254/700] Bump sass from 1.69.3 to 1.69.4 in /ext/sass (#167) Bumps [sass](https://github.com/sass/dart-sass) from 1.69.3 to 1.69.4. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.3...1.69.4) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index e729eb4b..30ce871b 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.3" + "sass": "1.69.4" } } From 67d59f0724969f9880d633c16e3916033f9b5234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Oct 2023 15:03:23 -0700 Subject: [PATCH 255/700] v1.69.4 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 20d01586..230cee53 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.69.3' + VERSION = '1.69.4' end end From 784f0a4288ed38cea5bff94a6e03b8d5756e8b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Oct 2023 16:27:13 -0700 Subject: [PATCH 256/700] Code style --- lib/sass/embedded/host/structifier.rb | 2 +- lib/sass/value/color.rb | 12 ++++++------ lib/sass/value/map.rb | 2 +- lib/sass/value/number.rb | 6 +++--- spec/sass_proto_spec.rb | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/sass/embedded/host/structifier.rb b/lib/sass/embedded/host/structifier.rb index 86559edc..934e9737 100644 --- a/lib/sass/embedded/host/structifier.rb +++ b/lib/sass/embedded/host/structifier.rb @@ -10,7 +10,7 @@ module Structifier module_function def to_struct(obj, *symbols) - return obj unless obj.is_a? Hash + return obj unless obj.is_a?(Hash) struct = Object.new symbols.each do |key| diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 07f44351..bcfd1914 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -50,42 +50,42 @@ def initialize(red: nil, # @return [Integer] def red - hsl_to_rgb unless defined? @red + hsl_to_rgb unless defined?(@red) @red end # @return [Integer] def green - hsl_to_rgb unless defined? @green + hsl_to_rgb unless defined?(@green) @green end # @return [Integer] def blue - hsl_to_rgb unless defined? @blue + hsl_to_rgb unless defined?(@blue) @blue end # @return [Numeric] def hue - rgb_to_hsl unless defined? @hue + rgb_to_hsl unless defined?(@hue) @hue end # @return [Numeric] def saturation - rgb_to_hsl unless defined? @saturation + rgb_to_hsl unless defined?(@saturation) @saturation end # @return [Numeric] def lightness - rgb_to_hsl unless defined? @lightness + rgb_to_hsl unless defined?(@lightness) @lightness end diff --git a/lib/sass/value/map.rb b/lib/sass/value/map.rb index 03c3b9f7..8e1a62f1 100644 --- a/lib/sass/value/map.rb +++ b/lib/sass/value/map.rb @@ -30,7 +30,7 @@ def ==(other) # @param index [Numeric, Value] # @return [List<(Value, Value)>, Value] def at(index) - if index.is_a? Numeric + if index.is_a?(Numeric) index = index.floor index = to_a_length + index if index.negative? return nil if index.negative? || index >= to_a_length diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index bdca78ed..ec53dd25 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -25,12 +25,12 @@ def initialize(value, unit = nil) denominator_units = [] when ::Hash numerator_units = unit.fetch(:numerator_units, []) - unless numerator_units.is_a? Array + unless numerator_units.is_a?(Array) raise Sass::ScriptError, "invalid numerator_units #{numerator_units.inspect}" end denominator_units = unit.fetch(:denominator_units, []) - unless denominator_units.is_a? Array + unless denominator_units.is_a?(Array) raise Sass::ScriptError, "invalid denominator_units #{denominator_units.inspect}" end else @@ -75,7 +75,7 @@ def initialize(value, unit = nil) # @return [::Boolean] def ==(other) - return false unless other.is_a? Sass::Value::Number + return false unless other.is_a?(Sass::Value::Number) return false if numerator_units.length != other.numerator_units.length || denominator_units.length != other.denominator_units.length diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 089c0a14..2915b082 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Sass do def remote_eq(lhs, rhs) to_host_value = lambda { |value| - if value.is_a? Sass::Value::ArgumentList + if value.is_a?(Sass::Value::ArgumentList) value.dup else value From 80d5b01adbff582c35c739f3825ba2f261b23443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Oct 2023 16:42:49 -0700 Subject: [PATCH 257/700] Code style --- lib/sass/embedded/host/structifier.rb | 2 +- lib/sass/value/function.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/embedded/host/structifier.rb b/lib/sass/embedded/host/structifier.rb index 934e9737..55a29758 100644 --- a/lib/sass/embedded/host/structifier.rb +++ b/lib/sass/embedded/host/structifier.rb @@ -17,7 +17,7 @@ def to_struct(obj, *symbols) next unless obj.key?(key) value = obj[key] - if value.respond_to? :call + if value.respond_to?(:call) struct.define_singleton_method key do |*args, **kwargs| value.call(*args, **kwargs) end diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 886887f0..c0d4641c 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -29,7 +29,7 @@ def initialize(signature, callback) # @return [::Boolean] def ==(other) if id.nil? - other.equal? self + other.equal?(self) else other.is_a?(Sass::Value::Function) && other.id == id end From efb1e44f156ebd2c6b93e8bf9bd486220156d15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Oct 2023 18:29:54 -0700 Subject: [PATCH 258/700] Fix concurrency issue with writev (#169) --- lib/sass/embedded/connection.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded/connection.rb b/lib/sass/embedded/connection.rb index 80b2f5e6..bf729fce 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/embedded/connection.rb @@ -11,6 +11,7 @@ class Embedded # It runs the `sass --embedded` command. class Connection def initialize(dispatcher) + @mutex = Mutex.new @stdin, stdout, stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) rescue Errno::ENOENT @@ -59,7 +60,9 @@ def write(id, proto) buffer = [] Varint.write(buffer, Varint.length(id) + proto.length) Varint.write(buffer, id) - @stdin.write(buffer.pack('C*'), proto) + @mutex.synchronize do + @stdin.write(buffer.pack('C*'), proto) + end end end From 6496c0c9b58f2e9a23b149155d6de5e28b4b3a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 19 Oct 2023 10:33:46 -0700 Subject: [PATCH 259/700] Code style --- lib/sass/embedded.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 1c05be37..2c0e1ffd 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -70,9 +70,8 @@ def instance at_exit do @instance.close end + @instance end - - @instance end end # rubocop:enable Layout/LineLength From 63a627057a947ab53191d374a3bef63683959e76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:35:59 -0700 Subject: [PATCH 260/700] Bump sass from 1.69.4 to 1.69.5 in /ext/sass (#170) Bumps [sass](https://github.com/sass/dart-sass) from 1.69.4 to 1.69.5. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.4...1.69.5) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 30ce871b..9101ffa3 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.4" + "sass": "1.69.5" } } From 34674f3ebdea5855e0eece26245c0c3d01962a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 25 Oct 2023 18:40:42 -0700 Subject: [PATCH 261/700] v1.69.5 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 230cee53..13ad8dba 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass class Embedded - VERSION = '1.69.4' + VERSION = '1.69.5' end end From 7035f7151f77cc400d277254635bc480b1194ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 25 Oct 2023 21:54:33 -0700 Subject: [PATCH 262/700] Update google-protobuf requirement from ~> 3.23 to ~> 3.24 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 49a55f37..60159ac9 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -37,6 +37,6 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.required_ruby_version = '>= 3.0.0' - spec.add_runtime_dependency 'google-protobuf', '~> 3.23' + spec.add_runtime_dependency 'google-protobuf', '~> 3.24' spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') end From 040ecd04cfd36d08d1434e363a55fb47c77828a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:42:12 -0700 Subject: [PATCH 263/700] Update rubocop-rspec requirement from ~> 2.24.0 to ~> 2.25.0 (#171) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.24.0...v2.25.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3aeca10f..9a0f10af 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.57.0' gem 'rubocop-performance', '~> 1.19.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.24.0' + gem 'rubocop-rspec', '~> 2.25.0' end From 0133ae6a86169d4e48f107acd95440d34245d0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Oct 2023 10:53:36 -0700 Subject: [PATCH 264/700] Fix rare flakiness on single-threaded request after a protocol error --- lib/sass/embedded/dispatcher.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/embedded/dispatcher.rb index a177bbe0..cfc4d620 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/embedded/dispatcher.rb @@ -104,9 +104,7 @@ def disconnect end def error(...) - Thread.new do - @dispatcher.error(...) - end + @dispatcher.error(...) end def send_proto(...) From 27c90c38b605fd30f8ad8978937c84c018dd3e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 1 Nov 2023 09:46:19 -0700 Subject: [PATCH 265/700] Remove required_rubygems_version (#172) --- sass-embedded.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 60159ac9..b294a853 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -24,7 +24,6 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA if ENV.key?('gem_platform') spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] spec.platform = ENV['gem_platform'] - spec.required_rubygems_version = '>= 3.3.22' if ENV['gem_platform'].include?('-linux-') else spec.extensions = ['ext/sass/Rakefile'] spec.files += [ From 52dee6c71744388d98149bec52c507978e5f225d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 30 Nov 2023 09:53:30 -0800 Subject: [PATCH 266/700] Rename Embedded to Compiler --- lib/sass/compiler.rb | 187 ++++++++++++++++ lib/sass/{embedded => compiler}/connection.rb | 2 +- lib/sass/{embedded => compiler}/dispatcher.rb | 2 +- lib/sass/{embedded => compiler}/host.rb | 2 +- .../host/function_registry.rb | 2 +- .../host/importer_registry.rb | 2 +- .../host/logger_registry.rb | 2 +- .../{embedded => compiler}/host/protofier.rb | 2 +- .../host/structifier.rb | 2 +- .../host/value_protofier.rb | 2 +- .../resilient_dispatcher.rb | 2 +- lib/sass/{embedded => compiler}/varint.rb | 2 +- lib/sass/embedded.rb | 209 ++---------------- lib/sass/embedded/version.rb | 2 +- 14 files changed, 213 insertions(+), 207 deletions(-) create mode 100644 lib/sass/compiler.rb rename lib/sass/{embedded => compiler}/connection.rb (99%) rename lib/sass/{embedded => compiler}/dispatcher.rb (99%) rename lib/sass/{embedded => compiler}/host.rb (99%) rename lib/sass/{embedded => compiler}/host/function_registry.rb (99%) rename lib/sass/{embedded => compiler}/host/importer_registry.rb (99%) rename lib/sass/{embedded => compiler}/host/logger_registry.rb (98%) rename lib/sass/{embedded => compiler}/host/protofier.rb (99%) rename lib/sass/{embedded => compiler}/host/structifier.rb (97%) rename lib/sass/{embedded => compiler}/host/value_protofier.rb (99%) rename lib/sass/{embedded => compiler}/resilient_dispatcher.rb (97%) rename lib/sass/{embedded => compiler}/varint.rb (97%) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb new file mode 100644 index 00000000..3f7b2eb9 --- /dev/null +++ b/lib/sass/compiler.rb @@ -0,0 +1,187 @@ +# frozen_string_literal: true + +require_relative 'canonicalize_context' +require_relative 'compile_error' +require_relative 'compile_result' +require_relative 'compiler/connection' +require_relative 'compiler/dispatcher' +require_relative 'compiler/host' +require_relative 'compiler/resilient_dispatcher' +require_relative 'compiler/varint' +require_relative 'embedded_protocol' +require_relative 'embedded/version' +require_relative 'logger/silent' +require_relative 'logger/source_location' +require_relative 'logger/source_span' +require_relative 'value' + +module Sass + # The {Embedded} host for using dart-sass. Each instance creates its own + # communication {Dispatcher} with a dedicated compiler process. + # + # @example + # sass = Sass::Compiler.new + # result = sass.compile_string('h1 { font-size: 40px; }') + # result = sass.compile('style.scss') + # sass.close + class Compiler + def initialize + @dispatcher = ResilientDispatcher.new + end + + # Compiles the Sass file at +path+ to CSS. + # @param path [String] + # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ + # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to + # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. + # @param source_map [Boolean] Whether or not Sass should generate a source map. + # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. + # @param style [String, Symbol] The OutputStyle of the compiled CSS. + # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. + # @param importers [Array] Custom importers that control how Sass resolves loads from rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error + # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. + # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and + # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or + # not to use colors depending on whether the user is using an interactive terminal. + # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. + # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by + # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. + # Stylesheets that are imported relative to the entrypoint are not considered dependencies. + # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per + # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every + # deprecation warning it encounters. + # @return [CompileResult] + # @raise [ArgumentError, CompileError] + # @see https://sass-lang.com/documentation/js-api/functions/compile/ + def compile(path, + load_paths: [], + + charset: true, + source_map: false, + source_map_include_sources: false, + style: :expanded, + + functions: {}, + importers: [], + + alert_ascii: false, + alert_color: nil, + logger: nil, + quiet_deps: false, + verbose: false) + raise ArgumentError, 'path must be set' if path.nil? + + Host.new(@dispatcher).compile_request( + path: path, + source: nil, + importer: nil, + load_paths: load_paths, + syntax: nil, + url: nil, + charset: charset, + source_map: source_map, + source_map_include_sources: source_map_include_sources, + style: style, + functions: functions, + importers: importers, + alert_color: alert_color, + alert_ascii: alert_ascii, + logger: logger, + quiet_deps: quiet_deps, + verbose: verbose + ) + end + + # Compiles a stylesheet whose contents is +source+ to CSS. + # @param source [String] + # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet. + # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param syntax [String, Symbol] The Syntax to use to parse the entrypoint stylesheet. + # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's + # used to resolve relative loads in the entrypoint stylesheet. + # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ + # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to + # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. + # @param source_map [Boolean] Whether or not Sass should generate a source map. + # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. + # @param style [String, Symbol] The OutputStyle of the compiled CSS. + # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. + # @param importers [Array] Custom importers that control how Sass resolves loads from rules like + # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. + # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error + # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. + # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and + # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or + # not to use colors depending on whether the user is using an interactive terminal. + # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. + # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by + # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. + # Stylesheets that are imported relative to the entrypoint are not considered dependencies. + # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per + # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every + # deprecation warning it encounters. + # @return [CompileResult] + # @raise [ArgumentError, CompileError] + # @see https://sass-lang.com/documentation/js-api/functions/compilestring/ + def compile_string(source, + importer: nil, + load_paths: [], + syntax: :scss, + url: nil, + + charset: true, + source_map: false, + source_map_include_sources: false, + style: :expanded, + + functions: {}, + importers: [], + + alert_ascii: false, + alert_color: nil, + logger: nil, + quiet_deps: false, + verbose: false) + raise ArgumentError, 'source must be set' if source.nil? + + Host.new(@dispatcher).compile_request( + path: nil, + source: source, + importer: importer, + load_paths: load_paths, + syntax: syntax, + url: url, + charset: charset, + source_map: source_map, + source_map_include_sources: source_map_include_sources, + style: style, + functions: functions, + importers: importers, + alert_color: alert_color, + alert_ascii: alert_ascii, + logger: logger, + quiet_deps: quiet_deps, + verbose: verbose + ) + end + + # @return [String] Information about the Sass implementation. + # @see https://sass-lang.com/documentation/js-api/variables/info/ + def info + @info ||= Host.new(@dispatcher).version_request + end + + def close + @dispatcher.close + end + + def closed? + @dispatcher.closed? + end + end +end diff --git a/lib/sass/embedded/connection.rb b/lib/sass/compiler/connection.rb similarity index 99% rename from lib/sass/embedded/connection.rb rename to lib/sass/compiler/connection.rb index bf729fce..8a5977d3 100644 --- a/lib/sass/embedded/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -5,7 +5,7 @@ require_relative '../../../ext/sass/cli' module Sass - class Embedded + class Compiler # The stdio based {Connection} between the {Dispatcher} and the compiler. # # It runs the `sass --embedded` command. diff --git a/lib/sass/embedded/dispatcher.rb b/lib/sass/compiler/dispatcher.rb similarity index 99% rename from lib/sass/embedded/dispatcher.rb rename to lib/sass/compiler/dispatcher.rb index cfc4d620..510bb7fe 100644 --- a/lib/sass/embedded/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler # The {Dispatcher} class. # # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler. diff --git a/lib/sass/embedded/host.rb b/lib/sass/compiler/host.rb similarity index 99% rename from lib/sass/embedded/host.rb rename to lib/sass/compiler/host.rb index dff5845b..9b1e5c8f 100644 --- a/lib/sass/embedded/host.rb +++ b/lib/sass/compiler/host.rb @@ -8,7 +8,7 @@ require_relative 'host/value_protofier' module Sass - class Embedded + class Compiler # The {Host} class. # # It communicates with {Dispatcher} and handles the host logic. diff --git a/lib/sass/embedded/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb similarity index 99% rename from lib/sass/embedded/host/function_registry.rb rename to lib/sass/compiler/host/function_registry.rb index aca89006..0747336c 100644 --- a/lib/sass/embedded/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler class Host # The {FunctionRegistry} class. # diff --git a/lib/sass/embedded/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb similarity index 99% rename from lib/sass/embedded/host/importer_registry.rb rename to lib/sass/compiler/host/importer_registry.rb index 51b39002..e6d7cb1d 100644 --- a/lib/sass/embedded/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler class Host # The {ImporterRegistry} class. # diff --git a/lib/sass/embedded/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb similarity index 98% rename from lib/sass/embedded/host/logger_registry.rb rename to lib/sass/compiler/host/logger_registry.rb index 46c0e67c..e0a7f94a 100644 --- a/lib/sass/embedded/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler class Host # The {LoggerRegistry} class. # diff --git a/lib/sass/embedded/host/protofier.rb b/lib/sass/compiler/host/protofier.rb similarity index 99% rename from lib/sass/embedded/host/protofier.rb rename to lib/sass/compiler/host/protofier.rb index 94b930de..c3f40d71 100644 --- a/lib/sass/embedded/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler class Host # The {Protofier} module. # diff --git a/lib/sass/embedded/host/structifier.rb b/lib/sass/compiler/host/structifier.rb similarity index 97% rename from lib/sass/embedded/host/structifier.rb rename to lib/sass/compiler/host/structifier.rb index 55a29758..80b21575 100644 --- a/lib/sass/embedded/host/structifier.rb +++ b/lib/sass/compiler/host/structifier.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler class Host # The {Structifier} module. # diff --git a/lib/sass/embedded/host/value_protofier.rb b/lib/sass/compiler/host/value_protofier.rb similarity index 99% rename from lib/sass/embedded/host/value_protofier.rb rename to lib/sass/compiler/host/value_protofier.rb index be3be955..c6be6c6f 100644 --- a/lib/sass/embedded/host/value_protofier.rb +++ b/lib/sass/compiler/host/value_protofier.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler class Host # The {ValueProtofier} class. # diff --git a/lib/sass/embedded/resilient_dispatcher.rb b/lib/sass/compiler/resilient_dispatcher.rb similarity index 97% rename from lib/sass/embedded/resilient_dispatcher.rb rename to lib/sass/compiler/resilient_dispatcher.rb index 4fe6ad35..c1c53be5 100644 --- a/lib/sass/embedded/resilient_dispatcher.rb +++ b/lib/sass/compiler/resilient_dispatcher.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler # The {ResilientDispatcher} class. # # It recovers from failures and continues to function. diff --git a/lib/sass/embedded/varint.rb b/lib/sass/compiler/varint.rb similarity index 97% rename from lib/sass/embedded/varint.rb rename to lib/sass/compiler/varint.rb index 4787fdac..79877797 100644 --- a/lib/sass/embedded/varint.rb +++ b/lib/sass/compiler/varint.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + class Compiler # The {Varint} module. # # It reads and writes varints. diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 2c0e1ffd..92fdf4b0 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -1,19 +1,7 @@ # frozen_string_literal: true -require_relative 'canonicalize_context' -require_relative 'compile_error' -require_relative 'compile_result' -require_relative 'embedded/connection' -require_relative 'embedded/dispatcher' -require_relative 'embedded/host' -require_relative 'embedded/resilient_dispatcher' -require_relative 'embedded/varint' +require_relative 'compiler' require_relative 'embedded/version' -require_relative 'embedded_protocol' -require_relative 'logger/silent' -require_relative 'logger/source_location' -require_relative 'logger/source_span' -require_relative 'value' # The Sass module. # @@ -32,28 +20,28 @@ module Sass class << self # Compiles the Sass file at +path+ to CSS. # @overload compile(path, load_paths: [], charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, logger: nil, quiet_deps: false, verbose: false) - # @param (see Embedded#compile) - # @return (see Embedded#compile) - # @raise (see Embedded#compile) - # @see Embedded#compile + # @param (see Compiler#compile) + # @return (see Compiler#compile) + # @raise (see Compiler#compile) + # @see Compiler#compile def compile(...) instance.compile(...) end # Compiles a stylesheet whose contents is +source+ to CSS. # @overload compile_string(source, importer: nil, load_paths: [], syntax: :scss, url: nil, charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, logger: nil, quiet_deps: false, verbose: false) - # @param (see Embedded#compile_string) - # @return (see Embedded#compile_string) - # @raise (see Embedded#compile_string) - # @see Embedded#compile_string + # @param (see Compiler#compile_string) + # @return (see Compiler#compile_string) + # @raise (see Compiler#compile_string) + # @see Compiler#compile_string def compile_string(...) instance.compile_string(...) end - # @param (see Embedded#info) - # @return (see Embedded#info) - # @raise (see Embedded#info) - # @see Embedded#info + # @param (see Compiler#info) + # @return (see Compiler#info) + # @raise (see Compiler#info) + # @see Compiler#info def info instance.info end @@ -66,7 +54,7 @@ def instance @mutex.synchronize do return @instance if @instance - @instance = Embedded.new + @instance = Compiler.new at_exit do @instance.close end @@ -75,173 +63,4 @@ def instance end end # rubocop:enable Layout/LineLength - - # The {Embedded} host for using dart-sass. Each instance creates its own - # communication {Dispatcher} with a dedicated compiler process. - # - # @example - # embedded = Sass::Embedded.new - # result = embedded.compile_string('h1 { font-size: 40px; }') - # result = embedded.compile('style.scss') - # embedded.close - class Embedded - def initialize - @dispatcher = ResilientDispatcher.new - end - - # Compiles the Sass file at +path+ to CSS. - # @param path [String] - # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. - # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ - # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to - # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. - # @param source_map [Boolean] Whether or not Sass should generate a source map. - # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. - # @param style [String, Symbol] The OutputStyle of the compiled CSS. - # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. - # @param importers [Array] Custom importers that control how Sass resolves loads from rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. - # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error - # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. - # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and - # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or - # not to use colors depending on whether the user is using an interactive terminal. - # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. - # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by - # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. - # Stylesheets that are imported relative to the entrypoint are not considered dependencies. - # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per - # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every - # deprecation warning it encounters. - # @return [CompileResult] - # @raise [ArgumentError, CompileError] - # @see https://sass-lang.com/documentation/js-api/functions/compile/ - def compile(path, - load_paths: [], - - charset: true, - source_map: false, - source_map_include_sources: false, - style: :expanded, - - functions: {}, - importers: [], - - alert_ascii: false, - alert_color: nil, - logger: nil, - quiet_deps: false, - verbose: false) - raise ArgumentError, 'path must be set' if path.nil? - - Host.new(@dispatcher).compile_request( - path: path, - source: nil, - importer: nil, - load_paths: load_paths, - syntax: nil, - url: nil, - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - style: style, - functions: functions, - importers: importers, - alert_color: alert_color, - alert_ascii: alert_ascii, - logger: logger, - quiet_deps: quiet_deps, - verbose: verbose - ) - end - - # Compiles a stylesheet whose contents is +source+ to CSS. - # @param source [String] - # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet. - # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. - # @param syntax [String, Symbol] The Syntax to use to parse the entrypoint stylesheet. - # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's - # used to resolve relative loads in the entrypoint stylesheet. - # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ - # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to - # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. - # @param source_map [Boolean] Whether or not Sass should generate a source map. - # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. - # @param style [String, Symbol] The OutputStyle of the compiled CSS. - # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. - # @param importers [Array] Custom importers that control how Sass resolves loads from rules like - # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. - # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error - # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well. - # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and - # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or - # not to use colors depending on whether the user is using an interactive terminal. - # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. - # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by - # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. - # Stylesheets that are imported relative to the entrypoint are not considered dependencies. - # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per - # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every - # deprecation warning it encounters. - # @return [CompileResult] - # @raise [ArgumentError, CompileError] - # @see https://sass-lang.com/documentation/js-api/functions/compilestring/ - def compile_string(source, - importer: nil, - load_paths: [], - syntax: :scss, - url: nil, - - charset: true, - source_map: false, - source_map_include_sources: false, - style: :expanded, - - functions: {}, - importers: [], - - alert_ascii: false, - alert_color: nil, - logger: nil, - quiet_deps: false, - verbose: false) - raise ArgumentError, 'source must be set' if source.nil? - - Host.new(@dispatcher).compile_request( - path: nil, - source: source, - importer: importer, - load_paths: load_paths, - syntax: syntax, - url: url, - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - style: style, - functions: functions, - importers: importers, - alert_color: alert_color, - alert_ascii: alert_ascii, - logger: logger, - quiet_deps: quiet_deps, - verbose: verbose - ) - end - - # @return [String] Information about the Sass implementation. - # @see https://sass-lang.com/documentation/js-api/variables/info/ - def info - @info ||= Host.new(@dispatcher).version_request - end - - def close - @dispatcher.close - end - - def closed? - @dispatcher.closed? - end - end end diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 13ad8dba..ac677d40 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Sass - class Embedded + module Embedded VERSION = '1.69.5' end end From b3cd23ecd4419d9fbed4ed867b80a5ea5ca88468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 30 Nov 2023 10:00:20 -0800 Subject: [PATCH 267/700] Add Sass::Embedded.new for backward compatibility --- lib/sass/compiler.rb | 2 +- lib/sass/embedded.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 3f7b2eb9..ee2020f0 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -16,7 +16,7 @@ require_relative 'value' module Sass - # The {Embedded} host for using dart-sass. Each instance creates its own + # The {Compiler} for using dart-sass. Each instance creates its own # communication {Dispatcher} with a dedicated compiler process. # # @example diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 92fdf4b0..6172d522 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -63,4 +63,14 @@ def instance end end # rubocop:enable Layout/LineLength + + # The {Embedded} module. + module Embedded + module_function + + # @deprecated Use {Compiler.new} instead. + def new + Compiler.new + end + end end From 4970961371d750d25411181650cd65f5e7ec7af3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 07:28:44 -0800 Subject: [PATCH 268/700] Update rubocop requirement from ~> 1.57.0 to ~> 1.58.0 (#174) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.57.0 to ~> 1.58.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.57.0...v1.58.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Fix lint --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- Gemfile | 2 +- ext/sass/Rakefile | 2 +- spec/sass_importer_spec.rb | 68 +++++++++++++++++++------------------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Gemfile b/Gemfile index 9a0f10af..f3d6838a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.57.0' + gem 'rubocop', '~> 1.58.0' gem 'rubocop-performance', '~> 1.19.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.25.0' diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index e2efd33a..e8ae1217 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -164,7 +164,7 @@ module FileUtils cp source_path, dest_path else fetcher = Gem::RemoteFetcher.fetcher - symbol = "fetch_#{scheme}".to_sym + symbol = :"fetch_#{scheme}" raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol) if Rake::FileUtilsExt.verbose_flag diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 1535606e..77d2d0b7 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -10,7 +10,7 @@ canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |url| color = url.split(':')[1] - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss' } @@ -28,7 +28,7 @@ canonicalize: ->(*) { 'u:blue' }, load: lambda { |url| color = url.split(':')[1] - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss' } @@ -49,7 +49,7 @@ canonicalize: ->(*) { 'u:blue' }, load: lambda { |url| color = url.split(':')[1] - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss' } @@ -72,7 +72,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: 'a {b: c}', syntax: 'scss' } @@ -92,7 +92,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: 'a {b: c}', syntax: 'scss' } @@ -114,7 +114,7 @@ url }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -136,7 +136,7 @@ url.gsub(/^u:/, 'x:') }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -158,7 +158,7 @@ url.gsub(/^u:/, 'x:') }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -181,7 +181,7 @@ url.gsub(/^u:/, 'x:') }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -203,7 +203,7 @@ url.gsub(/^u:/, 'x:') }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -227,7 +227,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -248,7 +248,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -271,7 +271,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -291,7 +291,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -312,7 +312,7 @@ canonicalize: lambda { |*| }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -331,7 +331,7 @@ canonicalize: lambda { |*| }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -350,7 +350,7 @@ canonicalize: lambda { |*| }, load: lambda { |*| - return { + { contents: '@a', syntax: 'scss' } @@ -371,7 +371,7 @@ }, load: lambda { |url| color = url.split(':')[1] - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss', source_map_url: 'u:blue' @@ -489,7 +489,7 @@ "u:#{url}" }, load: lambda { |*| - return { + { contents: 'a {from: importer}', syntax: 'scss' } } @@ -507,7 +507,7 @@ importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| - return { contents: '$a: value; b {c: $a}', syntax: 'scss' } + { contents: '$a: value; b {c: $a}', syntax: 'scss' } } }] ) @@ -521,7 +521,7 @@ importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| - return { contents: "$a: value\nb\n c: $a", syntax: 'indented' } + { contents: "$a: value\nb\n c: $a", syntax: 'indented' } } }] ) @@ -535,7 +535,7 @@ importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| - return { contents: 'a {b: c}', syntax: 'css' } + { contents: 'a {b: c}', syntax: 'css' } } }] ) @@ -550,7 +550,7 @@ importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| - return { contents: "$a: value\nb\n c: $a", syntax: 'css' } + { contents: "$a: value\nb\n c: $a", syntax: 'css' } } }] ) @@ -569,7 +569,7 @@ }, load: lambda { |url| color = url.split(':')[1] - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss' } @@ -589,7 +589,7 @@ url }, load: lambda { |_url| - return { + { contents: 'a {from: relative}', syntax: 'scss' } @@ -627,7 +627,7 @@ }, load: lambda { |url| color = url.split(':')[1] - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss' } @@ -657,13 +657,13 @@ load: lambda { |url| pathname = url.split(':')[1] if pathname == 'midstream' - return { + { contents: "@import 'orange';", syntax: 'scss' } else color = pathname - return { + { contents: ".#{color} {color: #{color}}", syntax: 'scss' } @@ -688,7 +688,7 @@ url if url.start_with?('first:') }, load: lambda { |*| - return { + { contents: 'a {from: first}', syntax: 'scss' } @@ -701,7 +701,7 @@ url if url.start_with?('second:') }, load: lambda { |*| - return { + { contents: '@import "first:other";', syntax: 'scss' } @@ -721,7 +721,7 @@ def expect_from_import(canonicalize, expected) } { canonicalize: canonicalize, - load: ->(*) { return { contents: '', syntax: 'scss' } } + load: ->(*) { { contents: '', syntax: 'scss' } } } end @@ -1061,7 +1061,7 @@ def expect_from_import(canonicalize, expected) dir.url('other') }, load: lambda { |*| - return { contents: 'a {b: c}', syntax: 'scss' } + { contents: 'a {b: c}', syntax: 'scss' } } }] ) @@ -1077,7 +1077,7 @@ def expect_from_import(canonicalize, expected) importers: [{ canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| - return { + { contents: StringIO.new('not a string'), syntax: 'scss' } @@ -1097,7 +1097,7 @@ def expect_from_import(canonicalize, expected) importers: [{ canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| - return { + { contents: '', syntax: 'scss', source_map_url: {} From 2005736e88ad248471a1274af681c6e071b884c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Dec 2023 13:06:29 -0800 Subject: [PATCH 269/700] Close global compiler before Process.fork --- lib/sass/embedded.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 6172d522..e7157936 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -54,11 +54,20 @@ def instance @mutex.synchronize do return @instance if @instance - @instance = Compiler.new + instance = Compiler.new + + Process.singleton_class.prepend(Module.new do + define_method :_fork do + instance.close + super() + end + end) + at_exit do - @instance.close + instance.close end - @instance + + @instance = instance end end end From 4ae0d84d17753cdbba65d0fd13d3596a612330af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Dec 2023 13:20:12 -0800 Subject: [PATCH 270/700] Rename a variable --- lib/sass/embedded.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index e7157936..53668316 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -13,7 +13,7 @@ # @example # Sass.compile_string('h1 { font-size: 40px; }') module Sass - @instance = nil + @compiler = nil @mutex = Mutex.new # rubocop:disable Layout/LineLength @@ -25,7 +25,7 @@ class << self # @raise (see Compiler#compile) # @see Compiler#compile def compile(...) - instance.compile(...) + compiler.compile(...) end # Compiles a stylesheet whose contents is +source+ to CSS. @@ -35,7 +35,7 @@ def compile(...) # @raise (see Compiler#compile_string) # @see Compiler#compile_string def compile_string(...) - instance.compile_string(...) + compiler.compile_string(...) end # @param (see Compiler#info) @@ -43,31 +43,31 @@ def compile_string(...) # @raise (see Compiler#info) # @see Compiler#info def info - instance.info + compiler.info end private - def instance - return @instance if @instance + def compiler + return @compiler if @compiler @mutex.synchronize do - return @instance if @instance + return @compiler if @compiler - instance = Compiler.new + compiler = Compiler.new Process.singleton_class.prepend(Module.new do define_method :_fork do - instance.close + compiler.close super() end end) at_exit do - instance.close + compiler.close end - @instance = instance + @compiler = compiler end end end From a81f9bb8522b3401c6e90cf02e8a972fe3d7b432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Dec 2023 15:31:34 -0800 Subject: [PATCH 271/700] Support idle_timeout in global compiler (#175) --- lib/sass/compiler.rb | 2 +- lib/sass/compiler/dispatcher.rb | 8 ++++- lib/sass/compiler/resilient_dispatcher.rb | 7 +++-- lib/sass/embedded.rb | 38 ++++++++++++++++++++++- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index ee2020f0..928821ab 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -26,7 +26,7 @@ module Sass # sass.close class Compiler def initialize - @dispatcher = ResilientDispatcher.new + @dispatcher = ResilientDispatcher.new(Dispatcher) end # Compiles the Sass file at +path+ to CSS. diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index 510bb7fe..231de651 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -35,7 +35,7 @@ def unsubscribe(id) close end else - @id = 1 + idle end end end @@ -90,6 +90,12 @@ def send_proto(...) @connection.write(...) end + private + + def idle + @id = 1 + end + # The {Channel} between {Dispatcher} and {Host}. class Channel attr_reader :id diff --git a/lib/sass/compiler/resilient_dispatcher.rb b/lib/sass/compiler/resilient_dispatcher.rb index c1c53be5..abc382ff 100644 --- a/lib/sass/compiler/resilient_dispatcher.rb +++ b/lib/sass/compiler/resilient_dispatcher.rb @@ -6,8 +6,9 @@ class Compiler # # It recovers from failures and continues to function. class ResilientDispatcher - def initialize - @dispatcher = Dispatcher.new + def initialize(dispatcher_class) + @dispatcher_class = dispatcher_class + @dispatcher = @dispatcher_class.new @mutex = Mutex.new end @@ -29,7 +30,7 @@ def connect(...) @mutex.synchronize do @dispatcher.connect(...) rescue Errno::EBUSY - @dispatcher = Dispatcher.new + @dispatcher = @dispatcher_class.new @dispatcher.connect(...) end end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 53668316..e8e39553 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -54,7 +54,43 @@ def compiler @mutex.synchronize do return @compiler if @compiler - compiler = Compiler.new + compiler = Class.new(Compiler) do + def initialize + @dispatcher = self.class.const_get(:ResilientDispatcher).new(Class.new(self.class.const_get(:Dispatcher)) do + def initialize + super + + idle_timeout = 10 + @last_accessed_time = current_time + + Thread.new do + duration = idle_timeout + loop do + sleep(duration.negative? ? idle_timeout : duration) + evicted = @mutex.synchronize do + duration = idle_timeout - (current_time - @last_accessed_time) + @id = 0xffffffff if @observers.empty? && duration.negative? + end + break if evicted + end + close + end + end + + private + + def idle + super + + @last_accessed_time = current_time + end + + def current_time + Process.clock_gettime(Process::CLOCK_MONOTONIC) + end + end) + end + end.new Process.singleton_class.prepend(Module.new do define_method :_fork do From 9e6fbd8a42f6c88c660fde59586e83686a3880e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Dec 2023 16:03:35 -0800 Subject: [PATCH 272/700] Remove Embedded.new method --- lib/sass/embedded.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index e8e39553..ddd78f8d 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -108,14 +108,4 @@ def current_time end end # rubocop:enable Layout/LineLength - - # The {Embedded} module. - module Embedded - module_function - - # @deprecated Use {Compiler.new} instead. - def new - Compiler.new - end - end end From 632498b22b5e775ea9bfc1a7eeb61dd3c5d65c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Dec 2023 20:05:04 -0800 Subject: [PATCH 273/700] Remove duplicated require --- lib/sass/compiler.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 928821ab..00bb6037 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -9,7 +9,6 @@ require_relative 'compiler/resilient_dispatcher' require_relative 'compiler/varint' require_relative 'embedded_protocol' -require_relative 'embedded/version' require_relative 'logger/silent' require_relative 'logger/source_location' require_relative 'logger/source_span' From 42771ac09b001213b99b2b8386406555d2ae162b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 12:53:49 -0800 Subject: [PATCH 274/700] Update embedded.rb --- lib/sass/embedded.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index ddd78f8d..14e6776e 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -56,7 +56,7 @@ def compiler compiler = Class.new(Compiler) do def initialize - @dispatcher = self.class.const_get(:ResilientDispatcher).new(Class.new(self.class.const_get(:Dispatcher)) do + @dispatcher = Compiler.const_get(:ResilientDispatcher).new(Class.new(Compiler.const_get(:Dispatcher)) do def initialize super From 97c76dbe0c6262b39d0d422438e87227e18ddb67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 13:34:47 -0800 Subject: [PATCH 275/700] Set thread names --- lib/sass/compiler/connection.rb | 3 +++ lib/sass/embedded.rb | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 8a5977d3..9899e3df 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -22,8 +22,10 @@ def initialize(dispatcher) Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) end @stdin.binmode + @wait_thread.name = 'sass-embedded-process-waiter' Thread.new do + Thread.current.name = 'sass-embedded-process-stdout-poller' stdout.binmode loop do length = Varint.read(stdout) @@ -38,6 +40,7 @@ def initialize(dispatcher) end Thread.new do + Thread.current.name = 'sass-embedded-process-stderr-poller' loop do warn(stderr.readline, uplevel: 1) rescue IOError, Errno::EBADF diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 14e6776e..95081829 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -64,6 +64,7 @@ def initialize @last_accessed_time = current_time Thread.new do + Thread.current.name = 'sass-embedded-process-reaper' duration = idle_timeout loop do sleep(duration.negative? ? idle_timeout : duration) From 990870d78e46033dc798d11a9d027c33593f447f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 14:57:37 -0800 Subject: [PATCH 276/700] Avoid leaking file descriptors after Process.fork --- lib/sass/compiler/connection.rb | 18 ++++++++++-------- lib/sass/compiler/dispatcher.rb | 3 +++ lib/sass/embedded.rb | 5 +++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 9899e3df..fe723270 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -12,7 +12,7 @@ class Compiler class Connection def initialize(dispatcher) @mutex = Mutex.new - @stdin, stdout, stderr, @wait_thread = begin + @stdin, @stdout, @stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) rescue Errno::ENOENT require_relative '../elf' @@ -26,33 +26,35 @@ def initialize(dispatcher) Thread.new do Thread.current.name = 'sass-embedded-process-stdout-poller' - stdout.binmode + @stdout.binmode loop do - length = Varint.read(stdout) - id = Varint.read(stdout) - proto = stdout.read(length - Varint.length(id)) + length = Varint.read(@stdout) + id = Varint.read(@stdout) + proto = @stdout.read(length - Varint.length(id)) dispatcher.receive_proto(id, proto) rescue IOError, Errno::EBADF, Errno::EPROTO => e dispatcher.error(e) break end - stdout.close + @stdout.close end Thread.new do Thread.current.name = 'sass-embedded-process-stderr-poller' loop do - warn(stderr.readline, uplevel: 1) + warn(@stderr.readline, uplevel: 1) rescue IOError, Errno::EBADF break end - stderr.close + @stderr.close end end def close @stdin.close @wait_thread.join + @stdout.close + @stderr.close end def closed? diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index 231de651..99e14f3e 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -45,6 +45,9 @@ def connect(host) end def close + @mutex.synchronize do + @id = 0xffffffff + end @connection.close end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 95081829..60fe1b4d 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -95,8 +95,9 @@ def current_time Process.singleton_class.prepend(Module.new do define_method :_fork do - compiler.close - super() + pid = super() + compiler.close if pid.zero? + pid end end) From 840a403d61b48377d6e082849696fcb3bf0357f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 18:43:03 -0800 Subject: [PATCH 277/700] Update required_ruby_version from >= 3.0.0 to >= 3.1.3 --- .github/workflows/build.yml | 2 - .rubocop.yml | 2 +- ext/sass/Rakefile | 4 +- lib/sass/compiler.rb | 58 ++++++++++----------- lib/sass/compiler/host.rb | 22 ++++---- lib/sass/compiler/host/function_registry.rb | 4 +- lib/sass/compiler/host/importer_registry.rb | 4 +- lib/sass/value/argument_list.rb | 2 +- lib/sass/value/number.rb | 16 +++--- sass-embedded.gemspec | 2 +- spec/sandbox.rb | 4 +- spec/sass/value/color_spec.rb | 6 +-- spec/sass_compile_spec.rb | 16 +++--- spec/sass_importer_spec.rb | 2 +- 14 files changed, 71 insertions(+), 73 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 329088be..c456f6a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,6 @@ jobs: - ubuntu-latest - windows-latest ruby-version: - - '3.0' - '3.1' - '3.2' - '3.3' @@ -82,7 +81,6 @@ jobs: fail-fast: false matrix: ruby-version: - - '3.0' - '3.1' - '3.2' - '3.3-rc' diff --git a/.rubocop.yml b/.rubocop.yml index d6d29e92..8673806f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ AllCops: - '**/*_pb.rb' - 'vendor/**/*' - TargetRubyVersion: 3.0 + TargetRubyVersion: 3.1 NewCops: enable diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index e8ae1217..663f5b89 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -207,10 +207,10 @@ module FileUtils raise if spec.nil? || source.nil? if Rake::FileUtilsExt.nowrite_flag - installer = Gem::Installer.for_spec(spec, { force: true, install_dir: install_dir }) + installer = Gem::Installer.for_spec(spec, { force: true, install_dir: }) else path = source.download(spec, install_dir) - installer = Gem::Installer.at(path, { force: true, install_dir: install_dir }) + installer = Gem::Installer.at(path, { force: true, install_dir: }) installer.install end diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 00bb6037..57a8c95b 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -75,23 +75,23 @@ def compile(path, raise ArgumentError, 'path must be set' if path.nil? Host.new(@dispatcher).compile_request( - path: path, + path:, source: nil, importer: nil, - load_paths: load_paths, + load_paths:, syntax: nil, url: nil, - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - style: style, - functions: functions, - importers: importers, - alert_color: alert_color, - alert_ascii: alert_ascii, - logger: logger, - quiet_deps: quiet_deps, - verbose: verbose + charset:, + source_map:, + source_map_include_sources:, + style:, + functions:, + importers:, + alert_color:, + alert_ascii:, + logger:, + quiet_deps:, + verbose: ) end @@ -150,22 +150,22 @@ def compile_string(source, Host.new(@dispatcher).compile_request( path: nil, - source: source, - importer: importer, - load_paths: load_paths, - syntax: syntax, - url: url, - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, - style: style, - functions: functions, - importers: importers, - alert_color: alert_color, - alert_ascii: alert_ascii, - logger: logger, - quiet_deps: quiet_deps, - verbose: verbose + source:, + importer:, + load_paths:, + syntax:, + url:, + charset:, + source_map:, + source_map_include_sources:, + style:, + functions:, + importers:, + alert_color:, + alert_ascii:, + logger:, + quiet_deps:, + verbose: ) end diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 9b1e5c8f..6c4be54f 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -37,14 +37,14 @@ def compile_request(path:, compile_response = await do alert_color = $stderr.tty? if alert_color.nil? - @function_registry = FunctionRegistry.new(functions, alert_color: alert_color) - @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color: alert_color) + @function_registry = FunctionRegistry.new(functions, alert_color:) + @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) @logger_registry = LoggerRegistry.new(logger) send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( string: unless source.nil? EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( - source: source, + source:, url: url&.to_s, syntax: Protofier.to_proto_syntax(syntax), importer: (@importer_registry.register(importer) unless importer.nil?) @@ -52,15 +52,15 @@ def compile_request(path:, end, path: (File.absolute_path(path) unless path.nil?), style: Protofier.to_proto_output_style(style), - charset: charset, - source_map: source_map, - source_map_include_sources: source_map_include_sources, + charset:, + source_map:, + source_map_include_sources:, importers: @importer_registry.importers, global_functions: @function_registry.global_functions, - alert_ascii: alert_ascii, - alert_color: alert_color, - quiet_deps: quiet_deps, - verbose: verbose + alert_ascii:, + alert_color:, + quiet_deps:, + verbose: )) end @@ -70,7 +70,7 @@ def compile_request(path:, def version_request version_response = await0 do send_message0(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( - id: id + id: )) end diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 0747336c..26fa3f7d 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -55,8 +55,8 @@ def function_call(function_call_request) EmbeddedProtocol::InboundMessage::FunctionCallResponse.new( id: function_call_request.id, - success: success, - accessed_argument_lists: accessed_argument_lists + success:, + accessed_argument_lists: ) rescue StandardError => e EmbeddedProtocol::InboundMessage::FunctionCallResponse.new( diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index e6d7cb1d..56e72706 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -65,7 +65,7 @@ def canonicalize(canonicalize_request) EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( id: canonicalize_request.id, - url: url + url: ) rescue StandardError => e EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( @@ -100,7 +100,7 @@ def file_import(file_import_request) EmbeddedProtocol::InboundMessage::FileImportResponse.new( id: file_import_request.id, - file_url: file_url + file_url: ) rescue StandardError => e EmbeddedProtocol::InboundMessage::FileImportResponse.new( diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 018fed38..95eb819f 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -13,7 +13,7 @@ class ArgumentList < Value::List # @param keywords [Hash<::String, Value>] # @param separator [::String] def initialize(contents = [], keywords = {}, separator = ',') - super(contents, separator: separator) + super(contents, separator:) @id = 0 @keywords_accessed = false diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index ec53dd25..d58fc574 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -183,7 +183,7 @@ def convert(new_numerator_units, new_denominator_units, name = nil) def convert_value(new_numerator_units, new_denominator_units, name = nil) coerce_or_convert_value(new_numerator_units, new_denominator_units, coerce_unitless: false, - name: name) + name:) end # @param other [Number] @@ -200,9 +200,9 @@ def convert_to_match(other, name = nil, other_name = nil) def convert_value_to_match(other, name = nil, other_name = nil) coerce_or_convert_value(other.numerator_units, other.denominator_units, coerce_unitless: false, - name: name, - other: other, - other_name: other_name) + name:, + other:, + other_name:) end # @param new_numerator_units [Array<::String>] @@ -221,7 +221,7 @@ def coerce(new_numerator_units, new_denominator_units, name = nil) def coerce_value(new_numerator_units, new_denominator_units, name = nil) coerce_or_convert_value(new_numerator_units, new_denominator_units, coerce_unitless: true, - name: name) + name:) end # @param unit [::String] @@ -244,9 +244,9 @@ def coerce_to_match(other, name = nil, other_name = nil) def coerce_value_to_match(other, name = nil, other_name = nil) coerce_or_convert_value(other.numerator_units, other.denominator_units, coerce_unitless: true, - name: name, - other: other, - other_name: other_name) + name:, + other:, + other_name:) end # @return [Number] diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index b294a853..0a1b12ea 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA ] end - spec.required_ruby_version = '>= 3.0.0' + spec.required_ruby_version = '>= 3.1.3' spec.add_runtime_dependency 'google-protobuf', '~> 3.24' spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') diff --git a/spec/sandbox.rb b/spec/sandbox.rb index 8ac0a69b..ef5ebd20 100644 --- a/spec/sandbox.rb +++ b/spec/sandbox.rb @@ -38,8 +38,8 @@ def write(paths) end end - def chdir(&block) - Dir.chdir @root, &block + def chdir(&) + Dir.chdir(@root, &) end private diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb index 779b21d4..b83587fb 100644 --- a/spec/sass/value/color_spec.rb +++ b/spec/sass/value/color_spec.rb @@ -4,15 +4,15 @@ describe Sass::Value::Color do def rgb(red, green, blue, alpha = nil) - Sass::Value::Color.new(red: red, green: green, blue: blue, alpha: alpha) + Sass::Value::Color.new(red:, green:, blue:, alpha:) end def hsl(hue, saturation, lightness, alpha = nil) - Sass::Value::Color.new(hue: hue, saturation: saturation, lightness: lightness, alpha: alpha) + Sass::Value::Color.new(hue:, saturation:, lightness:, alpha:) end def hwb(hue, whiteness, blackness, alpha = nil) - Sass::Value::Color.new(hue: hue, whiteness: whiteness, blackness: blackness, alpha: alpha) + Sass::Value::Color.new(hue:, whiteness:, blackness:, alpha:) end describe 'construction' do diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index ff9f2893..85aca9c0 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -41,7 +41,7 @@ it 'contains the URL if one is passed' do url = 'file:///foo.scss' - expect(described_class.compile_string('a {b: c}', url: url).loaded_urls) + expect(described_class.compile_string('a {b: c}', url:).loaded_urls) .to eq([url]) end @@ -49,7 +49,7 @@ sandbox do |dir| url = dir.url('input.scss') dir.write({ '_other.scss' => 'a {b: c}' }) - expect(described_class.compile_string('@use "other"', url: url).loaded_urls) + expect(described_class.compile_string('@use "other"', url:).loaded_urls) .to eq([ url, dir.url('_other.scss') @@ -64,7 +64,7 @@ '_midstream.scss' => '@use "upstream"', '_upstream.scss' => 'a {b: c}' }) - expect(described_class.compile_string('@use "midstream"', url: url).loaded_urls) + expect(described_class.compile_string('@use "midstream"', url:).loaded_urls) .to eq([ url, dir.url('_midstream.scss'), @@ -82,7 +82,7 @@ '_right.scss' => '@use "upstream"', '_upstream.scss' => 'a {b: c}' }) - expect(described_class.compile_string('@use "left"; @use "right"', url: url).loaded_urls) + expect(described_class.compile_string('@use "left"; @use "right"', url:).loaded_urls) .to eq([ url, dir.url('_left.scss'), @@ -100,7 +100,7 @@ '_right.scss' => '@import "upstream"', '_upstream.scss' => 'a {b: c}' }) - expect(described_class.compile_string('@import "left"; @import "right"', url: url).loaded_urls) + expect(described_class.compile_string('@import "left"; @import "right"', url:).loaded_urls) .to eq([ url, dir.url('_left.scss'), @@ -251,7 +251,7 @@ it 'in syntax errors' do sandbox do |dir| url = dir.url('foo.scss') - expect { described_class.compile_string('a {b:', url: url) } + expect { described_class.compile_string('a {b:', url:) } .to raise_sass_compile_error.with_line(0).with_url(url) end end @@ -259,7 +259,7 @@ it 'in runtime errors' do sandbox do |dir| url = dir.url('foo.scss') - expect { described_class.compile_string('@error "oh no"', url: url) } + expect { described_class.compile_string('@error "oh no"', url:) } .to raise_sass_compile_error.with_line(0).with_url(url) end end @@ -267,7 +267,7 @@ it 'with multi-span errors' do sandbox do |dir| url = dir.url('foo.scss') - expect { described_class.compile_string('@use "sass:math"; @use "sass:math"', url: url) } + expect { described_class.compile_string('@use "sass:math"; @use "sass:math"', url:) } .to raise_sass_compile_error.with_line(0).with_url(url) end end diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 77d2d0b7..3e20bae4 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -720,7 +720,7 @@ def expect_from_import(canonicalize, expected) "u:#{url}" } { - canonicalize: canonicalize, + canonicalize:, load: ->(*) { { contents: '', syntax: 'scss' } } } end From 223e0728afe441beeacc0f713ae4c7d24808089a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 22:00:43 -0800 Subject: [PATCH 278/700] Handle Process.fork for all compiler instances --- lib/sass/compiler.rb | 1 + lib/sass/compiler/dispatcher.rb | 2 ++ lib/sass/embedded.rb | 8 ------ lib/sass/fork_tracker.rb | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 lib/sass/fork_tracker.rb diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 57a8c95b..daf82fad 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -9,6 +9,7 @@ require_relative 'compiler/resilient_dispatcher' require_relative 'compiler/varint' require_relative 'embedded_protocol' +require_relative 'fork_tracker' require_relative 'logger/silent' require_relative 'logger/source_location' require_relative 'logger/source_span' diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index 99e14f3e..b57bebf0 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -11,6 +11,7 @@ def initialize @observers = {} @mutex = Mutex.new @connection = Connection.new(self) + ForkTracker.add(self) end def subscribe(observer) @@ -49,6 +50,7 @@ def close @id = 0xffffffff end @connection.close + ForkTracker.delete(self) end def closed? diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 60fe1b4d..c78fc881 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -93,14 +93,6 @@ def current_time end end.new - Process.singleton_class.prepend(Module.new do - define_method :_fork do - pid = super() - compiler.close if pid.zero? - pid - end - end) - at_exit do compiler.close end diff --git a/lib/sass/fork_tracker.rb b/lib/sass/fork_tracker.rb new file mode 100644 index 00000000..92355aa5 --- /dev/null +++ b/lib/sass/fork_tracker.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Sass + # The {ForkTracker} module. + # + # It tracks objects that need to be closed after `Process.fork`. + module ForkTracker + @mutex = Mutex.new + @hash = {}.compare_by_identity + + class << self + def add(obj) + @mutex.synchronize do + @hash[obj] = true + end + end + + def delete(obj) + @mutex.synchronize do + @hash.delete(obj) + end + end + + def each(...) + @mutex.synchronize do + @hash.keys + end.each(...) + end + end + + # The {CoreExt} module. + # + # It closes objects after `Process.fork`. + module CoreExt + def _fork + pid = super + ForkTracker.each(&:close) if pid.zero? + pid + end + end + + private_constant :CoreExt + + Process.singleton_class.prepend(CoreExt) + end + + private_constant :ForkTracker +end From 8ef0da53d7d0fa56f0923573f90d7845d2465baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 23:00:48 -0800 Subject: [PATCH 279/700] Fix flaky Errno::EBADF on truffleruby --- lib/sass/compiler/connection.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index fe723270..4aca5ce6 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -36,7 +36,9 @@ def initialize(dispatcher) dispatcher.error(e) break end - @stdout.close + @mutex.synchronize do + @stdout.close + end end Thread.new do @@ -46,19 +48,25 @@ def initialize(dispatcher) rescue IOError, Errno::EBADF break end - @stderr.close + @mutex.synchronize do + @stderr.close + end end end def close - @stdin.close - @wait_thread.join - @stdout.close - @stderr.close + @mutex.synchronize do + @stdin.close + @wait_thread.join + @stdout.close + @stderr.close + end end def closed? - @stdin.closed? && !@wait_thread.alive? + @mutex.synchronize do + @stdin.closed? && !@wait_thread.alive? + end end def write(id, proto) From ebc008415881b8a61c66da0da0b00d0b6184a619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Dec 2023 23:54:13 -0800 Subject: [PATCH 280/700] Refactor --- lib/sass/compiler/connection.rb | 3 ++- lib/sass/compiler/dispatcher.rb | 26 +++++++++++++++++++------- lib/sass/embedded.rb | 4 ++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 4aca5ce6..31b6c445 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -22,7 +22,6 @@ def initialize(dispatcher) Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) end @stdin.binmode - @wait_thread.name = 'sass-embedded-process-waiter' Thread.new do Thread.current.name = 'sass-embedded-process-stdout-poller' @@ -52,6 +51,8 @@ def initialize(dispatcher) @stderr.close end end + + @wait_thread.name = 'sass-embedded-process-waiter' end def close diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index b57bebf0..a6842ffb 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -16,7 +16,7 @@ def initialize def subscribe(observer) @mutex.synchronize do - raise Errno::EBUSY if @id == 0xffffffff + raise Errno::EBUSY if _closed? id = @id @id = id.next @@ -29,14 +29,14 @@ def unsubscribe(id) @mutex.synchronize do @observers.delete(id) - return unless @observers.empty? + return unless _idle? - if @id == 0xffffffff + if _closed? Thread.new do close end else - idle + _idle end end end @@ -47,7 +47,7 @@ def connect(host) def close @mutex.synchronize do - @id = 0xffffffff + _close end @connection.close ForkTracker.delete(self) @@ -59,7 +59,7 @@ def closed? def error(error) observers = @mutex.synchronize do - @id = 0xffffffff + _close @observers.values end @@ -97,10 +97,22 @@ def send_proto(...) private - def idle + def _close + @id = 0xffffffff + end + + def _closed? + @id == 0xffffffff + end + + def _idle @id = 1 end + def _idle? + @observers.empty? + end + # The {Channel} between {Dispatcher} and {Host}. class Channel attr_reader :id diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index c78fc881..f5682098 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -70,7 +70,7 @@ def initialize sleep(duration.negative? ? idle_timeout : duration) evicted = @mutex.synchronize do duration = idle_timeout - (current_time - @last_accessed_time) - @id = 0xffffffff if @observers.empty? && duration.negative? + _close if _idle? && duration.negative? end break if evicted end @@ -80,7 +80,7 @@ def initialize private - def idle + def _idle super @last_accessed_time = current_time From 8b7a646ae988dc885e944bd48db9c1d628015e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 00:25:37 -0800 Subject: [PATCH 281/700] Use constant instead of module instance variable --- lib/sass/fork_tracker.rb | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/sass/fork_tracker.rb b/lib/sass/fork_tracker.rb index 92355aa5..4c84dc24 100644 --- a/lib/sass/fork_tracker.rb +++ b/lib/sass/fork_tracker.rb @@ -5,29 +5,32 @@ module Sass # # It tracks objects that need to be closed after `Process.fork`. module ForkTracker - @mutex = Mutex.new - @hash = {}.compare_by_identity - - class << self - def add(obj) - @mutex.synchronize do - @hash[obj] = true - end - end + HASH = {}.compare_by_identity + + MUTEX = Mutex.new + + private_constant :HASH, :MUTEX + + module_function - def delete(obj) - @mutex.synchronize do - @hash.delete(obj) - end + def add(obj) + MUTEX.synchronize do + HASH[obj] = true end + end - def each(...) - @mutex.synchronize do - @hash.keys - end.each(...) + def delete(obj) + MUTEX.synchronize do + HASH.delete(obj) end end + def each(...) + MUTEX.synchronize do + HASH.keys + end.each(...) + end + # The {CoreExt} module. # # It closes objects after `Process.fork`. From c350e706d35b0d9746215223855d70481fbaf054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 09:20:44 -0800 Subject: [PATCH 282/700] Improve poller performance by rescue only once --- lib/sass/compiler/connection.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 31b6c445..a54a2e40 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -31,10 +31,9 @@ def initialize(dispatcher) id = Varint.read(@stdout) proto = @stdout.read(length - Varint.length(id)) dispatcher.receive_proto(id, proto) - rescue IOError, Errno::EBADF, Errno::EPROTO => e - dispatcher.error(e) - break end + rescue IOError, Errno::EBADF, Errno::EPROTO => e + dispatcher.error(e) @mutex.synchronize do @stdout.close end @@ -44,9 +43,8 @@ def initialize(dispatcher) Thread.current.name = 'sass-embedded-process-stderr-poller' loop do warn(@stderr.readline, uplevel: 1) - rescue IOError, Errno::EBADF - break end + rescue IOError, Errno::EBADF @mutex.synchronize do @stderr.close end From d37d05df2ad112a94550ed893d0ae9f169635df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 10:17:36 -0800 Subject: [PATCH 283/700] Add comments on running dart devtools --- lib/sass/compiler/connection.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index a54a2e40..e9736ce8 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -21,11 +21,20 @@ def initialize(dispatcher) Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) end + @stdin.binmode Thread.new do Thread.current.name = 'sass-embedded-process-stdout-poller' + + # # https://dart.dev/tools/dart-devtools + # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') + # warn(@stdout.readline, uplevel: 1) + # warn(@stdout.readline, uplevel: 1) + # end + @stdout.binmode + loop do length = Varint.read(@stdout) id = Varint.read(@stdout) From 9bd0454da1e74f88f4f1d45975560dd5101687d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 10:48:26 -0800 Subject: [PATCH 284/700] Warn with uplevel 0 --- lib/sass/compiler/connection.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index e9736ce8..78bf93cf 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -29,8 +29,8 @@ def initialize(dispatcher) # # https://dart.dev/tools/dart-devtools # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') - # warn(@stdout.readline, uplevel: 1) - # warn(@stdout.readline, uplevel: 1) + # warn(@stdout.readline, uplevel: 0) + # warn(@stdout.readline, uplevel: 0) # end @stdout.binmode @@ -51,7 +51,7 @@ def initialize(dispatcher) Thread.new do Thread.current.name = 'sass-embedded-process-stderr-poller' loop do - warn(@stderr.readline, uplevel: 1) + warn(@stderr.readline, uplevel: 0) end rescue IOError, Errno::EBADF @mutex.synchronize do From a338da8cdc6abc3ea2bec75410f80a73daae3239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 11:33:43 -0800 Subject: [PATCH 285/700] Update embedded.rb --- lib/sass/embedded.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index f5682098..0d2483a8 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -68,11 +68,11 @@ def initialize duration = idle_timeout loop do sleep(duration.negative? ? idle_timeout : duration) - evicted = @mutex.synchronize do + reaped = @mutex.synchronize do duration = idle_timeout - (current_time - @last_accessed_time) - _close if _idle? && duration.negative? + duration.negative? && _idle? && _close end - break if evicted + break if reaped end close end From 8541d6a219dc26266a108f8b344b5c0b769114ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 11:35:34 -0800 Subject: [PATCH 286/700] Update embedded.rb --- lib/sass/embedded.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 0d2483a8..7d2339d0 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -68,11 +68,10 @@ def initialize duration = idle_timeout loop do sleep(duration.negative? ? idle_timeout : duration) - reaped = @mutex.synchronize do + break if @mutex.synchronize do duration = idle_timeout - (current_time - @last_accessed_time) duration.negative? && _idle? && _close end - break if reaped end close end From 95fea6f53660f5969a3c5ef6058ce2ea63fa827b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 15:19:03 -0800 Subject: [PATCH 287/700] Update google-protobuf requirement from ~> 3.24 to ~> 3.25 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 0a1b12ea..2a36dcaf 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -36,6 +36,6 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.required_ruby_version = '>= 3.1.3' - spec.add_runtime_dependency 'google-protobuf', '~> 3.24' + spec.add_runtime_dependency 'google-protobuf', '~> 3.25' spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') end From 2e9d41190d074e8135de0cf70623d7bc613e10d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 18:07:38 -0800 Subject: [PATCH 288/700] Add pid to thread name --- lib/sass/compiler/connection.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 78bf93cf..f3e0ac0d 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -25,7 +25,7 @@ def initialize(dispatcher) @stdin.binmode Thread.new do - Thread.current.name = 'sass-embedded-process-stdout-poller' + Thread.current.name = "sass-embedded-process-stdout-poller-#{@wait_thread.pid}" # # https://dart.dev/tools/dart-devtools # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') @@ -49,7 +49,7 @@ def initialize(dispatcher) end Thread.new do - Thread.current.name = 'sass-embedded-process-stderr-poller' + Thread.current.name = "sass-embedded-process-stderr-poller-#{@wait_thread.pid}" loop do warn(@stderr.readline, uplevel: 0) end @@ -59,7 +59,7 @@ def initialize(dispatcher) end end - @wait_thread.name = 'sass-embedded-process-waiter' + @wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}" end def close From f292bb4fc51deb0b5898ed9f65f01886d0179599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Dec 2023 18:30:02 -0800 Subject: [PATCH 289/700] Add spec for Process.fork --- spec/sass_fork_spec.rb | 224 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 spec/sass_fork_spec.rb diff --git a/spec/sass_fork_spec.rb b/spec/sass_fork_spec.rb new file mode 100644 index 00000000..17d21c0d --- /dev/null +++ b/spec/sass_fork_spec.rb @@ -0,0 +1,224 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sass, skip: (Process.respond_to?(:fork) ? false : 'Process.fork is not usable') do + describe 'after fork' do + it 'works in parent process' do + pid = Process.fork do + exit 0 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(described_class.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + end + + it 'works in child process' do + pid = Process.fork do + expect(described_class.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + exit 0 + rescue StandardError + exit 1 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + end + + it 'works in both parent and child process' do + pid = Process.fork do + expect(described_class.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + exit 0 + rescue StandardError + exit 1 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(described_class.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + end + end + + describe 'running compiler after fork' do + it 'remains running in parent process' do + sass = Sass::Compiler.new + expect(sass.closed?).to be(false) + + pid = Process.fork do + exit 0 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(sass.closed?).to be(false) + ensure + sass&.close + end + + it 'is closed in child process' do + sass = Sass::Compiler.new + expect(sass.closed?).to be(false) + + pid = Process.fork do + expect(sass.closed?).to be(true) + exit 0 + rescue StandardError + exit 1 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + ensure + sass&.close + end + + it 'works in parent process' do + sass = Sass::Compiler.new + + pid = Process.fork do + exit 0 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + ensure + sass&.close + end + + it 'works in child process' do + sass = Sass::Compiler.new + + pid = Process.fork do + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + exit 0 + rescue StandardError + exit 1 + ensure + sass.close + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + ensure + sass&.close + end + + it 'works in both parent and child process' do + sass = Sass::Compiler.new + + pid = Process.fork do + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + exit 0 + rescue StandardError + exit 1 + ensure + sass.close + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + ensure + sass&.close + end + end + + describe 'closed compiler after fork' do + it 'remains closed in parent process' do + sass = Sass::Compiler.new + sass.close + expect(sass.closed?).to be(true) + + pid = Process.fork do + exit 0 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(sass.closed?).to be(true) + ensure + sass&.close + end + + it 'remains closed in child process' do + sass = Sass::Compiler.new + sass.close + expect(sass.closed?).to be(true) + + pid = Process.fork do + expect(sass.closed?).to be(true) + exit 0 + rescue StandardError + exit 1 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + ensure + sass&.close + end + + it 'works in parent process' do + sass = Sass::Compiler.new + sass.close + + pid = Process.fork do + exit 0 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + ensure + sass&.close + end + + it 'works in child process' do + sass = Sass::Compiler.new + sass.close + + pid = Process.fork do + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + exit 0 + rescue StandardError + exit 1 + ensure + sass.close + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + ensure + sass&.close + end + + it 'works in both parent and child process' do + sass = Sass::Compiler.new + sass.close + + pid = Process.fork do + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + exit 0 + rescue StandardError + exit 1 + ensure + sass.close + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(sass.compile_string('a {b: c}').css) + .to eq("a {\n b: c;\n}") + ensure + sass&.close + end + end +end From f22a525c344a63937d24ce327ee0184783c15f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 5 Dec 2023 09:02:35 -0800 Subject: [PATCH 290/700] Add CompileError#to_css_string --- lib/sass/compile_error.rb | 70 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 21ae1c96..f0b573dc 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -15,6 +15,7 @@ class CompileError < StandardError # @!visibility private def initialize(message, full_message, sass_stack, span, loaded_urls) super(message) + @full_message = full_message @sass_stack = sass_stack @span = span @@ -23,9 +24,74 @@ def initialize(message, full_message, sass_stack, span, loaded_urls) # @return [String] def full_message(...) - return super(...) if @full_message.nil? + return super if @full_message.nil? + + +@full_message + end + + # @return [String] + def to_css_string + message = full_message(highlight: false).gsub(/\e\[[0-9;]*m/, '') + + <<~CSS + /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ + + body::before { + display: block; + padding: 1em; + margin-bottom: 1em; + border-bottom: 2px solid; + font-family: monospace, monospace; + white-space: pre; + content: #{serialize_quoted_string(message)}; + } + CSS + end + + private + + def serialize_quoted_string(string, force_double_quote: false) + include_single_quote = false + include_double_quote = false - @full_message = +@full_message + buffer = [0] + string.each_codepoint do |codepoint| + case codepoint + when 34 + case + when force_double_quote + buffer << 92 << 34 + when include_single_quote + return serialize_quoted_string(string, force_double_quote: true) + else + include_double_quote = true + buffer << 34 + end + when 39 + case + when force_double_quote + buffer << 39 + when include_double_quote + return serialize_quoted_string(string, force_double_quote: true) + else + include_single_quote = true + buffer << 39 + end + when 92 + buffer << 92 << 92 + else + if (codepoint < 32 && codepoint != 9) || codepoint > 126 + buffer << 92 + buffer.concat(codepoint.to_s(16).codepoints) + buffer << 32 + else + buffer << codepoint + end + end + end + buffer[0] = force_double_quote || !include_double_quote ? 34 : 39 + buffer << buffer[0] + buffer.pack('U*') end end end From 5578a25c17167794c875b432dce7f796e4f22d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 6 Dec 2023 12:16:19 -0800 Subject: [PATCH 291/700] Explictly control full message highlight --- lib/sass/compile_error.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index f0b573dc..76a03e46 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -23,15 +23,20 @@ def initialize(message, full_message, sass_stack, span, loaded_urls) end # @return [String] - def full_message(...) + def full_message(highlight: nil, **) return super if @full_message.nil? - +@full_message + highlight = $stderr.tty? if highlight.nil? + if highlight + +@full_message + else + @full_message.gsub(/\e\[[0-9;]*m/, '') + end end # @return [String] def to_css_string - message = full_message(highlight: false).gsub(/\e\[[0-9;]*m/, '') + message = full_message(highlight: false, order: :top) <<~CSS /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ From 82e4ea65bc041865c11e6a4f08c695261e28bad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 6 Dec 2023 14:26:16 -0800 Subject: [PATCH 292/700] Optimize serialize_quoted_string --- lib/sass/compile_error.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 76a03e46..db624410 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -84,8 +84,10 @@ def serialize_quoted_string(string, force_double_quote: false) end when 92 buffer << 92 << 92 + when 9 + buffer << 9 else - if (codepoint < 32 && codepoint != 9) || codepoint > 126 + if codepoint < 32 || codepoint > 126 buffer << 92 buffer.concat(codepoint.to_s(16).codepoints) buffer << 32 From ca64bf103143b44532f7444df3c322e3cc3b3348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 10:10:09 -0800 Subject: [PATCH 293/700] Use Exception.to_tty? instead of $stderr.tty? for highlighting --- lib/sass/compile_error.rb | 2 +- lib/sass/compiler.rb | 1 + lib/sass/compiler/host.rb | 2 +- lib/sass/core_ext.rb | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 lib/sass/core_ext.rb diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index db624410..bb914a72 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -26,7 +26,7 @@ def initialize(message, full_message, sass_stack, span, loaded_urls) def full_message(highlight: nil, **) return super if @full_message.nil? - highlight = $stderr.tty? if highlight.nil? + highlight = Exception.to_tty? if highlight.nil? if highlight +@full_message else diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index daf82fad..3a9e46a3 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -8,6 +8,7 @@ require_relative 'compiler/host' require_relative 'compiler/resilient_dispatcher' require_relative 'compiler/varint' +require_relative 'core_ext' require_relative 'embedded_protocol' require_relative 'fork_tracker' require_relative 'logger/silent' diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 6c4be54f..c2868727 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -35,7 +35,7 @@ def compile_request(path:, quiet_deps:, verbose:) compile_response = await do - alert_color = $stderr.tty? if alert_color.nil? + alert_color = Exception.to_tty? if alert_color.nil? @function_registry = FunctionRegistry.new(functions, alert_color:) @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) diff --git a/lib/sass/core_ext.rb b/lib/sass/core_ext.rb new file mode 100644 index 00000000..5a81c6f2 --- /dev/null +++ b/lib/sass/core_ext.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +unless Exception.respond_to?(:to_tty?) + # rubocop:disable Style/GlobalStdStream + def Exception.to_tty? + $stderr == STDERR && STDERR.tty? + end + # rubocop:enable Style/GlobalStdStream +end From ccd0858917e369960f44307ed6698f34cfd48b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 12:43:04 -0800 Subject: [PATCH 294/700] Rename to_css_string to to_css --- lib/sass/compile_error.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index bb914a72..7aa05262 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -35,7 +35,7 @@ def full_message(highlight: nil, **) end # @return [String] - def to_css_string + def to_css message = full_message(highlight: false, order: :top) <<~CSS From f50a0002bc24ab12109bac189191a917aca6bab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 12:55:59 -0800 Subject: [PATCH 295/700] Rename a file --- lib/sass/compiler.rb | 2 +- lib/sass/{core_ext.rb => exception.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/sass/{core_ext.rb => exception.rb} (100%) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 3a9e46a3..405aaf98 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -8,7 +8,7 @@ require_relative 'compiler/host' require_relative 'compiler/resilient_dispatcher' require_relative 'compiler/varint' -require_relative 'core_ext' +require_relative 'exception' require_relative 'embedded_protocol' require_relative 'fork_tracker' require_relative 'logger/silent' diff --git a/lib/sass/core_ext.rb b/lib/sass/exception.rb similarity index 100% rename from lib/sass/core_ext.rb rename to lib/sass/exception.rb From 49085a69f869324bb8226600f84b16af157a7e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 13:08:20 -0800 Subject: [PATCH 296/700] Add Serializer module --- lib/sass/compile_error.rb | 50 +--------------------------------- lib/sass/compiler.rb | 1 + lib/sass/serializer.rb | 56 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 49 deletions(-) create mode 100644 lib/sass/serializer.rb diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 7aa05262..064b1a71 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -48,57 +48,9 @@ def to_css border-bottom: 2px solid; font-family: monospace, monospace; white-space: pre; - content: #{serialize_quoted_string(message)}; + content: #{Serializer.dump_quoted_string(message)}; } CSS end - - private - - def serialize_quoted_string(string, force_double_quote: false) - include_single_quote = false - include_double_quote = false - - buffer = [0] - string.each_codepoint do |codepoint| - case codepoint - when 34 - case - when force_double_quote - buffer << 92 << 34 - when include_single_quote - return serialize_quoted_string(string, force_double_quote: true) - else - include_double_quote = true - buffer << 34 - end - when 39 - case - when force_double_quote - buffer << 39 - when include_double_quote - return serialize_quoted_string(string, force_double_quote: true) - else - include_single_quote = true - buffer << 39 - end - when 92 - buffer << 92 << 92 - when 9 - buffer << 9 - else - if codepoint < 32 || codepoint > 126 - buffer << 92 - buffer.concat(codepoint.to_s(16).codepoints) - buffer << 32 - else - buffer << codepoint - end - end - end - buffer[0] = force_double_quote || !include_double_quote ? 34 : 39 - buffer << buffer[0] - buffer.pack('U*') - end end end diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 405aaf98..28cff546 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -14,6 +14,7 @@ require_relative 'logger/silent' require_relative 'logger/source_location' require_relative 'logger/source_span' +require_relative 'serializer' require_relative 'value' module Sass diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb new file mode 100644 index 00000000..204fb1e0 --- /dev/null +++ b/lib/sass/serializer.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Sass + # The {Serializer} module. + module Serializer + module_function + + def dump_quoted_string(string, force_double_quote: false) + include_single_quote = false + include_double_quote = false + + buffer = [0] + string.each_codepoint do |codepoint| + case codepoint + when 34 + case + when force_double_quote + buffer << 92 << 34 + when include_single_quote + return dump_quoted_string(string, force_double_quote: true) + else + include_double_quote = true + buffer << 34 + end + when 39 + case + when force_double_quote + buffer << 39 + when include_double_quote + return dump_quoted_string(string, force_double_quote: true) + else + include_single_quote = true + buffer << 39 + end + when 92 + buffer << 92 << 92 + when 9 + buffer << 9 + else + if codepoint < 32 || codepoint > 126 + buffer << 92 + buffer.concat(codepoint.to_s(16).codepoints) + buffer << 32 + else + buffer << codepoint + end + end + end + buffer[0] = force_double_quote || !include_double_quote ? 34 : 39 + buffer << buffer[0] + buffer.pack('U*') + end + end + + private_constant :Serializer +end From 99a70e98c761a52c8eaf32006279b119a11b44ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 13:10:46 -0800 Subject: [PATCH 297/700] Use inline rubocop:disable --- lib/sass/exception.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 5a81c6f2..52beb7c0 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -1,9 +1,7 @@ # frozen_string_literal: true unless Exception.respond_to?(:to_tty?) - # rubocop:disable Style/GlobalStdStream def Exception.to_tty? - $stderr == STDERR && STDERR.tty? + $stderr == STDERR && STDERR.tty? # rubocop:disable Style/GlobalStdStream end - # rubocop:enable Style/GlobalStdStream end From 046baf1e3426cec80da31c45615f5039f4dac1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 15:31:25 -0800 Subject: [PATCH 298/700] Optimize dump_quoted_string --- lib/sass/serializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index 204fb1e0..c495cc46 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -9,7 +9,7 @@ def dump_quoted_string(string, force_double_quote: false) include_single_quote = false include_double_quote = false - buffer = [0] + buffer = [34] string.each_codepoint do |codepoint| case codepoint when 34 @@ -46,7 +46,7 @@ def dump_quoted_string(string, force_double_quote: false) end end end - buffer[0] = force_double_quote || !include_double_quote ? 34 : 39 + buffer[0] = 39 unless force_double_quote || !include_double_quote buffer << buffer[0] buffer.pack('U*') end From 1cddb71b1f4d1142be0620c60ad5bb5e38bec62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 21:22:01 -0800 Subject: [PATCH 299/700] Set position: static for error css --- lib/sass/compile_error.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 064b1a71..15901581 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -42,6 +42,7 @@ def to_css /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ body::before { + position: static; display: block; padding: 1em; margin-bottom: 1em; From 7d1725d301eff4ed5926680a9079085ed7085944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 21:26:43 -0800 Subject: [PATCH 300/700] Set explict margin for error css --- lib/sass/compile_error.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb index 15901581..d5b771ae 100644 --- a/lib/sass/compile_error.rb +++ b/lib/sass/compile_error.rb @@ -45,7 +45,7 @@ def to_css position: static; display: block; padding: 1em; - margin-bottom: 1em; + margin: 0 0 1em; border-bottom: 2px solid; font-family: monospace, monospace; white-space: pre; From 94838a806e43fc2a3ac6a59f24f5dd5d61510c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 21:56:33 -0800 Subject: [PATCH 301/700] Move exception classes to exception.rb --- lib/sass/compile_error.rb | 57 ---------------------------------- lib/sass/compiler.rb | 1 - lib/sass/exception.rb | 64 +++++++++++++++++++++++++++++++++++++++ lib/sass/script_error.rb | 10 ------ lib/sass/value.rb | 1 - 5 files changed, 64 insertions(+), 69 deletions(-) delete mode 100644 lib/sass/compile_error.rb delete mode 100644 lib/sass/script_error.rb diff --git a/lib/sass/compile_error.rb b/lib/sass/compile_error.rb deleted file mode 100644 index d5b771ae..00000000 --- a/lib/sass/compile_error.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -module Sass - # An exception thrown because a Sass compilation failed. - class CompileError < StandardError - # @return [String, nil] - attr_reader :sass_stack - - # @return [Logger::SourceSpan, nil] - attr_reader :span - - # @return [Array] - attr_reader :loaded_urls - - # @!visibility private - def initialize(message, full_message, sass_stack, span, loaded_urls) - super(message) - - @full_message = full_message - @sass_stack = sass_stack - @span = span - @loaded_urls = loaded_urls - end - - # @return [String] - def full_message(highlight: nil, **) - return super if @full_message.nil? - - highlight = Exception.to_tty? if highlight.nil? - if highlight - +@full_message - else - @full_message.gsub(/\e\[[0-9;]*m/, '') - end - end - - # @return [String] - def to_css - message = full_message(highlight: false, order: :top) - - <<~CSS - /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ - - body::before { - position: static; - display: block; - padding: 1em; - margin: 0 0 1em; - border-bottom: 2px solid; - font-family: monospace, monospace; - white-space: pre; - content: #{Serializer.dump_quoted_string(message)}; - } - CSS - end - end -end diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 28cff546..3e6da9cc 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative 'canonicalize_context' -require_relative 'compile_error' require_relative 'compile_result' require_relative 'compiler/connection' require_relative 'compiler/dispatcher' diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 52beb7c0..7cd54611 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -1,5 +1,69 @@ # frozen_string_literal: true +module Sass + # An exception thrown because a Sass compilation failed. + class CompileError < StandardError + # @return [String, nil] + attr_reader :sass_stack + + # @return [Logger::SourceSpan, nil] + attr_reader :span + + # @return [Array] + attr_reader :loaded_urls + + # @!visibility private + def initialize(message, full_message, sass_stack, span, loaded_urls) + super(message) + + @full_message = full_message + @sass_stack = sass_stack + @span = span + @loaded_urls = loaded_urls + end + + # @return [String] + def full_message(highlight: nil, **) + return super if @full_message.nil? + + highlight = Exception.to_tty? if highlight.nil? + if highlight + +@full_message + else + @full_message.gsub(/\e\[[0-9;]*m/, '') + end + end + + # @return [String] + def to_css + message = full_message(highlight: false, order: :top) + + <<~CSS + /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ + + body::before { + position: static; + display: block; + padding: 1em; + margin: 0 0 1em; + border-bottom: 2px solid; + font-family: monospace, monospace; + white-space: pre; + content: #{Serializer.dump_quoted_string(message)}; + } + CSS + end + end + + # An exception thrown by Sass Script. + class ScriptError < StandardError + def initialize(message, name = nil) + super(name.nil? ? message : "$#{name}: #{message}") + end + end +end + +# https://github.com/jruby/jruby/issues/8033 unless Exception.respond_to?(:to_tty?) def Exception.to_tty? $stderr == STDERR && STDERR.tty? # rubocop:disable Style/GlobalStdStream diff --git a/lib/sass/script_error.rb b/lib/sass/script_error.rb deleted file mode 100644 index 924434d3..00000000 --- a/lib/sass/script_error.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -module Sass - # An exception thrown by Sass Script. - class ScriptError < StandardError - def initialize(message, name = nil) - super(name.nil? ? message : "$#{name}: #{message}") - end - end -end diff --git a/lib/sass/value.rb b/lib/sass/value.rb index 3b686298..3f6d7fd8 100644 --- a/lib/sass/value.rb +++ b/lib/sass/value.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative 'calculation_value' -require_relative 'script_error' module Sass # The abstract base class of Sass's value types. From b5dbf244914fb54e263bb35872ea34b7b728e4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 21:58:58 -0800 Subject: [PATCH 302/700] Order require statements --- lib/sass/compiler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 3e6da9cc..e5002436 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -7,8 +7,8 @@ require_relative 'compiler/host' require_relative 'compiler/resilient_dispatcher' require_relative 'compiler/varint' -require_relative 'exception' require_relative 'embedded_protocol' +require_relative 'exception' require_relative 'fork_tracker' require_relative 'logger/silent' require_relative 'logger/source_location' From c14a2b215913c634a90163ab96b2a3703e425260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 7 Dec 2023 23:37:10 -0800 Subject: [PATCH 303/700] Optimize serializer --- lib/sass/serializer.rb | 56 ++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index c495cc46..fc82d5a1 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -5,7 +5,7 @@ module Sass module Serializer module_function - def dump_quoted_string(string, force_double_quote: false) + def dump_quoted_string(string) include_single_quote = false include_double_quote = false @@ -13,25 +13,44 @@ def dump_quoted_string(string, force_double_quote: false) string.each_codepoint do |codepoint| case codepoint when 34 - case - when force_double_quote - buffer << 92 << 34 - when include_single_quote - return dump_quoted_string(string, force_double_quote: true) - else - include_double_quote = true - buffer << 34 - end + return dump_double_quoted_string(string) if include_single_quote + + include_double_quote = true + buffer << 34 when 39 - case - when force_double_quote - buffer << 39 - when include_double_quote - return dump_quoted_string(string, force_double_quote: true) + return dump_double_quoted_string(string) if include_double_quote + + include_single_quote = true + buffer << 39 + when 92 + buffer << 92 << 92 + when 9 + buffer << 9 + else + if codepoint < 32 || codepoint > 126 + buffer << 92 + buffer.concat(codepoint.to_s(16).codepoints) + buffer << 32 else - include_single_quote = true - buffer << 39 + buffer << codepoint end + end + end + if include_double_quote + buffer[0] = 39 + buffer << 39 + else + buffer << 34 + end + buffer.pack('U*') + end + + def dump_double_quoted_string(string) + buffer = [34] + string.each_codepoint do |codepoint| + case codepoint + when 34 + buffer << 92 << 34 when 92 buffer << 92 << 92 when 9 @@ -46,8 +65,7 @@ def dump_quoted_string(string, force_double_quote: false) end end end - buffer[0] = 39 unless force_double_quote || !include_double_quote - buffer << buffer[0] + buffer << 34 buffer.pack('U*') end end From acfb15d6f291befcfff3daa56ef2cf79393fc4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 00:16:04 -0800 Subject: [PATCH 304/700] Update serializer.rb --- lib/sass/serializer.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index fc82d5a1..564fc297 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -6,9 +6,8 @@ module Serializer module_function def dump_quoted_string(string) - include_single_quote = false include_double_quote = false - + include_single_quote = false buffer = [34] string.each_codepoint do |codepoint| case codepoint From 3a2b2d322e074e5a2fea5c7e86b46d4fc0872b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 09:12:54 -0800 Subject: [PATCH 305/700] Add spec for Sass::CompileError#to_css --- spec/sass/compile_error_spec.rb | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 spec/sass/compile_error_spec.rb diff --git a/spec/sass/compile_error_spec.rb b/spec/sass/compile_error_spec.rb new file mode 100644 index 00000000..a1c917e8 --- /dev/null +++ b/spec/sass/compile_error_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sass::CompileError do + describe '.to_css' do + describe 'generates valid css for error message' do + it 'without quotes' do + expect { Sass.compile_string('a { b:') } + .to raise_error(described_class) do |error| + expect(error.full_message).not_to include('"') + expect(error.full_message).not_to include("'") + expect(Sass.compile_string(error.to_css).css).to include(error.message) + end + end + + it 'with double quote' do + expect { Sass.compile_string('a { b: "') } + .to raise_error(described_class) do |error| + expect(error.full_message).to include('"') + expect(error.full_message).not_to include("'") + expect(Sass.compile_string(error.to_css).css).to include(error.message) + end + end + + it 'with single quote' do + expect { Sass.compile_string("a { b: '") } + .to raise_error(described_class) do |error| + expect(error.full_message).to include("'") + expect(error.full_message).not_to include('"') + expect(Sass.compile_string(error.to_css).css).to include(error.message) + end + end + + it 'with double quote and single quote' do + expect { Sass.compile_string("a { b: 'c'") } + .to raise_error(described_class) do |error| + expect(error.full_message).to include("'") + expect(error.full_message).to include('"') + expect(Sass.compile_string(error.to_css).css).to include(error.message) + end + end + + it 'with css comment' do + expect { Sass.compile_string('/* a */ b {') } + .to raise_error(described_class) do |error| + expect(error.full_message).to include('/* a */') + expect(Sass.compile_string(error.to_css).css).to include(error.message) + end + end + end + end +end From d0db532c7465141221af3cc5f0d75347f6a3341a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 10:01:36 -0800 Subject: [PATCH 306/700] Add encoding spec for Sass::CompileError#to_css --- spec/sass/compile_error_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/sass/compile_error_spec.rb b/spec/sass/compile_error_spec.rb index a1c917e8..7e555a7d 100644 --- a/spec/sass/compile_error_spec.rb +++ b/spec/sass/compile_error_spec.rb @@ -49,5 +49,25 @@ end end end + + it 'generates css comment with UTF-8 character set' do + expect { Sass.compile_string('/* コメント */ a {') } + .to raise_error(described_class) do |error| + expect(error.full_message).to include('コメント') + comment = %r{/\*[^*]*\*+([^/*][^*]*\*+)*/}.match(error.to_css)[0] + expect(comment).to include('コメント') + end + end + + it 'generates css rule with US-ASCII character set' do + expect { Sass.compile_string('/* コメント */ a {') } + .to raise_error(described_class) do |error| + expect(error.full_message).to include('コメント') + rule = error.to_css.sub(%r{/\*[^*]*\*+([^/*][^*]*\*+)*/}, '') + expect(rule).not_to include('コメント') + expect(rule.codepoints).to all(be < 128) + expect(Sass.compile_string(rule).css).to include('コメント') + end + end end end From 680a4410561c1fe013263772a9b07f0e429ac428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 14:41:23 -0800 Subject: [PATCH 307/700] Correct function signature in documentation --- lib/sass/exception.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 7cd54611..bc73773a 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -23,7 +23,7 @@ def initialize(message, full_message, sass_stack, span, loaded_urls) end # @return [String] - def full_message(highlight: nil, **) + def full_message(highlight: nil, order: nil, **) return super if @full_message.nil? highlight = Exception.to_tty? if highlight.nil? From 36f8fae1b98fac8754faae6bd5a8f1d267ed7620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 15:07:26 -0800 Subject: [PATCH 308/700] Use fully qualified methods --- exe/sass | 4 ++-- lib/sass/compiler/connection.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exe/sass b/exe/sass index 58b15a55..16e0e5df 100755 --- a/exe/sass +++ b/exe/sass @@ -7,13 +7,13 @@ module Sass # The `sass` command line interface class CLI begin - exec(*COMMAND, *ARGV) + Kernel.exec(*COMMAND, *ARGV) rescue Errno::ENOENT require_relative '../lib/sass/elf' raise if ELF::INTERPRETER.nil? - exec(ELF::INTERPRETER, *COMMAND, *ARGV) + Kernel.exec(ELF::INTERPRETER, *COMMAND, *ARGV) end end diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index f3e0ac0d..04430a17 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -29,8 +29,8 @@ def initialize(dispatcher) # # https://dart.dev/tools/dart-devtools # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') - # warn(@stdout.readline, uplevel: 0) - # warn(@stdout.readline, uplevel: 0) + # Kernel.warn(@stdout.readline, uplevel: 0) + # Kernel.warn(@stdout.readline, uplevel: 0) # end @stdout.binmode @@ -51,7 +51,7 @@ def initialize(dispatcher) Thread.new do Thread.current.name = "sass-embedded-process-stderr-poller-#{@wait_thread.pid}" loop do - warn(@stderr.readline, uplevel: 0) + Kernel.warn(@stderr.readline, uplevel: 0) end rescue IOError, Errno::EBADF @mutex.synchronize do From f9769feaaea902620db509ce3af34db33e928c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 16:58:02 -0800 Subject: [PATCH 309/700] Workaround jruby issue --- lib/sass/compiler/host.rb | 2 +- lib/sass/exception.rb | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index c2868727..d4dae481 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -35,7 +35,7 @@ def compile_request(path:, quiet_deps:, verbose:) compile_response = await do - alert_color = Exception.to_tty? if alert_color.nil? + alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil? @function_registry = FunctionRegistry.new(functions, alert_color:) @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index bc73773a..2d77318d 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -26,7 +26,7 @@ def initialize(message, full_message, sass_stack, span, loaded_urls) def full_message(highlight: nil, order: nil, **) return super if @full_message.nil? - highlight = Exception.to_tty? if highlight.nil? + highlight = Exception.respond_to?(:to_tty?) && Exception.to_tty? if highlight.nil? if highlight +@full_message else @@ -62,10 +62,3 @@ def initialize(message, name = nil) end end end - -# https://github.com/jruby/jruby/issues/8033 -unless Exception.respond_to?(:to_tty?) - def Exception.to_tty? - $stderr == STDERR && STDERR.tty? # rubocop:disable Style/GlobalStdStream - end -end From bddeafd4360fa1270625dd66f73ead7ef2907152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 17:20:10 -0800 Subject: [PATCH 310/700] Update compile_error_spec.rb --- spec/sass/compile_error_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/sass/compile_error_spec.rb b/spec/sass/compile_error_spec.rb index 7e555a7d..447ed4e1 100644 --- a/spec/sass/compile_error_spec.rb +++ b/spec/sass/compile_error_spec.rb @@ -54,7 +54,7 @@ expect { Sass.compile_string('/* コメント */ a {') } .to raise_error(described_class) do |error| expect(error.full_message).to include('コメント') - comment = %r{/\*[^*]*\*+([^/*][^*]*\*+)*/}.match(error.to_css)[0] + comment = error.to_css[%r{/\*[^*]*\*+([^/*][^*]*\*+)*/}] expect(comment).to include('コメント') end end From b2380b96c2e398605f440aaaf1138825a1acd9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 8 Dec 2023 17:36:15 -0800 Subject: [PATCH 311/700] Set explict border for error css --- lib/sass/exception.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 2d77318d..1c44ed66 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -46,7 +46,8 @@ def to_css display: block; padding: 1em; margin: 0 0 1em; - border-bottom: 2px solid; + border-width: 0 0 2px; + border-bottom-style: solid; font-family: monospace, monospace; white-space: pre; content: #{Serializer.dump_quoted_string(message)}; From ad206d2476229f74414650ae0fa222249507a4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 10 Dec 2023 08:20:30 -0800 Subject: [PATCH 312/700] Update Rakefile --- ext/sass/Rakefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 663f5b89..b1c253fb 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -251,8 +251,6 @@ module SassConfig 'arm' when /ppc64le|powerpc64le/ 'powerpc64le' - when /s390x/ - 's390x' else RbConfig::CONFIG['host_cpu'] end From 18be9cb250b21b35820afaae474f0f988b8030dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 10 Dec 2023 08:34:46 -0800 Subject: [PATCH 313/700] Drop support for Windows 10 on ARM (end-of-life) --- ext/sass/Rakefile | 14 +---- ext/sass/win32_api.rb | 133 ------------------------------------------ sass-embedded.gemspec | 3 +- 3 files changed, 2 insertions(+), 148 deletions(-) delete mode 100644 ext/sass/win32_api.rb diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index b1c253fb..c3495f97 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -257,19 +257,7 @@ module SassConfig ARCH = "#{CPU}-#{OS}".freeze - EMULATION = if ARCH == 'aarch64-windows' - begin - require_relative 'win32_api' - - if Win32API.x64? - 'x86_64' - elsif Win32API.x86? - 'i386' - end - rescue LoadError - 'i386' - end - end + EMULATION = ('x86_64' if ARCH == 'aarch64-windows') end private_constant :Platform diff --git a/ext/sass/win32_api.rb b/ext/sass/win32_api.rb deleted file mode 100644 index 792e477f..00000000 --- a/ext/sass/win32_api.rb +++ /dev/null @@ -1,133 +0,0 @@ -# frozen_string_literal: true - -require 'fiddle' - -# @!visibility private -module SassConfig - # @see https://learn.microsoft.com/en-us/windows/win32/api/ - module Win32API - Kernel32 = Fiddle.dlopen('Kernel32.dll') - - # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants - module ImageFileMachineConstants - IMAGE_FILE_MACHINE_I386 = 0x014c - IMAGE_FILE_MACHINE_ARMNT = 0x01c4 - IMAGE_FILE_MACHINE_AMD64 = 0x8664 - IMAGE_FILE_MACHINE_ARM64 = 0xaa64 - end - - private_constant :ImageFileMachineConstants - - # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes - module MachineAttributes - USER_ENABLED = 0x00000001 - KERNEL_ENABLED = 0x00000002 - WOW64_CONTAINER = 0x00000004 - end - - private_constant :MachineAttributes - - # Specifies the ways in which an architecture of code can run on a host operating system. - class MachineTypeAttributes - def initialize(machine_type_attributes) - @machine_type_attributes = machine_type_attributes - end - - # The specified architecture of code can run in user mode. - def user_enabled? - @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED - end - - # The specified architecture of code can run in kernel mode. - def kernel_enabled? - @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED - end - - # The specified architecture of code runs on WOW64. - def wow64_container? - @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER - end - end - - private_constant :MachineTypeAttributes - - class << self - def x86? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled? - end - - def arm? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled? - end - - def x64? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled? - end - - def arm64? - get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled? - end - - private - - begin - # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes - GetMachineTypeAttributes = Fiddle::Function.new( - Kernel32['GetMachineTypeAttributes'], - [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_LONG - ) - - def get_machine_type_attributes(machine) - p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE) - raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero? - - MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i')) - end - rescue Fiddle::DLError - # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess - GetCurrentProcess = Fiddle::Function.new( - Kernel32['GetCurrentProcess'], - [], - Fiddle::TYPE_VOIDP - ) - - # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2 - IsWow64Process2 = Fiddle::Function.new( - Kernel32['IsWow64Process2'], - [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_CHAR - ) - - # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported - IsWow64GuestMachineSupported = Fiddle::Function.new( - Kernel32['IsWow64GuestMachineSupported'], - [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP], - Fiddle::TYPE_LONG - ) - - def get_machine_type_attributes(machine) - h_process = GetCurrentProcess.call - p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) - p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE) - raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero? - - if p_native_machine.to_str.unpack1('S!') == machine - return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED) - end - - p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE) - raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero? - - if p_machine_is_supported.to_str.unpack1('c').zero? - MachineTypeAttributes.new(0) - else - MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER) - end - end - end - end - end - - private_constant :Win32API -end diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 2a36dcaf..2bdd0f0e 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -29,8 +29,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.files += [ 'ext/sass/Rakefile', 'ext/sass/expand-archive.ps1', - 'ext/sass/package.json', - 'ext/sass/win32_api.rb' + 'ext/sass/package.json' ] end From 96dcfefbc3b348b23fb44393c638577b977482f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 07:48:24 -0800 Subject: [PATCH 314/700] Update rubocop requirement from ~> 1.58.0 to ~> 1.59.0 (#177) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.58.0...v1.59.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f3d6838a..4a0ec6e0 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.58.0' + gem 'rubocop', '~> 1.59.0' gem 'rubocop-performance', '~> 1.19.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.25.0' From bb4a6e88fdccbf609fd9fb78fe509632fbc4fde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 11 Dec 2023 16:56:06 -0800 Subject: [PATCH 315/700] Move repo to github org account --- README.md | 2 +- sass-embedded.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f9d663e..d4c0a11e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Embedded Sass Host for Ruby -[![build](https://github.com/ntkme/sass-embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ntkme/sass-embedded-host-ruby/actions/workflows/build.yml) +[![build](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml) [![gem](https://badge.fury.io/rb/sass-embedded.svg)](https://rubygems.org/gems/sass-embedded) This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md). diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 2bdd0f0e..cb9b4dcb 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.email = ['i@ntk.me'] spec.summary = 'Use dart-sass with Ruby!' spec.description = 'A Ruby library that will communicate with Embedded Dart Sass using the Embedded Sass protocol.' - spec.homepage = 'https://github.com/ntkme/sass-embedded-host-ruby' + spec.homepage = 'https://github.com/sass-contrib/sass-embedded-host-ruby' spec.license = 'MIT' spec.metadata = { 'documentation_uri' => "https://rubydoc.info/gems/#{spec.name}/#{spec.version}", From 4131614ca30c6a63a5a1e53abe78eeb3796d49b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 11 Dec 2023 17:08:24 -0800 Subject: [PATCH 316/700] Update repo urls --- ext/sass/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index c3495f97..d7c11674 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -285,10 +285,10 @@ module SassConfig when 'linux' 'linux' when 'linux-android' - repo = 'https://github.com/dart-android/dart-sass' + repo = 'https://github.com/sass-contrib/dart-sass-android' 'android' when 'linux-musl' - repo = 'https://github.com/dart-musl/dart-sass' + repo = 'https://github.com/sass-contrib/dart-sass-musl' 'linux' when 'windows' 'windows' From 1585c2f445ec5d5208911e753daa41f3529ae42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Dec 2023 08:52:59 -0800 Subject: [PATCH 317/700] Add links to js-api-spec --- spec/sass/value/argument_list_spec.rb | 1 + spec/sass/value/boolean_spec.rb | 1 + spec/sass/value/calculation_spec.rb | 1 + spec/sass/value/color_spec.rb | 1 + spec/sass/value/function_spec.rb | 1 + spec/sass/value/list_spec.rb | 1 + spec/sass/value/map_spec.rb | 1 + spec/sass/value/mixin_spec.rb | 1 + spec/sass/value/null_spec.rb | 1 + spec/sass/value/number_spec.rb | 1 + spec/sass/value/string_spec.rb | 1 + spec/sass_compile_spec.rb | 2 ++ spec/sass_function_spec.rb | 1 + spec/sass_importer_spec.rb | 2 ++ spec/sass_logger_spec.rb | 2 ++ 15 files changed, 18 insertions(+) diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index 5d1f7d0f..2e2a006d 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/argument-list.test.ts describe Sass::Value::ArgumentList do it 'passes an argument list' do fn = double diff --git a/spec/sass/value/boolean_spec.rb b/spec/sass/value/boolean_spec.rb index 4979b5bf..c4060e60 100644 --- a/spec/sass/value/boolean_spec.rb +++ b/spec/sass/value/boolean_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/boolean.test.ts describe Sass::Value::Boolean do describe 'sassTrue' do value = Sass::Value::Boolean::TRUE diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 77a9f3af..bd49b293 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/calculation.test.ts describe Sass::Value::Calculation do valid_calculation_values = [ Sass::Value::Number.new(1), diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb index b83587fb..8140e927 100644 --- a/spec/sass/value/color_spec.rb +++ b/spec/sass/value/color_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color.test.ts describe Sass::Value::Color do def rgb(red, green, blue, alpha = nil) Sass::Value::Color.new(red:, green:, blue:, alpha:) diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index 8214e491..42ce4020 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/function.test.ts describe Sass::Value::Function do it 'can round-trip a function reference from Sass' do fn = double diff --git a/spec/sass/value/list_spec.rb b/spec/sass/value/list_spec.rb index c98d199e..8c1a3211 100644 --- a/spec/sass/value/list_spec.rb +++ b/spec/sass/value/list_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/list.test.ts describe Sass::Value::List do describe 'construction' do list = nil diff --git a/spec/sass/value/map_spec.rb b/spec/sass/value/map_spec.rb index 282928f1..cb73d59b 100644 --- a/spec/sass/value/map_spec.rb +++ b/spec/sass/value/map_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/map.test.ts describe Sass::Value::Map do map = nil before do diff --git a/spec/sass/value/mixin_spec.rb b/spec/sass/value/mixin_spec.rb index 478c53d3..15f0dabe 100644 --- a/spec/sass/value/mixin_spec.rb +++ b/spec/sass/value/mixin_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/mixin.test.ts describe Sass::Value::Mixin do it 'can round-trip a mixin reference from Sass' do fn = double diff --git a/spec/sass/value/null_spec.rb b/spec/sass/value/null_spec.rb index 42d2b2ab..549d72dc 100644 --- a/spec/sass/value/null_spec.rb +++ b/spec/sass/value/null_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/null.test.ts describe Sass::Value::Null do value = Sass::Value::Null::NULL diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 6993c618..0df443a8 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/number.test.ts describe Sass::Value::Number do precision = 10 diff --git a/spec/sass/value/string_spec.rb b/spec/sass/value/string_spec.rb index a7e3b7db..bea48b45 100644 --- a/spec/sass/value/string_spec.rb +++ b/spec/sass/value/string_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/string.test.ts describe Sass::Value::String do describe 'construction' do it 'creates a quoted string with the given text' do diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 85aca9c0..8df00795 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -2,6 +2,8 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/compile.node.test.ts +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/compile.test.ts RSpec.describe Sass do describe '.compile_string' do describe 'success' do diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index 533df55e..d2fc079a 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/function.test.ts RSpec.describe Sass do it 'passes an argument to a custom function and uses its return value' do fn = double diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 3e20bae4..e7518742 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -2,6 +2,8 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/importer.node.test.ts +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/importer.test.ts RSpec.describe Sass do it 'uses an importer to resolve an @import' do result = described_class.compile_string( diff --git a/spec/sass_logger_spec.rb b/spec/sass_logger_spec.rb index 5ccfc872..57a842d1 100644 --- a/spec/sass_logger_spec.rb +++ b/spec/sass_logger_spec.rb @@ -2,6 +2,8 @@ require 'spec_helper' +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/logger.node.test.ts +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/logger.test.ts RSpec.describe Sass do it 'emits debug to stderr by default' do stdio = capture_stdio do From ab9f7a66d980d4dca6cb747a90876a657d52c5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 17 Dec 2023 13:09:21 -0800 Subject: [PATCH 318/700] Explict idle check --- lib/sass/compiler/dispatcher.rb | 4 ++-- lib/sass/embedded.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index a6842ffb..d1545356 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -29,7 +29,7 @@ def unsubscribe(id) @mutex.synchronize do @observers.delete(id) - return unless _idle? + return unless @observers.empty? if _closed? Thread.new do @@ -110,7 +110,7 @@ def _idle end def _idle? - @observers.empty? + @id == 1 end # The {Channel} between {Dispatcher} and {Host}. diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 7d2339d0..4b7d724b 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -70,7 +70,7 @@ def initialize sleep(duration.negative? ? idle_timeout : duration) break if @mutex.synchronize do duration = idle_timeout - (current_time - @last_accessed_time) - duration.negative? && _idle? && _close + _closed? || (duration.negative? && _idle? && _close) end end close From eea9016be7a418784abac60be28e01928e428a5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 08:36:03 -0800 Subject: [PATCH 319/700] Update rubocop-performance requirement from ~> 1.19.0 to ~> 1.20.0 (#178) Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.19.0...v1.20.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4a0ec6e0..ee24652d 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' gem 'rubocop', '~> 1.59.0' - gem 'rubocop-performance', '~> 1.19.0' + gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.25.0' end From 1b08edcf7bd39ce31b349902f84140df87a93852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 18 Dec 2023 09:18:56 -0800 Subject: [PATCH 320/700] Fix handling of soft closed dispatcher in reaper --- lib/sass/embedded.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 4b7d724b..0d90fd5a 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -69,11 +69,15 @@ def initialize loop do sleep(duration.negative? ? idle_timeout : duration) break if @mutex.synchronize do + raise Errno::EBUSY if _closed? + duration = idle_timeout - (current_time - @last_accessed_time) - _closed? || (duration.negative? && _idle? && _close) + duration.negative? && _idle? && _close end end close + rescue Errno::EBUSY + # do nothing end end From 6b4dd230ce12c23378411b45b50770da6ec9cf36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 20 Dec 2023 12:21:50 -0800 Subject: [PATCH 321/700] Update CONTRIBUTING.md --- CONTRIBUTING.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fa340b3..ab9eb758 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,3 +25,53 @@ │ │ on polling thread │ │ └─────────────┘ └────────────┘ ``` + +## Host Dispatcher State Diagram + +``` +┌───────────────────┐ ┌─────────┐ +│ │ │ │ +│ Initialize... │ ┌───────────────────► Close │ +│ │ │ │ │ +└─────────┬─────────┘ │ └─────────┘ + │ Yes │ + │ ┌──────────┴─────────┐ ┌─────────┐ +┌─────────▼─────────┐ No │ │ Yes │ │ +│ ◄─────────────────────────────┤ id == 0xFFFFFFFF ◄─────────┤ Idle? ◄──────────┐ +│ id = 0x00000001 │ │ │ │ │ │ +│ ├───────────────┐ └────────────────────┘ └─────────┘ │ +└───────────────────┘ │ │ + ┌────────────▼────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │ + │ │ │ │ │ │ │ + │ CompileRequest(id: 1) ├───► ├───► CompileResponse(id: 1) │ │ + │ │ │ │ │ │ │ + └────────────┬────────────┘ │ │ └─────────────┬────────────┘ │ +┌───────────────────┐ │ │ │ │ │ +│ ◄───────────────┘ │ │ └───────────────┤ +│ id = 0x00000002 │ │ │ │ +│ ├───────────────┐ │ │ │ +└───────────────────┘ │ │ │ │ + ┌────────────▼────────────┐ │ │ ┌──────────────────────────┐ │ + │ │ │ dart │ │ │ │ + │ CompileRequest(id: 2) ├───► ├───► CompileResponse(id: 2) │ │ + │ │ │ sass │ │ │ │ + └────────────┬────────────┘ │ │ └────────────┬─────────────┘ │ +┌───────────────────┐ │ │ embedded │ │ │ +│ ◄───────────────┘ │ │ └────────────────┤ +│ ... │ │ compiler │ │ +│ ├───────────────┐ │ │ │ +└───────────────────┘ │ │ dispatcher │ │ + ┌────────────▼────────────┐ │ │ ┌──────────────────────────┐ │ + │ │ │ │ │ │ │ + │ CompileRequest(.....) ├───► ├───► CompileResponse(.....) │ │ + │ │ │ │ │ │ │ + └────────────┬────────────┘ │ │ └────────────┬─────────────┘ │ +┌───────────────────┐ │ │ │ │ │ +│ ◄───────────────┘ ┌─────────┐ │ │ └────────────────┤ +│ id = 0xFFFFFFFF │ │ │ │ │ │ +│ ◄──────────────────┤ Error ◄───┤ │ │ +└─────────┬─────────┘ │ │ │ │ │ + │ └─────────┘ └──────────────┘ │ + │ │ + └───────────────────────────────────────────────────────────────────────────────────────────┘ +``` From e1d02d6313b78cc1574b7e2b637fd3bdf94c65ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 27 Dec 2023 02:39:44 -0800 Subject: [PATCH 322/700] Test ruby:3.3-alpine --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c456f6a4..000e6ab4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,7 +83,7 @@ jobs: ruby-version: - '3.1' - '3.2' - - '3.3-rc' + - '3.3' steps: - name: Checkout From 8eea31d62cffa1367d4773cd309fc8edf0846267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 27 Dec 2023 09:16:08 -0800 Subject: [PATCH 323/700] Test ruby 3.3 on windows --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 000e6ab4..e4d6eff7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,8 +39,6 @@ jobs: - truffleruby - truffleruby+graalvm exclude: - - os: windows-latest - ruby-version: '3.3' - os: windows-latest ruby-version: truffleruby - os: windows-latest From 82c41a9c05461e88a87eba780186768ecc4e8f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 27 Dec 2023 14:46:50 -0800 Subject: [PATCH 324/700] Update exception.rb --- lib/sass/exception.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 1c44ed66..dd8f6070 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -36,10 +36,10 @@ def full_message(highlight: nil, order: nil, **) # @return [String] def to_css - message = full_message(highlight: false, order: :top) + content = full_message(highlight: false, order: :top) <<~CSS - /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ + /* #{content.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ body::before { position: static; @@ -50,7 +50,7 @@ def to_css border-bottom-style: solid; font-family: monospace, monospace; white-space: pre; - content: #{Serializer.dump_quoted_string(message)}; + content: #{Serializer.dump_quoted_string(content)}; } CSS end From d1e53820349a759fdd8e712faa4550e58a472262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 27 Dec 2023 15:47:40 -0800 Subject: [PATCH 325/700] Fix a potential deadlock after an exception in custom logger --- lib/sass/compiler/dispatcher.rb | 4 ++-- lib/sass/compiler/host.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index d1545356..6bc699a1 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -75,12 +75,12 @@ def error(error) def receive_proto(id, proto) case id when 1...0xffffffff - @mutex.synchronize { @observers[id] }.receive_proto(proto) + @mutex.synchronize { @observers[id] }&.receive_proto(proto) when 0 outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) oneof = outbound_message.message message = outbound_message.public_send(oneof) - @mutex.synchronize { @observers[message.id] }.public_send(oneof, message) + @mutex.synchronize { @observers[message.id] }&.public_send(oneof, message) when 0xffffffff outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto) oneof = outbound_message.message diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index d4dae481..94ca7be1 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -100,6 +100,8 @@ def error(message) def log_event(message) @logger_registry.log(message) + rescue StandardError => e + @channel.error(e) end def canonicalize_request(message) From fc54ef363ad58efbebb604f4e3d3623498f84c68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Dec 2023 17:00:07 -0800 Subject: [PATCH 326/700] Bump sass from 1.69.5 to 1.69.6 in /ext/sass (#179) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump sass from 1.69.5 to 1.69.6 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.69.5 to 1.69.6. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.5...1.69.6) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Switch to official musl and android builds --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- ext/sass/Rakefile | 4 +--- ext/sass/package.json | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index d7c11674..1625b719 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -285,11 +285,9 @@ module SassConfig when 'linux' 'linux' when 'linux-android' - repo = 'https://github.com/sass-contrib/dart-sass-android' 'android' when 'linux-musl' - repo = 'https://github.com/sass-contrib/dart-sass-musl' - 'linux' + 'linux-musl' when 'windows' 'windows' else diff --git a/ext/sass/package.json b/ext/sass/package.json index 9101ffa3..6e46cb84 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.5" + "sass": "1.69.6" } } From fcc2b37426c9d2a634684ffde6ea88734ff2de1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 28 Dec 2023 17:29:47 -0800 Subject: [PATCH 327/700] v1.69.6 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index ac677d40..c58995e9 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.69.5' + VERSION = '1.69.6' end end From 6f783f5ca2fef2ad9b883707a1380368115738e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 28 Dec 2023 21:13:41 -0800 Subject: [PATCH 328/700] Implement .to_s for Sass::Value::String --- lib/sass/serializer.rb | 71 ++++++++++++++++++++++++++++++++++++++-- lib/sass/value/string.rb | 9 +++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index 564fc297..4c4c3bee 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -26,7 +26,7 @@ def dump_quoted_string(string) when 9 buffer << 9 else - if codepoint < 32 || codepoint > 126 + if codepoint < 32 || codepoint >= 127 buffer << 92 buffer.concat(codepoint.to_s(16).codepoints) buffer << 32 @@ -55,7 +55,7 @@ def dump_double_quoted_string(string) when 9 buffer << 9 else - if codepoint < 32 || codepoint > 126 + if codepoint < 32 || codepoint >= 127 buffer << 92 buffer.concat(codepoint.to_s(16).codepoints) buffer << 32 @@ -67,6 +67,73 @@ def dump_double_quoted_string(string) buffer << 34 buffer.pack('U*') end + + def serialize_quoted_string(string) + include_double_quote = false + include_single_quote = false + buffer = [34] + string.each_codepoint do |codepoint| + case codepoint + when 34 + return serialize_double_quoted_string(string) if include_single_quote + + include_double_quote = true + buffer << 34 + when 39 + return serialize_double_quoted_string(string) if include_double_quote + + include_single_quote = true + buffer << 39 + when 92 + buffer << 92 << 92 + when 9 + buffer << 9 + else + if codepoint < 32 || codepoint == 127 + buffer << 92 + buffer.concat(codepoint.to_s(16).codepoints) + buffer << 32 + else + buffer << codepoint + end + end + end + if include_double_quote + buffer[0] = 39 + buffer << 39 + else + buffer << 34 + end + buffer.pack('U*') + end + + def serialize_double_quoted_string(string) + buffer = [34] + string.each_codepoint do |codepoint| + case codepoint + when 34 + buffer << 92 << 34 + when 92 + buffer << 92 << 92 + when 9 + buffer << 9 + else + if codepoint < 32 || codepoint == 127 + buffer << 92 + buffer.concat(codepoint.to_s(16).codepoints) + buffer << 32 + else + buffer << codepoint + end + end + end + buffer << 34 + buffer.pack('U*') + end + + def serialize_unquoted_string(string) + string.gsub(/\n +/, "\n") + end end private_constant :Serializer diff --git a/lib/sass/value/string.rb b/lib/sass/value/string.rb index ef67381e..8df980d2 100644 --- a/lib/sass/value/string.rb +++ b/lib/sass/value/string.rb @@ -59,6 +59,15 @@ def sass_index_to_string_index(sass_index, name = nil) index.negative? ? text.length + index : index - 1 end + + # @return [String] + def to_s + if @quoted + Serializer.serialize_quoted_string(@text) + else + Serializer.serialize_unquoted_string(@text) + end + end end end end From 123e6a0198f159df1499466425a762f6d273fe01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 12:17:12 -0800 Subject: [PATCH 329/700] Add spec for Sass::Value::String.to_s --- spec/sass/value/string_to_s_spec.rb | 111 ++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 spec/sass/value/string_to_s_spec.rb diff --git a/spec/sass/value/string_to_s_spec.rb b/spec/sass/value/string_to_s_spec.rb new file mode 100644 index 00000000..1bf6c54c --- /dev/null +++ b/spec/sass/value/string_to_s_spec.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Sass::Value::String do + describe '.to_s' do + describe 'serialize quoted string' do + it 'without quote in text' do + string = described_class.new('c') + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with double quote in text' do + string = described_class.new('"') + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with single quote in text' do + string = described_class.new("'") + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with double quote and single quote in text' do + string = described_class.new('\'"') + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with special characters in text' do + string = described_class.new((0..255).to_a.pack('U*')) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected.sub('\0', "\uFFFD")) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + end + + describe 'serialize unquoted string' do + it 'without quote in text' do + string = described_class.new('c', quoted: false) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with double quote in text' do + string = described_class.new('""', quoted: false) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with single quote in text' do + string = described_class.new("''", quoted: false) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected.tr("'", '"')) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with double quote and single quote in text' do + string = described_class.new('"\'"', quoted: false) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + + it 'with newline followed by spaces in text' do + string = described_class.new("a\nb\n c\n d", quoted: false) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = Sass.compile_string("a { b: #{string} }").css + expect(actual).to eq(expected) + + expected = Sass.compile_string(expected).css + expect(actual).to eq(expected) + end + end + end +end From 06c8df3cf6c55ed75955d4bda23868bef838c849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 12:50:26 -0800 Subject: [PATCH 330/700] Add spec for Sass#info --- spec/sass_info_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 spec/sass_info_spec.rb diff --git a/spec/sass_info_spec.rb b/spec/sass_info_spec.rb new file mode 100644 index 00000000..0032c9ba --- /dev/null +++ b/spec/sass_info_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sass do + describe '.info' do + it 'begins with a unique identifier for the Sass implementation' do + expect(described_class.info).to start_with("sass-embedded\t") + end + + it 'followed by its package version' do + version = described_class.info.split("\t")[1] + expect { Gem::Version.new(version) }.not_to raise_error + end + end +end From e7d97c67981fd6c85372e1ac041b7cae55ba1a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 13:01:02 -0800 Subject: [PATCH 331/700] Update sass_proto_spec.rb --- spec/sass_proto_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 2915b082..9ee7af4a 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -14,7 +14,7 @@ def remote_eq(lhs, rhs) result = nil Sass.compile_string( - 'a{b:yield(lhs()==rhs())}', + '$_: yield(lhs()==rhs());', functions: { 'yield($value)' => lambda { |args| result = args[0].assert_boolean.to_bool From 3555737a34d58b94f584401ab1dc59d9935edc80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 13:09:53 -0800 Subject: [PATCH 332/700] Update argument_list.rb --- lib/sass/value/argument_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 95eb819f..e43a62e5 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -8,7 +8,7 @@ module Value # map as well as the positional arguments. # # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/ - class ArgumentList < Value::List + class ArgumentList < List # @param contents [Array] # @param keywords [Hash<::String, Value>] # @param separator [::String] From acfbdf5b67157411ea69276563d60befbe34d27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 13:13:22 -0800 Subject: [PATCH 333/700] Update sass_proto_spec.rb --- spec/sass_proto_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 9ee7af4a..365c45ed 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -127,7 +127,7 @@ def remote_eq(lhs, rhs) expect( described_class.compile_string( - 'a {b: foo(bar())}', + '$_: foo(bar());', functions: { 'foo($arg)': foo, 'bar()': bar From 586a349df587908c6a63b1c92994a20b1c751536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 15:46:32 -0800 Subject: [PATCH 334/700] Update sass_info_spec.rb --- spec/sass_info_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/sass_info_spec.rb b/spec/sass_info_spec.rb index 0032c9ba..8c38461f 100644 --- a/spec/sass_info_spec.rb +++ b/spec/sass_info_spec.rb @@ -9,7 +9,7 @@ end it 'followed by its package version' do - version = described_class.info.split("\t")[1] + version = described_class.info.split[1] expect { Gem::Version.new(version) }.not_to raise_error end end From 4f9b264ca1178074c0d2923c5705b240c78ca56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 19:03:59 -0800 Subject: [PATCH 335/700] Update sass_info_spec.rb --- spec/sass_info_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/sass_info_spec.rb b/spec/sass_info_spec.rb index 8c38461f..ca2a5750 100644 --- a/spec/sass_info_spec.rb +++ b/spec/sass_info_spec.rb @@ -4,12 +4,18 @@ RSpec.describe Sass do describe '.info' do + identifier = 'sass-embedded' + it 'begins with a unique identifier for the Sass implementation' do - expect(described_class.info).to start_with("sass-embedded\t") + expect(described_class.info).to start_with(identifier) + end + + it 'followed by U+0009 TAB' do + expect(described_class.info[identifier.length]).to eq("\t") end it 'followed by its package version' do - version = described_class.info.split[1] + version = described_class.info.slice(identifier.length + 1).split[0] expect { Gem::Version.new(version) }.not_to raise_error end end From d6ed0d95e41f8789bd1b0df1f47c4cca5d0e4022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 20:03:36 -0800 Subject: [PATCH 336/700] Make Sass#info more informative --- lib/sass/compiler.rb | 5 ++++- lib/sass/compiler/host.rb | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index e5002436..5316133e 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -174,7 +174,10 @@ def compile_string(source, # @return [String] Information about the Sass implementation. # @see https://sass-lang.com/documentation/js-api/variables/info/ def info - @info ||= Host.new(@dispatcher).version_request + @info ||= <<~INFO.freeze + sass-embedded\t#{Embedded::VERSION}\t(Embedded Host)\t[Ruby] + #{Host.new(@dispatcher).version_request} + INFO end def close diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 94ca7be1..4bd6e033 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -74,7 +74,12 @@ def version_request )) end - "sass-embedded\t#{version_response.implementation_version}" + info = "#{version_response.implementation_name}\t#{version_response.implementation_version}\t(Sass Compiler)" + case version_response.implementation_name + when /\bdart\b/i + info << "\t[Dart]" + end + info end def compile_response(message) From a28a82e283fca2d9e8362abf4e5c5d0c44d75e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 23:05:15 -0800 Subject: [PATCH 337/700] Add spec for Sass::ELF --- lib/sass/elf.rb | 4 ++-- spec/sass/elf_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 spec/sass/elf_spec.rb diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index d3c422fb..6b81cac8 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -150,7 +150,7 @@ class ELF def initialize(buffer) @buffer = buffer @ehdr = read_ehdr - @buffer.seek(@ehdr[:e_phoff], :SET) + @buffer.seek(@ehdr[:e_phoff], IO::SEEK_SET) @proghdrs = Array.new(@ehdr[:e_phnum]) do read_phdr end @@ -176,7 +176,7 @@ def interpreter phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP } return if phdr.nil? - @buffer.seek(phdr[:p_offset], :SET) + @buffer.seek(phdr[:p_offset], IO::SEEK_SET) interpreter = @buffer.read(phdr[:p_filesz]) raise ArgumentError unless interpreter.end_with?("\0") diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb new file mode 100644 index 00000000..1455ac48 --- /dev/null +++ b/spec/sass/elf_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Sass::ELF', skip: (File.exist?('/proc/self/exe') ? false : '/proc/self/exe is not available') do + let!(:described_class) do + require 'sass/elf' + + Sass.const_get(:ELF) + end + + describe 'ruby program interpreter' do + it 'starts with ld-' do + expect(File.basename(described_class::INTERPRETER)).to start_with('ld-') + end + end + + describe 'dart program interpreter' do + let!(:interpreter) do + File.open(Sass.const_get(:CLI)::COMMAND[0], 'rb') do |file| + described_class.new(file).interpreter + end + end + + it 'starts with ld-' do + expect(File.basename(interpreter)).to start_with('ld-') + end + + it 'is the same as ruby' do + expect(File.basename(interpreter)) + .to eq(File.basename(described_class::INTERPRETER)) + end + end +end From 8553bfffbfc1354798088f6baf598c4e7a55d520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 29 Dec 2023 23:40:02 -0800 Subject: [PATCH 338/700] Use let in rspec --- spec/sass/elf_spec.rb | 4 +-- spec/sass/value/argument_list_spec.rb | 10 +++---- spec/sass/value/boolean_spec.rb | 8 ++++-- spec/sass/value/calculation_spec.rb | 38 ++++++++++++++++----------- spec/sass/value/color_spec.rb | 25 +++++++----------- spec/sass/value/list_spec.rb | 35 ++++++++++-------------- spec/sass/value/map_spec.rb | 27 +++++++++---------- spec/sass/value/null_spec.rb | 4 ++- spec/sass/value/number_spec.rb | 29 +++++++++----------- spec/sass/value/string_spec.rb | 15 +++++------ spec/sass_info_spec.rb | 4 ++- 11 files changed, 96 insertions(+), 103 deletions(-) diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb index 1455ac48..81c78d52 100644 --- a/spec/sass/elf_spec.rb +++ b/spec/sass/elf_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Sass::ELF', skip: (File.exist?('/proc/self/exe') ? false : '/proc/self/exe is not available') do - let!(:described_class) do + let(:described_class) do require 'sass/elf' Sass.const_get(:ELF) @@ -16,7 +16,7 @@ end describe 'dart program interpreter' do - let!(:interpreter) do + let(:interpreter) do File.open(Sass.const_get(:CLI)::COMMAND[0], 'rb') do |file| described_class.new(file).interpreter end diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index 2e2a006d..f3cdcc79 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -75,9 +75,8 @@ end describe 'construction' do - list = nil - before do - list = described_class.new( + let(:list) do + described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], { 'd' => Sass::Value::String.new('e') } ) @@ -117,9 +116,8 @@ end describe 'equality' do - list = nil - before do - list = described_class.new( + let(:list) do + described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], { 'd' => Sass::Value::String.new('e') } ) diff --git a/spec/sass/value/boolean_spec.rb b/spec/sass/value/boolean_spec.rb index c4060e60..8cbf19d1 100644 --- a/spec/sass/value/boolean_spec.rb +++ b/spec/sass/value/boolean_spec.rb @@ -5,7 +5,9 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/boolean.test.ts describe Sass::Value::Boolean do describe 'sassTrue' do - value = Sass::Value::Boolean::TRUE + let(:value) do + Sass::Value::Boolean::TRUE + end it 'is truthy' do expect(value.to_bool).to be(true) @@ -36,7 +38,9 @@ end describe 'sassFalse' do - value = Sass::Value::Boolean::FALSE + let(:value) do + Sass::Value::Boolean::FALSE + end it 'is falsey' do expect(value.to_bool).to be(false) diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index bd49b293..4a99ad24 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -4,18 +4,22 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/calculation.test.ts describe Sass::Value::Calculation do - valid_calculation_values = [ - Sass::Value::Number.new(1), - Sass::Value::String.new('1', quoted: false), - described_class.calc(Sass::Value::Number.new(1)), - Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), Sass::Value::Number.new(1)) - ] - invalid_calculation_values = [Sass::Value::String.new('1', quoted: true)] + let(:valid_calculation_values) do + [ + Sass::Value::Number.new(1), + Sass::Value::String.new('1', quoted: false), + described_class.calc(Sass::Value::Number.new(1)), + Sass::CalculationValue::CalculationOperation.new('+', Sass::Value::Number.new(1), Sass::Value::Number.new(1)) + ] + end + + let(:invalid_calculation_values) do + [Sass::Value::String.new('1', quoted: true)] + end describe 'construction' do - calculation = nil - before do - calculation = described_class.calc(Sass::Value::Number.new(1)) + let(:calculation) do + described_class.calc(Sass::Value::Number.new(1)) end it 'is a value' do @@ -313,8 +317,13 @@ end describe 'CalculationOperation' do - valid_operators = ['+', '-', '*', '/'] - invalid_operators = ['||', '&&', 'plus', 'minus', ''] + let(:valid_operators) do + ['+', '-', '*', '/'] + end + + let(:invalid_operators) do + ['||', '&&', 'plus', 'minus', ''] + end describe 'construction' do it 'rejects invalid operators' do @@ -365,9 +374,8 @@ end describe 'stores' do - operation = nil - before do - operation = Sass::CalculationValue::CalculationOperation.new( + let(:operation) do + Sass::CalculationValue::CalculationOperation.new( '+', Sass::Value::Number.new(1), Sass::Value::Number.new(2) diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb index 8140e927..1bd91f6c 100644 --- a/spec/sass/value/color_spec.rb +++ b/spec/sass/value/color_spec.rb @@ -18,9 +18,8 @@ def hwb(hue, whiteness, blackness, alpha = nil) describe 'construction' do describe 'type' do - color = nil - before do - color = rgb(18, 52, 86) + let(:color) do + rgb(18, 52, 86) end it 'is a value' do @@ -101,9 +100,8 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'an RGB color' do - color = nil - before do - color = rgb(18, 52, 86) + let(:color) do + rgb(18, 52, 86) end it 'has RGB channels' do @@ -136,9 +134,8 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'an HSL color' do - color = nil - before do - color = hsl(120, 42, 42) + let(:color) do + hsl(120, 42, 42) end it 'has RGB channels' do @@ -176,9 +173,8 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'an HWB color' do - color = nil - before do - color = hwb(120, 42, 42) + let(:color) do + hwb(120, 42, 42) end it 'has RGB channels' do @@ -216,9 +212,8 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'changing color values' do - color = nil - before do - color = rgb(18, 52, 86) + let(:color) do + rgb(18, 52, 86) end describe 'change() for RGB' do diff --git a/spec/sass/value/list_spec.rb b/spec/sass/value/list_spec.rb index 8c1a3211..c19627f8 100644 --- a/spec/sass/value/list_spec.rb +++ b/spec/sass/value/list_spec.rb @@ -5,9 +5,8 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/list.test.ts describe Sass::Value::List do describe 'construction' do - list = nil - before do - list = described_class.new( + let(:list) do + described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], separator: ',' ) @@ -36,9 +35,8 @@ end describe 'equality' do - list = nil - before do - list = described_class.new( + let(:list) do + described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], separator: ',' ) @@ -111,9 +109,8 @@ end describe 'Sass to Ruby index conversion' do - list = nil - before do - list = described_class.new( + let(:list) do + described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')] ) end @@ -196,9 +193,8 @@ end describe 'at()' do - list = nil - before do - list = described_class.new( + let(:list) do + described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')] ) end @@ -231,9 +227,8 @@ end describe 'single-element list' do - list = nil - before do - list = described_class.new([Sass::Value::Number.new(1)]) + let(:list) do + described_class.new([Sass::Value::Number.new(1)]) end it 'has a comma separator' do @@ -250,9 +245,8 @@ end describe 'a scalar value' do - string = nil - before do - string = Sass::Value::String.new('blue') + let(:string) do + Sass::Value::String.new('blue') end it 'has an undecided separator' do @@ -305,9 +299,8 @@ end describe 'an empty list' do - list = nil - before do - list = described_class.new + let(:list) do + described_class.new end it 'defaults to a comma separator' do diff --git a/spec/sass/value/map_spec.rb b/spec/sass/value/map_spec.rb index cb73d59b..e63b2d0b 100644 --- a/spec/sass/value/map_spec.rb +++ b/spec/sass/value/map_spec.rb @@ -4,12 +4,11 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/map.test.ts describe Sass::Value::Map do - map = nil - before do - map = described_class.new({ - Sass::Value::String.new('a') => Sass::Value::String.new('b'), - Sass::Value::String.new('c') => Sass::Value::String.new('d') - }) + let(:map) do + described_class.new({ + Sass::Value::String.new('a') => Sass::Value::String.new('b'), + Sass::Value::String.new('c') => Sass::Value::String.new('d') + }) end describe 'construction' do @@ -151,12 +150,11 @@ end describe 'at()' do - map = nil - before do - map = described_class.new({ - Sass::Value::String.new('a') => Sass::Value::String.new('b'), - Sass::Value::String.new('c') => Sass::Value::String.new('d') - }) + let(:map) do + described_class.new({ + Sass::Value::String.new('a') => Sass::Value::String.new('b'), + Sass::Value::String.new('c') => Sass::Value::String.new('d') + }) end describe 'with a number' do @@ -227,9 +225,8 @@ end describe 'an empty map' do - map = nil - before do - map = described_class.new + let(:map) do + described_class.new end it 'has a nil separator' do diff --git a/spec/sass/value/null_spec.rb b/spec/sass/value/null_spec.rb index 549d72dc..2c8392df 100644 --- a/spec/sass/value/null_spec.rb +++ b/spec/sass/value/null_spec.rb @@ -4,7 +4,9 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/null.test.ts describe Sass::Value::Null do - value = Sass::Value::Null::NULL + let(:value) do + Sass::Value::Null::NULL + end it 'is falsey' do expect(value.to_bool).to be(false) diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 0df443a8..9c9d84df 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -4,13 +4,14 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/number.test.ts describe Sass::Value::Number do - precision = 10 + let(:precision) do + 10 + end describe 'unitless' do describe 'integer' do - number = nil - before do - number = described_class.new(123) + let(:number) do + described_class.new(123) end describe 'construction' do @@ -167,9 +168,8 @@ end describe 'fuzzy integer' do - number = nil - before do - number = described_class.new(123.000000000001) + let(:number) do + described_class.new(123.000000000001) end it 'has the correct value' do @@ -204,9 +204,8 @@ end describe 'double' do - number = nil - before do - number = described_class.new(123.456) + let(:number) do + described_class.new(123.456) end it 'has the correct value' do @@ -222,9 +221,8 @@ end describe 'single numerator unit' do - number = nil - before do - number = described_class.new(123, 'px') + let(:number) do + described_class.new(123, 'px') end describe 'construction' do @@ -390,9 +388,8 @@ end describe 'numerator and denominator units' do - number = nil - before do - number = described_class.new(123, { numerator_units: ['px'], denominator_units: ['ms'] }) + let(:number) do + described_class.new(123, { numerator_units: ['px'], denominator_units: ['ms'] }) end describe 'construction' do diff --git a/spec/sass/value/string_spec.rb b/spec/sass/value/string_spec.rb index bea48b45..aacaa065 100644 --- a/spec/sass/value/string_spec.rb +++ b/spec/sass/value/string_spec.rb @@ -64,9 +64,8 @@ end describe 'index handling' do - string = nil - before do - string = described_class.new('nb') + let(:string) do + described_class.new('nb') end it 'rejects a zero index' do @@ -82,9 +81,8 @@ end describe 'ASCII' do - string = nil - before do - string = described_class.new('nb') + let(:string) do + described_class.new('nb') end it 'converts a positive index' do @@ -104,9 +102,8 @@ end describe 'Unicode' do - string = nil - before do - string = described_class.new('a👭b👬c') + let(:string) do + described_class.new('a👭b👬c') end it 'converts a positive index' do diff --git a/spec/sass_info_spec.rb b/spec/sass_info_spec.rb index ca2a5750..cf56d1fb 100644 --- a/spec/sass_info_spec.rb +++ b/spec/sass_info_spec.rb @@ -4,7 +4,9 @@ RSpec.describe Sass do describe '.info' do - identifier = 'sass-embedded' + let(:identifier) do + 'sass-embedded' + end it 'begins with a unique identifier for the Sass implementation' do expect(described_class.info).to start_with(identifier) From 1c66b7eed685bff214e30ce4e623dbd2da51c853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 02:54:30 -0800 Subject: [PATCH 339/700] Add spec for Sass::Compiler --- lib/sass/compiler/resilient_dispatcher.rb | 15 +- spec/sass/compiler_spec.rb | 141 ++++++++++++++++++ .../fork_tracker_spec.rb} | 102 +------------ 3 files changed, 157 insertions(+), 101 deletions(-) create mode 100644 spec/sass/compiler_spec.rb rename spec/{sass_fork_spec.rb => sass/fork_tracker_spec.rb} (54%) diff --git a/lib/sass/compiler/resilient_dispatcher.rb b/lib/sass/compiler/resilient_dispatcher.rb index abc382ff..f2867e3e 100644 --- a/lib/sass/compiler/resilient_dispatcher.rb +++ b/lib/sass/compiler/resilient_dispatcher.rb @@ -12,22 +12,25 @@ def initialize(dispatcher_class) @mutex = Mutex.new end - def close(...) + def close @mutex.synchronize do - @dispatcher.close(...) + unless @dispatcher.nil? + @dispatcher.close + @dispatcher = nil + end end end - def closed?(...) + def closed? @mutex.synchronize do - @dispatcher.closed?(...) + @dispatcher.nil? end end def connect(...) - @dispatcher.connect(...) - rescue Errno::EBUSY @mutex.synchronize do + raise IOError, 'closed compiler' if @dispatcher.nil? + @dispatcher.connect(...) rescue Errno::EBUSY @dispatcher = @dispatcher_class.new diff --git a/spec/sass/compiler_spec.rb b/spec/sass/compiler_spec.rb new file mode 100644 index 00000000..43e40953 --- /dev/null +++ b/spec/sass/compiler_spec.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/compiler.node.test.ts +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/compiler.test.ts +RSpec.describe Sass::Compiler do + let(:functions) do + { + 'foo($args)' => ->(args) { args[0] } + } + end + + let(:importers) do + [ + { + canonicalize: ->(url, _) { "u:#{url}" }, + load: lambda do |url| + { + contents: ".import {value: #{url.split(':')[1]}} @debug \"imported\";", + syntax: :scss + } + end + } + ] + end + + let(:logger) do + { + debug: instance_double(Proc, call: nil) + } + end + + let!(:compiler) do + described_class.new + end + + after do + compiler.close + end + + describe 'compile_string' do + it 'performs complete compilations' do + result = compiler.compile_string('@import "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:) + expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: baz;\n}") + expect(logger[:debug]).to have_received(:call) + end + + it 'performs compilations in callbacks' do + nested_importer = { + canonicalize: ->(*) { 'foo:bar' }, + load: lambda do |*| + { + contents: compiler.compile_string('x {y: z}').css, + syntax: :scss + } + end + } + + result = compiler.compile_string('@import "nested"; a {b: c}', importers: [nested_importer]) + expect(result.css).to eq("x {\n y: z;\n}\n\na {\n b: c;\n}") + end + + it 'throws after being disposed' do + compiler.close + expect { compiler.compile_string('$a: b; c {d: $a}') }.to raise_error(IOError, 'closed compiler') + end + + it 'succeeds after a compilation failure' do + expect { compiler.compile_string('a') }.to raise_sass_compile_error.with_message('expected "{"') + result = compiler.compile_string('x {y: z}') + expect(result.css).to eq("x {\n y: z;\n}") + end + + it 'handles multiple concurrent compilations' do + results = Array.new(100) do |i| + Thread.new do + compiler.compile_string("@import \"#{i}\"; .fn {value: foo(#{i})}", importers:, functions:, logger:) + end + end.map(&:value) + + results.each_with_index do |result, i| + expect(result.css).to eq(".import {\n value: #{i};\n}\n\n.fn {\n value: #{i};\n}") + end + end + end + + describe 'compile' do + it 'performs complete compilations' do + sandbox do |dir| + dir.write({ 'input.scss' => '@import "bar"; .fn {value: foo(bar)}' }) + result = compiler.compile(dir.path('input.scss'), importers:, functions:, logger:) + expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: bar;\n}") + expect(logger[:debug]).to have_received(:call) + end + end + + it 'performs compilations in callbacks' do + sandbox do |dir| + dir.write({ 'input-nested.scss' => 'x {y: z}' }) + nested_importer = { + canonicalize: ->(*) { 'foo:bar' }, + load: lambda do |*| + { + contents: compiler.compile(dir.path('input-nested.scss')).css, + syntax: :scss + } + end + } + + dir.write({ 'input.scss' => '@import "nested"; a {b: c}' }) + result = compiler.compile(dir.path('input.scss'), importers: [nested_importer]) + expect(result.css).to eq("x {\n y: z;\n}\n\na {\n b: c;\n}") + end + end + + it 'throws after being disposed' do + sandbox do |dir| + dir.write({ 'input.scss' => '$a: b; c {d: $a}' }) + compiler.close + expect { compiler.compile(dir.path('input.scss')) }.to raise_error(IOError, 'closed compiler') + end + end + + it 'handles multiple concurrent compilations' do + sandbox do |dir| + results = Array.new(100) do |i| + Thread.new do + filename = "input-#{i}.scss" + dir.write({ filename => "@import \"#{i}\"; .fn {value: foo(#{i})}" }) + compiler.compile(dir.path(filename), importers:, functions:, logger:) + end + end.map(&:value) + + results.each_with_index do |result, i| + expect(result.css).to eq(".import {\n value: #{i};\n}\n\n.fn {\n value: #{i};\n}") + end + end + end + end +end diff --git a/spec/sass_fork_spec.rb b/spec/sass/fork_tracker_spec.rb similarity index 54% rename from spec/sass_fork_spec.rb rename to spec/sass/fork_tracker_spec.rb index 17d21c0d..6af7eba3 100644 --- a/spec/sass_fork_spec.rb +++ b/spec/sass/fork_tracker_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe Sass, skip: (Process.respond_to?(:fork) ? false : 'Process.fork is not usable') do - describe 'after fork' do +RSpec.describe 'Sass::ForkTracker', skip: (Process.respond_to?(:fork) ? false : 'Process.fork is not usable') do + describe 'global compiler after fork' do it 'works in parent process' do pid = Process.fork do exit 0 @@ -11,13 +11,13 @@ _, result = Process.wait2(pid) expect(result.exitstatus).to be(0) - expect(described_class.compile_string('a {b: c}').css) + expect(Sass.compile_string('a {b: c}').css) .to eq("a {\n b: c;\n}") end it 'works in child process' do pid = Process.fork do - expect(described_class.compile_string('a {b: c}').css) + expect(Sass.compile_string('a {b: c}').css) .to eq("a {\n b: c;\n}") exit 0 rescue StandardError @@ -29,7 +29,7 @@ it 'works in both parent and child process' do pid = Process.fork do - expect(described_class.compile_string('a {b: c}').css) + expect(Sass.compile_string('a {b: c}').css) .to eq("a {\n b: c;\n}") exit 0 rescue StandardError @@ -38,43 +38,12 @@ _, result = Process.wait2(pid) expect(result.exitstatus).to be(0) - expect(described_class.compile_string('a {b: c}').css) + expect(Sass.compile_string('a {b: c}').css) .to eq("a {\n b: c;\n}") end end - describe 'running compiler after fork' do - it 'remains running in parent process' do - sass = Sass::Compiler.new - expect(sass.closed?).to be(false) - - pid = Process.fork do - exit 0 - end - _, result = Process.wait2(pid) - expect(result.exitstatus).to be(0) - - expect(sass.closed?).to be(false) - ensure - sass&.close - end - - it 'is closed in child process' do - sass = Sass::Compiler.new - expect(sass.closed?).to be(false) - - pid = Process.fork do - expect(sass.closed?).to be(true) - exit 0 - rescue StandardError - exit 1 - end - _, result = Process.wait2(pid) - expect(result.exitstatus).to be(0) - ensure - sass&.close - end - + describe 'opened compiler after fork' do it 'works in parent process' do sass = Sass::Compiler.new @@ -163,62 +132,5 @@ ensure sass&.close end - - it 'works in parent process' do - sass = Sass::Compiler.new - sass.close - - pid = Process.fork do - exit 0 - end - _, result = Process.wait2(pid) - expect(result.exitstatus).to be(0) - - expect(sass.compile_string('a {b: c}').css) - .to eq("a {\n b: c;\n}") - ensure - sass&.close - end - - it 'works in child process' do - sass = Sass::Compiler.new - sass.close - - pid = Process.fork do - expect(sass.compile_string('a {b: c}').css) - .to eq("a {\n b: c;\n}") - exit 0 - rescue StandardError - exit 1 - ensure - sass.close - end - _, result = Process.wait2(pid) - expect(result.exitstatus).to be(0) - ensure - sass&.close - end - - it 'works in both parent and child process' do - sass = Sass::Compiler.new - sass.close - - pid = Process.fork do - expect(sass.compile_string('a {b: c}').css) - .to eq("a {\n b: c;\n}") - exit 0 - rescue StandardError - exit 1 - ensure - sass.close - end - _, result = Process.wait2(pid) - expect(result.exitstatus).to be(0) - - expect(sass.compile_string('a {b: c}').css) - .to eq("a {\n b: c;\n}") - ensure - sass&.close - end end end From f79c28d9be258a95c25e04320ee06691705f4394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 03:09:46 -0800 Subject: [PATCH 340/700] Rename Sass::Compiler::ResilientDispatcher to Sass::Compiler::DispatcherManager --- lib/sass/compiler.rb | 4 ++-- .../{resilient_dispatcher.rb => dispatcher_manager.rb} | 8 ++++---- lib/sass/embedded.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename lib/sass/compiler/{resilient_dispatcher.rb => dispatcher_manager.rb} (82%) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 5316133e..23160bd7 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -4,8 +4,8 @@ require_relative 'compile_result' require_relative 'compiler/connection' require_relative 'compiler/dispatcher' +require_relative 'compiler/dispatcher_manager' require_relative 'compiler/host' -require_relative 'compiler/resilient_dispatcher' require_relative 'compiler/varint' require_relative 'embedded_protocol' require_relative 'exception' @@ -27,7 +27,7 @@ module Sass # sass.close class Compiler def initialize - @dispatcher = ResilientDispatcher.new(Dispatcher) + @dispatcher = DispatcherManager.new(Dispatcher) end # Compiles the Sass file at +path+ to CSS. diff --git a/lib/sass/compiler/resilient_dispatcher.rb b/lib/sass/compiler/dispatcher_manager.rb similarity index 82% rename from lib/sass/compiler/resilient_dispatcher.rb rename to lib/sass/compiler/dispatcher_manager.rb index f2867e3e..62136bdf 100644 --- a/lib/sass/compiler/resilient_dispatcher.rb +++ b/lib/sass/compiler/dispatcher_manager.rb @@ -2,10 +2,10 @@ module Sass class Compiler - # The {ResilientDispatcher} class. + # The {DispatcherManager} class. # - # It recovers from failures and continues to function. - class ResilientDispatcher + # It manages the lifecycle of {Dispatcher}. + class DispatcherManager def initialize(dispatcher_class) @dispatcher_class = dispatcher_class @dispatcher = @dispatcher_class.new @@ -39,6 +39,6 @@ def connect(...) end end - private_constant :ResilientDispatcher + private_constant :DispatcherManager end end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 0d90fd5a..08983fd8 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -56,7 +56,7 @@ def compiler compiler = Class.new(Compiler) do def initialize - @dispatcher = Compiler.const_get(:ResilientDispatcher).new(Class.new(Compiler.const_get(:Dispatcher)) do + @dispatcher = Compiler.const_get(:DispatcherManager).new(Class.new(Compiler.const_get(:Dispatcher)) do def initialize super From e60d877b5aa6880683fbb90c4c2980bb76b7284f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 03:22:44 -0800 Subject: [PATCH 341/700] Update sass_info_spec.rb --- spec/sass_info_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/sass_info_spec.rb b/spec/sass_info_spec.rb index cf56d1fb..367d858c 100644 --- a/spec/sass_info_spec.rb +++ b/spec/sass_info_spec.rb @@ -17,8 +17,8 @@ end it 'followed by its package version' do - version = described_class.info.slice(identifier.length + 1).split[0] - expect { Gem::Version.new(version) }.not_to raise_error + version = described_class.info.split[1] + expect(version).to eq(described_class::Embedded::VERSION) end end end From 048300f952ded9c7830436df6b0266c9cf58088f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 09:48:44 -0800 Subject: [PATCH 342/700] Use subject in rspec --- spec/sass/compiler_spec.rb | 16 ++++++++-------- spec/sass/elf_spec.rb | 2 +- spec/sass/value/argument_list_spec.rb | 4 ++-- spec/sass/value/boolean_spec.rb | 4 ++-- spec/sass/value/calculation_spec.rb | 4 ++-- spec/sass/value/color_spec.rb | 10 +++++----- spec/sass/value/list_spec.rb | 14 +++++++------- spec/sass/value/map_spec.rb | 6 +++--- spec/sass/value/null_spec.rb | 2 +- spec/sass/value/number_spec.rb | 10 +++++----- spec/sass/value/string_spec.rb | 6 +++--- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/spec/sass/compiler_spec.rb b/spec/sass/compiler_spec.rb index 43e40953..a6302c81 100644 --- a/spec/sass/compiler_spec.rb +++ b/spec/sass/compiler_spec.rb @@ -5,6 +5,14 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/compiler.node.test.ts # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/compiler.test.ts RSpec.describe Sass::Compiler do + subject!(:compiler) do + described_class.new + end + + after do + compiler.close + end + let(:functions) do { 'foo($args)' => ->(args) { args[0] } @@ -31,14 +39,6 @@ } end - let!(:compiler) do - described_class.new - end - - after do - compiler.close - end - describe 'compile_string' do it 'performs complete compilations' do result = compiler.compile_string('@import "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:) diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb index 81c78d52..5fc04082 100644 --- a/spec/sass/elf_spec.rb +++ b/spec/sass/elf_spec.rb @@ -16,7 +16,7 @@ end describe 'dart program interpreter' do - let(:interpreter) do + subject(:interpreter) do File.open(Sass.const_get(:CLI)::COMMAND[0], 'rb') do |file| described_class.new(file).interpreter end diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index f3cdcc79..d7b9f664 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -75,7 +75,7 @@ end describe 'construction' do - let(:list) do + subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], { 'd' => Sass::Value::String.new('e') } @@ -116,7 +116,7 @@ end describe 'equality' do - let(:list) do + subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], { 'd' => Sass::Value::String.new('e') } diff --git a/spec/sass/value/boolean_spec.rb b/spec/sass/value/boolean_spec.rb index 8cbf19d1..0839479c 100644 --- a/spec/sass/value/boolean_spec.rb +++ b/spec/sass/value/boolean_spec.rb @@ -5,7 +5,7 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/boolean.test.ts describe Sass::Value::Boolean do describe 'sassTrue' do - let(:value) do + subject(:value) do Sass::Value::Boolean::TRUE end @@ -38,7 +38,7 @@ end describe 'sassFalse' do - let(:value) do + subject(:value) do Sass::Value::Boolean::FALSE end diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 4a99ad24..99b82a36 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -18,7 +18,7 @@ end describe 'construction' do - let(:calculation) do + subject(:calculation) do described_class.calc(Sass::Value::Number.new(1)) end @@ -374,7 +374,7 @@ end describe 'stores' do - let(:operation) do + subject(:operation) do Sass::CalculationValue::CalculationOperation.new( '+', Sass::Value::Number.new(1), diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb index 1bd91f6c..0ad5b044 100644 --- a/spec/sass/value/color_spec.rb +++ b/spec/sass/value/color_spec.rb @@ -18,7 +18,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) describe 'construction' do describe 'type' do - let(:color) do + subject(:color) do rgb(18, 52, 86) end @@ -100,7 +100,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'an RGB color' do - let(:color) do + subject(:color) do rgb(18, 52, 86) end @@ -134,7 +134,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'an HSL color' do - let(:color) do + subject(:color) do hsl(120, 42, 42) end @@ -173,7 +173,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'an HWB color' do - let(:color) do + subject(:color) do hwb(120, 42, 42) end @@ -212,7 +212,7 @@ def hwb(hue, whiteness, blackness, alpha = nil) end describe 'changing color values' do - let(:color) do + subject(:color) do rgb(18, 52, 86) end diff --git a/spec/sass/value/list_spec.rb b/spec/sass/value/list_spec.rb index c19627f8..70d3ae82 100644 --- a/spec/sass/value/list_spec.rb +++ b/spec/sass/value/list_spec.rb @@ -5,7 +5,7 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/list.test.ts describe Sass::Value::List do describe 'construction' do - let(:list) do + subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], separator: ',' @@ -35,7 +35,7 @@ end describe 'equality' do - let(:list) do + subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], separator: ',' @@ -109,7 +109,7 @@ end describe 'Sass to Ruby index conversion' do - let(:list) do + subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')] ) @@ -193,7 +193,7 @@ end describe 'at()' do - let(:list) do + subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')] ) @@ -227,7 +227,7 @@ end describe 'single-element list' do - let(:list) do + subject(:list) do described_class.new([Sass::Value::Number.new(1)]) end @@ -245,7 +245,7 @@ end describe 'a scalar value' do - let(:string) do + subject(:string) do Sass::Value::String.new('blue') end @@ -299,7 +299,7 @@ end describe 'an empty list' do - let(:list) do + subject(:list) do described_class.new end diff --git a/spec/sass/value/map_spec.rb b/spec/sass/value/map_spec.rb index e63b2d0b..7d933368 100644 --- a/spec/sass/value/map_spec.rb +++ b/spec/sass/value/map_spec.rb @@ -4,7 +4,7 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/map.test.ts describe Sass::Value::Map do - let(:map) do + subject(:map) do described_class.new({ Sass::Value::String.new('a') => Sass::Value::String.new('b'), Sass::Value::String.new('c') => Sass::Value::String.new('d') @@ -150,7 +150,7 @@ end describe 'at()' do - let(:map) do + subject(:map) do described_class.new({ Sass::Value::String.new('a') => Sass::Value::String.new('b'), Sass::Value::String.new('c') => Sass::Value::String.new('d') @@ -225,7 +225,7 @@ end describe 'an empty map' do - let(:map) do + subject(:map) do described_class.new end diff --git a/spec/sass/value/null_spec.rb b/spec/sass/value/null_spec.rb index 2c8392df..58a552bb 100644 --- a/spec/sass/value/null_spec.rb +++ b/spec/sass/value/null_spec.rb @@ -4,7 +4,7 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/null.test.ts describe Sass::Value::Null do - let(:value) do + subject(:value) do Sass::Value::Null::NULL end diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index 9c9d84df..a5cfc51c 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -10,7 +10,7 @@ describe 'unitless' do describe 'integer' do - let(:number) do + subject(:number) do described_class.new(123) end @@ -168,7 +168,7 @@ end describe 'fuzzy integer' do - let(:number) do + subject(:number) do described_class.new(123.000000000001) end @@ -204,7 +204,7 @@ end describe 'double' do - let(:number) do + subject(:number) do described_class.new(123.456) end @@ -221,7 +221,7 @@ end describe 'single numerator unit' do - let(:number) do + subject(:number) do described_class.new(123, 'px') end @@ -388,7 +388,7 @@ end describe 'numerator and denominator units' do - let(:number) do + subject(:number) do described_class.new(123, { numerator_units: ['px'], denominator_units: ['ms'] }) end diff --git a/spec/sass/value/string_spec.rb b/spec/sass/value/string_spec.rb index aacaa065..2c587cfe 100644 --- a/spec/sass/value/string_spec.rb +++ b/spec/sass/value/string_spec.rb @@ -64,7 +64,7 @@ end describe 'index handling' do - let(:string) do + subject(:string) do described_class.new('nb') end @@ -81,7 +81,7 @@ end describe 'ASCII' do - let(:string) do + subject(:string) do described_class.new('nb') end @@ -102,7 +102,7 @@ end describe 'Unicode' do - let(:string) do + subject(:string) do described_class.new('a👭b👬c') end From 7d3de983483ab8d9384604780c75e1c9f7bf563e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 10:17:42 -0800 Subject: [PATCH 343/700] Add spec for Sass::ForkTracker --- spec/sass/fork_tracker_spec.rb | 69 ++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/spec/sass/fork_tracker_spec.rb b/spec/sass/fork_tracker_spec.rb index 6af7eba3..170de420 100644 --- a/spec/sass/fork_tracker_spec.rb +++ b/spec/sass/fork_tracker_spec.rb @@ -3,8 +3,55 @@ require 'spec_helper' RSpec.describe 'Sass::ForkTracker', skip: (Process.respond_to?(:fork) ? false : 'Process.fork is not usable') do - describe 'global compiler after fork' do - it 'works in parent process' do + let(:described_class) do + Sass.const_get(:ForkTracker) + end + + it 'tracks global compiler process' do + Sass.compile_string('a { b: c }') + + expect(described_class.each.size).to eq(1) + end + + it 'tracks new compiler process' do + compiler = Sass::Compiler.new + + expect(described_class.each.size).to eq(2) + + compiler.close + + expect(described_class.each.size).to eq(1) + end + + it 'tracks running compiler processes in parent process after fork' do + expect(described_class.each.size).to eq(1) + + pid = Process.fork do + exit 0 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + expect(described_class.each.size).to eq(1) + end + + it 'closes running compiler processes in child process after fork' do + compiler = Sass::Compiler.new + + pid = Process.fork do + expect(described_class.each.size).to eq(0) + exit 0 + rescue StandardError + exit 1 + end + _, result = Process.wait2(pid) + expect(result.exitstatus).to be(0) + + compiler.close + end + + describe 'global compiler' do + it 'works in parent process after fork' do pid = Process.fork do exit 0 end @@ -15,7 +62,7 @@ .to eq("a {\n b: c;\n}") end - it 'works in child process' do + it 'works in child process after fork' do pid = Process.fork do expect(Sass.compile_string('a {b: c}').css) .to eq("a {\n b: c;\n}") @@ -27,7 +74,7 @@ expect(result.exitstatus).to be(0) end - it 'works in both parent and child process' do + it 'works in both parent and child process after fork' do pid = Process.fork do expect(Sass.compile_string('a {b: c}').css) .to eq("a {\n b: c;\n}") @@ -43,8 +90,8 @@ end end - describe 'opened compiler after fork' do - it 'works in parent process' do + describe 'new compiler' do + it 'works in parent process after fork' do sass = Sass::Compiler.new pid = Process.fork do @@ -59,7 +106,7 @@ sass&.close end - it 'works in child process' do + it 'works in child process after fork' do sass = Sass::Compiler.new pid = Process.fork do @@ -77,7 +124,7 @@ sass&.close end - it 'works in both parent and child process' do + it 'works in both parent and child process after fork' do sass = Sass::Compiler.new pid = Process.fork do @@ -99,8 +146,8 @@ end end - describe 'closed compiler after fork' do - it 'remains closed in parent process' do + describe 'closed compiler' do + it 'remains closed in parent process after fork' do sass = Sass::Compiler.new sass.close expect(sass.closed?).to be(true) @@ -116,7 +163,7 @@ sass&.close end - it 'remains closed in child process' do + it 'remains closed in child process after fork' do sass = Sass::Compiler.new sass.close expect(sass.closed?).to be(true) From 7058ceba8cba6ac4f40add0b29710cceded4c3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 10:34:44 -0800 Subject: [PATCH 344/700] Add spec for assert_function and assert_mixin --- spec/sass/value/function_spec.rb | 16 ++++++++++++++-- spec/sass/value/mixin_spec.rb | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index 42ce4020..9f87d95c 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -8,8 +8,20 @@ fn = double allow(fn).to receive(:call) { |args| expect(args.length).to eq(1) - expect(args[0]).to be_a(described_class) - args[0] + value = args[0] + + expect(value).to be_a(described_class) + expect { value.assert_boolean }.to raise_error(Sass::ScriptError) + expect { value.assert_calculation }.to raise_error(Sass::ScriptError) + expect { value.assert_color }.to raise_error(Sass::ScriptError) + expect(value.assert_function).to be(value) + expect { value.assert_map }.to raise_error(Sass::ScriptError) + expect(value.to_map).to be_nil + expect { value.assert_mixin }.to raise_error(Sass::ScriptError) + expect { value.assert_number }.to raise_error(Sass::ScriptError) + expect { value.assert_string }.to raise_error(Sass::ScriptError) + + value } expect( diff --git a/spec/sass/value/mixin_spec.rb b/spec/sass/value/mixin_spec.rb index 15f0dabe..33de18e4 100644 --- a/spec/sass/value/mixin_spec.rb +++ b/spec/sass/value/mixin_spec.rb @@ -8,8 +8,20 @@ fn = double allow(fn).to receive(:call) { |args| expect(args.length).to eq(1) - expect(args[0]).to be_a(described_class) - args[0] + value = args[0] + + expect(value).to be_a(described_class) + expect { value.assert_boolean }.to raise_error(Sass::ScriptError) + expect { value.assert_calculation }.to raise_error(Sass::ScriptError) + expect { value.assert_color }.to raise_error(Sass::ScriptError) + expect { value.assert_function }.to raise_error(Sass::ScriptError) + expect { value.assert_map }.to raise_error(Sass::ScriptError) + expect(value.to_map).to be_nil + expect(value.assert_mixin).to be(value) + expect { value.assert_number }.to raise_error(Sass::ScriptError) + expect { value.assert_string }.to raise_error(Sass::ScriptError) + + value } expect( From de8832d57c609c59bd7ad4c569700df2d4ec466a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 11:04:46 -0800 Subject: [PATCH 345/700] Let Sass::Value::Function take a block as argument --- lib/sass/compiler/host/value_protofier.rb | 2 +- lib/sass/value/function.rb | 4 +++- spec/sass/value/function_spec.rb | 16 +++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/sass/compiler/host/value_protofier.rb b/lib/sass/compiler/host/value_protofier.rb index c6be6c6f..6f48f881 100644 --- a/lib/sass/compiler/host/value_protofier.rb +++ b/lib/sass/compiler/host/value_protofier.rb @@ -179,7 +179,7 @@ def from_proto(proto) end ) when :compiler_function - Sass::Value::Function.new(nil, nil).instance_eval do + Sass::Value::Function.new(nil).instance_eval do @id = obj.id self end diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index c0d4641c..46d35bae 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -10,7 +10,9 @@ class Function # @param signature [::String] # @param callback [Proc] - def initialize(signature, callback) + def initialize(signature, &callback) + raise Sass::ScriptError, 'no block given' unless signature.nil? || callback + @signature = signature @callback = callback end diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index 9f87d95c..11347f1b 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -41,15 +41,15 @@ expect(fn).to have_received(:call) end - it 'can call a function reference from JS' do + it 'can call a function reference from Ruby' do fn = double allow(fn).to receive(:call) { |args| expect(args.length).to eq(0) - described_class.new('plusOne($n)', lambda { |args2| - expect(args2.length).to eq(1) - expect(args2[0].assert_number.value).to eq(2) - Sass::Value::Number.new(args2[0].assert_number.value + 1) - }) + described_class.new('plusOne($n)') do |arguments| + expect(arguments.length).to eq(1) + expect(arguments[0].assert_number.value).to eq(2) + Sass::Value::Number.new(arguments[0].assert_number.value + 1) + end } expect( @@ -84,9 +84,7 @@ it scope do fn = double allow(fn).to receive(:call) { |*| - described_class.new(signature, lambda { |*| - Sass::Value::Null::NULL - }) + described_class.new(signature) { |*| Sass::Value::Null::NULL } } expect do From 2a478901a5692d8a74ddf0781d667e74b0073237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 11:57:50 -0800 Subject: [PATCH 346/700] Update compiler_spec.rb --- spec/sass/compiler_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/sass/compiler_spec.rb b/spec/sass/compiler_spec.rb index a6302c81..3aafca03 100644 --- a/spec/sass/compiler_spec.rb +++ b/spec/sass/compiler_spec.rb @@ -43,7 +43,7 @@ it 'performs complete compilations' do result = compiler.compile_string('@import "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:) expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: baz;\n}") - expect(logger[:debug]).to have_received(:call) + expect(logger[:debug]).to have_received(:call).once end it 'performs compilations in callbacks' do @@ -91,7 +91,7 @@ dir.write({ 'input.scss' => '@import "bar"; .fn {value: foo(bar)}' }) result = compiler.compile(dir.path('input.scss'), importers:, functions:, logger:) expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: bar;\n}") - expect(logger[:debug]).to have_received(:call) + expect(logger[:debug]).to have_received(:call).once end end From 8aa29710f0aec725719af5e39a77e306bb43d166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 12:27:34 -0800 Subject: [PATCH 347/700] Deep freeze Sass::CLI::COMMAND --- ext/sass/Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 1625b719..765f05e6 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -41,12 +41,12 @@ file 'cli.rb' => %w[dart-sass] do |t| command = if File.exist?(runtime) && File.exist?(snapshot) " - File.absolute_path('#{runtime}', __dir__), - File.absolute_path('#{snapshot}', __dir__) + File.absolute_path('#{runtime}', __dir__).freeze, + File.absolute_path('#{snapshot}', __dir__).freeze " else " - File.absolute_path('#{exe}', __dir__) + File.absolute_path('#{exe}', __dir__).freeze " end From 3f02b0a4fb2ac72cc0c2972dcaba67dc2c83ed42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 14:07:14 -0800 Subject: [PATCH 348/700] Internalize assert_calculation_value --- lib/sass/calculation_value.rb | 10 ++++++---- lib/sass/calculation_value/calculation_operation.rb | 4 ++-- lib/sass/value.rb | 6 ------ lib/sass/value/calculation.rb | 4 +++- lib/sass/value/string.rb | 8 -------- 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/sass/calculation_value.rb b/lib/sass/calculation_value.rb index df589fe8..b9109446 100644 --- a/lib/sass/calculation_value.rb +++ b/lib/sass/calculation_value.rb @@ -5,10 +5,12 @@ module Sass # # @see https://sass-lang.com/documentation/js-api/types/calculationvalue/ module CalculationValue - # @return [CalculationValue] - # @raise [ScriptError] - def assert_calculation_value(_name = nil) - self + private + + def assert_calculation_value(value) + raise Sass::ScriptError, "#{value} is not a calculation value" unless value.is_a?(Sass::CalculationValue) + + raise Sass::ScriptError, "Expected #{value} to be unquoted" if value.is_a?(Sass::Value::String) && value.quoted? end end end diff --git a/lib/sass/calculation_value/calculation_operation.rb b/lib/sass/calculation_value/calculation_operation.rb index 2ffd53c3..11cfdf2f 100644 --- a/lib/sass/calculation_value/calculation_operation.rb +++ b/lib/sass/calculation_value/calculation_operation.rb @@ -18,8 +18,8 @@ class CalculationOperation def initialize(operator, left, right) raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator) - left.assert_calculation_value - right.assert_calculation_value + assert_calculation_value(left) + assert_calculation_value(right) @operator = operator.freeze @left = left.freeze diff --git a/lib/sass/value.rb b/lib/sass/value.rb index 3f6d7fd8..72c51ccc 100644 --- a/lib/sass/value.rb +++ b/lib/sass/value.rb @@ -66,12 +66,6 @@ def assert_calculation(name = nil) raise Sass::ScriptError.new("#{self} is not a calculation", name) end - # @return [CalculationValue] - # @raise [ScriptError] - def assert_calculation_value(name = nil) - raise Sass::ScriptError.new("#{self} is not a calculation value", name) - end - # @return [Color] # @raise [ScriptError] def assert_color(name = nil) diff --git a/lib/sass/value/calculation.rb b/lib/sass/value/calculation.rb index efdf20f8..32f26c0e 100644 --- a/lib/sass/value/calculation.rb +++ b/lib/sass/value/calculation.rb @@ -53,7 +53,9 @@ def valid_clamp_arg?(value) private def initialize(name, arguments) - arguments.each(&:assert_calculation_value) + arguments.each do |value| + assert_calculation_value(value) + end @name = name.freeze @arguments = arguments.freeze diff --git a/lib/sass/value/string.rb b/lib/sass/value/string.rb index 8df980d2..0b9383be 100644 --- a/lib/sass/value/string.rb +++ b/lib/sass/value/string.rb @@ -39,14 +39,6 @@ def assert_string(_name = nil) self end - # @return [CalculationValue] - # @raise [ScriptError] - def assert_calculation_value(name = nil) - raise Sass::ScriptError.new("Expected #{self} to be an unquoted string.", name) if quoted? - - self - end - # @param sass_index [Number] # @return [Integer] def sass_index_to_string_index(sass_index, name = nil) From dba34ad2e2474689f7290328b1052189ee263204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 30 Dec 2023 21:37:49 -0800 Subject: [PATCH 349/700] Simplify Sass::Serializer --- lib/sass/exception.rb | 2 +- lib/sass/serializer.rb | 141 +++++----------------------- lib/sass/value/string.rb | 6 +- spec/sass/value/string_to_s_spec.rb | 86 ++++++++++------- 4 files changed, 76 insertions(+), 159 deletions(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index dd8f6070..4b851f7d 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -50,7 +50,7 @@ def to_css border-bottom-style: solid; font-family: monospace, monospace; white-space: pre; - content: #{Serializer.dump_quoted_string(content)}; + content: #{Serializer.serialize_quoted_string(content, ascii_only: true)}; } CSS end diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index 4c4c3bee..9687b615 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -5,134 +5,35 @@ module Sass module Serializer module_function - def dump_quoted_string(string) - include_double_quote = false - include_single_quote = false - buffer = [34] + def serialize_quoted_string(string, ascii_only: false) + buffer = [0x22] string.each_codepoint do |codepoint| - case codepoint - when 34 - return dump_double_quoted_string(string) if include_single_quote - - include_double_quote = true - buffer << 34 - when 39 - return dump_double_quoted_string(string) if include_double_quote - - include_single_quote = true - buffer << 39 - when 92 - buffer << 92 << 92 - when 9 - buffer << 9 - else - if codepoint < 32 || codepoint >= 127 - buffer << 92 - buffer.concat(codepoint.to_s(16).codepoints) - buffer << 32 - else - buffer << codepoint - end - end - end - if include_double_quote - buffer[0] = 39 - buffer << 39 - else - buffer << 34 - end - buffer.pack('U*') - end - - def dump_double_quoted_string(string) - buffer = [34] - string.each_codepoint do |codepoint| - case codepoint - when 34 - buffer << 92 << 34 - when 92 - buffer << 92 << 92 - when 9 - buffer << 9 - else - if codepoint < 32 || codepoint >= 127 - buffer << 92 - buffer.concat(codepoint.to_s(16).codepoints) - buffer << 32 - else - buffer << codepoint - end - end - end - buffer << 34 - buffer.pack('U*') - end - - def serialize_quoted_string(string) - include_double_quote = false - include_single_quote = false - buffer = [34] - string.each_codepoint do |codepoint| - case codepoint - when 34 - return serialize_double_quoted_string(string) if include_single_quote - - include_double_quote = true - buffer << 34 - when 39 - return serialize_double_quoted_string(string) if include_double_quote - - include_single_quote = true - buffer << 39 - when 92 - buffer << 92 << 92 - when 9 - buffer << 9 - else - if codepoint < 32 || codepoint == 127 - buffer << 92 - buffer.concat(codepoint.to_s(16).codepoints) - buffer << 32 - else - buffer << codepoint - end - end - end - if include_double_quote - buffer[0] = 39 - buffer << 39 - else - buffer << 34 - end - buffer.pack('U*') - end - - def serialize_double_quoted_string(string) - buffer = [34] - string.each_codepoint do |codepoint| - case codepoint - when 34 - buffer << 92 << 34 - when 92 - buffer << 92 << 92 - when 9 - buffer << 9 + if codepoint.zero? + # If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD). + buffer << 0xFFFD + elsif codepoint == 0x22 + # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character. + buffer << 0x5C << 0x22 + elsif codepoint == 0x5C + # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character. + buffer << 0x5C << 0x5C + elsif codepoint < 0x20 || (ascii_only ? codepoint >= 0x7F : codepoint == 0x7F) + # If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F, then the character escaped as + # code point. + buffer << 0x5C + buffer.concat(codepoint.to_s(16).codepoints) + buffer << 0x20 else - if codepoint < 32 || codepoint == 127 - buffer << 92 - buffer.concat(codepoint.to_s(16).codepoints) - buffer << 32 - else - buffer << codepoint - end + # Otherwise, the character itself. + buffer << codepoint end end - buffer << 34 + buffer << 0x22 buffer.pack('U*') end def serialize_unquoted_string(string) - string.gsub(/\n +/, "\n") + string.tr("\0", "\uFFFD").gsub(/\n */, ' ') end end diff --git a/lib/sass/value/string.rb b/lib/sass/value/string.rb index 0b9383be..1738355d 100644 --- a/lib/sass/value/string.rb +++ b/lib/sass/value/string.rb @@ -54,11 +54,7 @@ def sass_index_to_string_index(sass_index, name = nil) # @return [String] def to_s - if @quoted - Serializer.serialize_quoted_string(@text) - else - Serializer.serialize_unquoted_string(@text) - end + @quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text) end end end diff --git a/spec/sass/value/string_to_s_spec.rb b/spec/sass/value/string_to_s_spec.rb index 1bf6c54c..6656276b 100644 --- a/spec/sass/value/string_to_s_spec.rb +++ b/spec/sass/value/string_to_s_spec.rb @@ -11,8 +11,15 @@ actual = Sass.compile_string("a { b: #{string} }").css expect(actual).to eq(expected) - expected = Sass.compile_string(expected).css - expect(actual).to eq(expected) + result = nil + Sass.compile_string("$_: yield(#{string});", + functions: { + 'yield($value)' => lambda { |args| + result = args[0].assert_string + Sass::Value::Null::NULL + } + }) + expect(result).to eq(string) end it 'with double quote in text' do @@ -21,8 +28,15 @@ actual = Sass.compile_string("a { b: #{string} }").css expect(actual).to eq(expected) - expected = Sass.compile_string(expected).css - expect(actual).to eq(expected) + result = nil + Sass.compile_string("$_: yield(#{string});", + functions: { + 'yield($value)' => lambda { |args| + result = args[0].assert_string + Sass::Value::Null::NULL + } + }) + expect(result).to eq(string) end it 'with single quote in text' do @@ -31,8 +45,15 @@ actual = Sass.compile_string("a { b: #{string} }").css expect(actual).to eq(expected) - expected = Sass.compile_string(expected).css - expect(actual).to eq(expected) + result = nil + Sass.compile_string("$_: yield(#{string});", + functions: { + 'yield($value)' => lambda { |args| + result = args[0].assert_string + Sass::Value::Null::NULL + } + }) + expect(result).to eq(string) end it 'with double quote and single quote in text' do @@ -41,18 +62,32 @@ actual = Sass.compile_string("a { b: #{string} }").css expect(actual).to eq(expected) - expected = Sass.compile_string(expected).css - expect(actual).to eq(expected) + result = nil + Sass.compile_string("$_: yield(#{string});", + functions: { + 'yield($value)' => lambda { |args| + result = args[0].assert_string + Sass::Value::Null::NULL + } + }) + expect(result).to eq(string) end it 'with special characters in text' do - string = described_class.new((0..255).to_a.pack('U*')) + string = described_class.new((1..256).to_a.pack('U*')) expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected.sub('\0', "\uFFFD")) - - expected = Sass.compile_string(expected).css expect(actual).to eq(expected) + + result = nil + Sass.compile_string("$_: yield(#{string});", + functions: { + 'yield($value)' => lambda { |args| + result = args[0].assert_string + Sass::Value::Null::NULL + } + }) + expect(result).to eq(string) end end @@ -60,50 +95,35 @@ it 'without quote in text' do string = described_class.new('c', quoted: false) expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - expected = Sass.compile_string(expected).css + actual = "a {\n b: #{string};\n}" expect(actual).to eq(expected) end it 'with double quote in text' do string = described_class.new('""', quoted: false) expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - expected = Sass.compile_string(expected).css + actual = "a {\n b: #{string};\n}" expect(actual).to eq(expected) end it 'with single quote in text' do string = described_class.new("''", quoted: false) expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected.tr("'", '"')) - - expected = Sass.compile_string(expected).css + actual = "a {\n b: #{string};\n}" expect(actual).to eq(expected) end it 'with double quote and single quote in text' do string = described_class.new('"\'"', quoted: false) expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - expected = Sass.compile_string(expected).css + actual = "a {\n b: #{string};\n}" expect(actual).to eq(expected) end it 'with newline followed by spaces in text' do - string = described_class.new("a\nb\n c\n d", quoted: false) + string = described_class.new("a b\n c\n d\n\t e \n f", quoted: false) expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - expected = Sass.compile_string(expected).css + actual = "a {\n b: #{string};\n}" expect(actual).to eq(expected) end end From ae9d568b2d2d77db002a8015fa4fa6efe45aade8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 10:01:00 -0800 Subject: [PATCH 350/700] Update Sass.info format for unknown implementation name --- lib/sass/compiler/host.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 4bd6e033..2e8befc2 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -74,12 +74,14 @@ def version_request )) end - info = "#{version_response.implementation_name}\t#{version_response.implementation_version}\t(Sass Compiler)" - case version_response.implementation_name - when /\bdart\b/i - info << "\t[Dart]" - end - info + lang = case version_response.implementation_name + when /\bdart\b/i + '[Dart]' + else + '[?]' + end + + "#{version_response.implementation_name}\t#{version_response.implementation_version}\t(Sass Compiler)\t#{lang}" end def compile_response(message) From d94a6c8f1eb82c69c41e7ef4ac95972ad200c828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 12:40:15 -0800 Subject: [PATCH 351/700] Use Trusted Publishing on RubyGems.org --- .github/workflows/release.yml | 16 ++++++++++++---- sass-embedded.gemspec | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69fed6cf..71ac4a9c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,9 @@ jobs: runs-on: ubuntu-latest + permissions: + id-token: write + steps: - name: Checkout uses: actions/checkout@v4 @@ -26,10 +29,11 @@ jobs: - name: Compile run: bundle exec rake compile + - name: Configure trusted publishing credentials + uses: rubygems/configure-rubygems-credentials@v1.0.0 + - name: Release run: rake -f -r bundler/gem_tasks release - env: - GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} release-pre-compiled: @@ -39,6 +43,9 @@ jobs: runs-on: ${{ matrix.os }} + permissions: + id-token: write + strategy: fail-fast: false matrix: @@ -92,7 +99,8 @@ jobs: - name: Compile run: bundle exec rake compile ext_platform=${{ matrix.platform }} + - name: Configure trusted publishing credentials + uses: rubygems/configure-rubygems-credentials@v1.0.0 + - name: Release run: rake -f -r bundler/gem_tasks release gem_platform=${{ matrix.platform }} - env: - GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index cb9b4dcb..d8eff20f 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -2,7 +2,7 @@ require_relative 'lib/sass/embedded/version' -Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA +Gem::Specification.new do |spec| spec.name = 'sass-embedded' spec.version = Sass::Embedded::VERSION spec.authors = ['なつき'] @@ -14,7 +14,8 @@ Gem::Specification.new do |spec| # rubocop:disable Gemspec/RequireMFA spec.metadata = { 'documentation_uri' => "https://rubydoc.info/gems/#{spec.name}/#{spec.version}", 'source_code_uri' => "#{spec.homepage}/tree/v#{spec.version}", - 'funding_uri' => 'https://github.com/sponsors/ntkme' + 'funding_uri' => 'https://github.com/sponsors/ntkme', + 'rubygems_mfa_required' => 'true' } spec.bindir = 'exe' From 611b7be741b5fb7cab13e3ea9363b03bedc08e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 21:36:35 -0800 Subject: [PATCH 352/700] Update serializer.rb --- lib/sass/serializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index 9687b615..ff3c47c3 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -18,8 +18,8 @@ def serialize_quoted_string(string, ascii_only: false) # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character. buffer << 0x5C << 0x5C elsif codepoint < 0x20 || (ascii_only ? codepoint >= 0x7F : codepoint == 0x7F) - # If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F, then the character escaped as - # code point. + # If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F, + # then the character escaped as code point. buffer << 0x5C buffer.concat(codepoint.to_s(16).codepoints) buffer << 0x20 From e6507f3c356841e8f67563af46f13b13b4425920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 21:39:44 -0800 Subject: [PATCH 353/700] Update value.rb --- lib/sass/value.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/value.rb b/lib/sass/value.rb index 72c51ccc..a3cbec14 100644 --- a/lib/sass/value.rb +++ b/lib/sass/value.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require_relative 'calculation_value' - module Sass # The abstract base class of Sass's value types. # @@ -123,6 +121,7 @@ def to_a_length end end +require_relative 'calculation_value' require_relative 'value/list' require_relative 'value/argument_list' require_relative 'value/boolean' From fe7e253df86a4337337a237944df60a4c226a27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 21:41:27 -0800 Subject: [PATCH 354/700] Update fork_tracker.rb --- lib/sass/fork_tracker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/fork_tracker.rb b/lib/sass/fork_tracker.rb index 4c84dc24..2453bae8 100644 --- a/lib/sass/fork_tracker.rb +++ b/lib/sass/fork_tracker.rb @@ -44,7 +44,7 @@ def _fork private_constant :CoreExt - Process.singleton_class.prepend(CoreExt) + Process.singleton_class.prepend(CoreExt) if Process.respond_to?(:_fork) end private_constant :ForkTracker From 54b08f10a5448e2da09ac4547a253b8022a1e87c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 22:06:46 -0800 Subject: [PATCH 355/700] Improve CalculationValue error message --- lib/sass/calculation_value.rb | 10 +++++++--- lib/sass/calculation_value/calculation_operation.rb | 7 ++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/sass/calculation_value.rb b/lib/sass/calculation_value.rb index b9109446..68f69de7 100644 --- a/lib/sass/calculation_value.rb +++ b/lib/sass/calculation_value.rb @@ -7,10 +7,14 @@ module Sass module CalculationValue private - def assert_calculation_value(value) - raise Sass::ScriptError, "#{value} is not a calculation value" unless value.is_a?(Sass::CalculationValue) + def assert_calculation_value(value, name = nil) + if !value.is_a?(Sass::CalculationValue) || (value.is_a?(Sass::Value::String) && value.quoted?) + raise Sass::ScriptError.new( + "#{value} must be one of SassNumber, unquoted SassString, SassCalculation, CalculationOperation", name + ) + end - raise Sass::ScriptError, "Expected #{value} to be unquoted" if value.is_a?(Sass::Value::String) && value.quoted? + value end end end diff --git a/lib/sass/calculation_value/calculation_operation.rb b/lib/sass/calculation_value/calculation_operation.rb index 11cfdf2f..32a1eb67 100644 --- a/lib/sass/calculation_value/calculation_operation.rb +++ b/lib/sass/calculation_value/calculation_operation.rb @@ -18,12 +18,9 @@ class CalculationOperation def initialize(operator, left, right) raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator) - assert_calculation_value(left) - assert_calculation_value(right) - @operator = operator.freeze - @left = left.freeze - @right = right.freeze + @left = assert_calculation_value(left, 'left') + @right = assert_calculation_value(right, 'right') end # @return [::String] From 1fe1292fcee85e4182978fce28f7375e8aecff67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 22:18:15 -0800 Subject: [PATCH 356/700] Fix flaky concurrent access to rspec double --- spec/sass/compiler_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/sass/compiler_spec.rb b/spec/sass/compiler_spec.rb index 3aafca03..fb57d6b1 100644 --- a/spec/sass/compiler_spec.rb +++ b/spec/sass/compiler_spec.rb @@ -75,7 +75,8 @@ it 'handles multiple concurrent compilations' do results = Array.new(100) do |i| Thread.new do - compiler.compile_string("@import \"#{i}\"; .fn {value: foo(#{i})}", importers:, functions:, logger:) + compiler.compile_string("@import \"#{i}\"; .fn {value: foo(#{i})}", + importers:, functions:, logger: Sass::Logger.silent) end end.map(&:value) @@ -128,7 +129,8 @@ Thread.new do filename = "input-#{i}.scss" dir.write({ filename => "@import \"#{i}\"; .fn {value: foo(#{i})}" }) - compiler.compile(dir.path(filename), importers:, functions:, logger:) + compiler.compile(dir.path(filename), + importers:, functions:, logger: Sass::Logger.silent) end end.map(&:value) From 4cedcb9fa2f4631aae68da25e0ac013cc45b52b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Dec 2023 22:55:38 -0800 Subject: [PATCH 357/700] Update dispatcher.rb --- lib/sass/compiler/dispatcher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index 6bc699a1..c8b4f5a0 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -123,7 +123,7 @@ def initialize(dispatcher, host) end def disconnect - @dispatcher.unsubscribe(id) + @dispatcher.unsubscribe(@id) end def error(...) From ae25371848404d0cd42d06513a8196aa02737598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 1 Jan 2024 15:27:33 -0800 Subject: [PATCH 358/700] Freeze Sass::Value::Function signature --- lib/sass/value/function.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 46d35bae..557d3982 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -13,8 +13,8 @@ class Function def initialize(signature, &callback) raise Sass::ScriptError, 'no block given' unless signature.nil? || callback - @signature = signature - @callback = callback + @signature = signature.freeze + @callback = callback.freeze end # @return [Integer, nil] From 9119924196b2aee153a39da43ea65d2e2520a360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 2 Jan 2024 11:21:07 -0800 Subject: [PATCH 359/700] Convert String like objects such as ActiveSupport::SafeBuffer to String --- lib/sass/compiler/host.rb | 2 +- lib/sass/compiler/host/importer_registry.rb | 2 +- lib/sass/compiler/host/value_protofier.rb | 2 +- spec/sass_importer_spec.rb | 6 ++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 2e8befc2..0cb84eac 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -44,7 +44,7 @@ def compile_request(path:, send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( string: unless source.nil? EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( - source:, + source: source.to_str, url: url&.to_s, syntax: Protofier.to_proto_syntax(syntax), importer: (@importer_registry.register(importer) unless importer.nil?) diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index 56e72706..d215610b 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -81,7 +81,7 @@ def import(import_request) EmbeddedProtocol::InboundMessage::ImportResponse.new( id: import_request.id, success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new( - contents: importer_result.contents, + contents: importer_result.contents.to_str, syntax: Protofier.to_proto_syntax(importer_result.syntax), source_map_url: (importer_result.source_map_url&.to_s if importer_result.respond_to?(:source_map_url)) ) diff --git a/lib/sass/compiler/host/value_protofier.rb b/lib/sass/compiler/host/value_protofier.rb index 6f48f881..d69b1fe3 100644 --- a/lib/sass/compiler/host/value_protofier.rb +++ b/lib/sass/compiler/host/value_protofier.rb @@ -16,7 +16,7 @@ def to_proto(obj) when Sass::Value::String EmbeddedProtocol::Value.new( string: EmbeddedProtocol::Value::String.new( - text: obj.text, + text: obj.text.to_str, quoted: obj.quoted? ) ) diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index e7518742..8eff24ed 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -1080,15 +1080,13 @@ def expect_from_import(canonicalize, expected) canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| { - contents: StringIO.new('not a string'), + contents: :'not a string', syntax: 'scss' } } }] ) - end.to raise_sass_compile_error.with_line(0).with_message( - "Invalid argument for string field 'contents' (given StringIO)" - ) + end.to raise_sass_compile_error.with_line(0).with_message("undefined method `to_str'") end end From 84f0eeb980784624b77fbd4ee20656ea82bc90e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:34:54 -0800 Subject: [PATCH 360/700] Bump sass from 1.69.6 to 1.69.7 in /ext/sass (#180) Bumps [sass](https://github.com/sass/dart-sass) from 1.69.6 to 1.69.7. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.6...1.69.7) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 6e46cb84..008f7707 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.6" + "sass": "1.69.7" } } From 34a7ff9baa5a18b0835addc96a644a78d9a7becf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 2 Jan 2024 14:41:11 -0800 Subject: [PATCH 361/700] v1.69.7 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index c58995e9..21fe106c 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.69.6' + VERSION = '1.69.7' end end From 949d810d77eb734b835ee039eb5f3d849250f931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 2 Jan 2024 16:57:59 -0800 Subject: [PATCH 362/700] Remove trailing newline in Sass.info --- lib/sass/compiler.rb | 8 ++++---- lib/sass/compiler/host.rb | 20 ++++++++++++-------- spec/sass_info_spec.rb | 4 ++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 23160bd7..c67aade1 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -174,10 +174,10 @@ def compile_string(source, # @return [String] Information about the Sass implementation. # @see https://sass-lang.com/documentation/js-api/variables/info/ def info - @info ||= <<~INFO.freeze - sass-embedded\t#{Embedded::VERSION}\t(Embedded Host)\t[Ruby] - #{Host.new(@dispatcher).version_request} - INFO + @info ||= [ + ['sass-embedded', Embedded::VERSION, '(Embedded Host)', '[Ruby]'].join("\t"), + Host.new(@dispatcher).version_request.join("\t") + ].join("\n").freeze end def close diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 0cb84eac..e9f06890 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -74,14 +74,18 @@ def version_request )) end - lang = case version_response.implementation_name - when /\bdart\b/i - '[Dart]' - else - '[?]' - end - - "#{version_response.implementation_name}\t#{version_response.implementation_version}\t(Sass Compiler)\t#{lang}" + info = [ + version_response.implementation_name, + version_response.implementation_version, + '(Sass Compiler)' + ] + + case version_response.implementation_name + when 'dart-sass' + info << '[Dart]' + end + + info end def compile_response(message) diff --git a/spec/sass_info_spec.rb b/spec/sass_info_spec.rb index 367d858c..62d43244 100644 --- a/spec/sass_info_spec.rb +++ b/spec/sass_info_spec.rb @@ -20,5 +20,9 @@ version = described_class.info.split[1] expect(version).to eq(described_class::Embedded::VERSION) end + + it 'has no trailing whitespace' do + expect(described_class.info).to eq(described_class.info.strip) + end end end From f832e37de5291e05f64b93c5a7403d14a57ea7df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jan 2024 09:15:15 -0800 Subject: [PATCH 363/700] Update rubocop-rspec requirement from ~> 2.25.0 to ~> 2.26.0 (#181) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.25.0...v2.26.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ee24652d..10875467 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.59.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.25.0' + gem 'rubocop-rspec', '~> 2.26.0' end From 23be802204d50fc52f84c01f4f59efed1e580623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 10:19:06 -0800 Subject: [PATCH 364/700] Match Sass::Value::List with js-api --- lib/sass/compiler/host/value_protofier.rb | 4 ++-- lib/sass/value/list.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/sass/compiler/host/value_protofier.rb b/lib/sass/compiler/host/value_protofier.rb index d69b1fe3..5ab37c68 100644 --- a/lib/sass/compiler/host/value_protofier.rb +++ b/lib/sass/compiler/host/value_protofier.rb @@ -57,7 +57,7 @@ def to_proto(obj) EmbeddedProtocol::Value.new( argument_list: EmbeddedProtocol::Value::ArgumentList.new( id: obj.instance_eval { @id }, - contents: obj.contents.map { |element| to_proto(element) }, + contents: obj.to_a.map { |element| to_proto(element) }, keywords: obj.keywords.transform_values { |value| to_proto(value) }, separator: ListSeparator.to_proto(obj.separator) ) @@ -65,7 +65,7 @@ def to_proto(obj) when Sass::Value::List EmbeddedProtocol::Value.new( list: EmbeddedProtocol::Value::List.new( - contents: obj.contents.map { |element| to_proto(element) }, + contents: obj.to_a.map { |element| to_proto(element) }, separator: ListSeparator.to_proto(obj.separator), has_brackets: obj.bracketed? ) diff --git a/lib/sass/value/list.rb b/lib/sass/value/list.rb index c3269e39..dac01e65 100644 --- a/lib/sass/value/list.rb +++ b/lib/sass/value/list.rb @@ -21,9 +21,6 @@ def initialize(contents = [], separator: ',', bracketed: false) @bracketed = bracketed.freeze end - # @return [Array] - attr_reader :contents - # @return [::String, nil] attr_reader :separator @@ -35,7 +32,7 @@ def bracketed? # @return [::Boolean] def ==(other) (other.is_a?(Sass::Value::List) && - other.contents == contents && + other.to_a == to_a && other.separator == separator && other.bracketed? == bracketed?) || (to_a.empty? && other.is_a?(Sass::Value::Map) && other.to_a.empty?) @@ -56,7 +53,10 @@ def hash @hash ||= contents.hash end - alias to_a contents + # @return [Array] + def to_a + @contents + end # @return [Map, nil] def to_map From a192c24134047d260cf99131f58bdd052575d493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 10:36:39 -0800 Subject: [PATCH 365/700] Do not duplicate Numeric --- lib/sass/value/number.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index d58fc574..6b290d9e 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -38,7 +38,6 @@ def initialize(value, unit = nil) end unless denominator_units.empty? && numerator_units.empty? - value = value.dup numerator_units = numerator_units.dup new_denominator_units = [] From 784f0f2120a761ed7f8a5cb189dba5104cf368e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 10:46:00 -0800 Subject: [PATCH 366/700] Use Symbol keys for Sass::Value::ArgumentList keywords --- lib/sass/compiler/host/value_protofier.rb | 6 +++--- lib/sass/value/argument_list.rb | 6 +++--- spec/sass/value/argument_list_spec.rb | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/sass/compiler/host/value_protofier.rb b/lib/sass/compiler/host/value_protofier.rb index 5ab37c68..03f3c306 100644 --- a/lib/sass/compiler/host/value_protofier.rb +++ b/lib/sass/compiler/host/value_protofier.rb @@ -58,7 +58,7 @@ def to_proto(obj) argument_list: EmbeddedProtocol::Value::ArgumentList.new( id: obj.instance_eval { @id }, contents: obj.to_a.map { |element| to_proto(element) }, - keywords: obj.keywords.transform_values { |value| to_proto(value) }, + keywords: obj.keywords.to_h { |key, value| [key.to_s, to_proto(value)] }, separator: ListSeparator.to_proto(obj.separator) ) ) @@ -156,8 +156,8 @@ def from_proto(proto) obj.contents.map do |element| from_proto(element) end, - obj.keywords.entries.to_h.transform_values! do |value| - from_proto(value) + obj.keywords.entries.to_h do |key, value| + [key.to_sym, from_proto(value)] end, ListSeparator.from_proto(obj.separator) ).instance_eval do diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index e43a62e5..0165215d 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -10,17 +10,17 @@ module Value # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/ class ArgumentList < List # @param contents [Array] - # @param keywords [Hash<::String, Value>] + # @param keywords [Hash] # @param separator [::String] def initialize(contents = [], keywords = {}, separator = ',') super(contents, separator:) @id = 0 @keywords_accessed = false - @keywords = keywords.transform_keys(&:to_s).freeze + @keywords = keywords.freeze end - # @return [Hash<::String, Value>] + # @return [Hash] def keywords @keywords_accessed = true @keywords diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index d7b9f664..11d481d0 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -37,7 +37,7 @@ expect(args[0].to_a.length).to eq(0) keywords = args[0].keywords expect(keywords).to eq({ - 'bar' => Sass::Value::String.new('baz', quoted: false) + bar: Sass::Value::String.new('baz', quoted: false) }) Sass::Value::Null::NULL } @@ -78,7 +78,7 @@ subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], - { 'd' => Sass::Value::String.new('e') } + { d: Sass::Value::String.new('e') } ) end @@ -110,7 +110,7 @@ it 'returns its keywords' do expect(list.keywords).to eq( - { 'd' => Sass::Value::String.new('e') } + { d: Sass::Value::String.new('e') } ) end end @@ -119,7 +119,7 @@ subject(:list) do described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], - { 'd' => Sass::Value::String.new('e') } + { d: Sass::Value::String.new('e') } ) end @@ -127,7 +127,7 @@ expect(list).to eq( described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], - { 'd' => Sass::Value::String.new('e') } + { d: Sass::Value::String.new('e') } ) ) end @@ -136,7 +136,7 @@ expect(list).to eq( described_class.new( [Sass::Value::String.new('a'), Sass::Value::String.new('b'), Sass::Value::String.new('c')], - { 'f' => Sass::Value::String.new('g') } + { f: Sass::Value::String.new('g') } ) ) end From fd3091fb32afac4d66e1cb80d57d772ce80b2dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 11:14:32 -0800 Subject: [PATCH 367/700] Freeze Sass::Value::Number units --- lib/sass/value/number.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index 6b290d9e..ce8c4e88 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -62,8 +62,8 @@ def initialize(value, unit = nil) end @value = value.freeze - @numerator_units = numerator_units.freeze - @denominator_units = denominator_units.freeze + @numerator_units = numerator_units.each(&:freeze).freeze + @denominator_units = denominator_units.each(&:freeze).freeze end # @return [Numeric] From 0a00738679a775b750c2e4e00e53436f4ce21c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 11:17:37 -0800 Subject: [PATCH 368/700] Revert "Do not duplicate Numeric" This reverts commit a192c24134047d260cf99131f58bdd052575d493. --- lib/sass/value/number.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index ce8c4e88..69bd4161 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -38,6 +38,7 @@ def initialize(value, unit = nil) end unless denominator_units.empty? && numerator_units.empty? + value = value.dup numerator_units = numerator_units.dup new_denominator_units = [] From c8436a8e3ac005b30c65728fca9ad57d131768ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 11:37:47 -0800 Subject: [PATCH 369/700] Test ruby-head --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4d6eff7..9ff5d1cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,7 @@ jobs: - '3.1' - '3.2' - '3.3' + - head - jruby - truffleruby - truffleruby+graalvm From 0dedf6f07d754effb988cf52399738a078ff174d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 11:52:32 -0800 Subject: [PATCH 370/700] Test jruby-head --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ff5d1cc..f7f4f280 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,7 @@ jobs: - '3.3' - head - jruby + - jruby-head - truffleruby - truffleruby+graalvm exclude: @@ -58,12 +59,12 @@ jobs: - name: Compile run: bundle exec rake compile - - name: Install - run: rake -f -r bundler/gem_tasks install - - name: Spec run: bundle exec rake spec + - name: Install + run: rake -f -r bundler/gem_tasks install + spec-musl: name: spec (alpine-latest, ${{ matrix.ruby-version }}) From 2c51ef778eabc67517b47ac7554bfd3df9dfb08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 5 Jan 2024 15:03:15 -0800 Subject: [PATCH 371/700] Fix potential uninitialized constant --- lib/sass/compiler.rb | 1 + lib/sass/embedded.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index c67aade1..a9ae8aac 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -7,6 +7,7 @@ require_relative 'compiler/dispatcher_manager' require_relative 'compiler/host' require_relative 'compiler/varint' +require_relative 'embedded/version' require_relative 'embedded_protocol' require_relative 'exception' require_relative 'fork_tracker' diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 08983fd8..fee5bcbe 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative 'compiler' -require_relative 'embedded/version' # The Sass module. # From 98392fa813d378638ba23fc48ba6afbe22ccb603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 6 Jan 2024 15:46:25 -0800 Subject: [PATCH 372/700] Match serialize_quoted_string with dart-sass - Improve serializer performance by up to 27x --- lib/sass/exception.rb | 10 +- lib/sass/serializer.rb | 43 ++++--- spec/sass/value/string_to_s_spec.rb | 166 +++++++++------------------- 3 files changed, 80 insertions(+), 139 deletions(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 4b851f7d..d05d3b42 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -28,7 +28,7 @@ def full_message(highlight: nil, order: nil, **) highlight = Exception.respond_to?(:to_tty?) && Exception.to_tty? if highlight.nil? if highlight - +@full_message + @full_message.dup else @full_message.gsub(/\e\[[0-9;]*m/, '') end @@ -38,7 +38,7 @@ def full_message(highlight: nil, order: nil, **) def to_css content = full_message(highlight: false, order: :top) - <<~CSS + <<~CSS.freeze /* #{content.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */ body::before { @@ -50,7 +50,11 @@ def to_css border-bottom-style: solid; font-family: monospace, monospace; white-space: pre; - content: #{Serializer.serialize_quoted_string(content, ascii_only: true)}; + content: #{Serializer.serialize_quoted_string(content).gsub(/[^[:ascii:]][\h\t ]?/) do |match| + replacement = "\\#{match.ord.to_s(16)}" + replacement << " #{match[1]}" if match.length > 1 + replacement + end}; } CSS end diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index ff3c47c3..8216eeb8 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -5,31 +5,26 @@ module Sass module Serializer module_function - def serialize_quoted_string(string, ascii_only: false) - buffer = [0x22] - string.each_codepoint do |codepoint| - if codepoint.zero? - # If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD). - buffer << 0xFFFD - elsif codepoint == 0x22 - # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character. - buffer << 0x5C << 0x22 - elsif codepoint == 0x5C - # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character. - buffer << 0x5C << 0x5C - elsif codepoint < 0x20 || (ascii_only ? codepoint >= 0x7F : codepoint == 0x7F) - # If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F, - # then the character escaped as code point. - buffer << 0x5C - buffer.concat(codepoint.to_s(16).codepoints) - buffer << 0x20 - else - # Otherwise, the character itself. - buffer << codepoint - end + CSS_ESCAPE = { + "\0" => "\uFFFD", + '\\' => '\\\\', + '"' => '\\"', + "'" => "\\'", + **[*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"].product( + [*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil] + ).to_h do |c, x| + ["#{c}#{x}".freeze, "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze] + end + }.freeze + + private_constant :CSS_ESCAPE + + def serialize_quoted_string(string) + if !string.include?('"') || string.include?("'") + %("#{string.gsub(/[\0\\"]|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}") + else + %('#{string.gsub(/[\0\\']|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}') end - buffer << 0x22 - buffer.pack('U*') end def serialize_unquoted_string(string) diff --git a/spec/sass/value/string_to_s_spec.rb b/spec/sass/value/string_to_s_spec.rb index 6656276b..257d70dc 100644 --- a/spec/sass/value/string_to_s_spec.rb +++ b/spec/sass/value/string_to_s_spec.rb @@ -5,126 +5,68 @@ describe Sass::Value::String do describe '.to_s' do describe 'serialize quoted string' do - it 'without quote in text' do - string = described_class.new('c') - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - result = nil - Sass.compile_string("$_: yield(#{string});", - functions: { - 'yield($value)' => lambda { |args| - result = args[0].assert_string - Sass::Value::Null::NULL - } - }) - expect(result).to eq(string) + let(:whitespace) do + " \t\r\n\v\f".chars.repeated_permutation(3).map(&:join) end - it 'with double quote in text' do - string = described_class.new('"') - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - result = nil - Sass.compile_string("$_: yield(#{string});", - functions: { - 'yield($value)' => lambda { |args| - result = args[0].assert_string - Sass::Value::Null::NULL - } - }) - expect(result).to eq(string) - end - - it 'with single quote in text' do - string = described_class.new("'") - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - result = nil - Sass.compile_string("$_: yield(#{string});", - functions: { - 'yield($value)' => lambda { |args| - result = args[0].assert_string - Sass::Value::Null::NULL - } - }) - expect(result).to eq(string) + let(:cntrl) do + [*"\x01".."\x1F", "\x7F"].repeated_permutation(2).map(&:join) end - it 'with double quote and single quote in text' do - string = described_class.new('\'"') - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - result = nil - Sass.compile_string("$_: yield(#{string});", - functions: { - 'yield($value)' => lambda { |args| - result = args[0].assert_string - Sass::Value::Null::NULL - } - }) - expect(result).to eq(string) - end - - it 'with special characters in text' do - string = described_class.new((1..256).to_a.pack('U*')) - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = Sass.compile_string("a { b: #{string} }").css - expect(actual).to eq(expected) - - result = nil - Sass.compile_string("$_: yield(#{string});", - functions: { - 'yield($value)' => lambda { |args| - result = args[0].assert_string - Sass::Value::Null::NULL - } - }) - expect(result).to eq(string) + { + 'without quote or backslash in text' => 'c', + 'with double quote in text' => '"', + 'with single quote in text' => "'", + 'with double quote and single quote in text' => '\'"', + 'with more double quote than single quote in text' => '"\'"', + 'with more single quote than double quote in text' => "'\"'", + 'with backslash in text' => '\\', + 'with [[:space:]] in text' => proc { whitespace.join }, + 'with [[:space:]] followed by [[:alpha:]] in text' => proc { whitespace.join('x') }, + 'with [[:space:]] followed by [[:xdigit:]] in text' => proc { whitespace.join('c') }, + 'with [[:cntrl:]] in text' => proc { cntrl.join }, + 'with [[:cntrl:]] followed by [[:alpha:]] in text' => proc { cntrl.join('x') }, + 'with [[:cntrl:]] followed by [[:xdigit:]] in text' => proc { cntrl.join('c') }, + 'with [[:ascii:]] in text' => [*"\1".."\x7F"].join + }.each do |doc_string, subject_string| + it doc_string do + string = described_class.new(subject_string.is_a?(Proc) ? instance_eval(&subject_string) : subject_string) + expected = Sass.compile_string('a { b: foo() }', + charset: false, + style: :compressed, + functions: { 'foo()' => ->(_) { string } }).css + actual = "a{b:#{string}}" + expect(actual).to eq(expected) + expect(actual).to eq(Sass.compile_string(actual, charset: false, style: :compressed).css) + + result = nil + Sass.compile_string("$_: yield(#{string});", + functions: { + 'yield($value)' => lambda { |args| + result = args[0].assert_string + Sass::Value::Null::NULL + } + }) + expect(result).to eq(string) + end end end describe 'serialize unquoted string' do - it 'without quote in text' do - string = described_class.new('c', quoted: false) - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = "a {\n b: #{string};\n}" - expect(actual).to eq(expected) - end - - it 'with double quote in text' do - string = described_class.new('""', quoted: false) - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = "a {\n b: #{string};\n}" - expect(actual).to eq(expected) - end - - it 'with single quote in text' do - string = described_class.new("''", quoted: false) - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = "a {\n b: #{string};\n}" - expect(actual).to eq(expected) - end - - it 'with double quote and single quote in text' do - string = described_class.new('"\'"', quoted: false) - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = "a {\n b: #{string};\n}" - expect(actual).to eq(expected) - end - - it 'with newline followed by spaces in text' do - string = described_class.new("a b\n c\n d\n\t e \n f", quoted: false) - expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css - actual = "a {\n b: #{string};\n}" - expect(actual).to eq(expected) + { + 'without quote or backslash in text': 'c', + 'with double quote in text': 'url("a")', + 'with single quote in text': "url('b')", + 'with double quote and single quote in text': 'url("\'")', + 'without backslash in text': '\\', + 'with newline followed by space in text': " \n".chars.repeated_permutation(3).map(&:join).join('x') + }.each do |doc_string, subject_string| + it doc_string do + string = described_class.new(subject_string, quoted: false) + expected = Sass.compile_string('a { b: foo() }', functions: { 'foo()' => ->(_) { string } }).css + actual = "a {\n b: #{string};\n}" + expect(actual).to eq(expected) + end end end end From 89a97ab6856c0d31246de869150d006613f486a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 Jan 2024 01:19:41 -0800 Subject: [PATCH 373/700] Update sass-embedded.gemspec --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index d8eff20f..52e5c34d 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| ] end - spec.required_ruby_version = '>= 3.1.3' + spec.required_ruby_version = '>= 3.1.0' spec.add_runtime_dependency 'google-protobuf', '~> 3.25' spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') From e10b463b5b1ee6bf8d6031f0b8ec3fe975cdd60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 Jan 2024 01:29:54 -0800 Subject: [PATCH 374/700] Refactor dispatcher --- lib/sass/compiler/dispatcher.rb | 28 ----------------------- lib/sass/compiler/dispatcher_manager.rb | 30 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index c8b4f5a0..f9684504 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -41,10 +41,6 @@ def unsubscribe(id) end end - def connect(host) - Channel.new(self, host) - end - def close @mutex.synchronize do _close @@ -112,30 +108,6 @@ def _idle def _idle? @id == 1 end - - # The {Channel} between {Dispatcher} and {Host}. - class Channel - attr_reader :id - - def initialize(dispatcher, host) - @dispatcher = dispatcher - @id = @dispatcher.subscribe(host) - end - - def disconnect - @dispatcher.unsubscribe(@id) - end - - def error(...) - @dispatcher.error(...) - end - - def send_proto(...) - @dispatcher.send_proto(...) - end - end - - private_constant :Channel end private_constant :Dispatcher diff --git a/lib/sass/compiler/dispatcher_manager.rb b/lib/sass/compiler/dispatcher_manager.rb index 62136bdf..c603cf7c 100644 --- a/lib/sass/compiler/dispatcher_manager.rb +++ b/lib/sass/compiler/dispatcher_manager.rb @@ -27,16 +27,40 @@ def closed? end end - def connect(...) + def connect(host) @mutex.synchronize do raise IOError, 'closed compiler' if @dispatcher.nil? - @dispatcher.connect(...) + Channel.new(@dispatcher, host) rescue Errno::EBUSY @dispatcher = @dispatcher_class.new - @dispatcher.connect(...) + Channel.new(@dispatcher, host) end end + + # The {Channel} between {Dispatcher} and {Host}. + class Channel + attr_reader :id + + def initialize(dispatcher, host) + @dispatcher = dispatcher + @id = @dispatcher.subscribe(host) + end + + def disconnect + @dispatcher.unsubscribe(@id) + end + + def error(...) + @dispatcher.error(...) + end + + def send_proto(...) + @dispatcher.send_proto(...) + end + end + + private_constant :Channel end private_constant :DispatcherManager From 961b3251f1e518902f9eb9de654bbb91240d602e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 12 Jan 2024 01:33:16 -0800 Subject: [PATCH 375/700] Refactor FunctionRegistry --- lib/sass/compiler/host/function_registry.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 26fa3f7d..b0dac360 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -42,11 +42,18 @@ def register(function) end def function_call(function_call_request) + function = case function_call_request.identifier + when :name + @functions_by_name[function_call_request.name] + when :function_id + @functions_by_id[function_call_request.function_id] + end + arguments = function_call_request.arguments.map do |argument| value_protofier.from_proto(argument) end - success = value_protofier.to_proto(get(function_call_request).call(arguments)) + success = value_protofier.to_proto(function.call(arguments)) accessed_argument_lists = arguments.filter_map do |argument| if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed } argument.instance_eval { @id } @@ -67,15 +74,6 @@ def function_call(function_call_request) private - def get(function_call_request) - case function_call_request.identifier - when :name - @functions_by_name[function_call_request.name] - when :function_id - @functions_by_id[function_call_request.function_id] - end - end - def value_protofier @value_protofier ||= ValueProtofier.new(self) end From 7d4bc5b4670fc90c832b1a2bc74919c575025b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 14 Jan 2024 10:10:05 -0800 Subject: [PATCH 376/700] Update CONTRIBUTING.md --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ab9eb758..9eff0ba8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,11 +35,11 @@ │ │ │ │ │ └─────────┬─────────┘ │ └─────────┘ │ Yes │ - │ ┌──────────┴─────────┐ ┌─────────┐ -┌─────────▼─────────┐ No │ │ Yes │ │ -│ ◄─────────────────────────────┤ id == 0xFFFFFFFF ◄─────────┤ Idle? ◄──────────┐ -│ id = 0x00000001 │ │ │ │ │ │ -│ ├───────────────┐ └────────────────────┘ └─────────┘ │ + │ ┌───────────┴──────────┐ ┌─────────┐ +┌─────────▼─────────┐ No │ │ Yes │ │ +│ ◄────────────────────────────┤ id == 0xFFFFFFFF ? ◄────────┤ Idle? ◄──────────┐ +│ id = 0x00000001 │ │ │ │ │ │ +│ ├───────────────┐ └──────────────────────┘ └─────────┘ │ └───────────────────┘ │ │ ┌────────────▼────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │ │ │ │ │ │ │ │ From 5eaf7a4fa7647fb02adb78b37157964dda1e3f42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 08:39:38 -0800 Subject: [PATCH 377/700] Update rubocop requirement from ~> 1.59.0 to ~> 1.60.0 (#182) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.59.0 to ~> 1.60.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.59.0...v1.60.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Update spec helper --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- Gemfile | 2 +- spec/sandbox.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 10875467..fd409f7e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.12.0' - gem 'rubocop', '~> 1.59.0' + gem 'rubocop', '~> 1.60.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.26.0' diff --git a/spec/sandbox.rb b/spec/sandbox.rb index ef5ebd20..84a5e0e0 100644 --- a/spec/sandbox.rb +++ b/spec/sandbox.rb @@ -7,7 +7,7 @@ module Sandbox def sandbox Dir.mktmpdir do |dir| - yield SandboxDirectory.new dir + yield SandboxDirectory.new(dir) end end @@ -38,8 +38,8 @@ def write(paths) end end - def chdir(&) - Dir.chdir(@root, &) + def chdir(...) + Dir.chdir(@root, ...) end private From 906dc5e03950c5c257c9635e37952d6c082f3af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 11:43:44 -0800 Subject: [PATCH 378/700] Update sass-embedded.gemspec --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 52e5c34d..3fbc0042 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -32,10 +32,10 @@ Gem::Specification.new do |spec| 'ext/sass/expand-archive.ps1', 'ext/sass/package.json' ] + spec.add_runtime_dependency 'rake', '>= 13.0.0' end spec.required_ruby_version = '>= 3.1.0' spec.add_runtime_dependency 'google-protobuf', '~> 3.25' - spec.add_runtime_dependency 'rake', '>= 13.0.0' unless ENV.key?('gem_platform') end From 7431fd0fb5742f1d4c67c9526637ca8444aa62b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:26:50 -0800 Subject: [PATCH 379/700] Bump sass from 1.69.7 to 1.70.0 in /ext/sass (#183) Bumps [sass](https://github.com/sass/dart-sass) from 1.69.7 to 1.70.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.69.7...1.70.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 008f7707..3ae0c301 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.69.7" + "sass": "1.70.0" } } From 82c52b7a4ad950b238c068949e9138a53fcd5c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 01:48:47 -0800 Subject: [PATCH 380/700] Support CompileRequest.silent of embedded protocol --- lib/sass/compiler/host.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index e9f06890..245351c3 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -60,6 +60,7 @@ def compile_request(path:, alert_ascii:, alert_color:, quiet_deps:, + silent: logger == Logger.silent, verbose: )) end From de6ec539cb6c69cf637ef7c3190e010a396e79ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 19:48:51 -0800 Subject: [PATCH 381/700] Refactor CanonicalizeContext --- lib/sass/canonicalize_context.rb | 6 +++--- lib/sass/compiler/host/importer_registry.rb | 4 ++-- lib/sass/compiler/host/protofier.rb | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/sass/canonicalize_context.rb b/lib/sass/canonicalize_context.rb index 56bcc2b2..aa6d1256 100644 --- a/lib/sass/canonicalize_context.rb +++ b/lib/sass/canonicalize_context.rb @@ -13,9 +13,9 @@ class CanonicalizeContext attr_reader :from_import # @!visibility private - def initialize(containing_url, from_import) - @containing_url = containing_url - @from_import = from_import + def initialize(canonicalize_request) + @containing_url = canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url + @from_import = canonicalize_request.from_import end end end diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index d215610b..650d285b 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -61,7 +61,7 @@ def register(importer) def canonicalize(canonicalize_request) importer = @importers_by_id[canonicalize_request.importer_id] url = importer.canonicalize(canonicalize_request.url, - Protofier.from_proto_canonicalize_context(canonicalize_request))&.to_s + CanonicalizeContext.new(canonicalize_request))&.to_s EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( id: canonicalize_request.id, @@ -96,7 +96,7 @@ def import(import_request) def file_import(file_import_request) importer = @importers_by_id[file_import_request.importer_id] file_url = importer.find_file_url(file_import_request.url, - Protofier.from_proto_canonicalize_context(file_import_request))&.to_s + CanonicalizeContext.new(file_import_request))&.to_s EmbeddedProtocol::InboundMessage::FileImportResponse.new( id: file_import_request.id, diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index c3f40d71..f05d3aa1 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -9,13 +9,6 @@ class Host module Protofier module_function - def from_proto_canonicalize_context(canonicalize_request) - CanonicalizeContext.new( - canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url, - canonicalize_request.from_import - ) - end - def from_proto_compile_response(compile_response) oneof = compile_response.result result = compile_response.public_send(oneof) From fc06bda32aecf66f054ce346f290363f50b44463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 19:59:25 -0800 Subject: [PATCH 382/700] Refactor Logger::SourceSpan --- lib/sass/compiler/host/logger_registry.rb | 4 ++-- lib/sass/compiler/host/protofier.rb | 20 +------------------- lib/sass/logger/source_location.rb | 8 ++++---- lib/sass/logger/source_span.rb | 12 ++++++------ 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index e0a7f94a..99dc1baa 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -13,7 +13,7 @@ def initialize(logger) if logger.respond_to?(:debug) define_singleton_method(:debug) do |event| logger.debug(event.message, - span: Protofier.from_proto_source_span(event.span)) + span: event.span.nil? ? nil : Logger::SourceSpan.new(event.span)) end end @@ -21,7 +21,7 @@ def initialize(logger) define_singleton_method(:warn) do |event| logger.warn(event.message, deprecation: event.type == :DEPRECATION_WARNING, - span: Protofier.from_proto_source_span(event.span), + span: event.span.nil? ? nil : Logger::SourceSpan.new(event.span), stack: event.stack_trace) end end diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index f05d3aa1..79547209 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -18,7 +18,7 @@ def from_proto_compile_response(compile_response) result.message, result.formatted == '' ? nil : result.formatted, result.stack_trace == '' ? nil : result.stack_trace, - from_proto_source_span(result.span), + result.span.nil? ? nil : Logger::SourceSpan.new(result.span), compile_response.loaded_urls ) when :success @@ -32,24 +32,6 @@ def from_proto_compile_response(compile_response) end end - def from_proto_source_span(source_span) - return if source_span.nil? - - Logger::SourceSpan.new(from_proto_source_location(source_span.start), - from_proto_source_location(source_span.end), - source_span.text, - source_span.url == '' ? nil : source_span.url, - source_span.context == '' ? nil : source_span.context) - end - - def from_proto_source_location(source_location) - return if source_location.nil? - - Logger::SourceLocation.new(source_location.offset, - source_location.line, - source_location.column) - end - def to_proto_syntax(syntax) case syntax&.to_sym when :scss diff --git a/lib/sass/logger/source_location.rb b/lib/sass/logger/source_location.rb index 59f872e5..19a4d328 100644 --- a/lib/sass/logger/source_location.rb +++ b/lib/sass/logger/source_location.rb @@ -12,10 +12,10 @@ class SourceLocation attr_reader :offset, :line, :column # @!visibility private - def initialize(offset, line, column) - @offset = offset - @line = line - @column = column + def initialize(source_location) + @offset = source_location.offset + @line = source_location.line + @column = source_location.column end end end diff --git a/lib/sass/logger/source_span.rb b/lib/sass/logger/source_span.rb index cdc31af2..3f22ca37 100644 --- a/lib/sass/logger/source_span.rb +++ b/lib/sass/logger/source_span.rb @@ -16,12 +16,12 @@ class SourceSpan attr_reader :url, :context # @!visibility private - def initialize(start, end_, text, url, context) - @start = start - @end = end_ - @text = text - @url = url - @context = context + def initialize(source_span) + @start = source_span.start.nil? ? nil : Logger::SourceLocation.new(source_span.start) + @end = source_span.end.nil? ? nil : Logger::SourceLocation.new(source_span.end) + @text = source_span.text + @url = source_span.url == '' ? nil : source_span.url + @context = source_span.context == '' ? nil : source_span.context end end end From e843f16ee56ff23c8855819ed131fe1b77d6fa0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:07:57 -0800 Subject: [PATCH 383/700] Refactor CompileResponse --- lib/sass/compiler/host.rb | 30 ++++++++++++++++-- lib/sass/compiler/host/function_registry.rb | 2 ++ lib/sass/compiler/host/protofier.rb | 34 --------------------- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 245351c3..abf2e471 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -51,7 +51,14 @@ def compile_request(path:, ) end, path: (File.absolute_path(path) unless path.nil?), - style: Protofier.to_proto_output_style(style), + style: case style&.to_sym + when :expanded + EmbeddedProtocol::OutputStyle::EXPANDED + when :compressed + EmbeddedProtocol::OutputStyle::COMPRESSED + else + raise ArgumentError, 'style must be one of :expanded, :compressed' + end, charset:, source_map:, source_map_include_sources:, @@ -65,7 +72,26 @@ def compile_request(path:, )) end - Protofier.from_proto_compile_response(compile_response) + oneof = compile_response.result + result = compile_response.public_send(oneof) + case oneof + when :failure + raise CompileError.new( + result.message, + result.formatted == '' ? nil : result.formatted, + result.stack_trace == '' ? nil : result.stack_trace, + result.span.nil? ? nil : Logger::SourceSpan.new(result.span), + compile_response.loaded_urls + ) + when :success + CompileResult.new( + result.css, + result.source_map == '' ? nil : result.source_map, + compile_response.loaded_urls + ) + else + raise ArgumentError, "Unknown CompileResponse.result #{result}" + end end def version_request diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index b0dac360..953c2d20 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -47,6 +47,8 @@ def function_call(function_call_request) @functions_by_name[function_call_request.name] when :function_id @functions_by_id[function_call_request.function_id] + else + raise ArgumentError, "Unknown FunctionCallRequest.identifier #{function_call_request.identifier}" end arguments = function_call_request.arguments.map do |argument| diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 79547209..6fcbe9e7 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -9,29 +9,6 @@ class Host module Protofier module_function - def from_proto_compile_response(compile_response) - oneof = compile_response.result - result = compile_response.public_send(oneof) - case oneof - when :failure - raise CompileError.new( - result.message, - result.formatted == '' ? nil : result.formatted, - result.stack_trace == '' ? nil : result.stack_trace, - result.span.nil? ? nil : Logger::SourceSpan.new(result.span), - compile_response.loaded_urls - ) - when :success - CompileResult.new( - result.css, - result.source_map == '' ? nil : result.source_map, - compile_response.loaded_urls - ) - else - raise ArgumentError, "Unknown CompileResponse.result #{result}" - end - end - def to_proto_syntax(syntax) case syntax&.to_sym when :scss @@ -44,17 +21,6 @@ def to_proto_syntax(syntax) raise ArgumentError, 'syntax must be one of :scss, :indented, :css' end end - - def to_proto_output_style(style) - case style&.to_sym - when :expanded - EmbeddedProtocol::OutputStyle::EXPANDED - when :compressed - EmbeddedProtocol::OutputStyle::COMPRESSED - else - raise ArgumentError, 'style must be one of :expanded, :compressed' - end - end end private_constant :Protofier From 7b08480e981bcd692f643499be01a620a625ac06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:14:42 -0800 Subject: [PATCH 384/700] Remove Protofier --- lib/sass/compiler/host.rb | 3 +-- lib/sass/compiler/host/importer_registry.rb | 15 ++++++++++- lib/sass/compiler/host/protofier.rb | 29 --------------------- 3 files changed, 15 insertions(+), 32 deletions(-) delete mode 100644 lib/sass/compiler/host/protofier.rb diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index abf2e471..968a81a8 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -3,7 +3,6 @@ require_relative 'host/function_registry' require_relative 'host/importer_registry' require_relative 'host/logger_registry' -require_relative 'host/protofier' require_relative 'host/structifier' require_relative 'host/value_protofier' @@ -46,7 +45,7 @@ def compile_request(path:, EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( source: source.to_str, url: url&.to_s, - syntax: Protofier.to_proto_syntax(syntax), + syntax: @importer_registry.syntax_to_proto(syntax), importer: (@importer_registry.register(importer) unless importer.nil?) ) end, diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index 650d285b..cc241ada 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -82,7 +82,7 @@ def import(import_request) id: import_request.id, success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new( contents: importer_result.contents.to_str, - syntax: Protofier.to_proto_syntax(importer_result.syntax), + syntax: syntax_to_proto(importer_result.syntax), source_map_url: (importer_result.source_map_url&.to_s if importer_result.respond_to?(:source_map_url)) ) ) @@ -108,6 +108,19 @@ def file_import(file_import_request) error: e.full_message(highlight: @highlight, order: :top) ) end + + def syntax_to_proto(syntax) + case syntax&.to_sym + when :scss + EmbeddedProtocol::Syntax::SCSS + when :indented + EmbeddedProtocol::Syntax::INDENTED + when :css + EmbeddedProtocol::Syntax::CSS + else + raise ArgumentError, 'syntax must be one of :scss, :indented, :css' + end + end end private_constant :ImporterRegistry diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb deleted file mode 100644 index 6fcbe9e7..00000000 --- a/lib/sass/compiler/host/protofier.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -module Sass - class Compiler - class Host - # The {Protofier} module. - # - # It converts Pure Ruby types and Protobuf Ruby types. - module Protofier - module_function - - def to_proto_syntax(syntax) - case syntax&.to_sym - when :scss - EmbeddedProtocol::Syntax::SCSS - when :indented - EmbeddedProtocol::Syntax::INDENTED - when :css - EmbeddedProtocol::Syntax::CSS - else - raise ArgumentError, 'syntax must be one of :scss, :indented, :css' - end - end - end - - private_constant :Protofier - end - end -end From 6ecfcf8ecf4f7a1a49d7cfdf1ccaff8b6e6e730e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:19:40 -0800 Subject: [PATCH 385/700] Rename ValueProtofier to Protofier --- lib/sass/compiler/host.rb | 2 +- lib/sass/compiler/host/function_registry.rb | 8 ++++---- .../compiler/host/{value_protofier.rb => protofier.rb} | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename lib/sass/compiler/host/{value_protofier.rb => protofier.rb} (99%) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 968a81a8..0fbb5f9b 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -4,7 +4,7 @@ require_relative 'host/importer_registry' require_relative 'host/logger_registry' require_relative 'host/structifier' -require_relative 'host/value_protofier' +require_relative 'host/protofier' module Sass class Compiler diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 953c2d20..75e01dc0 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -52,10 +52,10 @@ def function_call(function_call_request) end arguments = function_call_request.arguments.map do |argument| - value_protofier.from_proto(argument) + protofier.from_proto(argument) end - success = value_protofier.to_proto(function.call(arguments)) + success = protofier.to_proto(function.call(arguments)) accessed_argument_lists = arguments.filter_map do |argument| if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed } argument.instance_eval { @id } @@ -76,8 +76,8 @@ def function_call(function_call_request) private - def value_protofier - @value_protofier ||= ValueProtofier.new(self) + def protofier + @protofier ||= Protofier.new(self) end end diff --git a/lib/sass/compiler/host/value_protofier.rb b/lib/sass/compiler/host/protofier.rb similarity index 99% rename from lib/sass/compiler/host/value_protofier.rb rename to lib/sass/compiler/host/protofier.rb index 03f3c306..8b0e6eee 100644 --- a/lib/sass/compiler/host/value_protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -3,10 +3,10 @@ module Sass class Compiler class Host - # The {ValueProtofier} class. + # The {Protofier} class. # # It converts Pure Ruby types and Protobuf Ruby types. - class ValueProtofier + class Protofier def initialize(function_registry) @function_registry = function_registry end @@ -384,7 +384,7 @@ def from_proto(separator) private_constant :ListSeparator end - private_constant :ValueProtofier + private_constant :Protofier end end end From 02a65bc33b2239411e7b73ccfff8aa04265a9dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:24:20 -0800 Subject: [PATCH 386/700] Refactor FunctionRegistry --- lib/sass/compiler/host/function_registry.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 75e01dc0..7a54b593 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -42,13 +42,15 @@ def register(function) end def function_call(function_call_request) - function = case function_call_request.identifier + oneof = function_call_request.identifier + identifier = function_call_request.public_send(oneof) + function = case oneof when :name - @functions_by_name[function_call_request.name] + @functions_by_name[identifier] when :function_id - @functions_by_id[function_call_request.function_id] + @functions_by_id[identifier] else - raise ArgumentError, "Unknown FunctionCallRequest.identifier #{function_call_request.identifier}" + raise ArgumentError, "Unknown FunctionCallRequest.identifier #{identifier}" end arguments = function_call_request.arguments.map do |argument| From b665435958da25535f38b169a0db5c699ac9db93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:28:06 -0800 Subject: [PATCH 387/700] Order require statements --- lib/sass/compiler/host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 0fbb5f9b..cf38d414 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -3,8 +3,8 @@ require_relative 'host/function_registry' require_relative 'host/importer_registry' require_relative 'host/logger_registry' -require_relative 'host/structifier' require_relative 'host/protofier' +require_relative 'host/structifier' module Sass class Compiler From e9a19d4dc50293a770eebc0bc83377cdcfdf1330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:52:15 -0800 Subject: [PATCH 388/700] Update sass-embedded.gemspec --- sass-embedded.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 3fbc0042..42886f3f 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -12,6 +12,7 @@ Gem::Specification.new do |spec| spec.homepage = 'https://github.com/sass-contrib/sass-embedded-host-ruby' spec.license = 'MIT' spec.metadata = { + 'bug_tracker_uri' => "#{spec.homepage}/issues", 'documentation_uri' => "https://rubydoc.info/gems/#{spec.name}/#{spec.version}", 'source_code_uri' => "#{spec.homepage}/tree/v#{spec.version}", 'funding_uri' => 'https://github.com/sponsors/ntkme', From 356c6e27a4cfa28df4c2e319b1ed6295cbfa0f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jan 2024 20:56:45 -0800 Subject: [PATCH 389/700] v1.70.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 21fe106c..6340dfc0 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.69.7' + VERSION = '1.70.0' end end From ca98bf4fc9a6c7588cb10188542bea17da09ab92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 19 Jan 2024 20:23:48 -0800 Subject: [PATCH 390/700] Fix repeatedly registered host function --- lib/sass/compiler/host/function_registry.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 7a54b593..31e1da99 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -30,15 +30,13 @@ def initialize(functions, alert_color:) end def register(function) - return if @ids_by_function.key?(function) + @ids_by_function.fetch(function) do |fn| + id = @id + @id = id.next - id = @id - @id = id.next - - @ids_by_function[function] = id - @functions_by_id[id] = function - - id + @functions_by_id[id] = fn + @ids_by_function[fn] = id + end end def function_call(function_call_request) From a73a5c4349e9cdab302267fd905eb2e736cfa49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 20 Jan 2024 03:13:59 -0800 Subject: [PATCH 391/700] Handle Unknown LogEvent.type --- lib/sass/compiler/host/logger_registry.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index 99dc1baa..aeb9c27f 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -33,6 +33,8 @@ def log(event) debug(event) when :DEPRECATION_WARNING, :WARNING warn(event) + else + raise ArgumentError, "Unknown LogEvent.type #{event.type}" end end From 09fc9902f7ec9d7ff5f0951f9c4ea834a63448dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 20 Jan 2024 04:42:31 -0800 Subject: [PATCH 392/700] Use compare_by_identity when appropriate --- lib/sass/compiler/dispatcher.rb | 2 +- lib/sass/compiler/host/function_registry.rb | 4 ++-- lib/sass/compiler/host/importer_registry.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index f9684504..c1791ea9 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -8,7 +8,7 @@ class Compiler class Dispatcher def initialize @id = 1 - @observers = {} + @observers = {}.compare_by_identity @mutex = Mutex.new @connection = Connection.new(self) ForkTracker.add(self) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 31e1da99..75fbb7ee 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -23,8 +23,8 @@ def initialize(functions, alert_color:) end @id = 0 - @functions_by_id = {} - @ids_by_function = {} + @functions_by_id = {}.compare_by_identity + @ids_by_function = {}.compare_by_identity @highlight = alert_color end diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index cc241ada..4e4be2d4 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -11,7 +11,7 @@ class ImporterRegistry def initialize(importers, load_paths, alert_color:) @id = 0 - @importers_by_id = {} + @importers_by_id = {}.compare_by_identity @importers = importers .map { |importer| register(importer) } .concat( From b5f2ea8f7c7905f843336b11ad35c8b331f45f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 20 Jan 2024 05:32:25 -0800 Subject: [PATCH 393/700] Rename classes --- lib/sass/compiler.rb | 14 ++++++------- .../{dispatcher_manager.rb => channel.rb} | 20 +++++++++---------- lib/sass/compiler/host.rb | 18 ++++++++--------- lib/sass/embedded.rb | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) rename lib/sass/compiler/{dispatcher_manager.rb => channel.rb} (76%) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index a9ae8aac..be299241 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -2,9 +2,9 @@ require_relative 'canonicalize_context' require_relative 'compile_result' +require_relative 'compiler/channel' require_relative 'compiler/connection' require_relative 'compiler/dispatcher' -require_relative 'compiler/dispatcher_manager' require_relative 'compiler/host' require_relative 'compiler/varint' require_relative 'embedded/version' @@ -28,7 +28,7 @@ module Sass # sass.close class Compiler def initialize - @dispatcher = DispatcherManager.new(Dispatcher) + @channel = Channel.new(Dispatcher) end # Compiles the Sass file at +path+ to CSS. @@ -77,7 +77,7 @@ def compile(path, verbose: false) raise ArgumentError, 'path must be set' if path.nil? - Host.new(@dispatcher).compile_request( + Host.new(@channel).compile_request( path:, source: nil, importer: nil, @@ -151,7 +151,7 @@ def compile_string(source, verbose: false) raise ArgumentError, 'source must be set' if source.nil? - Host.new(@dispatcher).compile_request( + Host.new(@channel).compile_request( path: nil, source:, importer:, @@ -177,16 +177,16 @@ def compile_string(source, def info @info ||= [ ['sass-embedded', Embedded::VERSION, '(Embedded Host)', '[Ruby]'].join("\t"), - Host.new(@dispatcher).version_request.join("\t") + Host.new(@channel).version_request.join("\t") ].join("\n").freeze end def close - @dispatcher.close + @channel.close end def closed? - @dispatcher.closed? + @channel.closed? end end end diff --git a/lib/sass/compiler/dispatcher_manager.rb b/lib/sass/compiler/channel.rb similarity index 76% rename from lib/sass/compiler/dispatcher_manager.rb rename to lib/sass/compiler/channel.rb index c603cf7c..174f495c 100644 --- a/lib/sass/compiler/dispatcher_manager.rb +++ b/lib/sass/compiler/channel.rb @@ -2,10 +2,10 @@ module Sass class Compiler - # The {DispatcherManager} class. + # The {Channel} class. # # It manages the lifecycle of {Dispatcher}. - class DispatcherManager + class Channel def initialize(dispatcher_class) @dispatcher_class = dispatcher_class @dispatcher = @dispatcher_class.new @@ -27,19 +27,19 @@ def closed? end end - def connect(host) + def stream(host) @mutex.synchronize do raise IOError, 'closed compiler' if @dispatcher.nil? - Channel.new(@dispatcher, host) + Stream.new(@dispatcher, host) rescue Errno::EBUSY @dispatcher = @dispatcher_class.new - Channel.new(@dispatcher, host) + Stream.new(@dispatcher, host) end end - # The {Channel} between {Dispatcher} and {Host}. - class Channel + # The {Stream} between {Dispatcher} and {Host}. + class Stream attr_reader :id def initialize(dispatcher, host) @@ -47,7 +47,7 @@ def initialize(dispatcher, host) @id = @dispatcher.subscribe(host) end - def disconnect + def close @dispatcher.unsubscribe(@id) end @@ -60,9 +60,9 @@ def send_proto(...) end end - private_constant :Channel + private_constant :Stream end - private_constant :DispatcherManager + private_constant :Channel end end diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index cf38d414..c8198848 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -12,8 +12,8 @@ class Compiler # # It communicates with {Dispatcher} and handles the host logic. class Host - def initialize(dispatcher) - @dispatcher = dispatcher + def initialize(channel) + @channel = channel end def compile_request(path:, @@ -128,7 +128,7 @@ def error(message) case message when EmbeddedProtocol::ProtocolError @error = Errno::EPROTO.new(message.message) - @channel.error(@error) + @stream.error(@error) else @error ||= message end @@ -138,7 +138,7 @@ def error(message) def log_event(message) @logger_registry.log(message) rescue StandardError => e - @channel.error(e) + @stream.error(e) end def canonicalize_request(message) @@ -186,7 +186,7 @@ def await def listen @queue = Queue.new - @channel = @dispatcher.connect(self) + @stream = @channel.stream(self) yield @@ -194,22 +194,22 @@ def listen @result ensure - @channel&.disconnect + @stream&.close @queue&.close end def id - @channel.id + @stream.id end def send_message0(...) inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @channel.send_proto(0, inbound_message.to_proto) + @stream.send_proto(0, inbound_message.to_proto) end def send_message(...) inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @channel.send_proto(id, inbound_message.to_proto) + @stream.send_proto(id, inbound_message.to_proto) end end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index fee5bcbe..329c0804 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -55,7 +55,7 @@ def compiler compiler = Class.new(Compiler) do def initialize - @dispatcher = Compiler.const_get(:DispatcherManager).new(Class.new(Compiler.const_get(:Dispatcher)) do + @channel = Compiler.const_get(:Channel).new(Class.new(Compiler.const_get(:Dispatcher)) do def initialize super From 0adb40e263505339e8633a8c680cf63ef152098f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 30 Jan 2024 09:24:34 -0800 Subject: [PATCH 394/700] Fix rubygems-head --- .github/workflows/build.yml | 2 -- ext/sass/Rakefile | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7f4f280..56d51335 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,9 +35,7 @@ jobs: - '3.1' - '3.2' - '3.3' - - head - jruby - - jruby-head - truffleruby - truffleruby+graalvm exclude: diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 765f05e6..ac987c56 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -138,16 +138,22 @@ module FileUtils def fetch(source_uri, dest_path = nil) require 'rubygems/remote_fetcher' - unless source_uri.is_a?(URI::Generic) + source_uri = begin + Gem::Uri.parse!(source_uri) + rescue NoMethodError begin - source_uri = URI.parse(source_uri) + URI.parse(source_uri) rescue StandardError - source_uri = URI.parse(URI::DEFAULT_PARSER.escape(source_uri.to_s)) + URI.parse(URI::DEFAULT_PARSER.escape(source_uri.to_s)) end end scheme = source_uri.scheme - source_path = URI::DEFAULT_PARSER.unescape(source_uri.path || source_uri.opaque) + source_path = begin + Gem::URI::DEFAULT_PARSER + rescue NameError + URI::DEFAULT_PARSER + end.unescape(source_uri.path || source_uri.opaque) if Gem.win_platform? && scheme =~ /^[a-z]$/i && !source_path.include?(':') source_path = "#{scheme}:#{source_path}" @@ -167,10 +173,7 @@ module FileUtils symbol = :"fetch_#{scheme}" raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol) - if Rake::FileUtilsExt.verbose_flag - redacted_uri = Gem::RemoteFetcher::FetchError.new('', source_uri).uri - Rake.rake_output_message "fetch #{redacted_uri}" - end + Rake.rake_output_message "fetch #{Gem::Uri.new(source_uri).redacted}" if Rake::FileUtilsExt.verbose_flag unless Rake::FileUtilsExt.nowrite_flag data = fetcher.public_send(symbol, source_uri) @@ -351,7 +354,7 @@ module SassConfig uri = "#{repo}/#{version}/protoc-#{version}-#{os}-#{cpu}.exe" - Gem::RemoteFetcher.fetcher.fetch_https(URI.parse("#{uri}.sha1")) + Gem::RemoteFetcher.fetcher.fetch_https(Gem::Uri.new("#{uri}.sha1")) uri rescue Gem::RemoteFetcher::FetchError @@ -362,7 +365,7 @@ module SassConfig tuples.sort.reverse_each do |name_tuple, _source| uri = "#{repo}/#{name_tuple.version}/protoc-#{name_tuple.version}-#{os}-#{cpu}.exe" - Gem::RemoteFetcher.fetcher.fetch_https(URI.parse("#{uri}.sha1")) + Gem::RemoteFetcher.fetcher.fetch_https(Gem::Uri.new("#{uri}.sha1")) return uri rescue Gem::RemoteFetcher::FetchError From 4bd9f366015c3936b4c2ca9ce5e358445ae36c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 31 Jan 2024 08:37:26 -0800 Subject: [PATCH 395/700] Test macos arm64 --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56d51335..f38b9908 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,7 @@ jobs: fail-fast: false matrix: os: + - macos-14 - macos-latest - ubuntu-latest - windows-latest From b04d5974b946e8b953077a654fe35211906619e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 31 Jan 2024 10:57:29 -0800 Subject: [PATCH 396/700] Use mv instead of cp_r --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ac987c56..25d6cc13 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -21,7 +21,7 @@ file 'dart-sass' do |t| raise if ENV.key?('DART_SASS') gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| - cp_r File.absolute_path("ext/sass/#{t.name}", dir), t.name + mv File.absolute_path("ext/sass/#{t.name}", dir), t.name end rescue StandardError archive = fetch(ENV.fetch('DART_SASS') { SassConfig.default_dart_sass }) From b87ae0749c023cf1f7f364afcffe0f921bd6dacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 31 Jan 2024 11:22:37 -0800 Subject: [PATCH 397/700] Update Rakefile --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 25d6cc13..07af49a0 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -185,7 +185,7 @@ module FileUtils end def gem_install(name, version, platform) - install_dir = File.absolute_path('ruby', __dir__) + install_dir = File.absolute_path('ruby') if Rake::FileUtilsExt.verbose_flag Rake.rake_output_message [ From 1285f64ac29651235eb6e2ad084f0162508218f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 09:26:58 -0800 Subject: [PATCH 398/700] Update rspec requirement from ~> 3.12.0 to ~> 3.13.0 (#184) Updates the requirements on [rspec](https://github.com/rspec/rspec-metagem) to permit the latest version. - [Commits](https://github.com/rspec/rspec-metagem/compare/v3.12.0...v3.13.0) --- updated-dependencies: - dependency-name: rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index fd409f7e..bc56660f 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' - gem 'rspec', '~> 3.12.0' + gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.60.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' From 82e596ecbd1b7574990a4c40e6afc846e8331e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 6 Feb 2024 17:26:10 -0800 Subject: [PATCH 399/700] Add Sass::NodePackageImporter --- lib/sass/compiler.rb | 1 + lib/sass/compiler/host/importer_registry.rb | 60 ++++++++++++--------- lib/sass/node_package_importer.rb | 13 +++++ 3 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 lib/sass/node_package_importer.rb diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index be299241..281bd1a9 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -14,6 +14,7 @@ require_relative 'logger/silent' require_relative 'logger/source_location' require_relative 'logger/source_span' +require_relative 'node_package_importer' require_relative 'serializer' require_relative 'value' diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index 4e4be2d4..306a0a92 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -26,35 +26,43 @@ def initialize(importers, load_paths, alert_color:) end def register(importer) - importer = Structifier.to_struct(importer, :canonicalize, :load, :non_canonical_scheme, :find_file_url) - - is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load) - is_file_importer = importer.respond_to?(:find_file_url) - - raise ArgumentError, 'importer must be an Importer or a FileImporter' if is_importer == is_file_importer - - id = @id - @id = id.next - - @importers_by_id[id] = importer - if is_importer + if importer.is_a?(Sass::NodePackageImporter) EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( - importer_id: id, - non_canonical_scheme: if importer.respond_to?(:non_canonical_scheme) - non_canonical_scheme = importer.non_canonical_scheme - if non_canonical_scheme.is_a?(String) - [non_canonical_scheme] - else - non_canonical_scheme || [] - end - else - [] - end + node_package_importer: EmbeddedProtocol::NodePackageImporter.new( + entry_point_directory: importer.instance_eval { @entry_point_directory } + ) ) else - EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( - file_importer_id: id - ) + importer = Structifier.to_struct(importer, :canonicalize, :load, :non_canonical_scheme, :find_file_url) + + is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load) + is_file_importer = importer.respond_to?(:find_file_url) + + raise ArgumentError, 'importer must be an Importer or a FileImporter' if is_importer == is_file_importer + + id = @id + @id = id.next + + @importers_by_id[id] = importer + if is_importer + EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( + importer_id: id, + non_canonical_scheme: if importer.respond_to?(:non_canonical_scheme) + non_canonical_scheme = importer.non_canonical_scheme + if non_canonical_scheme.is_a?(String) + [non_canonical_scheme] + else + non_canonical_scheme || [] + end + else + [] + end + ) + else + EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( + file_importer_id: id + ) + end end end diff --git a/lib/sass/node_package_importer.rb b/lib/sass/node_package_importer.rb new file mode 100644 index 00000000..76e2bd89 --- /dev/null +++ b/lib/sass/node_package_importer.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Sass + # The built-in Node.js package importer. This loads pkg: URLs from node_modules + # according to the standard Node.js resolution algorithm. + # + # @see https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/ + class NodePackageImporter + def initialize(entry_point_directory) + @entry_point_directory = File.absolute_path(entry_point_directory) + end + end +end From 0b982e28565ae10c88acc2f721ca53b76999f844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 7 Feb 2024 08:15:15 -0800 Subject: [PATCH 400/700] Update node_package_importer.rb --- lib/sass/node_package_importer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sass/node_package_importer.rb b/lib/sass/node_package_importer.rb index 76e2bd89..9aa34662 100644 --- a/lib/sass/node_package_importer.rb +++ b/lib/sass/node_package_importer.rb @@ -7,6 +7,8 @@ module Sass # @see https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/ class NodePackageImporter def initialize(entry_point_directory) + raise ArgumentError, 'entry_point_directory must be set' if entry_point_directory.nil? + @entry_point_directory = File.absolute_path(entry_point_directory) end end From 8825431a6c93702d0133ad7a757f2975fdcba99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Feb 2024 10:01:43 -0800 Subject: [PATCH 401/700] Update doc for Sass::Compiler --- lib/sass/compiler.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 281bd1a9..dfe8dbbb 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -19,14 +19,15 @@ require_relative 'value' module Sass - # The {Compiler} for using dart-sass. Each instance creates its own - # communication {Dispatcher} with a dedicated compiler process. + # A synchronous {Compiler}. + # Each compiler instance exposes the {#compile} and {#compile_string} methods within the lifespan of the compiler. # # @example # sass = Sass::Compiler.new # result = sass.compile_string('h1 { font-size: 40px; }') # result = sass.compile('style.scss') # sass.close + # @see https://sass-lang.com/documentation/js-api/classes/compiler/ class Compiler def initialize @channel = Channel.new(Dispatcher) From 0ea5a05ad6fbcbb3d70e1d255a333ce6c039d910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 15 Feb 2024 19:49:51 -0800 Subject: [PATCH 402/700] Update for cli_pkg 2.8.0 --- ext/sass/Rakefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 07af49a0..89260846 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -282,6 +282,8 @@ module SassConfig message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}" + env = '' + os = case Platform::OS when 'darwin' 'macos' @@ -290,7 +292,8 @@ module SassConfig when 'linux-android' 'android' when 'linux-musl' - 'linux-musl' + env = '-musl' + 'linux' when 'windows' 'windows' else @@ -312,7 +315,7 @@ module SassConfig ext = Platform::OS == 'windows' ? 'zip' : 'tar.gz' - "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}.#{ext}" + "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}#{env}.#{ext}" end def default_protoc From c33c3c704349a7b85563cb347bc51a8dacc58946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 15 Feb 2024 20:17:15 -0800 Subject: [PATCH 403/700] Use sass-contrib/dart-sass-musl for 1.71.0 --- ext/sass/Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 89260846..ee0b6887 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -292,6 +292,7 @@ module SassConfig when 'linux-android' 'android' when 'linux-musl' + repo = 'https://github.com/sass-contrib/dart-sass-musl' env = '-musl' 'linux' when 'windows' From 02e158dc998d5d279d82ab1d42ec1c18ebe343a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 20:40:43 -0800 Subject: [PATCH 404/700] Bump sass from 1.70.0 to 1.71.0 in /ext/sass (#185) Bumps [sass](https://github.com/sass/dart-sass) from 1.70.0 to 1.71.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.70.0...1.71.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 3ae0c301..84e13b4e 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.70.0" + "sass": "1.71.0" } } From 0bf660968641ef278fa52ae16842a0fa828f6e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 15 Feb 2024 20:50:46 -0800 Subject: [PATCH 405/700] v1.71.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 6340dfc0..51ddf794 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.70.0' + VERSION = '1.71.0' end end From 21850f68e2d3bd7ed614149378315369366ec2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 15 Feb 2024 21:56:42 -0800 Subject: [PATCH 406/700] Revert "Use sass-contrib/dart-sass-musl for 1.71.0" This reverts commit c33c3c704349a7b85563cb347bc51a8dacc58946. --- ext/sass/Rakefile | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ee0b6887..89260846 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -292,7 +292,6 @@ module SassConfig when 'linux-android' 'android' when 'linux-musl' - repo = 'https://github.com/sass-contrib/dart-sass-musl' env = '-musl' 'linux' when 'windows' From 861fdfbe707613a137739a6fd809acbf4484b4b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 16 Feb 2024 09:12:23 -0800 Subject: [PATCH 407/700] Use `Message.encode(proto)` instead of `proto.to_proto` --- lib/sass/compiler/host.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index c8198848..39ca8efc 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -204,12 +204,12 @@ def id def send_message0(...) inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @stream.send_proto(0, inbound_message.to_proto) + @stream.send_proto(0, EmbeddedProtocol::InboundMessage.encode(inbound_message)) end def send_message(...) inbound_message = EmbeddedProtocol::InboundMessage.new(...) - @stream.send_proto(id, inbound_message.to_proto) + @stream.send_proto(id, EmbeddedProtocol::InboundMessage.encode(inbound_message)) end end From 955e823bd618bf7868d468d6c07f53b931576672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Feb 2024 11:10:58 -0800 Subject: [PATCH 408/700] Return Array instead of Google::Protobuf::RepeatedField --- lib/sass/compiler/host.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 39ca8efc..ce13d7b9 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -80,13 +80,13 @@ def compile_request(path:, result.formatted == '' ? nil : result.formatted, result.stack_trace == '' ? nil : result.stack_trace, result.span.nil? ? nil : Logger::SourceSpan.new(result.span), - compile_response.loaded_urls + compile_response.loaded_urls.to_a ) when :success CompileResult.new( result.css, result.source_map == '' ? nil : result.source_map, - compile_response.loaded_urls + compile_response.loaded_urls.to_a ) else raise ArgumentError, "Unknown CompileResponse.result #{result}" From 01cc95d752cb72deb0a8e37a5c8f4ac3b35bbd6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Feb 2024 11:17:55 -0800 Subject: [PATCH 409/700] Update doc for NodePackageImporter --- lib/sass/node_package_importer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sass/node_package_importer.rb b/lib/sass/node_package_importer.rb index 9aa34662..91fb14fe 100644 --- a/lib/sass/node_package_importer.rb +++ b/lib/sass/node_package_importer.rb @@ -4,6 +4,8 @@ module Sass # The built-in Node.js package importer. This loads pkg: URLs from node_modules # according to the standard Node.js resolution algorithm. # + # @param entry_point_directory [String] The directory where the {NodePackageImporter} should start when resolving + # `pkg:` URLs in sources other than files on disk. # @see https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/ class NodePackageImporter def initialize(entry_point_directory) From aade8c8b41d7e712904ba4c4ca4b7f834c0163ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Feb 2024 12:44:38 -0800 Subject: [PATCH 410/700] Wrap rspec doubles --- spec/sass/compiler_spec.rb | 10 +++++++--- spec/sass/value/argument_list_spec.rb | 6 +++--- spec/sass/value/function_spec.rb | 6 +++--- spec/sass/value/mixin_spec.rb | 2 +- spec/sass_compile_spec.rb | 2 +- spec/sass_function_spec.rb | 12 ++++++------ spec/sass_importer_spec.rb | 2 +- spec/sass_proto_spec.rb | 4 ++-- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/spec/sass/compiler_spec.rb b/spec/sass/compiler_spec.rb index fb57d6b1..0764766b 100644 --- a/spec/sass/compiler_spec.rb +++ b/spec/sass/compiler_spec.rb @@ -33,9 +33,13 @@ ] end + let(:logger_instance_double) do + instance_double(Proc, call: nil) + end + let(:logger) do { - debug: instance_double(Proc, call: nil) + debug: ->(*args, **kwargs) { logger_instance_double.call(*args, **kwargs) } } end @@ -43,7 +47,7 @@ it 'performs complete compilations' do result = compiler.compile_string('@import "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:) expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: baz;\n}") - expect(logger[:debug]).to have_received(:call).once + expect(logger_instance_double).to have_received(:call).once end it 'performs compilations in callbacks' do @@ -92,7 +96,7 @@ dir.write({ 'input.scss' => '@import "bar"; .fn {value: foo(bar)}' }) result = compiler.compile(dir.path('input.scss'), importers:, functions:, logger:) expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: bar;\n}") - expect(logger[:debug]).to have_received(:call).once + expect(logger_instance_double).to have_received(:call).once end end diff --git a/spec/sass/value/argument_list_spec.rb b/spec/sass/value/argument_list_spec.rb index 11d481d0..7309e8c2 100644 --- a/spec/sass/value/argument_list_spec.rb +++ b/spec/sass/value/argument_list_spec.rb @@ -21,7 +21,7 @@ Sass.compile_string( 'a {b: foo(x, y, z)}', functions: { - 'foo($arg...)': fn + 'foo($arg...)': ->(args) { fn.call(args) } } ).css ).to eq('') @@ -46,7 +46,7 @@ Sass.compile_string( 'a {b: foo($bar: baz)}', functions: { - 'foo($arg...)': fn + 'foo($arg...)': ->(args) { fn.call(args) } } ).css ).to eq('') @@ -66,7 +66,7 @@ Sass.compile_string( 'a {b: foo($bar: baz)}', functions: { - 'foo($arg...)': fn + 'foo($arg...)': ->(args) { fn.call(args) } } ).css end.to raise_sass_compile_error.with_line(0).without_url diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index 11347f1b..79e1bb70 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -33,7 +33,7 @@ a {b: meta.call(foo(meta.get-function('plusOne')), 2)} ", functions: { - 'foo($arg)': fn + 'foo($arg)': ->(args) { fn.call(args) } } ).css ).to eq("a {\n b: 3;\n}") @@ -60,7 +60,7 @@ a {b: meta.call(foo(), 2)} ", functions: { - 'foo()': fn + 'foo()': ->(args) { fn.call(args) } } ).css ).to eq("a {\n b: 3;\n}") @@ -91,7 +91,7 @@ Sass.compile_string( 'a {b: inspect(foo())}', functions: { - 'foo()': fn + 'foo()': ->(args) { fn.call(args) } } ) end.to raise_sass_compile_error.with_line(0).without_url diff --git a/spec/sass/value/mixin_spec.rb b/spec/sass/value/mixin_spec.rb index 33de18e4..5c3fa66a 100644 --- a/spec/sass/value/mixin_spec.rb +++ b/spec/sass/value/mixin_spec.rb @@ -38,7 +38,7 @@ @include meta.apply(foo(meta.get-mixin('a'))); ", functions: { - 'foo($arg)': fn + 'foo($arg)': ->(args) { fn.call(args) } } ).css ).to eq("a {\n b: c;\n}") diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 8df00795..66b634ba 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -277,7 +277,7 @@ it 'throws an error for an unrecognized style' do expect { described_class.compile_string('a {b: c}', style: 'unrecognized style') } - .to raise_error(ArgumentError) + .to raise_error(defined?(RBS::Test::Tester::TypeError) ? RBS::Test::Tester::TypeError : ArgumentError) end it "doesn't throw a Sass exception for an argument error" do diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index d2fc079a..069de413 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -16,7 +16,7 @@ described_class.compile_string( 'a {b: foo(bar)}', functions: { - 'foo($arg)': fn + 'foo($arg)': ->(args) { fn.call(args) } } ).css ).to eq("a {\n b: \"result\";\n}") @@ -35,7 +35,7 @@ described_class.compile_string( 'a {b: foo()}', functions: { - 'foo()': fn + 'foo()': ->(args) { fn.call(args) } } ).css ).to eq('') @@ -57,7 +57,7 @@ described_class.compile_string( 'a {b: foo(x, y, z)}', functions: { - 'foo($arg1, $arg2, $arg3)': fn + 'foo($arg1, $arg2, $arg3)': ->(args) { fn.call(args) } } ).css ).to eq('') @@ -77,7 +77,7 @@ described_class.compile_string( 'a {b: foo()}', functions: { - 'foo($arg: default)': fn + 'foo($arg: default)': ->(args) { fn.call(args) } } ).css ).to eq('') @@ -142,7 +142,7 @@ described_class.compile_string( 'a {b: foo_bar()}', functions: { - 'foo-bar()': fn + 'foo-bar()': ->(args) { fn.call(args) } } ).css ).to eq('') @@ -158,7 +158,7 @@ described_class.compile_string( 'a {b: foo-bar()}', functions: { - 'foo_bar()': fn + 'foo_bar()': ->(args) { fn.call(args) } } ).css ).to eq('') diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 8eff24ed..edd039dc 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -722,7 +722,7 @@ def expect_from_import(canonicalize, expected) "u:#{url}" } { - canonicalize:, + canonicalize: ->(*args) { canonicalize.call(*args) }, load: ->(*) { { contents: '', syntax: 'scss' } } } end diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 365c45ed..2f836b00 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -129,8 +129,8 @@ def remote_eq(lhs, rhs) described_class.compile_string( '$_: foo(bar());', functions: { - 'foo($arg)': foo, - 'bar()': bar + 'foo($arg)': ->(args) { foo.call(args) }, + 'bar()': ->(args) { bar.call(args) } } ).css ).to eq('') From 8205760d9ad9a3c50491a1aaa647089e806dcbd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Feb 2024 12:52:08 -0800 Subject: [PATCH 411/700] Fix typo in doc --- lib/sass/compiler/dispatcher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index c1791ea9..b039b732 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -4,7 +4,7 @@ module Sass class Compiler # The {Dispatcher} class. # - # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler. + # It dispatches messages between multiple instances of {Host} and a single {Connection} to the compiler. class Dispatcher def initialize @id = 1 From f43f8efb770ba0d6c445a0deb349985dbd75e0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Feb 2024 14:16:15 -0800 Subject: [PATCH 412/700] Skip testing invalid type when RBS is loaded --- spec/sass_compile_spec.rb | 4 +++- spec/sass_function_spec.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 66b634ba..3e5b391a 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -276,8 +276,10 @@ end it 'throws an error for an unrecognized style' do + skip 'RBS::Test::Tester is loaded' if defined?(RBS::Test::Tester) + expect { described_class.compile_string('a {b: c}', style: 'unrecognized style') } - .to raise_error(defined?(RBS::Test::Tester::TypeError) ? RBS::Test::Tester::TypeError : ArgumentError) + .to raise_error(ArgumentError) end it "doesn't throw a Sass exception for an argument error" do diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index 069de413..7e108f66 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -98,6 +98,8 @@ end it 'not returning' do + skip 'RBS::Test::Tester is loaded' if defined?(RBS::Test::Tester) + expect do described_class.compile_string( 'a {b: foo()}', @@ -110,6 +112,8 @@ describe 'returning a non-Value' do it 'directly' do + skip 'RBS::Test::Tester is loaded' if defined?(RBS::Test::Tester) + expect do described_class.compile_string( 'a {b: foo()}', From 2d9e49e8961afbdd76bdbe30413210b315f3405b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 17 Feb 2024 14:24:50 -0800 Subject: [PATCH 413/700] Use `%w[]` for array of strings --- lib/sass/calculation_value/calculation_operation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/calculation_value/calculation_operation.rb b/lib/sass/calculation_value/calculation_operation.rb index 32a1eb67..55347d14 100644 --- a/lib/sass/calculation_value/calculation_operation.rb +++ b/lib/sass/calculation_value/calculation_operation.rb @@ -8,7 +8,7 @@ module CalculationValue class CalculationOperation include CalculationValue - OPERATORS = ['+', '-', '*', '/'].freeze + OPERATORS = %w[+ - * /].freeze private_constant :OPERATORS From 4b5af24a6a2e07e0c23b61dd63aa2eabdd9da031 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:16:39 -0800 Subject: [PATCH 414/700] Bump sass from 1.71.0 to 1.71.1 in /ext/sass (#186) Bumps [sass](https://github.com/sass/dart-sass) from 1.71.0 to 1.71.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.71.0...1.71.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 84e13b4e..edd7c8b5 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.71.0" + "sass": "1.71.1" } } From 95ef355da991d2e6fc92bfacbf53919660f9f3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 20 Feb 2024 18:17:15 -0800 Subject: [PATCH 415/700] v1.71.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 51ddf794..cd9b07a5 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.71.0' + VERSION = '1.71.1' end end From 03f74d116784755c536ae2880377a0c50a6f08c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:22:23 -0800 Subject: [PATCH 416/700] Update rubocop requirement from ~> 1.60.0 to ~> 1.61.0 (#188) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.60.0...v1.61.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index bc56660f..bda7dd61 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.60.0' + gem 'rubocop', '~> 1.61.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.26.0' From dde4266fdc2baeaa6ad9b52e2d5378198e8b16e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 09:32:41 -0800 Subject: [PATCH 417/700] Update rubocop-rspec requirement from ~> 2.26.0 to ~> 2.27.1 (#190) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.26.0...v2.27.1) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index bda7dd61..c331c502 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.61.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.26.0' + gem 'rubocop-rspec', '~> 2.27.1' end From bba6bf978376460927620d60fb610d427dce0eae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 08:54:11 -0800 Subject: [PATCH 418/700] Update rubocop requirement from ~> 1.61.0 to ~> 1.62.0 (#191) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.61.0...v1.62.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c331c502..e756400f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.61.0' + gem 'rubocop', '~> 1.62.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.27.1' From 0f565151c99aca5c9cc2b44c421e6ec1398cb4ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 11:29:08 -0700 Subject: [PATCH 419/700] Update google-protobuf requirement from ~> 3.25 to >= 3.25, < 5.0 (#193) Updates the requirements on [google-protobuf](https://github.com/protocolbuffers/protobuf) to permit the latest version. - [Release notes](https://github.com/protocolbuffers/protobuf/releases) - [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl) - [Commits](https://github.com/protocolbuffers/protobuf/commits) --- updated-dependencies: - dependency-name: google-protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 42886f3f..1b72de96 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -38,5 +38,5 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.1.0' - spec.add_runtime_dependency 'google-protobuf', '~> 3.25' + spec.add_runtime_dependency 'google-protobuf', '>= 3.25', '< 5.0' end From c8b9be15a0ed256f3410555d7605464e7191d526 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:37:01 -0700 Subject: [PATCH 420/700] Bump sass from 1.71.1 to 1.72.0 in /ext/sass (#194) Bumps [sass](https://github.com/sass/dart-sass) from 1.71.1 to 1.72.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.71.1...1.72.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index edd7c8b5..74288e82 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.71.1" + "sass": "1.72.0" } } From 29aa450311b1d2a907976bd87dafad8ad438755f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Mar 2024 14:51:37 -0700 Subject: [PATCH 421/700] Skip broken jruby test caused by ffi-compiler-1.3.1 --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f38b9908..0bbfdb79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,6 +62,7 @@ jobs: run: bundle exec rake spec - name: Install + if: matrix.ruby-version != 'jruby' # ffi-compiler-1.3.1 is broken run: rake -f -r bundler/gem_tasks install spec-musl: From 940a90485ce384719a961fa964441554af032ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Mar 2024 15:03:47 -0700 Subject: [PATCH 422/700] v1.72.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index cd9b07a5..95be9c69 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.71.1' + VERSION = '1.72.0' end end From 951956ea2387607af3ecebc1c5ebb4c6ec28f6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Mar 2024 15:33:03 -0700 Subject: [PATCH 423/700] Limit parallel jobs for releasing gem --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71ac4a9c..c9797550 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,6 +48,7 @@ jobs: strategy: fail-fast: false + max-parallel: 1 matrix: include: - os: macos-latest From 9d2de6cd383696c9f3ccab6eee83d32f8a29ef37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 13 Mar 2024 17:52:59 -0700 Subject: [PATCH 424/700] Revert "Skip broken jruby test caused by ffi-compiler-1.3.1" This reverts commit 29aa450311b1d2a907976bd87dafad8ad438755f. --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0bbfdb79..f38b9908 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,7 +62,6 @@ jobs: run: bundle exec rake spec - name: Install - if: matrix.ruby-version != 'jruby' # ffi-compiler-1.3.1 is broken run: rake -f -r bundler/gem_tasks install spec-musl: From d86146356d7f3fd17b041ebc05f4f2e5c4dda3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 19 Mar 2024 14:21:55 -0700 Subject: [PATCH 425/700] Support linux-riscv64 (#195) --- .github/workflows/release.yml | 6 ++++++ ext/sass/Rakefile | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9797550..4a8ae6c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,6 +59,8 @@ jobs: platform: aarch64-linux-android - os: ubuntu-latest platform: arm-linux-androideabi + - os: ubuntu-latest + platform: riscv64-linux-android - os: ubuntu-latest platform: x86-linux-android - os: ubuntu-latest @@ -67,6 +69,8 @@ jobs: platform: aarch64-linux-gnu - os: ubuntu-latest platform: arm-linux-gnueabihf + - os: ubuntu-latest + platform: riscv64-linux-gnu - os: ubuntu-latest platform: x86-linux-gnu - os: ubuntu-latest @@ -75,6 +79,8 @@ jobs: platform: aarch64-linux-musl - os: ubuntu-latest platform: arm-linux-musleabihf + - os: ubuntu-latest + platform: riscv64-linux-musl - os: ubuntu-latest platform: x86-linux-musl - os: ubuntu-latest diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 89260846..429306a7 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -309,6 +309,8 @@ module SassConfig 'arm64' when 'arm' 'arm' + when 'riscv64' + 'riscv64' else raise NotImplementedError, message end From b04e5a3b3b1c4d42db3dfb2b2ed59b65ce7853f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 19 Mar 2024 14:36:59 -0700 Subject: [PATCH 426/700] Support windows-arm64 (#196) --- .github/workflows/release.yml | 2 ++ ext/sass/Rakefile | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a8ae6c9..142e1e29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,6 +85,8 @@ jobs: platform: x86-linux-musl - os: ubuntu-latest platform: x86_64-linux-musl + - os: windows-latest + platform: aarch64-mingw-ucrt - os: windows-latest platform: x64-mingw-ucrt - os: windows-latest diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 429306a7..97171bd8 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -247,7 +247,7 @@ module SassConfig when /amd64|x86_64|x64/ 'x86_64' when /i\d86|x86|i86pc/ - 'i386' + 'x86' when /arm64|aarch64/ 'aarch64' when /arm/ @@ -259,8 +259,6 @@ module SassConfig end ARCH = "#{CPU}-#{OS}".freeze - - EMULATION = ('x86_64' if ARCH == 'aarch64-windows') end private_constant :Platform @@ -300,8 +298,8 @@ module SassConfig raise NotImplementedError, message end - cpu = case Platform::EMULATION || Platform::CPU - when 'i386' + cpu = case Platform::CPU + when 'x86' 'ia32' when 'x86_64' 'x64' @@ -342,8 +340,8 @@ module SassConfig raise NotImplementedError, message end - cpu = case Platform::EMULATION || Platform::CPU - when 'i386' + cpu = case Platform::CPU + when 'x86' 'x86_32' when 'x86_64' 'x86_64' @@ -407,7 +405,7 @@ module SassConfig end def gem_platform - platform = Gem::Platform.new("#{Platform::EMULATION || Platform::CPU}-#{RbConfig::CONFIG['host_os']}") + platform = Gem::Platform.new("#{Platform::CPU}-#{RbConfig::CONFIG['host_os']}") case Platform::OS when 'darwin' Gem::Platform.new([RbConfig::CONFIG['host_cpu'], platform.os]) @@ -419,10 +417,12 @@ module SassConfig end when 'windows' case platform.cpu + when 'x86' + Gem::Platform.new('x86-mingw32') when 'x86_64' - Gem::Platform.new('x64-mingw32') + Gem::Platform.new('x64-mingw-ucrt') else - Gem::Platform.new([platform.cpu, 'mingw32']) + Gem::Platform.new([platform.cpu, 'mingw', 'ucrt']) end else platform From 2d8ee02f0f0b1dd96e3a393712289bc463de7a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 21 Mar 2024 01:21:14 -0700 Subject: [PATCH 427/700] Add platform x86-mingw-ucrt for mingw-w64-clang-i686-ruby --- .github/workflows/release.yml | 2 ++ ext/sass/Rakefile | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 142e1e29..569016f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,6 +91,8 @@ jobs: platform: x64-mingw-ucrt - os: windows-latest platform: x64-mingw32 + - os: windows-latest + platform: x86-mingw-ucrt - os: windows-latest platform: x86-mingw32 diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 97171bd8..6d37a4e5 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -417,8 +417,6 @@ module SassConfig end when 'windows' case platform.cpu - when 'x86' - Gem::Platform.new('x86-mingw32') when 'x86_64' Gem::Platform.new('x64-mingw-ucrt') else From fa0619d0acae996a769817ce4feda2daad6efc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 22 Mar 2024 00:42:05 -0700 Subject: [PATCH 428/700] Add cygwin and mswin builds --- .github/workflows/release.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 569016f7..1937b205 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,16 +85,24 @@ jobs: platform: x86-linux-musl - os: ubuntu-latest platform: x86_64-linux-musl + - os: windows-latest + platform: x86-cygwin + - os: windows-latest + platform: x86_64-cygwin - os: windows-latest platform: aarch64-mingw-ucrt - os: windows-latest platform: x64-mingw-ucrt - - os: windows-latest - platform: x64-mingw32 - os: windows-latest platform: x86-mingw-ucrt + - os: windows-latest + platform: x64-mingw32 - os: windows-latest platform: x86-mingw32 + - os: windows-latest + platform: x64-mswin64 + - os: windows-latest + platform: x86-mswin32 steps: - name: Checkout From ea83a69cec5ec9ebaaf13b2cd117978f4b217f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 26 Mar 2024 08:43:07 -0700 Subject: [PATCH 429/700] Test ruby-head, jruby-head, and truffleruby-head --- .github/workflows/schedule.yml | 49 ++++++++++++++++++++++++++++++++++ spec/sass_importer_spec.rb | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/schedule.yml diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml new file mode 100644 index 00000000..c4cceab0 --- /dev/null +++ b/.github/workflows/schedule.yml @@ -0,0 +1,49 @@ +name: schedule + +on: + schedule: + - cron: '0 0 * * 0' + workflow_dispatch: + +jobs: + spec: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - macos-14 + - macos-latest + - ubuntu-latest + - windows-latest + ruby-version: + - ruby-head + - jruby-head + - truffleruby-head + - truffleruby+graalvm-head + exclude: + - os: windows-latest + ruby-version: truffleruby-head + - os: windows-latest + ruby-version: truffleruby+graalvm-head + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Compile + run: bundle exec rake compile + + - name: Spec + run: bundle exec rake spec + + - name: Install + run: rake -f -r bundler/gem_tasks install diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index edd039dc..d8dcf0b2 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -1086,7 +1086,7 @@ def expect_from_import(canonicalize, expected) } }] ) - end.to raise_sass_compile_error.with_line(0).with_message("undefined method `to_str'") + end.to raise_sass_compile_error.with_line(0).with_message('undefined method') end end From 34efad5f205d56c56d73c00c1223d03f3abda232 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 30 Mar 2024 17:00:19 -0700 Subject: [PATCH 430/700] Update rubocop-rspec requirement from ~> 2.27.1 to ~> 2.28.0 (#197) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.27.1...v2.28.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e756400f..f540d6fe 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.62.0' gem 'rubocop-performance', '~> 1.20.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.27.1' + gem 'rubocop-rspec', '~> 2.28.0' end From b6e47215cd622f5200841257b7eebade9082bde8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Mar 2024 09:39:37 -0700 Subject: [PATCH 431/700] Update documentation --- lib/sass/compiler.rb | 6 +++--- lib/sass/node_package_importer.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index dfe8dbbb..b31f48ca 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -42,7 +42,7 @@ def initialize # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. # @param source_map [Boolean] Whether or not Sass should generate a source map. # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. - # @param style [String, Symbol] The OutputStyle of the compiled CSS. + # @param style [Symbol] The OutputStyle of the compiled CSS. # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. # @param importers [Array] Custom importers that control how Sass resolves loads from rules like # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. @@ -105,7 +105,7 @@ def compile(path, # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet. # @param load_paths [Array] Paths in which to look for stylesheets loaded by rules like # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. - # @param syntax [String, Symbol] The Syntax to use to parse the entrypoint stylesheet. + # @param syntax [Symbol] The Syntax to use to parse the entrypoint stylesheet. # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's # used to resolve relative loads in the entrypoint stylesheet. # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+ @@ -113,7 +113,7 @@ def compile(path, # browsers or other consumers. If +charset+ is +false+, these annotations are omitted. # @param source_map [Boolean] Whether or not Sass should generate a source map. # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map. - # @param style [String, Symbol] The OutputStyle of the compiled CSS. + # @param style [Symbol] The OutputStyle of the compiled CSS. # @param functions [Hash] Additional built-in Sass functions that are available in all stylesheets. # @param importers [Array] Custom importers that control how Sass resolves loads from rules like # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/]. diff --git a/lib/sass/node_package_importer.rb b/lib/sass/node_package_importer.rb index 91fb14fe..07d6d54a 100644 --- a/lib/sass/node_package_importer.rb +++ b/lib/sass/node_package_importer.rb @@ -4,10 +4,10 @@ module Sass # The built-in Node.js package importer. This loads pkg: URLs from node_modules # according to the standard Node.js resolution algorithm. # - # @param entry_point_directory [String] The directory where the {NodePackageImporter} should start when resolving - # `pkg:` URLs in sources other than files on disk. # @see https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/ class NodePackageImporter + # @param entry_point_directory [String] The directory where the {NodePackageImporter} should start when resolving + # `pkg:` URLs in sources other than files on disk. def initialize(entry_point_directory) raise ArgumentError, 'entry_point_directory must be set' if entry_point_directory.nil? From 26fc389cffabd4c2c628d1c7a738af9448121263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Mar 2024 11:46:54 -0700 Subject: [PATCH 432/700] Prepare CompileRequest before connect to dispacther --- lib/sass/compiler/host.rb | 72 ++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index ce13d7b9..20570317 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -33,42 +33,44 @@ def compile_request(path:, logger:, quiet_deps:, verbose:) + alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil? + + @function_registry = FunctionRegistry.new(functions, alert_color:) + @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) + @logger_registry = LoggerRegistry.new(logger) + + compile_request = EmbeddedProtocol::InboundMessage::CompileRequest.new( + string: unless source.nil? + EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( + source: source.to_str, + url: url&.to_s, + syntax: @importer_registry.syntax_to_proto(syntax), + importer: (@importer_registry.register(importer) unless importer.nil?) + ) + end, + path: (File.absolute_path(path) unless path.nil?), + style: case style&.to_sym + when :expanded + EmbeddedProtocol::OutputStyle::EXPANDED + when :compressed + EmbeddedProtocol::OutputStyle::COMPRESSED + else + raise ArgumentError, 'style must be one of :expanded, :compressed' + end, + charset:, + source_map:, + source_map_include_sources:, + importers: @importer_registry.importers, + global_functions: @function_registry.global_functions, + alert_ascii:, + alert_color:, + quiet_deps:, + silent: logger == Logger.silent, + verbose: + ) + compile_response = await do - alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil? - - @function_registry = FunctionRegistry.new(functions, alert_color:) - @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) - @logger_registry = LoggerRegistry.new(logger) - - send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( - string: unless source.nil? - EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( - source: source.to_str, - url: url&.to_s, - syntax: @importer_registry.syntax_to_proto(syntax), - importer: (@importer_registry.register(importer) unless importer.nil?) - ) - end, - path: (File.absolute_path(path) unless path.nil?), - style: case style&.to_sym - when :expanded - EmbeddedProtocol::OutputStyle::EXPANDED - when :compressed - EmbeddedProtocol::OutputStyle::COMPRESSED - else - raise ArgumentError, 'style must be one of :expanded, :compressed' - end, - charset:, - source_map:, - source_map_include_sources:, - importers: @importer_registry.importers, - global_functions: @function_registry.global_functions, - alert_ascii:, - alert_color:, - quiet_deps:, - silent: logger == Logger.silent, - verbose: - )) + send_message(compile_request:) end oneof = compile_response.result From 007b95aaea6b9ab6a09b1e6808bc87183d828958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Mar 2024 12:01:21 -0700 Subject: [PATCH 433/700] Handle `Exception` other than `StandardError` --- lib/sass/compiler/host.rb | 5 +++-- spec/sass_compile_spec.rb | 2 -- spec/sass_function_spec.rb | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 20570317..da013a18 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -139,8 +139,6 @@ def error(message) def log_event(message) @logger_registry.log(message) - rescue StandardError => e - @stream.error(e) end def canonicalize_request(message) @@ -183,6 +181,9 @@ def await message = outbound_message.public_send(oneof) public_send(oneof, message) end + rescue Exception => e # rubocop:disable Lint/RescueException + @stream.error(e) + raise end end diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 3e5b391a..8df00795 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -276,8 +276,6 @@ end it 'throws an error for an unrecognized style' do - skip 'RBS::Test::Tester is loaded' if defined?(RBS::Test::Tester) - expect { described_class.compile_string('a {b: c}', style: 'unrecognized style') } .to raise_error(ArgumentError) end diff --git a/spec/sass_function_spec.rb b/spec/sass_function_spec.rb index 7e108f66..069de413 100644 --- a/spec/sass_function_spec.rb +++ b/spec/sass_function_spec.rb @@ -98,8 +98,6 @@ end it 'not returning' do - skip 'RBS::Test::Tester is loaded' if defined?(RBS::Test::Tester) - expect do described_class.compile_string( 'a {b: foo()}', @@ -112,8 +110,6 @@ describe 'returning a non-Value' do it 'directly' do - skip 'RBS::Test::Tester is loaded' if defined?(RBS::Test::Tester) - expect do described_class.compile_string( 'a {b: foo()}', From 6cf4618d6fefb40e4e214e952901c515bceee1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Mar 2024 13:46:15 -0700 Subject: [PATCH 434/700] Override `@id` for `ArgumentList#dup` but not `ArgumentList#clone` --- lib/sass/value/argument_list.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 0165215d..80550118 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -28,9 +28,9 @@ def keywords private - def initialize_copy(orig) - super + def initialize_dup(orig) @id = 0 + super end end end From eb6e400362c4f36f1cf992c2024ac5f06475d57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 31 Mar 2024 14:01:09 -0700 Subject: [PATCH 435/700] Fix flaky test on jruby --- lib/sass/compiler/host.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index da013a18..33d642bc 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -129,12 +129,11 @@ def version_response(message) def error(message) case message when EmbeddedProtocol::ProtocolError - @error = Errno::EPROTO.new(message.message) - @stream.error(@error) + raise Errno::EPROTO, message.message else @error ||= message + @queue.close end - @queue.close end def log_event(message) From fbbd426e003a3bf8b9b0a820ed7156aa7f69c234 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 08:06:30 -0700 Subject: [PATCH 436/700] Update rubocop-performance requirement from ~> 1.20.0 to ~> 1.21.0 (#198) Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.20.0...v1.21.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f540d6fe..a9afabd4 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.62.0' - gem 'rubocop-performance', '~> 1.20.0' + gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.28.0' end From 653d33998a7f3d21b5f1e1beb093a4ce5aafa52e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:37:56 -0700 Subject: [PATCH 437/700] Bump sass from 1.72.0 to 1.74.1 in /ext/sass (#199) Bumps [sass](https://github.com/sass/dart-sass) from 1.72.0 to 1.74.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.72.0...1.74.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 74288e82..7a6750f6 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.72.0" + "sass": "1.74.1" } } From adeda29b3a491363361c49db83fd29197aa7a7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 3 Apr 2024 19:14:54 -0700 Subject: [PATCH 438/700] Add basic support for deprecations API --- lib/sass/compiler.rb | 18 ++++++++++++++++++ lib/sass/compiler/host.rb | 6 ++++++ lib/sass/embedded.rb | 4 ++-- spec/sass_deprecations_spec.rb | 29 +++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 spec/sass_deprecations_spec.rb diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index b31f48ca..96377bbd 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -51,10 +51,13 @@ def initialize # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or # not to use colors depending on whether the user is using an interactive terminal. + # @param fatal_deprecations [Array] A set of deprecations to treat as fatal. + # @param future_deprecations [Array] A set of future deprecations to opt into early. # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. # Stylesheets that are imported relative to the entrypoint are not considered dependencies. + # @param silence_deprecations [Array] A set of active deprecations to ignore. # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every # deprecation warning it encounters. @@ -74,8 +77,11 @@ def compile(path, alert_ascii: false, alert_color: nil, + fatal_deprecations: [], + future_deprecations: [], logger: nil, quiet_deps: false, + silence_deprecations: [], verbose: false) raise ArgumentError, 'path must be set' if path.nil? @@ -94,8 +100,11 @@ def compile(path, importers:, alert_color:, alert_ascii:, + fatal_deprecations:, + future_deprecations:, logger:, quiet_deps:, + silence_deprecations:, verbose: ) end @@ -122,10 +131,13 @@ def compile(path, # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or # not to use colors depending on whether the user is using an interactive terminal. + # @param fatal_deprecations [Array] A set of deprecations to treat as fatal. + # @param future_deprecations [Array] A set of future deprecations to opt into early. # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass. # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+. # Stylesheets that are imported relative to the entrypoint are not considered dependencies. + # @param silence_deprecations [Array] A set of active deprecations to ignore. # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every # deprecation warning it encounters. @@ -148,8 +160,11 @@ def compile_string(source, alert_ascii: false, alert_color: nil, + fatal_deprecations: [], + future_deprecations: [], logger: nil, quiet_deps: false, + silence_deprecations: [], verbose: false) raise ArgumentError, 'source must be set' if source.nil? @@ -168,8 +183,11 @@ def compile_string(source, importers:, alert_color:, alert_ascii:, + fatal_deprecations:, + future_deprecations:, logger:, quiet_deps:, + silence_deprecations:, verbose: ) end diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 33d642bc..00012ed7 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -30,8 +30,11 @@ def compile_request(path:, importers:, alert_ascii:, alert_color:, + fatal_deprecations:, + future_deprecations:, logger:, quiet_deps:, + silence_deprecations:, verbose:) alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil? @@ -64,8 +67,11 @@ def compile_request(path:, global_functions: @function_registry.global_functions, alert_ascii:, alert_color:, + fatal_deprecation: fatal_deprecations, + future_deprecation: future_deprecations, quiet_deps:, silent: logger == Logger.silent, + silence_deprecation: silence_deprecations, verbose: ) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 329c0804..045c3515 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -18,7 +18,7 @@ module Sass # rubocop:disable Layout/LineLength class << self # Compiles the Sass file at +path+ to CSS. - # @overload compile(path, load_paths: [], charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, logger: nil, quiet_deps: false, verbose: false) + # @overload compile(path, load_paths: [], charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, fatal_deprecations: [], future_deprecations: [], logger: nil, quiet_deps: false, silence_deprecations: [], verbose: false) # @param (see Compiler#compile) # @return (see Compiler#compile) # @raise (see Compiler#compile) @@ -28,7 +28,7 @@ def compile(...) end # Compiles a stylesheet whose contents is +source+ to CSS. - # @overload compile_string(source, importer: nil, load_paths: [], syntax: :scss, url: nil, charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, logger: nil, quiet_deps: false, verbose: false) + # @overload compile_string(source, importer: nil, load_paths: [], syntax: :scss, url: nil, charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, fatal_deprecations: [], future_deprecations: [], logger: nil, quiet_deps: false, silence_deprecations: [], verbose: false) # @param (see Compiler#compile_string) # @return (see Compiler#compile_string) # @raise (see Compiler#compile_string) diff --git a/spec/sass_deprecations_spec.rb b/spec/sass_deprecations_spec.rb new file mode 100644 index 00000000..58ca1ddc --- /dev/null +++ b/spec/sass_deprecations_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/deprecations.test.ts +RSpec.describe Sass do + describe 'a warning' do + it 'is not emitted when deprecation id silenced' do + stdio = capture_stdio do + described_class.compile_string( + 'a { $b: c !global; }', + silence_deprecations: ['new-global'] + ) + end + expect(stdio.err).to be_empty + end + end + + describe 'an error' do + it 'is thrown when deprecation id made fatal' do + expect do + described_class.compile_string( + 'a { $b: c !global; }', + fatal_deprecations: ['new-global'] + ) + end.to raise_sass_compile_error + end + end +end From a167997fc19afbd652cb0ba6d6692b69e74badbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 3 Apr 2024 19:29:01 -0700 Subject: [PATCH 439/700] v1.74.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 95be9c69..cced26c1 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.72.0' + VERSION = '1.74.1' end end From 8ecdd72b49c2c53b5458666407abcab5582575ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:27:17 -0700 Subject: [PATCH 440/700] Update rubocop-rspec requirement from ~> 2.28.0 to ~> 2.29.1 (#200) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.28.0...v2.29.1) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a9afabd4..7563392b 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.62.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.28.0' + gem 'rubocop-rspec', '~> 2.29.1' end From 00be1ee53cb5de89f2a8667c73fbb88675f72471 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:09:23 -0700 Subject: [PATCH 441/700] Update rubocop requirement from ~> 1.62.0 to ~> 1.63.0 (#201) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.62.0...v1.63.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7563392b..dfadc2bc 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13.0.0' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.62.0' + gem 'rubocop', '~> 1.63.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.29.1' From 84d47dc9ac747f88563043449adb297cb80c537c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 8 Apr 2024 09:26:55 -0700 Subject: [PATCH 442/700] Update release automation --- .github/workflows/release.yml | 73 +++++++++++++++++------------------ Rakefile | 2 +- sass-embedded.gemspec | 8 ++-- 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1937b205..760fa183 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,55 +6,22 @@ on: - 'v*' jobs: - release: - - if: github.event.repository.fork == false - - runs-on: ubuntu-latest - - permissions: - id-token: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ruby - rubygems: latest - bundler-cache: true - - - name: Compile - run: bundle exec rake compile - - - name: Configure trusted publishing credentials - uses: rubygems/configure-rubygems-credentials@v1.0.0 - - - name: Release - run: rake -f -r bundler/gem_tasks release - - release-pre-compiled: + build: if: github.event.repository.fork == false - needs: [release] - runs-on: ${{ matrix.os }} - permissions: - id-token: write - strategy: fail-fast: false - max-parallel: 1 matrix: include: - os: macos-latest platform: arm64-darwin - os: macos-latest platform: x86_64-darwin + - os: ubuntu-latest + platform: ruby - os: ubuntu-latest platform: aarch64-linux-android - os: ubuntu-latest @@ -118,8 +85,40 @@ jobs: - name: Compile run: bundle exec rake compile ext_platform=${{ matrix.platform }} + - name: Build + run: rake -f -r bundler/gem_tasks build gem_platform=${{ matrix.platform }} + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: pkg-${{ matrix.platform }} + path: pkg/*.gem + if-no-files-found: error + compression-level: 0 + + release: + + if: github.event.repository.fork == false + + needs: [build] + + runs-on: ubuntu-latest + + permissions: + id-token: write + + steps: + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby + rubygems: latest + - name: Configure trusted publishing credentials uses: rubygems/configure-rubygems-credentials@v1.0.0 + - name: Download Artifact + uses: actions/download-artifact@v4 + - name: Release - run: rake -f -r bundler/gem_tasks release gem_platform=${{ matrix.platform }} + run: find . -name '*.gem' -print0 | sort -rz -t / -k 3 | xargs -0 -n 1 -- gem push diff --git a/Rakefile b/Rakefile index 4d17d81e..e0be435d 100644 --- a/Rakefile +++ b/Rakefile @@ -10,7 +10,7 @@ desc 'Compile all the extensions' task :compile do sh 'rake', '-C', 'ext/sass', 'clobber', 'install' - if ENV.key?('ext_platform') + if ENV.key?('ext_platform') && ENV['ext_platform'] != 'ruby' host_cpu, host_os = ENV['ext_platform'].split('-', 2) rm 'ext/sass/cli.rb' diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 1b72de96..e90b3941 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -22,11 +22,9 @@ Gem::Specification.new do |spec| spec.bindir = 'exe' spec.executables = ['sass'] spec.files = Dir['exe/**/*', 'ext/**/*_pb.rb', 'lib/**/*.rb'] + ['LICENSE', 'README.md'] + spec.platform = ENV.fetch('gem_platform', 'ruby') - if ENV.key?('gem_platform') - spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] - spec.platform = ENV['gem_platform'] - else + if spec.platform == Gem::Platform::RUBY spec.extensions = ['ext/sass/Rakefile'] spec.files += [ 'ext/sass/Rakefile', @@ -34,6 +32,8 @@ Gem::Specification.new do |spec| 'ext/sass/package.json' ] spec.add_runtime_dependency 'rake', '>= 13.0.0' + else + spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] end spec.required_ruby_version = '>= 3.1.0' From e815294dde6d7e6b671a69cd7d12b24f61a2db5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:26:04 -0700 Subject: [PATCH 443/700] Bump sass from 1.74.1 to 1.75.0 in /ext/sass (#202) Bumps [sass](https://github.com/sass/dart-sass) from 1.74.1 to 1.75.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.74.1...1.75.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 7a6750f6..08447c9a 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.74.1" + "sass": "1.75.0" } } From 4b2d78fed344f3c396c2f2e2cb51d63bdbff8bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 Apr 2024 16:30:16 -0700 Subject: [PATCH 444/700] v1.75.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index cced26c1..9388b282 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.74.1' + VERSION = '1.75.0' end end From a8d8aee153b02a87d2957c0bf2f9754a7cc4d56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 19 Apr 2024 00:19:19 -0700 Subject: [PATCH 445/700] Simplify windows absolute path handling in Rakefile --- ext/sass/Rakefile | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 6d37a4e5..54adc100 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -138,6 +138,8 @@ module FileUtils def fetch(source_uri, dest_path = nil) require 'rubygems/remote_fetcher' + source_uri = "/#{source_uri}" if File.absolute_path?(source_uri) && !source_uri.start_with?('/') + source_uri = begin Gem::Uri.parse!(source_uri) rescue NoMethodError @@ -153,32 +155,19 @@ module FileUtils Gem::URI::DEFAULT_PARSER rescue NameError URI::DEFAULT_PARSER - end.unescape(source_uri.path || source_uri.opaque) - - if Gem.win_platform? && scheme =~ /^[a-z]$/i && !source_path.include?(':') - source_path = "#{scheme}:#{source_path}" - scheme = nil - end + end.unescape(source_uri.path) dest_path = File.basename(source_path) if dest_path.nil? - case scheme - when nil, 'file' - if Gem.win_platform? && source_path[0].chr == '/' && source_path[1].chr =~ /[a-z]/i && source_path[2].chr == ':' - source_path = source_path[1..] - end - cp source_path, dest_path - else - fetcher = Gem::RemoteFetcher.fetcher - symbol = :"fetch_#{scheme}" - raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol) + fetcher = Gem::RemoteFetcher.fetcher + symbol = :"fetch_#{scheme.nil? ? 'file' : scheme}" + raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol) - Rake.rake_output_message "fetch #{Gem::Uri.new(source_uri).redacted}" if Rake::FileUtilsExt.verbose_flag + Rake.rake_output_message "fetch #{Gem::Uri.new(source_uri).redacted}" if Rake::FileUtilsExt.verbose_flag - unless Rake::FileUtilsExt.nowrite_flag - data = fetcher.public_send(symbol, source_uri) - Gem.write_binary(dest_path, data) - end + unless Rake::FileUtilsExt.nowrite_flag + data = fetcher.public_send(symbol, source_uri) + Gem.write_binary(dest_path, data) end dest_path From bb91dd6c1709516d0bc24b40c15f650743c7e149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 23 Apr 2024 10:41:14 -0700 Subject: [PATCH 446/700] Update build.yml --- .github/workflows/build.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f38b9908..ef0f2f6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,13 @@ name: build -on: [push, pull_request] +on: + pull_request: + push: + branches: + - '**' + tags-ignore: + - 'v*' + workflow_dispatch: jobs: lint: From 5ae6f5d3e7214ee67de818eb9757392f2cb93512 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:41:08 -0700 Subject: [PATCH 447/700] Bump sass from 1.75.0 to 1.76.0 in /ext/sass (#203) Bumps [sass](https://github.com/sass/dart-sass) from 1.75.0 to 1.76.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.75.0...1.76.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 08447c9a..ceecf880 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.75.0" + "sass": "1.76.0" } } From 369e97025a165a2317355043712238a9f4f16d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 30 Apr 2024 16:47:10 -0700 Subject: [PATCH 448/700] Update build.yml --- .github/workflows/build.yml | 1 - .github/workflows/schedule.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef0f2f6b..565d6a8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,6 @@ jobs: fail-fast: false matrix: os: - - macos-14 - macos-latest - ubuntu-latest - windows-latest diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index c4cceab0..0541b16a 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -14,7 +14,6 @@ jobs: fail-fast: false matrix: os: - - macos-14 - macos-latest - ubuntu-latest - windows-latest From 6c9820f33a06b17f5588ca587f707ac76bd8b307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 30 Apr 2024 16:54:22 -0700 Subject: [PATCH 449/700] v1.76.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 9388b282..2c4a1da1 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.75.0' + VERSION = '1.76.0' end end From 072a7627d70785cbd21e48a429c5e1a8df1b78c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 1 May 2024 11:49:27 -0700 Subject: [PATCH 450/700] Remove workaround for https://github.com/jruby/jruby/issues/8033 --- lib/sass/compiler/host.rb | 2 +- lib/sass/exception.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 00012ed7..5a11c5c3 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -36,7 +36,7 @@ def compile_request(path:, quiet_deps:, silence_deprecations:, verbose:) - alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil? + alert_color = Exception.to_tty? if alert_color.nil? @function_registry = FunctionRegistry.new(functions, alert_color:) @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index d05d3b42..28187825 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -26,7 +26,7 @@ def initialize(message, full_message, sass_stack, span, loaded_urls) def full_message(highlight: nil, order: nil, **) return super if @full_message.nil? - highlight = Exception.respond_to?(:to_tty?) && Exception.to_tty? if highlight.nil? + highlight = Exception.to_tty? if highlight.nil? if highlight @full_message.dup else From d48ab616580124c2c188cf2c2d9ce7bdd77d1f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 2 May 2024 16:20:20 -0700 Subject: [PATCH 451/700] Change Sass::CLI from a class to a module --- exe/sass | 2 +- ext/sass/Rakefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exe/sass b/exe/sass index 16e0e5df..ca4c0c28 100755 --- a/exe/sass +++ b/exe/sass @@ -5,7 +5,7 @@ require_relative '../ext/sass/cli' module Sass # The `sass` command line interface - class CLI + module CLI begin Kernel.exec(*COMMAND, *ARGV) rescue Errno::ENOENT diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 54adc100..041504e9 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -54,7 +54,7 @@ file 'cli.rb' => %w[dart-sass] do |t| # frozen_string_literal: true module Sass - class CLI + module CLI COMMAND = [#{command}].freeze end From 216d86f215cc778c3ad68cff100c3729b012a9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 6 May 2024 11:05:17 -0700 Subject: [PATCH 452/700] Fix a race condition where `@connection.close` is called before `@connection` is assigned when compiler crash on start --- lib/sass/compiler/connection.rb | 4 +++- lib/sass/compiler/dispatcher.rb | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 04430a17..69ca5bd1 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -10,7 +10,7 @@ class Compiler # # It runs the `sass --embedded` command. class Connection - def initialize(dispatcher) + def initialize @mutex = Mutex.new @stdin, @stdout, @stderr, @wait_thread = begin Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) @@ -23,7 +23,9 @@ def initialize(dispatcher) end @stdin.binmode + end + def listen(dispatcher) Thread.new do Thread.current.name = "sass-embedded-process-stdout-poller-#{@wait_thread.pid}" diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index b039b732..9fda6df9 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -10,7 +10,8 @@ def initialize @id = 1 @observers = {}.compare_by_identity @mutex = Mutex.new - @connection = Connection.new(self) + @connection = Connection.new + @connection.listen(self) ForkTracker.add(self) end From 3b196eb2f39499694ab82dbd7c1952deef559c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 6 May 2024 18:14:54 -0700 Subject: [PATCH 453/700] Detect broken rubygems (#204) --- lib/sass-embedded.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/sass-embedded.rb b/lib/sass-embedded.rb index 91324f6e..57876277 100755 --- a/lib/sass-embedded.rb +++ b/lib/sass-embedded.rb @@ -1,4 +1,21 @@ #!/usr/bin/env ruby # frozen_string_literal: true +spec = Gem.loaded_specs['sass-embedded'] +platform = spec&.platform +if platform.is_a?(Gem::Platform) && platform.os == 'linux' && platform.version.nil? + update = if Gem.disable_system_update_message + 'updating Ruby to version 3.2 or later' + else + "running 'gem update --system' to update RubyGems" + end + install = if defined?(Bundler) + "running 'rm -f Gemfile.lock && bundle install'" + else + "running 'gem install sass-embedded'" + end + raise LoadError, "The gemspec for #{spec.name} at #{spec.loaded_from} was broken. " \ + "Try #{update}, and then try #{install} to reinstall." +end + require_relative 'sass/embedded' From a14ed0e38ad9930da6d68aba1c68f959e4d6fceb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 18:26:29 -0700 Subject: [PATCH 454/700] Bump sass from 1.76.0 to 1.77.0 in /ext/sass (#205) Bumps [sass](https://github.com/sass/dart-sass) from 1.76.0 to 1.77.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.76.0...1.77.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index ceecf880..4ffd914f 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.76.0" + "sass": "1.77.0" } } From 2369cf8306923cf4e24fd5f3c05fe146b022f076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 6 May 2024 18:39:28 -0700 Subject: [PATCH 455/700] Move broken rubygems detection to ext/sass/cli.rb --- ext/sass/Rakefile | 17 +++++++++++++++++ lib/sass-embedded.rb | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 041504e9..aa5c438e 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -53,6 +53,23 @@ file 'cli.rb' => %w[dart-sass] do |t| File.write(t.name, <<~CLI_RB) # frozen_string_literal: true + spec = Gem.loaded_specs['sass-embedded'] + platform = spec&.platform + if platform.is_a?(Gem::Platform) && platform.os == 'linux' && platform.version.nil? + update = if Gem.disable_system_update_message + 'updating Ruby to version 3.2 or later' + else + "running 'gem update --system' to update RubyGems" + end + install = if defined?(Bundler) + "running 'rm -f Gemfile.lock && bundle install'" + else + "running 'gem install sass-embedded'" + end + raise LoadError, "The gemspec for \#{spec.name} at \#{spec.loaded_from} was broken. " \\ + "Try \#{update}, and then try \#{install} to reinstall." + end + module Sass module CLI COMMAND = [#{command}].freeze diff --git a/lib/sass-embedded.rb b/lib/sass-embedded.rb index 57876277..91324f6e 100755 --- a/lib/sass-embedded.rb +++ b/lib/sass-embedded.rb @@ -1,21 +1,4 @@ #!/usr/bin/env ruby # frozen_string_literal: true -spec = Gem.loaded_specs['sass-embedded'] -platform = spec&.platform -if platform.is_a?(Gem::Platform) && platform.os == 'linux' && platform.version.nil? - update = if Gem.disable_system_update_message - 'updating Ruby to version 3.2 or later' - else - "running 'gem update --system' to update RubyGems" - end - install = if defined?(Bundler) - "running 'rm -f Gemfile.lock && bundle install'" - else - "running 'gem install sass-embedded'" - end - raise LoadError, "The gemspec for #{spec.name} at #{spec.loaded_from} was broken. " \ - "Try #{update}, and then try #{install} to reinstall." -end - require_relative 'sass/embedded' From 30ebf714a45ec86d699c886c313304c8e3521a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 6 May 2024 18:54:01 -0700 Subject: [PATCH 456/700] Run broken rubygems detection only on linux --- ext/sass/Rakefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index aa5c438e..3b1ea66a 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -50,8 +50,7 @@ file 'cli.rb' => %w[dart-sass] do |t| " end - File.write(t.name, <<~CLI_RB) - # frozen_string_literal: true + validate_gemspec = <<~'VALIDATE_GEMSPEC' spec = Gem.loaded_specs['sass-embedded'] platform = spec&.platform @@ -66,10 +65,14 @@ file 'cli.rb' => %w[dart-sass] do |t| else "running 'gem install sass-embedded'" end - raise LoadError, "The gemspec for \#{spec.name} at \#{spec.loaded_from} was broken. " \\ - "Try \#{update}, and then try \#{install} to reinstall." + raise LoadError, "The gemspec for #{spec.name} at #{spec.loaded_from} was broken. " \ + "Try #{update}, and then try #{install} to reinstall." end + VALIDATE_GEMSPEC + File.write(t.name, <<~CLI_RB) + # frozen_string_literal: true + #{validate_gemspec if SassConfig.gem_platform.os == 'linux'} module Sass module CLI COMMAND = [#{command}].freeze From 6a17db0399714ed4da41cef4448073af5b5d54f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 6 May 2024 19:05:14 -0700 Subject: [PATCH 457/700] v1.77.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 2c4a1da1..2da7c9b0 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.76.0' + VERSION = '1.77.0' end end From 6cd3c23933e2c76e07683c19e7157f5cc4e3c64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 6 May 2024 20:01:10 -0700 Subject: [PATCH 458/700] Detect older versions of broken rubygems --- ext/sass/Rakefile | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 3b1ea66a..ec8f872b 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -52,21 +52,23 @@ file 'cli.rb' => %w[dart-sass] do |t| validate_gemspec = <<~'VALIDATE_GEMSPEC' - spec = Gem.loaded_specs['sass-embedded'] - platform = spec&.platform - if platform.is_a?(Gem::Platform) && platform.os == 'linux' && platform.version.nil? - update = if Gem.disable_system_update_message - 'updating Ruby to version 3.2 or later' - else - "running 'gem update --system' to update RubyGems" - end - install = if defined?(Bundler) - "running 'rm -f Gemfile.lock && bundle install'" - else - "running 'gem install sass-embedded'" - end - raise LoadError, "The gemspec for #{spec.name} at #{spec.loaded_from} was broken. " \ - "Try #{update}, and then try #{install} to reinstall." + if Gem::Platform.new('aarch64-linux-musl') === Gem::Platform.new('aarch64-linux') # rubocop:disable Style/CaseEquality + spec = Gem.loaded_specs['sass-embedded'] + platform = spec&.platform + if platform.is_a?(Gem::Platform) && platform.os == 'linux' + update = if Gem.disable_system_update_message + 'updating Ruby to version 3.2 or later' + else + "running 'gem update --system' to update RubyGems" + end + install = if defined?(Bundler) + "running 'rm -f Gemfile.lock && bundle install'" + else + "running 'gem install sass-embedded'" + end + raise LoadError, "The gemspec for #{spec.name} at #{spec.loaded_from} was broken. " \ + "Try #{update}, and then try #{install} to reinstall." + end end VALIDATE_GEMSPEC From 7fcc175cb38c4a5433eb625a05939fef8331a9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 7 May 2024 09:26:45 -0700 Subject: [PATCH 459/700] Skip cleanup if Rake::FileUtilsExt.nowrite_flag is set --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ec8f872b..c050d4f7 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -230,7 +230,7 @@ module FileUtils yield installer.dir ensure - rm_rf install_dir + rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag end end From 7f10921fe36fbb4ae74e434afa256988a3348b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 7 May 2024 11:39:29 -0700 Subject: [PATCH 460/700] Use Gem::Resolver::BestSet instead of Gem::SpecFetcher to fetch spec --- ext/sass/Rakefile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index c050d4f7..ae7da9af 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -196,6 +196,8 @@ module FileUtils end def gem_install(name, version, platform) + require 'rubygems/remote_fetcher' + install_dir = File.absolute_path('ruby') if Rake::FileUtilsExt.verbose_flag @@ -212,19 +214,20 @@ module FileUtils dependency = Gem::Dependency.new(name, version) - specs_and_sources, _errors = Gem::SpecFetcher.fetcher.spec_for_dependency(dependency, false) + dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil) - spec, source = specs_and_sources.find do |s, _| + resolver_spec = Gem::Resolver::BestSet.new.find_all(dependency_request).find do |s| s.platform == platform end - raise if spec.nil? || source.nil? + raise if resolver_spec.nil? + options = { force: true, install_dir: } if Rake::FileUtilsExt.nowrite_flag - installer = Gem::Installer.for_spec(spec, { force: true, install_dir: }) + installer = Gem::Installer.for_spec(resolver_spec.spec, options) else - path = source.download(spec, install_dir) - installer = Gem::Installer.at(path, { force: true, install_dir: }) + path = resolver_spec.download(options) + installer = Gem::Installer.at(path, options) installer.install end @@ -334,7 +337,9 @@ module SassConfig repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc' - spec = Gem::Dependency.new('google-protobuf').to_spec + dependency = Gem::Dependency.new('google-protobuf') + + spec = dependency.to_spec version = spec.version @@ -372,12 +377,14 @@ module SassConfig uri rescue Gem::RemoteFetcher::FetchError - tuples = Gem::SpecFetcher.fetcher.detect(:released) do |name_tuple| - name_tuple.name == spec.name && name_tuple.platform == 'ruby' + dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil) + + versions = Gem::Resolver::BestSet.new.find_all(dependency_request).filter_map do |s| + s.version if s.platform == 'ruby' end - tuples.sort.reverse_each do |name_tuple, _source| - uri = "#{repo}/#{name_tuple.version}/protoc-#{name_tuple.version}-#{os}-#{cpu}.exe" + versions.sort.reverse_each do |v| + uri = "#{repo}/#{v}/protoc-#{v}-#{os}-#{cpu}.exe" Gem::RemoteFetcher.fetcher.fetch_https(Gem::Uri.new("#{uri}.sha1")) From 70af551ebdc843ce71c97754efa40cde99f54618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 7 May 2024 11:54:57 -0700 Subject: [PATCH 461/700] Use constant Gem::Platform::RUBY --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ae7da9af..fbd80f06 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -380,7 +380,7 @@ module SassConfig dependency_request = Gem::Resolver::DependencyRequest.new(dependency, nil) versions = Gem::Resolver::BestSet.new.find_all(dependency_request).filter_map do |s| - s.version if s.platform == 'ruby' + s.version if s.platform == Gem::Platform::RUBY end versions.sort.reverse_each do |v| From 2c145537c7c3fe4e3c4da47845b9cd402e06ecee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 7 May 2024 14:52:08 -0700 Subject: [PATCH 462/700] Block platform linux native gem on ruby <3.2 Platform ruby gem can still be installed on ruby 3.1 --- ext/sass/Rakefile | 24 +----------------------- sass-embedded.gemspec | 6 +++++- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index fbd80f06..1f3ea2cb 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -50,31 +50,9 @@ file 'cli.rb' => %w[dart-sass] do |t| " end - validate_gemspec = <<~'VALIDATE_GEMSPEC' - - if Gem::Platform.new('aarch64-linux-musl') === Gem::Platform.new('aarch64-linux') # rubocop:disable Style/CaseEquality - spec = Gem.loaded_specs['sass-embedded'] - platform = spec&.platform - if platform.is_a?(Gem::Platform) && platform.os == 'linux' - update = if Gem.disable_system_update_message - 'updating Ruby to version 3.2 or later' - else - "running 'gem update --system' to update RubyGems" - end - install = if defined?(Bundler) - "running 'rm -f Gemfile.lock && bundle install'" - else - "running 'gem install sass-embedded'" - end - raise LoadError, "The gemspec for #{spec.name} at #{spec.loaded_from} was broken. " \ - "Try #{update}, and then try #{install} to reinstall." - end - end - VALIDATE_GEMSPEC - File.write(t.name, <<~CLI_RB) # frozen_string_literal: true - #{validate_gemspec if SassConfig.gem_platform.os == 'linux'} + module Sass module CLI COMMAND = [#{command}].freeze diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index e90b3941..c6ec1622 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -36,7 +36,11 @@ Gem::Specification.new do |spec| spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] end - spec.required_ruby_version = '>= 3.1.0' + spec.required_ruby_version = if spec.platform == Gem::Platform::RUBY || spec.platform.os != 'linux' + '>= 3.1.0' + else + '>= 3.2.0' + end spec.add_runtime_dependency 'google-protobuf', '>= 3.25', '< 5.0' end From 42c3c7ffd38a2855d644410a8eae8309471665d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 Apr 2024 22:45:15 -0700 Subject: [PATCH 463/700] Implement access tracking for containingUrl --- lib/sass/canonicalize_context.rb | 6 +++++- lib/sass/compiler/host/importer_registry.rb | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/sass/canonicalize_context.rb b/lib/sass/canonicalize_context.rb index aa6d1256..2f48dc85 100644 --- a/lib/sass/canonicalize_context.rb +++ b/lib/sass/canonicalize_context.rb @@ -7,13 +7,17 @@ module Sass # @see https://sass-lang.com/documentation/js-api/interfaces/canonicalizecontext/ class CanonicalizeContext # @return [String, nil] - attr_reader :containing_url + def containing_url + @containing_url_unused = false + @containing_url + end # @return [Boolean] attr_reader :from_import # @!visibility private def initialize(canonicalize_request) + @containing_url_unused = true @containing_url = canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url @from_import = canonicalize_request.from_import end diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index 306a0a92..4ebc3dd2 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -68,12 +68,14 @@ def register(importer) def canonicalize(canonicalize_request) importer = @importers_by_id[canonicalize_request.importer_id] + canonicalize_context = CanonicalizeContext.new(canonicalize_request) url = importer.canonicalize(canonicalize_request.url, - CanonicalizeContext.new(canonicalize_request))&.to_s + canonicalize_context)&.to_s EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( id: canonicalize_request.id, - url: + url:, + containing_url_unused: canonicalize_context.instance_eval { @containing_url_unused } ) rescue StandardError => e EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( @@ -103,12 +105,14 @@ def import(import_request) def file_import(file_import_request) importer = @importers_by_id[file_import_request.importer_id] + canonicalize_context = CanonicalizeContext.new(file_import_request) file_url = importer.find_file_url(file_import_request.url, - CanonicalizeContext.new(file_import_request))&.to_s + canonicalize_context)&.to_s EmbeddedProtocol::InboundMessage::FileImportResponse.new( id: file_import_request.id, - file_url: + file_url:, + containing_url_unused: canonicalize_context.instance_eval { @containing_url_unused } ) rescue StandardError => e EmbeddedProtocol::InboundMessage::FileImportResponse.new( From d9f0a5b370337d315ca544a243df7a45b3b7b8ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 16:22:48 -0700 Subject: [PATCH 464/700] Bump sass from 1.77.0 to 1.77.1 in /ext/sass (#207) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.0 to 1.77.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.0...1.77.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 4ffd914f..970237f3 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.0" + "sass": "1.77.1" } } From 054ae46f86f377d5e70263ba5feb719f5215cd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 10 May 2024 16:27:54 -0700 Subject: [PATCH 465/700] v1.77.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 2da7c9b0..fb079e77 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.0' + VERSION = '1.77.1' end end From fc890199cd0bfb2ae17d1867ba2ea5f47d56d55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 10 May 2024 17:06:11 -0700 Subject: [PATCH 466/700] Normalize gem platform aarch64-darwin to arm64-darwin --- ext/sass/Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 1f3ea2cb..57f8f774 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -404,7 +404,12 @@ module SassConfig platform = Gem::Platform.new("#{Platform::CPU}-#{RbConfig::CONFIG['host_os']}") case Platform::OS when 'darwin' - Gem::Platform.new([RbConfig::CONFIG['host_cpu'], platform.os]) + case platform.cpu + when 'aarch64' + Gem::Platform.new(['arm64', platform.os]) + else + platform + end when 'linux' if platform.version&.start_with?('gnu') platform From 5c76dac1817722b96729ca764c349be683806fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 14 May 2024 17:03:14 -0700 Subject: [PATCH 467/700] Update connection.rb --- lib/sass/compiler/connection.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 69ca5bd1..a25cceea 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -23,6 +23,8 @@ def initialize end @stdin.binmode + + @wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}" end def listen(dispatcher) @@ -60,8 +62,6 @@ def listen(dispatcher) @stderr.close end end - - @wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}" end def close From f0c1c3441155967fa22c7cc2b59177cf59913957 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 15:42:52 -0700 Subject: [PATCH 468/700] Bump sass from 1.77.1 to 1.77.2 in /ext/sass (#211) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.1 to 1.77.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.1...1.77.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 970237f3..0c7e709d 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.1" + "sass": "1.77.2" } } From d6c1dae3b0b642b6bed823b87addfdea16d67d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 16 May 2024 15:43:19 -0700 Subject: [PATCH 469/700] v1.77.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index fb079e77..4e428c38 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.1' + VERSION = '1.77.2' end end From c21ca0d1ab6053aa9c1d7ffbe5f754897d67f4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 16 May 2024 16:50:50 -0700 Subject: [PATCH 470/700] Update sass-embedded.gemspec --- sass-embedded.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index c6ec1622..98982b1b 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -31,15 +31,15 @@ Gem::Specification.new do |spec| 'ext/sass/expand-archive.ps1', 'ext/sass/package.json' ] - spec.add_runtime_dependency 'rake', '>= 13.0.0' + spec.add_runtime_dependency 'rake', '>= 13' else spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] end spec.required_ruby_version = if spec.platform == Gem::Platform::RUBY || spec.platform.os != 'linux' - '>= 3.1.0' + '>= 3.1' else - '>= 3.2.0' + '>= 3.2' end spec.add_runtime_dependency 'google-protobuf', '>= 3.25', '< 5.0' From a8358f7cdd0ad6af89d867346d6c4e0ed36101d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 17 May 2024 09:17:55 -0700 Subject: [PATCH 471/700] Update Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index dfadc2bc..70d39ffc 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'https://rubygems.org' gemspec group :development do - gem 'rake', '>= 13.0.0' + gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.63.0' gem 'rubocop-performance', '~> 1.21.0' From 266af6151c32dc9506af31397c65254339501ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 17 May 2024 12:39:24 -0700 Subject: [PATCH 472/700] Update release.yml --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 760fa183..e18bf224 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -114,11 +114,11 @@ jobs: ruby-version: ruby rubygems: latest - - name: Configure trusted publishing credentials - uses: rubygems/configure-rubygems-credentials@v1.0.0 - - name: Download Artifact uses: actions/download-artifact@v4 + - name: Configure trusted publishing credentials + uses: rubygems/configure-rubygems-credentials@v1.0.0 + - name: Release run: find . -name '*.gem' -print0 | sort -rz -t / -k 3 | xargs -0 -n 1 -- gem push From e24c4bba26fd70aa075f1c4e8a8838bc81fb28ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 17 May 2024 18:16:00 -0700 Subject: [PATCH 473/700] Add deprecation_type parameter to logger.warn --- lib/sass/compiler/host/logger_registry.rb | 4 +++- lib/sass/logger/silent.rb | 2 +- spec/sass_logger_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index aeb9c27f..28eda74d 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -19,8 +19,10 @@ def initialize(logger) if logger.respond_to?(:warn) # rubocop:disable Style/GuardClause define_singleton_method(:warn) do |event| + deprecation = event.type == :DEPRECATION_WARNING logger.warn(event.message, - deprecation: event.type == :DEPRECATION_WARNING, + deprecation:, + deprecation_type: (event.deprecation_type if deprecation), span: event.span.nil? ? nil : Logger::SourceSpan.new(event.span), stack: event.stack_trace) end diff --git a/lib/sass/logger/silent.rb b/lib/sass/logger/silent.rb index ac06b756..2737d7ec 100644 --- a/lib/sass/logger/silent.rb +++ b/lib/sass/logger/silent.rb @@ -18,7 +18,7 @@ def silent module Silent module_function - def warn(message, deprecation: false, span: nil, stack: nil); end + def warn(message, deprecation: false, deprecation_type: nil, span: nil, stack: nil); end def debug(message, span: nil); end end diff --git a/spec/sass_logger_spec.rb b/spec/sass_logger_spec.rb index 57a842d1..7b8fcf42 100644 --- a/spec/sass_logger_spec.rb +++ b/spec/sass_logger_spec.rb @@ -39,11 +39,12 @@ @include foo; ', logger: { - warn: lambda { |message, deprecation:, span:, stack:| + warn: lambda { |message, deprecation:, deprecation_type:, span:, stack:| expect(message).to eq('heck') expect(span).to be_nil expect(stack).to be_a(String) expect(deprecation).to be(false) + expect(deprecation_type).to be_nil } } ) From 33fa1150ec966a93a8ee0c2418f5d096d039732d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 07:50:00 -0700 Subject: [PATCH 474/700] Update rubocop requirement from ~> 1.63.0 to ~> 1.64.0 (#212) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.63.0...v1.64.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 70d39ffc..4755710e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.63.0' + gem 'rubocop', '~> 1.64.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 2.29.1' From 514f821cc5ff43efae1975e5bba684e54d46a343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 23 May 2024 08:02:00 -0700 Subject: [PATCH 475/700] Use modifiers on attrs --- lib/sass/value/function.rb | 4 +--- lib/sass/value/mixin.rb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 557d3982..0e5e998a 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -18,9 +18,7 @@ def initialize(signature, &callback) end # @return [Integer, nil] - attr_reader :id - - protected :id + protected attr_reader :id # @return [::String, nil] attr_reader :signature diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index 6593f625..2f65fdb3 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -13,9 +13,7 @@ class << self end # @return [Integer] - attr_reader :id - - protected :id + protected attr_reader :id # @return [::Boolean] def ==(other) From 7382819630b90ebab851ff75dd3b2a39f626992a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 15:12:45 -0700 Subject: [PATCH 476/700] Bump sass from 1.77.2 to 1.77.3 in /ext/sass (#213) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.2 to 1.77.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.2...1.77.3) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 0c7e709d..74a4edd3 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.2" + "sass": "1.77.3" } } From bac1a3a3211a32c305fa03120051b1089cf5a627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 29 May 2024 15:20:16 -0700 Subject: [PATCH 477/700] v1.77.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 4e428c38..47134b89 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.2' + VERSION = '1.77.3' end end From d468dc7bba651965c7917a210ecdb58e5c7f054e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 30 May 2024 16:45:25 -0700 Subject: [PATCH 478/700] Normalize deprecation to string for embedded protocol --- lib/sass/compiler/host.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 5a11c5c3..b1506c0b 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -67,11 +67,11 @@ def compile_request(path:, global_functions: @function_registry.global_functions, alert_ascii:, alert_color:, - fatal_deprecation: fatal_deprecations, - future_deprecation: future_deprecations, + fatal_deprecation: fatal_deprecations.map(&:to_s), + future_deprecation: future_deprecations.map(&:to_s), quiet_deps:, silent: logger == Logger.silent, - silence_deprecation: silence_deprecations, + silence_deprecation: silence_deprecations.map(&:to_s), verbose: ) From 1147fde8bca24284c0b1ffaa305adee0ba4bab63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 16:49:15 -0700 Subject: [PATCH 479/700] Bump sass from 1.77.3 to 1.77.4 in /ext/sass (#214) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.3 to 1.77.4. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.3...1.77.4) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 74a4edd3..218ef041 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.3" + "sass": "1.77.4" } } From 23c6b400f53dc6afc99c0ab1c0faf8c243bab258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 30 May 2024 16:56:38 -0700 Subject: [PATCH 480/700] Add spec for passing version for fatal_deprecations --- spec/sass_deprecations_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/sass_deprecations_spec.rb b/spec/sass_deprecations_spec.rb index 58ca1ddc..e1cb8527 100644 --- a/spec/sass_deprecations_spec.rb +++ b/spec/sass_deprecations_spec.rb @@ -25,5 +25,14 @@ ) end.to raise_sass_compile_error end + + it 'is thrown when version made fatal' do + expect do + described_class.compile_string( + 'a { $b: c !global; }', + fatal_deprecations: ['1.17.2'] + ) + end.to raise_sass_compile_error + end end end From 2132de6545ff8eddafc89fd35fd11c17a01b3d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 30 May 2024 17:02:12 -0700 Subject: [PATCH 481/700] v1.77.4 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 47134b89..06774bf3 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.3' + VERSION = '1.77.4' end end From 3e83ccd303e4d0e07267241d1036c744dae8286c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 31 May 2024 14:03:13 -0700 Subject: [PATCH 482/700] Make custom logger behave like js api --- lib/sass/compiler/host/logger_registry.rb | 51 ++++++++++++++++------- lib/sass/logger/silent.rb | 4 +- spec/sass_logger_spec.rb | 42 +++++++++---------- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index 28eda74d..e216c190 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -10,21 +10,11 @@ class LoggerRegistry def initialize(logger) logger = Structifier.to_struct(logger, :debug, :warn) - if logger.respond_to?(:debug) - define_singleton_method(:debug) do |event| - logger.debug(event.message, - span: event.span.nil? ? nil : Logger::SourceSpan.new(event.span)) - end - end + { debug: DebugContext, warn: WarnContext }.each do |symbol, context_class| + next unless logger.respond_to?(symbol) - if logger.respond_to?(:warn) # rubocop:disable Style/GuardClause - define_singleton_method(:warn) do |event| - deprecation = event.type == :DEPRECATION_WARNING - logger.warn(event.message, - deprecation:, - deprecation_type: (event.deprecation_type if deprecation), - span: event.span.nil? ? nil : Logger::SourceSpan.new(event.span), - stack: event.stack_trace) + define_singleton_method(symbol) do |event| + logger.public_send(symbol, event.message, context_class.new(event)) end end end @@ -49,6 +39,39 @@ def debug(event) def warn(event) Kernel.warn(event.formatted) end + + # Contextual information passed to `debug`. + class DebugContext + # @return [Logger::SourceSpan, nil] + attr_reader :span + + def initialize(event) + @span = event.span.nil? ? nil : Logger::SourceSpan.new(event.span) + end + end + + private_constant :DebugContext + + # Contextual information passed to `warn`. + class WarnContext < DebugContext + # @return [Boolean] + attr_reader :deprecation + + # @return [String, nil] + attr_reader :deprecation_type + + # @return [String] + attr_reader :stack + + def initialize(event) + super + @deprecation = event.type == :DEPRECATION_WARNING + @deprecation_type = (event.deprecation_type if @deprecation) + @stack = event.stack_trace + end + end + + private_constant :WarnContext end private_constant :LoggerRegistry diff --git a/lib/sass/logger/silent.rb b/lib/sass/logger/silent.rb index 2737d7ec..f090efa5 100644 --- a/lib/sass/logger/silent.rb +++ b/lib/sass/logger/silent.rb @@ -18,9 +18,9 @@ def silent module Silent module_function - def warn(message, deprecation: false, deprecation_type: nil, span: nil, stack: nil); end + def warn(message, options); end - def debug(message, span: nil); end + def debug(message, options); end end private_constant :Silent diff --git a/spec/sass_logger_spec.rb b/spec/sass_logger_spec.rb index 7b8fcf42..a8787a6a 100644 --- a/spec/sass_logger_spec.rb +++ b/spec/sass_logger_spec.rb @@ -19,12 +19,12 @@ described_class.compile_string( '* > { --foo: bar }', logger: { - warn: lambda { |message, span:, **| + warn: lambda { |message, options| expect(message).to include('only valid for nesting') - expect(span.start.line).to be(0) - expect(span.start.column).to be(0) - expect(span.end.line).to be(0) - expect(span.end.column).to be(3) + expect(options.span.start.line).to be(0) + expect(options.span.start.column).to be(0) + expect(options.span.end.line).to be(0) + expect(options.span.end.column).to be(3) } } ) @@ -39,12 +39,12 @@ @include foo; ', logger: { - warn: lambda { |message, deprecation:, deprecation_type:, span:, stack:| + warn: lambda { |message, options| expect(message).to eq('heck') - expect(span).to be_nil - expect(stack).to be_a(String) - expect(deprecation).to be(false) - expect(deprecation_type).to be_nil + expect(options.span).to be_nil + expect(options.stack).to be_a(String) + expect(options.deprecation).to be(false) + expect(options.deprecation_type).to be_nil } } ) @@ -54,7 +54,7 @@ described_class.compile_string( '@warn #abc', logger: { - warn: lambda { |message, **| + warn: lambda { |message, _options| expect(message).to eq('#abc') } } @@ -65,7 +65,7 @@ described_class.compile_string( '@warn null', logger: { - warn: lambda { |message, **| + warn: lambda { |message, _options| expect(message).to eq('') } } @@ -110,12 +110,12 @@ described_class.compile_string( '@debug heck', logger: { - debug: lambda { |message, span:, **| + debug: lambda { |message, options| expect(message).to eq('heck') - expect(span.start.line).to eq(0) - expect(span.start.column).to eq(0) - expect(span.end.line).to eq(0) - expect(span.end.column).to eq(11) + expect(options.span.start.line).to eq(0) + expect(options.span.start.column).to eq(0) + expect(options.span.end.line).to eq(0) + expect(options.span.end.column).to eq(11) } } ) @@ -125,7 +125,7 @@ described_class.compile_string( '@debug #abc', logger: { - debug: lambda { |message, **| + debug: lambda { |message, _options| expect(message).to eq('#abc') } } @@ -136,7 +136,7 @@ described_class.compile_string( '@debug null', logger: { - debug: lambda { |message, **| + debug: lambda { |message, _options| expect(message).to eq('null') } } @@ -195,10 +195,10 @@ described_class.compile( dir.path('style.scss'), logger: { - warn: lambda { |message, **| + warn: lambda { |message, _options| expect(message).to eq('heck warn') }, - debug: lambda { |message, **| + debug: lambda { |message, _options| expect(message).to eq('heck debug') } } From 52bcd9d6cee3908277c6afcfeafdda8e9d7eceaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 10:21:11 -0700 Subject: [PATCH 483/700] Update rubocop-rspec requirement from ~> 2.29.1 to ~> 2.30.0 (#215) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.29.1...v2.30.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4755710e..34e32c9f 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.64.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.29.1' + gem 'rubocop-rspec', '~> 2.30.0' end From ec5d707e1ac22241cff623972752af250d99df49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:24:09 -0700 Subject: [PATCH 484/700] Update rubocop-rspec requirement from ~> 2.30.0 to ~> 2.31.0 (#216) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.30.0...v2.31.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 34e32c9f..0ab169a4 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.64.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.30.0' + gem 'rubocop-rspec', '~> 2.31.0' end From a8ad650e90d90c7d35d386dbce6b61b1e2f46723 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:10:04 -0700 Subject: [PATCH 485/700] Update rubocop-rspec requirement from ~> 2.31.0 to ~> 3.0.1 (#217) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.31.0...v3.0.1) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0ab169a4..beb7e825 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.64.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.31.0' + gem 'rubocop-rspec', '~> 3.0.1' end From 9ac4d1e077ee1145f1cf9c27c89bf5363efc42c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 17:04:08 -0700 Subject: [PATCH 486/700] Bump sass from 1.77.4 to 1.77.5 in /ext/sass (#218) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.4 to 1.77.5. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.4...1.77.5) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 218ef041..a5e7c825 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.4" + "sass": "1.77.5" } } From 9565cf1797a62ea658995eccdfeba4183d289bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 11 Jun 2024 17:04:45 -0700 Subject: [PATCH 487/700] v1.77.5 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 06774bf3..7524483b 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.4' + VERSION = '1.77.5' end end From 4ca2a1481a118806e72e7dff898a1165a3735334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 15 Jun 2024 19:45:20 -0700 Subject: [PATCH 488/700] Add pid to reaper thread name --- lib/sass/compiler/connection.rb | 10 +++++++--- lib/sass/embedded.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index a25cceea..3c1094f1 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -24,12 +24,16 @@ def initialize @stdin.binmode - @wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}" + @wait_thread.name = "sass-embedded-process-waiter-#{id}" + end + + def id + @wait_thread.pid end def listen(dispatcher) Thread.new do - Thread.current.name = "sass-embedded-process-stdout-poller-#{@wait_thread.pid}" + Thread.current.name = "sass-embedded-process-stdout-poller-#{id}" # # https://dart.dev/tools/dart-devtools # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') @@ -53,7 +57,7 @@ def listen(dispatcher) end Thread.new do - Thread.current.name = "sass-embedded-process-stderr-poller-#{@wait_thread.pid}" + Thread.current.name = "sass-embedded-process-stderr-poller-#{id}" loop do Kernel.warn(@stderr.readline, uplevel: 0) end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 045c3515..2cb3c358 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -63,7 +63,7 @@ def initialize @last_accessed_time = current_time Thread.new do - Thread.current.name = 'sass-embedded-process-reaper' + Thread.current.name = "sass-embedded-process-reaper-#{@connection.id}" duration = idle_timeout loop do sleep(duration.negative? ? idle_timeout : duration) From 4db374cd71904831691ae3ed94ba6e39cbb8a320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 15 Jun 2024 22:18:54 -0700 Subject: [PATCH 489/700] Update embedded.rb --- lib/sass/embedded.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 2cb3c358..714e864b 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -63,7 +63,7 @@ def initialize @last_accessed_time = current_time Thread.new do - Thread.current.name = "sass-embedded-process-reaper-#{@connection.id}" + Thread.current.name = "sass-embedded-connection-reaper-#{@connection.id}" duration = idle_timeout loop do sleep(duration.negative? ? idle_timeout : duration) From c7a83dd61a93966d12b726d68a35155cc069c75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 15 Jun 2024 22:33:23 -0700 Subject: [PATCH 490/700] Update connection.rb --- lib/sass/compiler/connection.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index 3c1094f1..d59f46db 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -24,6 +24,14 @@ def initialize @stdin.binmode + # # https://dart.dev/tools/dart-devtools + # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') + # Kernel.warn(@stdout.readline, uplevel: 0) + # Kernel.warn(@stdout.readline, uplevel: 0) + # end + + @stdout.binmode + @wait_thread.name = "sass-embedded-process-waiter-#{id}" end @@ -34,15 +42,6 @@ def id def listen(dispatcher) Thread.new do Thread.current.name = "sass-embedded-process-stdout-poller-#{id}" - - # # https://dart.dev/tools/dart-devtools - # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe') - # Kernel.warn(@stdout.readline, uplevel: 0) - # Kernel.warn(@stdout.readline, uplevel: 0) - # end - - @stdout.binmode - loop do length = Varint.read(@stdout) id = Varint.read(@stdout) From cc56fe57a249d257e15b7802c402aa397b422270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Jun 2024 16:40:34 -0700 Subject: [PATCH 491/700] Update google-protobuf requirement from >= 3.25, < 5.0 to ~> 4.26 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 98982b1b..7cd8ce84 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_runtime_dependency 'google-protobuf', '>= 3.25', '< 5.0' + spec.add_runtime_dependency 'google-protobuf', '~> 4.26' end From b33d2795e72c72bb40cf14d94c2e64ac5fb108b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 21 Jun 2024 09:38:53 -0700 Subject: [PATCH 492/700] Update Rakefile --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 57f8f774..97ee6de7 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -138,7 +138,7 @@ module FileUtils def fetch(source_uri, dest_path = nil) require 'rubygems/remote_fetcher' - source_uri = "/#{source_uri}" if File.absolute_path?(source_uri) && !source_uri.start_with?('/') + source_uri = "/#{source_uri}" if !source_uri.start_with?('/') && File.absolute_path?(source_uri) source_uri = begin Gem::Uri.parse!(source_uri) From 8c4f4f0410e093c9505f07f7112951c2c580f286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 4 Jul 2024 23:58:28 -0700 Subject: [PATCH 493/700] Update sass-embedded.gemspec --- sass-embedded.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 7cd8ce84..25045e9c 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| 'ext/sass/expand-archive.ps1', 'ext/sass/package.json' ] - spec.add_runtime_dependency 'rake', '>= 13' + spec.add_dependency 'rake', '>= 13' else spec.files += Dir['ext/sass/dart-sass/**/*'] + ['ext/sass/cli.rb'] end @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_runtime_dependency 'google-protobuf', '~> 4.26' + spec.add_dependency 'google-protobuf', '~> 4.26' end From 82b588e537a238f6089e5e5e7e4cc62a782feefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 8 Jul 2024 17:19:46 -0700 Subject: [PATCH 494/700] Hide ScriptError from yard doc --- lib/sass/exception.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 28187825..bc882350 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -61,6 +61,7 @@ def to_css end # An exception thrown by Sass Script. + # @!visibility private class ScriptError < StandardError def initialize(message, name = nil) super(name.nil? ? message : "$#{name}: #{message}") From 07969b019d53d76f569165ae4c761a555124507c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 07:51:43 -0700 Subject: [PATCH 495/700] Update rubocop requirement from ~> 1.64.0 to ~> 1.65.0 (#224) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.64.0...v1.65.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index beb7e825..ed45a1f3 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.64.0' + gem 'rubocop', '~> 1.65.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.0.1' From 8090467f6255ec13f6e41af5be361f9cf8b2bfd1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2024 13:14:54 -0700 Subject: [PATCH 496/700] Bump sass from 1.77.5 to 1.77.8 in /ext/sass (#225) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.5 to 1.77.8. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.5...1.77.8) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index a5e7c825..fad68143 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.5" + "sass": "1.77.8" } } From 19323666b359bf3d58b562af09fdc75440453608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 11 Jul 2024 13:16:47 -0700 Subject: [PATCH 497/700] v1.77.8 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 7524483b..0438664b 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.5' + VERSION = '1.77.8' end end From 0519c9b87b07ab6a8d0d6fcb8b1323b79f24b7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 16 Jul 2024 16:51:02 -0700 Subject: [PATCH 498/700] Update google-protobuf requirement from ~> 4.26 to ~> 4.27 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 25045e9c..89b46abf 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_dependency 'google-protobuf', '~> 4.26' + spec.add_dependency 'google-protobuf', '~> 4.27' end From 4a367291b8c3e6e5c740fdc83bbaa9c7f88d290f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jul 2024 08:59:42 -0700 Subject: [PATCH 499/700] Document Compiler#compile raises IOError after close --- lib/sass/compiler.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index 96377bbd..f5ffba20 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -62,7 +62,7 @@ def initialize # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every # deprecation warning it encounters. # @return [CompileResult] - # @raise [ArgumentError, CompileError] + # @raise [ArgumentError, CompileError, IOError] # @see https://sass-lang.com/documentation/js-api/functions/compile/ def compile(path, load_paths: [], @@ -142,7 +142,7 @@ def compile(path, # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every # deprecation warning it encounters. # @return [CompileResult] - # @raise [ArgumentError, CompileError] + # @raise [ArgumentError, CompileError, IOError] # @see https://sass-lang.com/documentation/js-api/functions/compilestring/ def compile_string(source, importer: nil, From 0e1956c05984ab725ecf69798239632985a35847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 17 Jul 2024 09:55:43 -0700 Subject: [PATCH 500/700] Update documentation for Sass::ScriptError --- lib/sass/exception.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index bc882350..2a62a8c4 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -61,8 +61,8 @@ def to_css end # An exception thrown by Sass Script. - # @!visibility private class ScriptError < StandardError + # @!visibility private def initialize(message, name = nil) super(name.nil? ? message : "$#{name}: #{message}") end From a5f980addaa2ddcd023ae801412d404c9026fe6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 18 Jul 2024 17:28:38 -0700 Subject: [PATCH 501/700] Update specs for @import/global builtins deprecations (#226) --- spec/sass/compiler_spec.rb | 12 ++-- spec/sass_compile_spec.rb | 4 +- spec/sass_importer_spec.rb | 112 +++++++++++++++++++------------------ 3 files changed, 67 insertions(+), 61 deletions(-) diff --git a/spec/sass/compiler_spec.rb b/spec/sass/compiler_spec.rb index 0764766b..1bb63479 100644 --- a/spec/sass/compiler_spec.rb +++ b/spec/sass/compiler_spec.rb @@ -45,7 +45,7 @@ describe 'compile_string' do it 'performs complete compilations' do - result = compiler.compile_string('@import "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:) + result = compiler.compile_string('@use "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:) expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: baz;\n}") expect(logger_instance_double).to have_received(:call).once end @@ -61,7 +61,7 @@ end } - result = compiler.compile_string('@import "nested"; a {b: c}', importers: [nested_importer]) + result = compiler.compile_string('@use "nested"; a {b: c}', importers: [nested_importer]) expect(result.css).to eq("x {\n y: z;\n}\n\na {\n b: c;\n}") end @@ -79,7 +79,7 @@ it 'handles multiple concurrent compilations' do results = Array.new(100) do |i| Thread.new do - compiler.compile_string("@import \"#{i}\"; .fn {value: foo(#{i})}", + compiler.compile_string("@use \"#{i}\" as _; .fn {value: foo(#{i})}", importers:, functions:, logger: Sass::Logger.silent) end end.map(&:value) @@ -93,7 +93,7 @@ describe 'compile' do it 'performs complete compilations' do sandbox do |dir| - dir.write({ 'input.scss' => '@import "bar"; .fn {value: foo(bar)}' }) + dir.write({ 'input.scss' => '@use "bar"; .fn {value: foo(bar)}' }) result = compiler.compile(dir.path('input.scss'), importers:, functions:, logger:) expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: bar;\n}") expect(logger_instance_double).to have_received(:call).once @@ -113,7 +113,7 @@ end } - dir.write({ 'input.scss' => '@import "nested"; a {b: c}' }) + dir.write({ 'input.scss' => '@use "nested"; a {b: c}' }) result = compiler.compile(dir.path('input.scss'), importers: [nested_importer]) expect(result.css).to eq("x {\n y: z;\n}\n\na {\n b: c;\n}") end @@ -132,7 +132,7 @@ results = Array.new(100) do |i| Thread.new do filename = "input-#{i}.scss" - dir.write({ filename => "@import \"#{i}\"; .fn {value: foo(#{i})}" }) + dir.write({ filename => "@use \"#{i}\" as _; .fn {value: foo(#{i})}" }) compiler.compile(dir.path(filename), importers:, functions:, logger: Sass::Logger.silent) end diff --git a/spec/sass_compile_spec.rb b/spec/sass_compile_spec.rb index 8df00795..e6baf559 100644 --- a/spec/sass_compile_spec.rb +++ b/spec/sass_compile_spec.rb @@ -102,7 +102,9 @@ '_right.scss' => '@import "upstream"', '_upstream.scss' => 'a {b: c}' }) - expect(described_class.compile_string('@import "left"; @import "right"', url:).loaded_urls) + expect(described_class.compile_string('@import "left"; @import "right"', + url:, + silence_deprecations: ['import']).loaded_urls) .to eq([ url, dir.url('_left.scss'), diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index d8dcf0b2..84ac203d 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -5,9 +5,9 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/importer.node.test.ts # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/importer.test.ts RSpec.describe Sass do - it 'uses an importer to resolve an @import' do + it 'uses an importer to resolve a @use' do result = described_class.compile_string( - '@import "orange";', + '@use "orange";', importers: [{ canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |url| @@ -25,7 +25,7 @@ it 'passes the canonicalized URL to the importer' do result = described_class.compile_string( - '@import "orange";', + '@use "orange";', importers: [{ canonicalize: ->(*) { 'u:blue' }, load: lambda { |url| @@ -56,7 +56,8 @@ syntax: 'scss' } } - }] + }], + silence_deprecations: ['import'] ) expect(result.css).to eq(".blue {\n color: blue;\n}\n\n.blue {\n color: blue;\n}") @@ -67,7 +68,7 @@ it "isn't changed if it's root-relative" do result = described_class.compile_string( - '@import "/orange";', + '@use "/orange";', importers: [{ canonicalize: lambda { |url, _context| expect(url).to eq('/orange') @@ -99,7 +100,8 @@ syntax: 'scss' } } - }] + }], + silence_deprecations: ['import'] ) expect(result.css).to eq("a {\n b: c;\n}") @@ -109,7 +111,7 @@ describe 'the containing URL' do it 'is nil for a potentially canonical scheme' do result = described_class.compile_string( - '@import "u:orange"', + '@use "u:orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to be_nil @@ -131,7 +133,7 @@ describe 'in a list' do it 'is set to the original URL' do result = described_class.compile_string( - '@import "u:orange"', + '@use "u:orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to eq('x:original.scss') @@ -153,7 +155,7 @@ it 'is nil if the original URL is nil' do result = described_class.compile_string( - '@import "u:orange"', + '@use "u:orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to be_nil @@ -176,7 +178,7 @@ describe 'as a string' do it 'is set to the original URL' do result = described_class.compile_string( - '@import "u:orange"', + '@use "u:orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to eq('x:original.scss') @@ -198,7 +200,7 @@ it 'is nil if the original URL is nil' do result = described_class.compile_string( - '@import "u:orange"', + '@use "u:orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to be_nil @@ -222,7 +224,7 @@ describe 'for a schemeless load' do it 'is set to the original URL' do result = described_class.compile_string( - '@import "orange"', + '@use "orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to eq('x:original.scss') @@ -243,7 +245,7 @@ it 'is nil if the original URL is nil' do result = described_class.compile_string( - '@import "orange"', + '@use "orange"', importers: [{ canonicalize: lambda { |url, context| expect(context.containing_url).to be_nil @@ -267,7 +269,7 @@ it 'set as a list' do expect do described_class.compile_string( - '@import "orange"', + '@use "orange"', importers: [{ canonicalize: lambda { |url, _context| "u:#{url}" @@ -287,7 +289,7 @@ it 'set as a string' do expect do described_class.compile_string( - '@import "orange"', + '@use "orange"', importers: [{ canonicalize: lambda { |url, _context| "u:#{url}" @@ -366,7 +368,7 @@ it "uses an importer's source map URL" do result = described_class.compile_string( - '@import "orange";', + '@use "orange";', importers: [{ canonicalize: lambda { |url, _context| "u:#{url}" @@ -389,7 +391,7 @@ it 'wraps an error in canonicalize()' do expect do described_class.compile_string( - '@import "orange";', + '@use "orange";', importers: [{ canonicalize: lambda { |*| raise 'this import is bad actually' @@ -405,7 +407,7 @@ it 'wraps an error in load()' do expect do described_class.compile_string( - '@import "orange";', + '@use "orange";', importers: [{ canonicalize: lambda { |url, _context| "u:#{url}" @@ -423,7 +425,7 @@ dir.write({ 'dir/_other.scss' => 'a {from: dir}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(*) {}, load: lambda { |*| @@ -442,7 +444,7 @@ expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: lambda { |url, _context| "u:#{url}" @@ -458,7 +460,7 @@ it 'prefers a relative file load to an importer' do sandbox do |dir| dir.write({ - 'input.scss' => '@import "other"', + 'input.scss' => '@use "other"', '_other.scss' => 'a {from: relative}' }) @@ -480,7 +482,7 @@ it 'prefers an importer to a load path' do sandbox do |dir| dir.write({ - 'input.scss' => '@import "other"', + 'input.scss' => '@use "other"', 'dir/_other.scss' => 'a {from: load-path}' }) @@ -505,7 +507,7 @@ describe 'with syntax' do it 'scss, parses it as SCSS' do result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| @@ -519,7 +521,7 @@ it 'indented, parses it as the indented syntax' do result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| @@ -533,7 +535,7 @@ it 'css, allows plain CSS' do result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| @@ -548,7 +550,7 @@ it 'css, rejects SCSS' do expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(*) { 'u:other' }, load: lambda { |*| @@ -563,7 +565,7 @@ describe "compile_string()'s importer option" do it 'loads relative imports from the entrypoint' do result = described_class.compile_string( - '@import "orange";', + '@use "orange";', importer: { canonicalize: lambda { |url, _context| expect(url).to eq('u:orange') @@ -585,7 +587,7 @@ it 'takes precedence over the importer list for relative URLs' do result = described_class.compile_string( - '@import "other";', + '@use "other";', importer: { canonicalize: lambda { |url, _context| url @@ -613,7 +615,7 @@ it "doesn't load absolute imports" do result = described_class.compile_string( - '@import "u:orange";', + '@use "u:orange";', importer: { canonicalize: lambda { |*| raise 'canonicalize() should not be called' @@ -643,7 +645,7 @@ it "doesn't load from other importers" do result = described_class.compile_string( - '@import "u:midstream";', + '@use "u:midstream";', importer: { canonicalize: lambda { |*| raise 'canonicalize() should not be called' @@ -684,7 +686,7 @@ # importer first despite being in the second importer's file. second_called = false result = described_class.compile_string( - '@import "second:other";', + '@use "second:other";', importers: [{ canonicalize: lambda { |url, _context| url if url.start_with?('first:') @@ -704,7 +706,7 @@ }, load: lambda { |*| { - contents: '@import "first:other";', + contents: '@use "first:other";', syntax: 'scss' } } @@ -732,7 +734,8 @@ def expect_from_import(canonicalize, expected) described_class.compile_string( '@import "foo"', - importers: [expect_from_import(canonicalize, true)] + importers: [expect_from_import(canonicalize, true)], + silence_deprecations: ['import'] ) expect(canonicalize).to have_received(:call) @@ -778,7 +781,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.scss' => 'a {b: c}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('_other.scss') } }] @@ -792,7 +795,7 @@ def expect_from_import(canonicalize, expected) dir.write({ 'other/_index.scss' => 'a {b: c}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] @@ -806,7 +809,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.scss' => 'a {from: dir}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) {} }], @@ -821,7 +824,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.scss' => 'a {from: dir}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('nonexistent/other') } }], @@ -836,7 +839,7 @@ def expect_from_import(canonicalize, expected) dir.write({ 'dir/_other.scss' => 'a {b: c}' }) result = described_class.compile_string( - '@import "u:other";', + '@use "u:other";', importers: [{ find_file_url: lambda { |url, _context| expect(url).to eq('u:other') @@ -854,7 +857,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.scss' => 'a {b: c}' }) result = described_class.compile_string( - "@import \"#{dir.url('other')}\";", + "@use \"#{dir.url('other')}\";", importers: [{ find_file_url: lambda { |*| raise 'find_file_url() should not be called' @@ -867,12 +870,12 @@ def expect_from_import(canonicalize, expected) it "doesn't pass relative loads to the importer" do sandbox do |dir| - dir.write({ '_midstream.scss' => '@import "upstream"' }) + dir.write({ '_midstream.scss' => '@use "upstream"' }) dir.write({ '_upstream.scss' => 'a {b: c}' }) count = 0 result = described_class.compile_string( - '@import "midstream";', + '@use "midstream";', importers: [{ find_file_url: lambda { |*| raise 'find_file_url() should only be called once' if count > 0 @@ -889,7 +892,7 @@ def expect_from_import(canonicalize, expected) it 'wraps an error' do expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [ { find_file_url: lambda { |*| @@ -904,7 +907,7 @@ def expect_from_import(canonicalize, expected) it 'rejects a non-file URL' do expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { 'u:other.scss' } }] ) end.to raise_sass_compile_error.with_line(0) @@ -916,7 +919,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.scss' => '$a: value; b {c: $a}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] ) expect(result.css).to eq("b {\n c: value;\n}") @@ -928,7 +931,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.sass' => "$a: value\nb\n c: $a" }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] ) expect(result.css).to eq("b {\n c: value;\n}") @@ -940,7 +943,7 @@ def expect_from_import(canonicalize, expected) dir.write({ '_other.css' => 'a {b: c}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] ) expect(result.css).to eq("a {\n b: c;\n}") @@ -953,7 +956,7 @@ def expect_from_import(canonicalize, expected) expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: ->(*) { dir.url('other') } }] ) end.to raise_sass_compile_error.with_line(0).with_url(dir.url('_other.css')) @@ -973,7 +976,8 @@ def expect_from_import(canonicalize, expected) expect(context.from_import).to be(true) dir.url('other') } - }] + }], + silence_deprecations: ['import'] ) end end @@ -1001,7 +1005,7 @@ def expect_from_import(canonicalize, expected) sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) result = described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: lambda { |_url, context| expect(context.containing_url).to eq('x:original.scss') @@ -1018,7 +1022,7 @@ def expect_from_import(canonicalize, expected) sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) result = described_class.compile_string( - '@import "u:other";', + '@use "u:other";', importers: [{ find_file_url: lambda { |_url, context| expect(context.containing_url).to eq('x:original.scss') @@ -1035,7 +1039,7 @@ def expect_from_import(canonicalize, expected) sandbox do |dir| dir.write({ '_other.scss' => 'a {b: c}' }) result = described_class.compile_string( - '@import "u:other";', + '@use "u:other";', importers: [{ find_file_url: lambda { |_url, context| expect(context.containing_url).to be_nil @@ -1054,7 +1058,7 @@ def expect_from_import(canonicalize, expected) expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ find_file_url: lambda { |*| dir.url('other') @@ -1075,7 +1079,7 @@ def expect_from_import(canonicalize, expected) it 'throws an error in sync mode' do expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| @@ -1093,7 +1097,7 @@ def expect_from_import(canonicalize, expected) it 'throws an ArgumentError when the result source_map_url is missing a scheme' do expect do described_class.compile_string( - '@import "other";', + '@use "other";', importers: [{ canonicalize: ->(url, _context) { "u:#{url}" }, load: lambda { |*| From c3b1cf008129795f4d63ce5f05927ba184566dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 19 Jul 2024 11:49:08 -0700 Subject: [PATCH 502/700] Update specs for @import/global builtins deprecations --- spec/sass_importer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/sass_importer_spec.rb b/spec/sass_importer_spec.rb index 84ac203d..9f52cd46 100644 --- a/spec/sass_importer_spec.rb +++ b/spec/sass_importer_spec.rb @@ -662,7 +662,7 @@ pathname = url.split(':')[1] if pathname == 'midstream' { - contents: "@import 'orange';", + contents: "@use 'orange';", syntax: 'scss' } else From 35a6f265dac4ada569e0a621f277456de0919d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 1 Aug 2024 03:30:41 -0700 Subject: [PATCH 503/700] Optimize ELF parser --- lib/sass/elf.rb | 215 ++++++++++++++++++++++-------------------------- 1 file changed, 99 insertions(+), 116 deletions(-) diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index 6b81cac8..e56a362d 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -7,24 +7,49 @@ module Sass # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c class ELF + module PackInfo + PACK_MAP = { + U8: 'C', + S8: 'c', + u16: 'S<', + U16: 'S>', + s16: 's<', + S16: 's>', + u32: 'L<', + U32: 'L>', + s32: 'l<', + S32: 'l>', + u64: 'Q<', + U64: 'Q>', + s64: 'q<', + S64: 'q>' + }.freeze + + SIZE_MAP = PACK_MAP.to_h do |type, _| + [type, type.to_s[1..].to_i / 8] + end.freeze + end + + private_constant :PackInfo + # rubocop:disable Naming/ConstantName # 32-bit ELF base types. - Elf32_Addr = :__u32 - Elf32_Half = :__u16 - Elf32_Off = :__u32 - Elf32_Sword = :__s32 - Elf32_Word = :__u32 + Elf32_Addr = :u32 + Elf32_Half = :u16 + Elf32_Off = :u32 + Elf32_Sword = :s32 + Elf32_Word = :u32 # 64-bit ELF base types. - Elf64_Addr = :__u64 - Elf64_Half = :__u16 - Elf64_SHalf = :__s16 - Elf64_Off = :__u64 - Elf64_Sword = :__s32 - Elf64_Word = :__u32 - Elf64_Xword = :__u64 - Elf64_Sxword = :__s64 + Elf64_Addr = :u64 + Elf64_Half = :u16 + Elf64_SHalf = :s16 + Elf64_Off = :u64 + Elf64_Sword = :s32 + Elf64_Word = :u32 + Elf64_Xword = :u64 + Elf64_Sxword = :s64 # rubocop:enable Naming/ConstantName @@ -41,10 +66,6 @@ class ELF PT_HIOS = 0x6fffffff PT_LOPROC = 0x70000000 PT_HIPROC = 0x7fffffff - PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550) - PT_GNU_STACK = (PT_LOOS + 0x474e551) - PT_GNU_RELRO = (PT_LOOS + 0x474e552) - PT_GNU_PROPERTY = (PT_LOOS + 0x474e553) # These constants define the different elf file types ET_NONE = 0 @@ -60,37 +81,37 @@ class ELF # rubocop:disable Naming/ConstantName Elf32_Ehdr = [ - [:unsigned_char, :e_ident, EI_NIDENT], - [Elf32_Half, :e_type], - [Elf32_Half, :e_machine], - [Elf32_Word, :e_version], - [Elf32_Addr, :e_entry], - [Elf32_Off, :e_phoff], - [Elf32_Off, :e_shoff], - [Elf32_Word, :e_flags], - [Elf32_Half, :e_ehsize], - [Elf32_Half, :e_phentsize], - [Elf32_Half, :e_phnum], - [Elf32_Half, :e_shentsize], - [Elf32_Half, :e_shnum], - [Elf32_Half, :e_shstrndx] + [:U8, :e_ident, EI_NIDENT], + [Elf32_Half, :e_type], + [Elf32_Half, :e_machine], + [Elf32_Word, :e_version], + [Elf32_Addr, :e_entry], + [Elf32_Off, :e_phoff], + [Elf32_Off, :e_shoff], + [Elf32_Word, :e_flags], + [Elf32_Half, :e_ehsize], + [Elf32_Half, :e_phentsize], + [Elf32_Half, :e_phnum], + [Elf32_Half, :e_shentsize], + [Elf32_Half, :e_shnum], + [Elf32_Half, :e_shstrndx] ].freeze Elf64_Ehdr = [ - [:unsigned_char, :e_ident, EI_NIDENT], - [Elf64_Half, :e_type], - [Elf64_Half, :e_machine], - [Elf64_Word, :e_version], - [Elf64_Addr, :e_entry], - [Elf64_Off, :e_phoff], - [Elf64_Off, :e_shoff], - [Elf64_Word, :e_flags], - [Elf64_Half, :e_ehsize], - [Elf64_Half, :e_phentsize], - [Elf64_Half, :e_phnum], - [Elf64_Half, :e_shentsize], - [Elf64_Half, :e_shnum], - [Elf64_Half, :e_shstrndx] + [:U8, :e_ident, EI_NIDENT], + [Elf64_Half, :e_type], + [Elf64_Half, :e_machine], + [Elf64_Word, :e_version], + [Elf64_Addr, :e_entry], + [Elf64_Off, :e_phoff], + [Elf64_Off, :e_shoff], + [Elf64_Word, :e_flags], + [Elf64_Half, :e_ehsize], + [Elf64_Half, :e_phentsize], + [Elf64_Half, :e_phnum], + [Elf64_Half, :e_shentsize], + [Elf64_Half, :e_shnum], + [Elf64_Half, :e_shstrndx] ].freeze Elf32_Phdr = [ @@ -149,10 +170,39 @@ class ELF def initialize(buffer) @buffer = buffer - @ehdr = read_ehdr + + @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') } + raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG + + case @ehdr[:e_ident][EI_CLASS] + when ELFCLASS32 + elf_ehdr = Elf32_Ehdr + elf_phdr = Elf32_Phdr + when ELFCLASS64 + elf_ehdr = Elf64_Ehdr + elf_phdr = Elf64_Phdr + else + raise ArgumentError + end + + case @ehdr[:e_ident][EI_DATA] + when ELFDATA2LSB + little_endian = true + when ELFDATA2MSB + little_endian = false + else + raise ArgumentError + end + + elf_ehdr.drop(1).each do |type, name| + @ehdr[name] = read1(type, little_endian) + end + @buffer.seek(@ehdr[:e_phoff], IO::SEEK_SET) @proghdrs = Array.new(@ehdr[:e_phnum]) do - read_phdr + elf_phdr.to_h do |type, name| + [name, read1(type, little_endian)] + end end end @@ -185,75 +235,8 @@ def interpreter private - def file_class - @ehdr[:e_ident][EI_CLASS] - end - - def data_encoding - @ehdr[:e_ident][EI_DATA] - end - - def read_ehdr - @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') } - raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG - - case file_class - when ELFCLASS32 - Elf32_Ehdr - when ELFCLASS64 - Elf64_Ehdr - else - raise ArgumentError - end.drop(1).to_h do |field| - [field[1], read1(field[0])] - end.merge!(@ehdr) - end - - def read_phdr - case file_class - when ELFCLASS32 - Elf32_Phdr - when ELFCLASS64 - Elf64_Phdr - else - raise ArgumentError - end.to_h do |field| - [field[1], read1(field[0])] - end - end - - def explicit_endian - case data_encoding - when ELFDATA2LSB - '<' - when ELFDATA2MSB - '>' - else - raise ArgumentError - end - end - - def read1(type) - case type - when :__u8 - @buffer.read(1).unpack1('C') - when :__u16 - @buffer.read(2).unpack1("S#{explicit_endian}") - when :__u32 - @buffer.read(4).unpack1("L#{explicit_endian}") - when :__u64 - @buffer.read(8).unpack1("Q#{explicit_endian}") - when :__s8 - @buffer.read(1).unpack1('c') - when :__s16 - @buffer.read(2).unpack1("s#{explicit_endian}") - when :__s32 - @buffer.read(4).unpack1("l#{explicit_endian}") - when :__s64 - @buffer.read(8).unpack1("q#{explicit_endian}") - else - raise ArgumentError - end + def read1(type, little_endian) + @buffer.read(PackInfo::SIZE_MAP[type]).unpack1(PackInfo::PACK_MAP[little_endian ? type : type.upcase]) end INTERPRETER = begin From 5e79494c865e74bc9fc9dd535225f38a2c3090d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 8 Aug 2024 18:09:45 -0700 Subject: [PATCH 504/700] Omit the optional space when css escaping characters higher than U+100000 --- lib/sass/exception.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sass/exception.rb b/lib/sass/exception.rb index 2a62a8c4..c165d86e 100644 --- a/lib/sass/exception.rb +++ b/lib/sass/exception.rb @@ -51,8 +51,12 @@ def to_css font-family: monospace, monospace; white-space: pre; content: #{Serializer.serialize_quoted_string(content).gsub(/[^[:ascii:]][\h\t ]?/) do |match| - replacement = "\\#{match.ord.to_s(16)}" - replacement << " #{match[1]}" if match.length > 1 + ordinal = match.ord + replacement = "\\#{ordinal.to_s(16)}" + if match.length > 1 + replacement << ' ' if ordinal < 0x100000 + replacement << match[1] + end replacement end}; } From 1cea7e821e9841c0e0a9fbb5166404caa3c1c2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 13 Aug 2024 19:29:52 -0700 Subject: [PATCH 505/700] Optimize ELF parser --- lib/sass/elf.rb | 189 +++++++++++++++++++----------------------------- 1 file changed, 76 insertions(+), 113 deletions(-) diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index e56a362d..01587881 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -9,50 +9,75 @@ module Sass class ELF module PackInfo PACK_MAP = { - U8: 'C', - S8: 'c', - u16: 'S<', - U16: 'S>', - s16: 's<', - S16: 's>', - u32: 'L<', - U32: 'L>', - s32: 'l<', - S32: 'l>', - u64: 'Q<', - U64: 'Q>', - s64: 'q<', - S64: 'q>' + Elf32_Ehdr: 'S<2L<5S<6', + Elf64_Ehdr: 'S<2L') + [PackInfo::STRUCT_MAP[type], @buffer.read(size).unpack(format)].transpose.to_h end INTERPRETER = begin From 0cdb9d4722aa544978938d97d34f96db0ea2e410 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 01:00:59 -0700 Subject: [PATCH 506/700] Update rubocop requirement from ~> 1.65.0 to ~> 1.66.0 (#229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.65.0 to ~> 1.66.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.65.0...v1.66.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Fix lint --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- Gemfile | 2 +- lib/sass/value/number.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index ed45a1f3..9949659c 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.65.0' + gem 'rubocop', '~> 1.66.0' gem 'rubocop-performance', '~> 1.21.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.0.1' diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index 69bd4161..f3d91ae3 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -290,7 +290,7 @@ def coerce_or_convert_value(new_numerator_units, new_denominator_units, compatibility_error = lambda { unless other.nil? - message = +"#{self} and" + message = "#{self} and" message << " $#{other_name}:" unless other_name.nil? message << " #{other} have incompatible units" message << " (one has units and the other doesn't)" if unitless? || other_unitless From a591c2ec473e4b2e18c3f6bc7d7a4e823d89ef3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:10:47 -0700 Subject: [PATCH 507/700] Bump sass from 1.77.8 to 1.78.0 in /ext/sass (#230) Bumps [sass](https://github.com/sass/dart-sass) from 1.77.8 to 1.78.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.77.8...1.78.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index fad68143..7941b8d6 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.77.8" + "sass": "1.78.0" } } From 3441ebe8496e860908d39d5825e2da47e56a9961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 3 Sep 2024 16:22:05 -0700 Subject: [PATCH 508/700] v1.78.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 0438664b..03f7c34a 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.77.8' + VERSION = '1.78.0' end end From 5fb0c9d0e737c9357586590a69a910e05af60b26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:43:34 -0700 Subject: [PATCH 509/700] Update rubocop-performance requirement from ~> 1.21.0 to ~> 1.22.0 (#231) Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.21.0...v1.22.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9949659c..f0b90c92 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.66.0' - gem 'rubocop-performance', '~> 1.21.0' + gem 'rubocop-performance', '~> 1.22.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.0.1' end From ba2aef2a1565b192095bdc928aac9d46ebf08263 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:19:22 -0700 Subject: [PATCH 510/700] Bump sass from 1.78.0 to 1.79.1 in /ext/sass (#232) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump sass from 1.78.0 to 1.79.1 in /ext/sass Bumps [sass](https://github.com/sass/dart-sass) from 1.78.0 to 1.79.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.78.0...1.79.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update for embedded-protocol 3.0.0 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- ext/sass/package.json | 2 +- lib/sass/compiler/host/protofier.rb | 80 ++++++++++++++++------------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 7941b8d6..c2c82593 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.78.0" + "sass": "1.79.1" } } diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 8b0e6eee..f58bdf5b 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -27,29 +27,32 @@ def to_proto(obj) when Sass::Value::Color if obj.instance_eval { !defined?(@hue) } EmbeddedProtocol::Value.new( - rgb_color: EmbeddedProtocol::Value::RgbColor.new( - red: obj.red, - green: obj.green, - blue: obj.blue, - alpha: obj.alpha.to_f + color: EmbeddedProtocol::Value::Color.new( + channel1: obj.red, + channel2: obj.green, + channel3: obj.blue, + alpha: obj.alpha.to_f, + space: 'rgb' ) ) elsif obj.instance_eval { !defined?(@saturation) } EmbeddedProtocol::Value.new( - hwb_color: EmbeddedProtocol::Value::HwbColor.new( - hue: obj.hue.to_f, - whiteness: obj.whiteness.to_f, - blackness: obj.blackness.to_f, - alpha: obj.alpha.to_f + color: EmbeddedProtocol::Value::Color.new( + channel1: obj.hue.to_f, + channel2: obj.whiteness.to_f, + channel3: obj.blackness.to_f, + alpha: obj.alpha.to_f, + space: 'hwb' ) ) else EmbeddedProtocol::Value.new( - hsl_color: EmbeddedProtocol::Value::HslColor.new( - hue: obj.hue.to_f, - saturation: obj.saturation.to_f, - lightness: obj.lightness.to_f, - alpha: obj.alpha.to_f + color: EmbeddedProtocol::Value::Color.new( + channel1: obj.hue.to_f, + channel2: obj.saturation.to_f, + channel3: obj.lightness.to_f, + alpha: obj.alpha.to_f, + space: 'hsl' ) ) end @@ -130,27 +133,32 @@ def from_proto(proto) ) when :number Number.from_proto(obj) - when :rgb_color - Sass::Value::Color.new( - red: obj.red, - green: obj.green, - blue: obj.blue, - alpha: obj.alpha - ) - when :hsl_color - Sass::Value::Color.new( - hue: obj.hue, - saturation: obj.saturation, - lightness: obj.lightness, - alpha: obj.alpha - ) - when :hwb_color - Sass::Value::Color.new( - hue: obj.hue, - whiteness: obj.whiteness, - blackness: obj.blackness, - alpha: obj.alpha - ) + when :color + case obj.space + when 'rgb' + Sass::Value::Color.new( + red: obj.channel1, + green: obj.channel2, + blue: obj.channel3, + alpha: obj.alpha + ) + when 'hsl' + Sass::Value::Color.new( + hue: obj.channel1, + saturation: obj.channel2, + lightness: obj.channel3, + alpha: obj.alpha + ) + when 'hwb' + Sass::Value::Color.new( + hue: obj.channel1, + whiteness: obj.channel2, + blackness: obj.channel3, + alpha: obj.alpha + ) + else + raise NotImplementedError, 'CSS Color Level 4 will be supported in a future release' + end when :argument_list Sass::Value::ArgumentList.new( obj.contents.map do |element| From 0f27989acb081205d7e1eccbd5f2f3bf7c3e00fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 17 Sep 2024 20:23:50 -0700 Subject: [PATCH 511/700] v1.79.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 03f7c34a..b660e429 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.78.0' + VERSION = '1.79.1' end end From 86e88a686d4b03bbdfaf5c9b83446a53933a0f79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:34:58 -0700 Subject: [PATCH 512/700] Bump sass from 1.79.1 to 1.79.2 in /ext/sass (#233) Bumps [sass](https://github.com/sass/dart-sass) from 1.79.1 to 1.79.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.79.1...1.79.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index c2c82593..d0fc058d 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.79.1" + "sass": "1.79.2" } } From 03b795824c3a59eb8406a6b05da4aee3609a72ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 19 Sep 2024 16:35:31 -0700 Subject: [PATCH 513/700] v1.79.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index b660e429..3c5618dd 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.79.1' + VERSION = '1.79.2' end end From c4dcf7ae945372b2b9eaa48c8a96e046987b80d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:16:17 -0700 Subject: [PATCH 514/700] Bump sass from 1.79.2 to 1.79.3 in /ext/sass (#234) Bumps [sass](https://github.com/sass/dart-sass) from 1.79.2 to 1.79.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.79.2...1.79.3) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index d0fc058d..45fdfe11 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.79.2" + "sass": "1.79.3" } } From 0e4c0357342c2e8c405996fba1b28463a5991824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 20 Sep 2024 14:16:54 -0700 Subject: [PATCH 515/700] v1.79.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 3c5618dd..4e22c20d 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.79.2' + VERSION = '1.79.3' end end From 958a833507032b5866da563ff0a68c9243246005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 24 Sep 2024 14:53:09 -0700 Subject: [PATCH 516/700] Launch elf interpreter explicitly on nixos (#235) --- exe/sass | 10 +---- ext/sass/Rakefile | 65 +++++++++++++++++++++++++-------- lib/sass/compiler/connection.rb | 10 +---- lib/sass/elf.rb | 8 ++-- 4 files changed, 55 insertions(+), 38 deletions(-) diff --git a/exe/sass b/exe/sass index ca4c0c28..afba0b84 100755 --- a/exe/sass +++ b/exe/sass @@ -6,15 +6,7 @@ require_relative '../ext/sass/cli' module Sass # The `sass` command line interface module CLI - begin - Kernel.exec(*COMMAND, *ARGV) - rescue Errno::ENOENT - require_relative '../lib/sass/elf' - - raise if ELF::INTERPRETER.nil? - - Kernel.exec(ELF::INTERPRETER, *COMMAND, *ARGV) - end + Kernel.exec(*COMMAND, *ARGV) end private_constant :CLI diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 97ee6de7..0f6a65d7 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -30,6 +30,8 @@ rescue StandardError end file 'cli.rb' => %w[dart-sass] do |t| + require_relative '../../lib/sass/elf' + exe = 'dart-sass/sass' exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" @@ -40,27 +42,58 @@ file 'cli.rb' => %w[dart-sass] do |t| snapshot = 'dart-sass/src/sass.snapshot' command = if File.exist?(runtime) && File.exist?(snapshot) - " - File.absolute_path('#{runtime}', __dir__).freeze, - File.absolute_path('#{snapshot}', __dir__).freeze - " + [runtime, snapshot] else - " - File.absolute_path('#{exe}', __dir__).freeze - " + [exe] end - File.write(t.name, <<~CLI_RB) - # frozen_string_literal: true + interpreter = File.open(command[0], 'rb') do |file| + Sass.const_get(:ELF).new(file).interpreter + rescue ArgumentError + nil + end - module Sass - module CLI - COMMAND = [#{command}].freeze - end + command_source = command.map do |argument| + "File.absolute_path('#{argument}', __dir__).freeze" + end.join(', + ') - private_constant :CLI - end - CLI_RB + if interpreter.nil? + File.write(t.name, <<~CLI_RB) + # frozen_string_literal: true + + module Sass + module CLI + COMMAND = [ + #{command_source} + ].freeze + end + + private_constant :CLI + end + CLI_RB + else + File.write(t.name, <<~CLI_RB) + # frozen_string_literal: true + + require_relative '../../lib/sass/elf' + + module Sass + module CLI + INTERPRETER = '#{interpreter}' + + COMMAND = [ + *(ELF::INTERPRETER unless ELF::INTERPRETER.nil? || + ELF::INTERPRETER == INTERPRETER || + !ELF::INTERPRETER.end_with?(INTERPRETER)), + #{command_source} + ].freeze + end + + private_constant :CLI + end + CLI_RB + end end file 'embedded_sass.proto' => %w[cli.rb] do |t| diff --git a/lib/sass/compiler/connection.rb b/lib/sass/compiler/connection.rb index d59f46db..d5631034 100644 --- a/lib/sass/compiler/connection.rb +++ b/lib/sass/compiler/connection.rb @@ -12,15 +12,7 @@ class Compiler class Connection def initialize @mutex = Mutex.new - @stdin, @stdout, @stderr, @wait_thread = begin - Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) - rescue Errno::ENOENT - require_relative '../elf' - - raise if ELF::INTERPRETER.nil? - - Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__) - end + @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__) @stdin.binmode diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index 01587881..775deb41 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -147,7 +147,7 @@ def initialize(buffer) elf_ehdr = :Elf64_Ehdr elf_phdr = :Elf64_Phdr else - raise ArgumentError + raise EncodingError end case @ehdr[:e_ident][EI_DATA] @@ -156,7 +156,7 @@ def initialize(buffer) when ELFDATA2MSB little_endian = false else - raise ArgumentError + raise EncodingError end @ehdr.merge!(read(elf_ehdr, little_endian)) @@ -189,7 +189,7 @@ def interpreter @buffer.seek(phdr[:p_offset], IO::SEEK_SET) interpreter = @buffer.read(phdr[:p_filesz]) - raise ArgumentError unless interpreter.end_with?("\0") + raise EncodingError unless interpreter.end_with?("\0") interpreter.chomp!("\0") end @@ -215,7 +215,7 @@ def read(type, little_endian) end end end - end + end.freeze end private_constant :ELF From a0e9278a8b46746e051f89cd4ba2bab76c8760c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 24 Sep 2024 15:01:10 -0700 Subject: [PATCH 517/700] Fix elf spec on nixos --- spec/sass/elf_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb index 5fc04082..bf761c27 100644 --- a/spec/sass/elf_spec.rb +++ b/spec/sass/elf_spec.rb @@ -17,9 +17,7 @@ describe 'dart program interpreter' do subject(:interpreter) do - File.open(Sass.const_get(:CLI)::COMMAND[0], 'rb') do |file| - described_class.new(file).interpreter - end + Sass.const_get(:CLI)::INTERPRETER end it 'starts with ld-' do From 4f59827457e098d16cd21a72dff81713e8155c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 26 Sep 2024 20:30:16 -0700 Subject: [PATCH 518/700] CSS Color Module Level 4 (#236) --- lib/sass/compiler/host/protofier.rb | 71 +- lib/sass/value/color.rb | 699 ++++++++++++++---- lib/sass/value/color/channel.rb | 79 ++ lib/sass/value/color/conversions.rb | 464 ++++++++++++ lib/sass/value/color/gamut_map_method.rb | 45 ++ lib/sass/value/color/gamut_map_method/clip.rb | 45 ++ .../color/gamut_map_method/local_minde.rb | 94 +++ lib/sass/value/color/interpolation_method.rb | 51 ++ lib/sass/value/color/space.rb | 198 +++++ lib/sass/value/color/space/a98_rgb.rb | 57 ++ lib/sass/value/color/space/display_p3.rb | 57 ++ lib/sass/value/color/space/hsl.rb | 62 ++ lib/sass/value/color/space/hwb.rb | 63 ++ lib/sass/value/color/space/lab.rb | 77 ++ lib/sass/value/color/space/lch.rb | 52 ++ lib/sass/value/color/space/lms.rb | 133 ++++ lib/sass/value/color/space/oklab.rb | 70 ++ lib/sass/value/color/space/oklch.rb | 53 ++ lib/sass/value/color/space/prophoto_rgb.rb | 59 ++ lib/sass/value/color/space/rec2020.rb | 69 ++ lib/sass/value/color/space/rgb.rb | 52 ++ lib/sass/value/color/space/srgb.rb | 141 ++++ lib/sass/value/color/space/srgb_linear.rb | 72 ++ lib/sass/value/color/space/utils.rb | 109 +++ lib/sass/value/color/space/xyz_d50.rb | 100 +++ lib/sass/value/color/space/xyz_d65.rb | 57 ++ lib/sass/value/fuzzy_math.rb | 33 +- lib/sass/value/string.rb | 2 +- spec/sass/value/color/constructors.rb | 93 +++ .../value/color/interpolation_examples.rb | 437 +++++++++++ spec/sass/value/color/spaces.rb | 346 +++++++++ spec/sass/value/color/utils.rb | 43 ++ spec/sass/value/color_4_channels_spec.rb | 211 ++++++ spec/sass/value/color_4_conversions_spec.rb | 159 ++++ .../value/color_4_nonparametizable_spec.rb | 67 ++ spec/sass/value/color_4_spaces_spec.rb | 90 +++ spec/sass/value/color_legacy_spec.rb | 350 +++++++++ spec/sass/value/color_spec.rb | 331 --------- spec/spec_helper.rb | 30 + 39 files changed, 4669 insertions(+), 552 deletions(-) create mode 100644 lib/sass/value/color/channel.rb create mode 100644 lib/sass/value/color/conversions.rb create mode 100644 lib/sass/value/color/gamut_map_method.rb create mode 100644 lib/sass/value/color/gamut_map_method/clip.rb create mode 100644 lib/sass/value/color/gamut_map_method/local_minde.rb create mode 100644 lib/sass/value/color/interpolation_method.rb create mode 100644 lib/sass/value/color/space.rb create mode 100644 lib/sass/value/color/space/a98_rgb.rb create mode 100644 lib/sass/value/color/space/display_p3.rb create mode 100644 lib/sass/value/color/space/hsl.rb create mode 100644 lib/sass/value/color/space/hwb.rb create mode 100644 lib/sass/value/color/space/lab.rb create mode 100644 lib/sass/value/color/space/lch.rb create mode 100644 lib/sass/value/color/space/lms.rb create mode 100644 lib/sass/value/color/space/oklab.rb create mode 100644 lib/sass/value/color/space/oklch.rb create mode 100644 lib/sass/value/color/space/prophoto_rgb.rb create mode 100644 lib/sass/value/color/space/rec2020.rb create mode 100644 lib/sass/value/color/space/rgb.rb create mode 100644 lib/sass/value/color/space/srgb.rb create mode 100644 lib/sass/value/color/space/srgb_linear.rb create mode 100644 lib/sass/value/color/space/utils.rb create mode 100644 lib/sass/value/color/space/xyz_d50.rb create mode 100644 lib/sass/value/color/space/xyz_d65.rb create mode 100644 spec/sass/value/color/constructors.rb create mode 100644 spec/sass/value/color/interpolation_examples.rb create mode 100644 spec/sass/value/color/spaces.rb create mode 100644 spec/sass/value/color/utils.rb create mode 100644 spec/sass/value/color_4_channels_spec.rb create mode 100644 spec/sass/value/color_4_conversions_spec.rb create mode 100644 spec/sass/value/color_4_nonparametizable_spec.rb create mode 100644 spec/sass/value/color_4_spaces_spec.rb create mode 100644 spec/sass/value/color_legacy_spec.rb delete mode 100644 spec/sass/value/color_spec.rb diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index f58bdf5b..3140f211 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -25,37 +25,15 @@ def to_proto(obj) number: Number.to_proto(obj) ) when Sass::Value::Color - if obj.instance_eval { !defined?(@hue) } - EmbeddedProtocol::Value.new( - color: EmbeddedProtocol::Value::Color.new( - channel1: obj.red, - channel2: obj.green, - channel3: obj.blue, - alpha: obj.alpha.to_f, - space: 'rgb' - ) - ) - elsif obj.instance_eval { !defined?(@saturation) } - EmbeddedProtocol::Value.new( - color: EmbeddedProtocol::Value::Color.new( - channel1: obj.hue.to_f, - channel2: obj.whiteness.to_f, - channel3: obj.blackness.to_f, - alpha: obj.alpha.to_f, - space: 'hwb' - ) - ) - else - EmbeddedProtocol::Value.new( - color: EmbeddedProtocol::Value::Color.new( - channel1: obj.hue.to_f, - channel2: obj.saturation.to_f, - channel3: obj.lightness.to_f, - alpha: obj.alpha.to_f, - space: 'hsl' - ) + EmbeddedProtocol::Value.new( + color: EmbeddedProtocol::Value::Color.new( + channel1: obj.send(:channel0_or_nil), + channel2: obj.send(:channel1_or_nil), + channel3: obj.send(:channel2_or_nil), + alpha: obj.send(:alpha_or_nil), + space: obj.space ) - end + ) when Sass::Value::ArgumentList EmbeddedProtocol::Value.new( argument_list: EmbeddedProtocol::Value::ArgumentList.new( @@ -134,31 +112,14 @@ def from_proto(proto) when :number Number.from_proto(obj) when :color - case obj.space - when 'rgb' - Sass::Value::Color.new( - red: obj.channel1, - green: obj.channel2, - blue: obj.channel3, - alpha: obj.alpha - ) - when 'hsl' - Sass::Value::Color.new( - hue: obj.channel1, - saturation: obj.channel2, - lightness: obj.channel3, - alpha: obj.alpha - ) - when 'hwb' - Sass::Value::Color.new( - hue: obj.channel1, - whiteness: obj.channel2, - blackness: obj.channel3, - alpha: obj.alpha - ) - else - raise NotImplementedError, 'CSS Color Level 4 will be supported in a future release' - end + Sass::Value::Color.send( + :for_space, + obj.space, + obj.channel1, + obj.channel2, + obj.channel3, + obj.alpha + ) when :argument_list Sass::Value::ArgumentList.new( obj.contents.map do |element| diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index bcfd1914..1b057fb6 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -1,5 +1,11 @@ # frozen_string_literal: true +require_relative 'color/channel' +require_relative 'color/conversions' +require_relative 'color/gamut_map_method' +require_relative 'color/interpolation_method' +require_relative 'color/space' + module Sass module Value # Sass's color type. @@ -18,90 +24,149 @@ class Color # @param lightness [Numeric] # @param whiteness [Numeric] # @param blackness [Numeric] + # @param a [Numeric] + # @param b [Numeric] + # @param chroma [Numeric] + # @param x [Numeric] + # @param y [Numeric] + # @param z [Numeric] # @param alpha [Numeric] - def initialize(red: nil, - green: nil, - blue: nil, - hue: nil, - saturation: nil, - lightness: nil, - whiteness: nil, - blackness: nil, - alpha: 1) - @alpha = alpha.nil? ? 1 : FuzzyMath.assert_between(alpha, 0, 1, 'alpha') - if red && green && blue - @red = FuzzyMath.assert_between(FuzzyMath.round(red), 0, 255, 'red') - @green = FuzzyMath.assert_between(FuzzyMath.round(green), 0, 255, 'green') - @blue = FuzzyMath.assert_between(FuzzyMath.round(blue), 0, 255, 'blue') - elsif hue && saturation && lightness - @hue = hue % 360 - @saturation = FuzzyMath.assert_between(saturation, 0, 100, 'saturation') - @lightness = FuzzyMath.assert_between(lightness, 0, 100, 'lightness') - elsif hue && whiteness && blackness - @hue = hue % 360 - @whiteness = FuzzyMath.assert_between(whiteness, 0, 100, 'whiteness') - @blackness = FuzzyMath.assert_between(blackness, 0, 100, 'blackness') - hwb_to_rgb - @whiteness = @blackness = nil - else - raise Sass::ScriptError, 'Invalid Color' + # @param space [::String] + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'rgb') + # @overload initialize(hue: nil, saturation: nil, lightness: nil, alpha: nil, space: 'hsl') + # @overload initialize(hue: nil, whiteness: nil, blackness: nil, alpha: nil, space: 'hwb') + # @overload initialize(lightness: nil, a: nil, b: nil, alpha: nil, space: 'lab') + # @overload initialize(lightness: nil, a: nil, b: nil, alpha: nil, space: 'oklab') + # @overload initialize(lightness: nil, chroma: nil, hue: nil, alpha: nil, space: 'lch') + # @overload initialize(lightness: nil, chroma: nil, hue: nil, alpha: nil, space: 'oklch') + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'a98-rgb') + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'display-p3') + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'prophoto-rgb') + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'rec2020') + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'srgb') + # @overload initialize(red: nil, green: nil, blue: nil, alpha: nil, space: 'srgb-linear') + # @overload initialize(x: nil, y: nil, z: nil, alpha: nil, space: 'xyz') + # @overload initialize(x: nil, y: nil, z: nil, alpha: nil, space: 'xyz-d50') + # @overload initialize(x: nil, y: nil, z: nil, alpha: nil, space: 'xyz-d65') + def initialize(**options) + unless options.key?(:space) + options[:space] = case options + in {red: _, green: _, blue: _} + 'rgb' + in {hue: _, saturation: _, lightness: _} + 'hsl' + in {hue: _, whiteness: _, blackness: _} + 'hwb' + else + raise Sass::ScriptError.new('No color space found', 'space') + end end - end - # @return [Integer] - def red - hsl_to_rgb unless defined?(@red) + space = Space.from_name(options[:space]) - @red + keys = _assert_options(space, options) + + _initialize_for_space_internal(space, + options[keys[0]], + options[keys[1]], + options[keys[2]], + options.fetch(:alpha, 1)) end - # @return [Integer] - def green - hsl_to_rgb unless defined?(@green) + # @return [::String] + def space + _space.name + end - @green + # @param space [::String] + # @return [Color] + def to_space(space) + _to_space(Space.from_name(space)) end - # @return [Integer] - def blue - hsl_to_rgb unless defined?(@blue) + # @param space [::String] + # @return [::Boolean] + def in_gamut?(space = nil) + return to_space(space)._in_gamut? unless space.nil? - @blue + _in_gamut? end - # @return [Numeric] - def hue - rgb_to_hsl unless defined?(@hue) + # @param method [::String] + # @param space [::String] + # @return [Color] + def to_gamut(method:, space: nil) + return to_space(space).to_gamut(method:)._to_space(_space) unless space.nil? - @hue + _to_gamut(GamutMapMethod.from_name(method, 'method')) end - # @return [Numeric] - def saturation - rgb_to_hsl unless defined?(@saturation) + # @return [Array] + def channels_or_nil + [channel0_or_nil, channel1_or_nil, channel2_or_nil].freeze + end - @saturation + # @return [Array] + def channels + [channel0, channel1, channel2].freeze end + # @param channel [::String] + # @param space [::String] # @return [Numeric] - def lightness - rgb_to_hsl unless defined?(@lightness) + def channel(channel, space: nil) + return to_space(space).channel(channel) unless space.nil? + + channels = _space.channels + return channel0 if channel == channels[0].name + return channel1 if channel == channels[1].name + return channel2 if channel == channels[2].name + return alpha if channel == 'alpha' - @lightness + raise Sass::ScriptError.new("Color #{self} doesn't have a channel named \"#{channel}\".", channel) end - # @return [Numeric] - def whiteness - @whiteness ||= Rational([red, green, blue].min, 255) * 100 + # @param channel [::String] + # @return [::Boolean] + def channel_missing?(channel) + channels = _space.channels + return channel0_missing? if channel == channels[0].name + return channel1_missing? if channel == channels[1].name + return channel2_missing? if channel == channels[2].name + return alpha_missing? if channel == 'alpha' + + raise Sass::ScriptError.new("Color #{self} doesn't have a channel named \"#{channel}\".", channel) end - # @return [Numeric] - def blackness - @blackness ||= 100 - (Rational([red, green, blue].max, 255) * 100) + # @param channel [::String] + # @param space [::String] + # @return [::Boolean] + def channel_powerless?(channel, space: nil) + return to_space(space).channel_powerless?(channel) unless space.nil? + + channels = _space.channels + return channel0_powerless? if channel == channels[0].name + return channel1_powerless? if channel == channels[1].name + return channel2_powerless? if channel == channels[2].name + return false if channel == 'alpha' + + raise Sass::ScriptError.new("Color #{self} doesn't have a channel named \"#{channel}\".", channel) end - # @return [Numeric] - attr_reader :alpha + # @param other [Color] + # @param method [::String] + # @param weight [Numeric] + # @return [Color] + def interpolate(other, method: nil, weight: nil) + interpolation_method = if !method.nil? + InterpolationMethod.new(_space, HueInterpolationMethod.from_name(method)) + elsif !_space.polar? + InterpolationMethod.new(_space) + else + InterpolationMethod.new(_space, :shorter) + end + _interpolate(other, interpolation_method, weight:) + end # @param red [Numeric] # @param green [Numeric] @@ -111,52 +176,175 @@ def blackness # @param lightness [Numeric] # @param whiteness [Numeric] # @param blackness [Numeric] + # @param a [Numeric] + # @param b [Numeric] + # @param chroma [Numeric] + # @param x [Numeric] + # @param y [Numeric] + # @param z [Numeric] # @param alpha [Numeric] + # @param space [::String] + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'rgb') + # @overload change(hue: nil, saturation: nil, lightness: nil, alpha: nil, space: 'hsl') + # @overload change(hue: nil, whiteness: nil, blackness: nil, alpha: nil, space: 'hwb') + # @overload change(lightness: nil, a: nil, b: nil, alpha: nil, space: 'lab') + # @overload change(lightness: nil, a: nil, b: nil, alpha: nil, space: 'oklab') + # @overload change(lightness: nil, chroma: nil, hue: nil, alpha: nil, space: 'lch') + # @overload change(lightness: nil, chroma: nil, hue: nil, alpha: nil, space: 'oklch') + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'a98-rgb') + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'display-p3') + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'prophoto-rgb') + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'rec2020') + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'srgb') + # @overload change(red: nil, green: nil, blue: nil, alpha: nil, space: 'srgb-linear') + # @overload change(x: nil, y: nil, z: nil, alpha: nil, space: 'xyz') + # @overload change(x: nil, y: nil, z: nil, alpha: nil, space: 'xyz-d50') + # @overload change(x: nil, y: nil, z: nil, alpha: nil, space: 'xyz-d65') # @return [Color] - def change(red: nil, - green: nil, - blue: nil, - hue: nil, - saturation: nil, - lightness: nil, - whiteness: nil, - blackness: nil, - alpha: nil) - if whiteness || blackness - Sass::Value::Color.new(hue: hue || self.hue, - whiteness: whiteness || self.whiteness, - blackness: blackness || self.blackness, - alpha: alpha || self.alpha) - elsif hue || saturation || lightness - Sass::Value::Color.new(hue: hue || self.hue, - saturation: saturation || self.saturation, - lightness: lightness || self.lightness, - alpha: alpha || self.alpha) - elsif red || green || blue - Sass::Value::Color.new(red: red ? FuzzyMath.round(red) : self.red, - green: green ? FuzzyMath.round(green) : self.green, - blue: blue ? FuzzyMath.round(blue) : self.blue, - alpha: alpha || self.alpha) - else - dup.instance_eval do - @alpha = FuzzyMath.assert_between(alpha, 0, 1, 'alpha') - self + def change(**options) + space_set_explictly = !options[:space].nil? + space = space_set_explictly ? Space.from_name(options[:space]) : _space + + if legacy? && !space_set_explictly + case options + in {whiteness: _} | {blackness: _} + space = Space::HWB + in {saturation: _} | {lightness: _} + space = Space::HSL + in {hue: _} + space = if _space == Space::HWB + Space::HWB + else + Space::HSL + end + in {red: _} | {blue: _} | {green: _} + space = Space::RGB + else + end + + if space != _space + # deprecated end end + + keys = _assert_options(space, options) + + color = _to_space(space) + + changed_color = if space_set_explictly + Color.send(:for_space_internal, + space, + options.fetch(keys[0], color.channel0_or_nil), + options.fetch(keys[1], color.channel1_or_nil), + options.fetch(keys[2], color.channel2_or_nil), + options.fetch(:alpha, color.alpha_or_nil)) + else + changed_channel0_or_nil = options[keys[0]] + changed_channel1_or_nil = options[keys[1]] + changed_channel2_or_nil = options[keys[2]] + changed_alpha_or_nil = options[:alpha] + Color.send(:for_space_internal, + space, + changed_channel0_or_nil.nil? ? color.channel0_or_nil : changed_channel0_or_nil, + changed_channel1_or_nil.nil? ? color.channel1_or_nil : changed_channel1_or_nil, + changed_channel2_or_nil.nil? ? color.channel2_or_nil : changed_channel2_or_nil, + changed_alpha_or_nil.nil? ? color.alpha_or_nil : changed_alpha_or_nil) + end + + changed_color._to_space(_space) + end + + # return [Numeric] + def alpha + @alpha_or_nil.nil? ? 0 : @alpha_or_nil + end + + # return [::Boolean] + def legacy? + _space.legacy? + end + + # @deprecated + # @return [Numeric] + def red + _to_space(Space::RGB).channel('red').round + end + + # @deprecated + # @return [Numeric] + def green + _to_space(Space::RGB).channel('green').round + end + + # @deprecated + # @return [Numeric] + def blue + _to_space(Space::RGB).channel('blue').round + end + + # @deprecated + # @return [Numeric] + def hue + _to_space(Space::HSL).channel('hue') + end + + # @deprecated + # @return [Numeric] + def saturation + _to_space(Space::HSL).channel('saturation') + end + + # @deprecated + # @return [Numeric] + def lightness + _to_space(Space::HSL).channel('lightness') + end + + # @deprecated + # @return [Numeric] + def whiteness + _to_space(Space::HWB).channel('whiteness') + end + + # @deprecated + # @return [Numeric] + def blackness + _to_space(Space::HWB).channel('blackness') end # @return [::Boolean] def ==(other) - other.is_a?(Sass::Value::Color) && - other.red == red && - other.green == green && - other.blue == blue && - other.alpha == alpha + return false unless other.is_a?(Sass::Value::Color) + + if legacy? + return false unless other.legacy? + return false unless FuzzyMath.equals_nilable(other.alpha_or_nil, alpha_or_nil) + + if _space == other._space + FuzzyMath.equals_nilable(other.channel0_or_nil, channel0_or_nil) && + FuzzyMath.equals_nilable(other.channel1_or_nil, channel1_or_nil) && + FuzzyMath.equals_nilable(other.channel2_or_nil, channel2_or_nil) + else + _to_space(Space::RGB) == other._to_space(Space::RGB) + end + else + other._space == _space && + FuzzyMath.equals_nilable(other.channel0_or_nil, channel0_or_nil) && + FuzzyMath.equals_nilable(other.channel1_or_nil, channel1_or_nil) && + FuzzyMath.equals_nilable(other.channel2_or_nil, channel2_or_nil) && + FuzzyMath.equals_nilable(other.alpha_or_nil, alpha_or_nil) + end end # @return [Integer] def hash - @hash ||= [red, green, blue, alpha].hash + @hash ||= [ + _space, + channel0_or_nil&.finite? ? (channel0_or_nil * FuzzyMath::INVERSE_EPSILON).round : channel0_or_nil, # rubocop:disable Security/CompoundHash + channel1_or_nil&.finite? ? (channel1_or_nil * FuzzyMath::INVERSE_EPSILON).round : channel1_or_nil, # rubocop:disable Security/CompoundHash + channel2_or_nil&.finite? ? (channel2_or_nil * FuzzyMath::INVERSE_EPSILON).round : channel2_or_nil, # rubocop:disable Security/CompoundHash + alpha_or_nil&.finite? ? (alpha_or_nil * FuzzyMath::INVERSE_EPSILON).round : alpha_or_nil # rubocop:disable Security/CompoundHash + ].hash end # @return [Color] @@ -164,89 +352,276 @@ def assert_color(_name = nil) self end + protected + + attr_reader :channel0_or_nil, :channel1_or_nil, :channel2_or_nil, :alpha_or_nil + + def channel0 + @channel0_or_nil.nil? ? 0 : @channel0_or_nil + end + + def channel0_missing? + @channel0_or_nil.nil? + end + + def channel0_powerless? + case _space + when Space::HSL + FuzzyMath.equals(channel1, 0) + when Space::HWB + FuzzyMath.greater_than_or_equals(channel1 + channel2, 100) + else + false + end + end + + def channel1 + @channel1_or_nil.nil? ? 0 : @channel1_or_nil + end + + def channel1_missing? + @channel1_or_nil.nil? + end + + def channel1_powerless? + false + end + + def channel2 + @channel2_or_nil.nil? ? 0 : @channel2_or_nil + end + + def channel2_missing? + @channel2_or_nil.nil? + end + + def channel2_powerless? + case _space + when Space::LCH, Space::OKLCH + FuzzyMath.equals(channel1, 0) + else + false + end + end + + def alpha_missing? + @alpha_or_nil.nil? + end + + def _space + @space + end + + def _to_space(space) + return self if _space == space + + _space.convert(space, channel0_or_nil, channel1_or_nil, channel2_or_nil, alpha) + end + + def _in_gamut? + return true unless _space.bounded? + + _is_channel_in_gamut(channel0, _space.channels[0]) && + _is_channel_in_gamut(channel1, _space.channels[1]) && + _is_channel_in_gamut(channel2, _space.channels[2]) + end + + def _to_gamut(method) + _in_gamut? ? self : method.map(self) + end + private - def rgb_to_hsl - scaled_red = Rational(red, 255) - scaled_green = Rational(green, 255) - scaled_blue = Rational(blue, 255) - - max = [scaled_red, scaled_green, scaled_blue].max - min = [scaled_red, scaled_green, scaled_blue].min - delta = max - min - - if max == min - @hue = 0 - elsif max == scaled_red - @hue = ((scaled_green - scaled_blue) * 60 / delta) % 360 - elsif max == scaled_green - @hue = (((scaled_blue - scaled_red) * 60 / delta) + 120) % 360 - elsif max == scaled_blue - @hue = (((scaled_red - scaled_green) * 60 / delta) + 240) % 360 + def _assert_options(space, options) + keys = space.channels.map do |channel| + channel.name.to_sym + end << :alpha << :space + options.each_key do |key| + unless keys.include?(key) + raise Sass::ScriptError.new("`#{key}` is not a valid channel in `#{space.name}`.", key) + end end + keys + end - lightness = @lightness = (max + min) * 50 - - @saturation = if max == min - 0 - elsif lightness < 50 - delta * 100 / (max + min) - else - delta * 100 / (2 - max - min) - end - end - - def hsl_to_rgb - scaled_hue = Rational(hue, 360) - scaled_saturation = Rational(saturation, 100) - scaled_lightness = Rational(lightness, 100) - - tmp2 = if scaled_lightness <= 0.5 - scaled_lightness * (scaled_saturation + 1) - else - scaled_lightness + scaled_saturation - (scaled_lightness * scaled_saturation) - end - tmp1 = (scaled_lightness * 2) - tmp2 - @red = FuzzyMath.round(hsl_hue_to_rgb(tmp1, tmp2, scaled_hue + Rational(1, 3)) * 255) - @green = FuzzyMath.round(hsl_hue_to_rgb(tmp1, tmp2, scaled_hue) * 255) - @blue = FuzzyMath.round(hsl_hue_to_rgb(tmp1, tmp2, scaled_hue - Rational(1, 3)) * 255) - end - - def hsl_hue_to_rgb(tmp1, tmp2, hue) - hue += 1 if hue.negative? - hue -= 1 if hue > 1 - - if hue < Rational(1, 6) - tmp1 + ((tmp2 - tmp1) * hue * 6) - elsif hue < Rational(1, 2) - tmp2 - elsif hue < Rational(2, 3) - tmp1 + ((tmp2 - tmp1) * (Rational(2, 3) - hue) * 6) + def _initialize_for_space_internal(space, channel0, channel1, channel2, alpha = 1) + case space + when Space::HSL + _initialize_for_space( + space, + _normalize_hue(channel0, invert: !channel1.nil? && FuzzyMath.less_than(channel1, 0)), + channel1&.abs, + channel2, + alpha + ) + when Space::HWB + _initialize_for_space(space, _normalize_hue(channel0, invert: false), channel1, channel2, alpha) + when Space::LCH, Space::OKLCH + _initialize_for_space( + space, + channel0, + channel1&.abs, + _normalize_hue(channel2, invert: !channel1.nil? && FuzzyMath.less_than(channel1, 0)), + alpha + ) else - tmp1 + _initialize_for_space(space, channel0, channel1, channel2, alpha) end end - def hwb_to_rgb - scaled_hue = Rational(hue, 360) - scaled_whiteness = Rational(whiteness, 100) - scaled_blackness = Rational(blackness, 100) + def _initialize_for_space(space, channel0_or_nil, channel1_or_nil, channel2_or_nil, alpha) + @space = space + @channel0_or_nil = channel0_or_nil + @channel1_or_nil = channel1_or_nil + @channel2_or_nil = channel2_or_nil + @alpha_or_nil = alpha + + FuzzyMath.assert_between(@alpha_or_nil, 0, 1, 'alpha') unless @alpha_or_nil.nil? + end + + def _normalize_hue(hue, invert:) + return hue if hue.nil? - sum = scaled_whiteness + scaled_blackness - if sum > 1 - scaled_whiteness /= sum - scaled_blackness /= sum + ((hue % 360) + 360 + (invert ? 180 : 0)) % 360 + end + + def _is_channel_in_gamut(value, channel) + case channel + when LinearChannel + FuzzyMath.less_than_or_equals(value, channel.max) && FuzzyMath.greater_than_or_equals(value, channel.min) + else + true end + end - factor = 1 - scaled_whiteness - scaled_blackness - @red = hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue + Rational(1, 3)) - @green = hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue) - @blue = hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue - Rational(1, 3)) + def _interpolate(other, method, weight: nil) + weight = 0.5 if weight.nil? + if weight.negative? || weight > 1 + raise Sass::ScriptError.new("Expected #{wieght} to be within 0 and 1.", 'weight') + end + + return other if FuzzyMath.equals(weight, 0) + return self if FuzzyMath.equals(weight, 1) + + color1 = _to_space(method.space) + color2 = other._to_space(method.space) + + c1_missing0 = _analogous_channel_missing?(self, color1, 0) + c1_missing1 = _analogous_channel_missing?(self, color1, 1) + c1_missing2 = _analogous_channel_missing?(self, color1, 2) + c2_missing0 = _analogous_channel_missing?(other, color2, 0) + c2_missing1 = _analogous_channel_missing?(other, color2, 1) + c2_missing2 = _analogous_channel_missing?(other, color2, 2) + c1_channel0 = (c1_missing0 ? color2 : color1).channel0 + c1_channel1 = (c1_missing1 ? color2 : color1).channel1 + c1_channel2 = (c1_missing2 ? color2 : color1).channel2 + c2_channel0 = (c2_missing0 ? color1 : color2).channel0 + c2_channel1 = (c2_missing1 ? color1 : color2).channel1 + c2_channel2 = (c2_missing2 ? color1 : color2).channel2 + c1_alpha = alpha_or_nil.nil? ? other.alpha : alpha_or_nil + c2_alpha = other.alpha_or_nil.nil? ? alpha : other.alpha_or_nil + + c1_multiplier = (alpha_or_nil.nil? ? 1 : alpha_or_nil) * weight + c2_multiplier = (other.alpha_or_nil.nil? ? 1 : other.alpha_or_nil) * (1 - weight) + mixed_alpha = alpha_missing? && other.alpha_missing? ? nil : (c1_alpha * weight) + (c2_alpha * (1 - weight)) + mixed0 = if c1_missing0 && c2_missing0 + nil + else + ((c1_channel0 * c1_multiplier) + (c2_channel0 * c2_multiplier)) / + (mixed_alpha.nil? ? 1 : mixed_alpha) + end + mixed1 = if c1_missing1 && c2_missing1 + nil + else + ((c1_channel1 * c1_multiplier) + (c2_channel1 * c2_multiplier)) / + (mixed_alpha.nil? ? 1 : mixed_alpha) + end + mixed2 = if c1_missing2 && c2_missing2 + nil + else + ((c1_channel2 * c1_multiplier) + (c2_channel2 * c2_multiplier)) / + (mixed_alpha.nil? ? 1 : mixed_alpha) + end + + case method.space + when Space::HSL, Space::HWB + Color.send(:for_space_internal, + method.space, + c1_missing0 && c2_missing0 ? nil : _interpolate_hues(c1_channel0, c2_channel0, method.hue, weight), + mixed1, + mixed2, + mixed_alpha) + when Space::LCH, Space::OKLCH + Color.send(:for_space_internal, + method.space, + mixed0, + mixed1, + c1_missing2 && c2_missing2 ? nil : _interpolate_hues(c1_channel2, c2_channel2, method.hue, weight), + mixed_alpha) + else + Color.send(:_for_space, + method.space, mixed0, mixed1, mixed2, mixed_alpha) + end._to_space(_space) end - def hwb_hue_to_rgb(factor, scaled_whiteness, scaled_hue) - channel = (hsl_hue_to_rgb(0, 1, scaled_hue) * factor) + scaled_whiteness - FuzzyMath.round(channel * 255) + def _analogous_channel_missing?(original, output, output_channel_index) + return true if output.channels_or_nil[output_channel_index].nil? + + return false if original.equal?(output) + + output_channel = output.space.channels[output_channel_index] + original_channel = original.space.channels.find do |channel| + output_channel.analogous?(channel) + end + + return false if original_channel.nil? + + original.channel_missing?(original_channel.name) + end + + def _interpolate_hues(hue1, hue2, method, weight) + case method + when :shorter + diff = hue2 - hue1 + if diff > 180 + hue1 += 360 + elsif diff < -180 + hue2 += 360 + end + when :longer + diff = hue2 - hue1 + if diff.positive? && diff < 180 + hue2 += 360 + elsif diff > -180 && diff <= 0 + hue1 += 360 + end + when :increasing + hue2 += 360 if hue2 < hue1 + when :decreasing + hue1 += 360 if hue1 < hue2 + end + + (hue1 * weight) + (hue2 * (1 - weight)) + end + + class << self + private + + def for_space(space, channel0_or_nil, channel1_or_nil, channel2_or_nil, alpha) + _for_space(Space.from_name(space), channel0_or_nil, channel1_or_nil, channel2_or_nil, alpha) + end + + def for_space_internal(space, channel0, channel1, channel2, alpha) + o = allocate + o.send(:_initialize_for_space_internal, space, channel0, channel1, channel2, alpha) + o + end + + def _for_space(space, channel0_or_nil, channel1_or_nil, channel2_or_nil, alpha) + o = allocate + o.send(:_initialize_for_space, space, channel0_or_nil, channel1_or_nil, channel2_or_nil, alpha) + o + end end end end diff --git a/lib/sass/value/color/channel.rb b/lib/sass/value/color/channel.rb new file mode 100644 index 00000000..ec7089aa --- /dev/null +++ b/lib/sass/value/color/channel.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/channel.dart + class ColorChannel + # @return [::String] + attr_reader :name + + # @return [::Boolean] + def polar_angle? + @polar_angle + end + + # @return [::String, nil] + attr_reader :associated_unit + + # @param name [::String] + # @param polar_angle [::Boolean] + # @param associated_unit [::String] + def initialize(name, polar_angle:, associated_unit: nil) + @name = name + @polar_angle = polar_angle + @associated_unit = associated_unit + end + + # @return [::Boolean] + def analogous?(other) + case [name, other.name] + in ['red' | 'x', 'red' | 'x'] | + ['green' | 'y', 'green' | 'y'] | + ['blue' | 'z', 'blue' | 'z'] | + ['chroma' | 'saturation', 'chroma' | 'saturation'] | + ['lightness', 'lightness'] | + ['hue', 'hue'] + true + else + false + end + end + end + + private_constant :ColorChannel + + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/channel.dart + class LinearChannel < ColorChannel + # @return [Numeric] + attr_reader :min, :max + + # @return [::Boolean] + attr_reader :requires_percent, :lower_clamped, :upper_clamped + + # @param name [::String] + # @param min [Numeric] + # @param max [Numeric] + # @param requires_percent [::Boolean] + # @param lower_clamped [::Boolean] + # @param upper_clamped [::Boolean] + # @param conventionally_percent [::Boolean] + def initialize(name, min, max, requires_percent: false, lower_clamped: false, upper_clamped: false, + conventionally_percent: nil) + super(name, + polar_angle: false, + associated_unit: if conventionally_percent.nil? ? (min.zero? && max == 100) : conventionally_percent + '%' + end) + @min = min + @max = max + @requires_percent = requires_percent + @lower_clamped = lower_clamped + @upper_clamped = upper_clamped + end + end + + private_constant :LinearChannel + end + end +end diff --git a/lib/sass/value/color/conversions.rb b/lib/sass/value/color/conversions.rb new file mode 100644 index 00000000..927212b7 --- /dev/null +++ b/lib/sass/value/color/conversions.rb @@ -0,0 +1,464 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + # @see https:#www.w3.org/TR/css-color-4/#color-conversion-code. + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/conversions.dart + module Conversions + # The D50 white point. + D50 = [0.3457 / 0.3585, 1.00000, (1.0 - 0.3457 - 0.3585) / 0.3585].freeze + + # The transformation matrix for converting LMS colors to OKLab. + # + # Note that this can't be directly multiplied with {XYZ_D65_TO_LMS}; see Color + # Level 4 spec for details on how to convert between XYZ and OKLab. + LMS_TO_OKLAB = [ + 0.2104542553, 0.7936177850, -0.0040720468, + 1.9779984951, -2.4285922050, 0.4505937099, + 0.0259040371, 0.7827717662, -0.8086757660 + ].freeze + + # The transformation matrix for converting OKLab colors to LMS. + # + # Note that this can't be directly multiplied with {LMS_TO_XYZ_D65}; see Color + # Level 4 spec for details on how to convert between XYZ and OKLab. + OKLAB_TO_LMS = [ + 0.99999999845051981432, 0.396337792173767856780, 0.215803758060758803390, + 1.00000000888176077670, -0.105561342323656349400, -0.063854174771705903402, + 1.00000005467241091770, -0.089484182094965759684, -1.291485537864091739900 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to + # linear-light display-p3. + LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = [ + 0.82246196871436230, 0.17753803128563775, 0.00000000000000000, + 0.03319419885096161, 0.96680580114903840, 0.00000000000000000, + 0.01708263072112003, 0.07239744066396346, 0.91051992861491650 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # linear-light srgb. + LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = [ + 1.22494017628055980, -0.22494017628055996, 0.00000000000000000, + -0.04205695470968816, 1.04205695470968800, 0.00000000000000000, + -0.01963755459033443, -0.07863604555063188, 1.09827360014096630 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to + # linear-light a98-rgb. + LINEAR_SRGB_TO_LINEAR_A98_RGB = [ + 0.71512560685562470, 0.28487439314437535, 0.00000000000000000, + 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, + 0.00000000000000000, 0.04116194845011846, 0.95883805154988160 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to + # linear-light srgb. + LINEAR_A98_RGB_TO_LINEAR_SRGB = [ + 1.39835574396077830, -0.39835574396077830, 0.00000000000000000, + 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, + 0.00000000000000000, -0.04292898929447326, 1.04292898929447330 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to + # linear-light rec2020. + LINEAR_SRGB_TO_LINEAR_REC2020 = [ + 0.62740389593469900, 0.32928303837788370, 0.04331306568741722, + 0.06909728935823208, 0.91954039507545870, 0.01136231556630917, + 0.01639143887515027, 0.08801330787722575, 0.89559525324762400 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to + # linear-light srgb. + LINEAR_REC2020_TO_LINEAR_SRGB = [ + 1.66049100210843450, -0.58764113878854950, -0.07284986331988487, + -0.12455047452159074, 1.13289989712596030, -0.00834942260436947, + -0.01815076335490530, -0.10057889800800737, 1.11872966136291270 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to xyz. + LINEAR_SRGB_TO_XYZ_D65 = [ + 0.41239079926595950, 0.35758433938387796, 0.18048078840183430, + 0.21263900587151036, 0.71516867876775590, 0.07219231536073371, + 0.01933081871559185, 0.11919477979462598, 0.95053215224966060 + ].freeze + + # The transformation matrix for converting xyz colors to linear-light srgb. + XYZ_D65_TO_LINEAR_SRGB = [ + 3.24096994190452130, -1.53738317757009350, -0.49861076029300330, + -0.96924363628087980, 1.87596750150772060, 0.04155505740717561, + 0.05563007969699360, -0.20397695888897657, 1.05697151424287860 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to lms. + LINEAR_SRGB_TO_LMS = [ + 0.41222147080000016, 0.53633253629999990, 0.05144599290000001, + 0.21190349820000007, 0.68069954509999990, 0.10739695660000000, + 0.08830246190000005, 0.28171883759999994, 0.62997870050000000 + ].freeze + + # The transformation matrix for converting lms colors to linear-light srgb. + LMS_TO_LINEAR_SRGB = [ + 4.07674166134799300, -3.30771159040819240, 0.23096992872942781, + -1.26843800409217660, 2.60975740066337240, -0.34131939631021974, + -0.00419608654183720, -0.70341861445944950, 1.70761470093094480 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to + # linear-light prophoto-rgb. + LINEAR_SRGB_TO_LINEAR_PROPHOTO_RGB = [ + 0.52927697762261160, 0.33015450197849283, 0.14056852039889556, + 0.09836585954044917, 0.87347071290696180, 0.02816342755258900, + 0.01687534092138684, 0.11765941425612084, 0.86546524482249230 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # linear-light srgb. + LINEAR_PROPHOTO_RGB_TO_LINEAR_SRGB = [ + 2.03438084951699600, -0.72763578993413420, -0.30674505958286180, + -0.22882573163305037, 1.23174254119010480, -0.00291680955705449, + -0.00855882878391742, -0.15326670213803720, 1.16182553092195470 + ].freeze + + # The transformation matrix for converting linear-light srgb colors to xyz-d50. + LINEAR_SRGB_TO_XYZ_D50 = [ + 0.43606574687426936, 0.38515150959015960, 0.14307841996513868, + 0.22249317711056518, 0.71688701309448240, 0.06061980979495235, + 0.01392392146316939, 0.09708132423141015, 0.71409935681588070 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to linear-light srgb. + XYZ_D50_TO_LINEAR_SRGB = [ + 3.13413585290011780, -1.61738599801804200, -0.49066221791109754, + -0.97879547655577770, 1.91625437739598840, 0.03344287339036693, + 0.07195539255794733, -0.22897675981518200, 1.40538603511311820 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # linear-light a98-rgb. + LINEAR_DISPLAY_P3_TO_LINEAR_A98_RGB = [ + 0.86400513747404840, 0.13599486252595164, 0.00000000000000000, + -0.04205695470968816, 1.04205695470968800, 0.00000000000000000, + -0.02056038078232985, -0.03250613804550798, 1.05306651882783790 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to + # linear-light display-p3. + LINEAR_A98_RGB_TO_LINEAR_DISPLAY_P3 = [ + 1.15009441814101840, -0.15009441814101834, 0.00000000000000000, + 0.04641729862941844, 0.95358270137058150, 0.00000000000000000, + 0.02388759479083904, 0.02650477632633013, 0.94960762888283080 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # linear-light rec2020. + LINEAR_DISPLAY_P3_TO_LINEAR_REC2020 = [ + 0.75383303436172180, 0.19859736905261630, 0.04756959658566187, + 0.04574384896535833, 0.94177721981169350, 0.01247893122294812, + -0.00121034035451832, 0.01760171730108989, 0.98360862305342840 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to + # linear-light display-p3. + LINEAR_REC2020_TO_LINEAR_DISPLAY_P3 = [ + 1.34357825258433200, -0.28217967052613570, -0.06139858205819628, + -0.06529745278911953, 1.07578791584857460, -0.01049046305945495, + 0.00282178726170095, -0.01959849452449406, 1.01677670726279310 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # xyz. + LINEAR_DISPLAY_P3_TO_XYZ_D65 = [ + 0.48657094864821626, 0.26566769316909294, 0.19821728523436250, + 0.22897456406974884, 0.69173852183650620, 0.07928691409374500, + 0.00000000000000000, 0.04511338185890257, 1.04394436890097570 + ].freeze + + # The transformation matrix for converting xyz colors to linear-light + # display-p3. + XYZ_D65_TO_LINEAR_DISPLAY_P3 = [ + 2.49349691194142450, -0.93138361791912360, -0.40271078445071684, + -0.82948896956157490, 1.76266406031834680, 0.02362468584194359, + 0.03584583024378433, -0.07617238926804170, 0.95688452400768730 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # lms. + LINEAR_DISPLAY_P3_TO_LMS = [ + 0.48137985442585490, 0.46211836973903553, 0.05650177583510960, + 0.22883194490233110, 0.65321681282840370, 0.11795124216926511, + 0.08394575573016760, 0.22416526885956980, 0.69188897541026260 + ].freeze + + # The transformation matrix for converting lms colors to linear-light + # display-p3. + LMS_TO_LINEAR_DISPLAY_P3 = [ + 3.12776898667772140, -2.25713579553953770, 0.12936680863610234, + -1.09100904738343900, 2.41333175827934370, -0.32232271065457110, + -0.02601081320950207, -0.50804132569306730, 1.53405213885176520 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # linear-light prophoto-rgb. + LINEAR_DISPLAY_P3_TO_LINEAR_PROPHOTO_RGB = [ + 0.63168691934035890, 0.21393038569465722, 0.15438269496498390, + 0.08320371426648458, 0.88586513676302430, 0.03093114897049121, + -0.00127273456473881, 0.05075510433665735, 0.95051763022808140 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # linear-light display-p3. + LINEAR_PROPHOTO_RGB_TO_LINEAR_DISPLAY_P3 = [ + 1.63257560870691790, -0.37977161848259840, -0.25280399022431950, + -0.15370040233755072, 1.16670254724250140, -0.01300214490495082, + 0.01039319529676572, -0.06280731264959440, 1.05241411735282870 + ].freeze + + # The transformation matrix for converting linear-light display-p3 colors to + # xyz-d50. + LINEAR_DISPLAY_P3_TO_XYZ_D50 = [ + 0.51514644296811600, 0.29200998206385770, 0.15713925139759397, + 0.24120032212525520, 0.69222254113138180, 0.06657713674336294, + -0.00105013914714014, 0.04187827018907460, 0.78427647146852570 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to linear-light + # display-p3. + XYZ_D50_TO_LINEAR_DISPLAY_P3 = [ + 2.40393412185549730, -0.99003044249559310, -0.39761363181465614, + -0.84227001614546880, 1.79895801610670820, 0.01604562477090472, + 0.04819381686413303, -0.09738519815446048, 1.27367136933212730 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to + # linear-light rec2020. + LINEAR_A98_RGB_TO_LINEAR_REC2020 = [ + 0.87733384166365680, 0.07749370651571998, 0.04517245182062317, + 0.09662259146620378, 0.89152732024418050, 0.01185008828961569, + 0.02292106270284839, 0.04303668501067932, 0.93404225228647230 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to + # linear-light a98-rgb. + LINEAR_REC2020_TO_LINEAR_A98_RGB = [ + 1.15197839471591630, -0.09750305530240860, -0.05447533941350766, + -0.12455047452159074, 1.13289989712596030, -0.00834942260436947, + -0.02253038278105590, -0.04980650742838876, 1.07233689020944460 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to xyz. + LINEAR_A98_RGB_TO_XYZ_D65 = [ + 0.57666904291013080, 0.18555823790654627, 0.18822864623499472, + 0.29734497525053616, 0.62736356625546600, 0.07529145849399789, + 0.02703136138641237, 0.07068885253582714, 0.99133753683763890 + ].freeze + + # The transformation matrix for converting xyz colors to linear-light a98-rgb. + XYZ_D65_TO_LINEAR_A98_RGB = [ + 2.04158790381074600, -0.56500697427885960, -0.34473135077832950, + -0.96924363628087980, 1.87596750150772060, 0.04155505740717561, + 0.01344428063203102, -0.11836239223101823, 1.01517499439120540 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to lms. + LINEAR_A98_RGB_TO_LMS = [ + 0.57643226147714040, 0.36991322114441194, 0.05365451737844765, + 0.29631647387335260, 0.59167612662650690, 0.11200739940014041, + 0.12347825480374285, 0.21949869580674647, 0.65702304938951070 + ].freeze + + # The transformation matrix for converting lms colors to linear-light a98-rgb. + LMS_TO_LINEAR_A98_RGB = [ + 2.55403684790806950, -1.62197620262602140, 0.06793935455575403, + -1.26843800409217660, 2.60975740066337240, -0.34131939631021974, + -0.05623474718052319, -0.56704183411879500, 1.62327658124261400 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to + # linear-light prophoto-rgb. + LINEAR_A98_RGB_TO_LINEAR_PROPHOTO_RGB = [ + 0.74011750180477920, 0.11327951328898105, 0.14660298490623970, + 0.13755046469802620, 0.83307708026948400, 0.02937245503248977, + 0.02359772990871766, 0.07378347703906656, 0.90261879305221580 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # linear-light a98-rgb. + LINEAR_PROPHOTO_RGB_TO_LINEAR_A98_RGB = [ + 1.38965124815152000, -0.16945907691487766, -0.22019217123664242, + -0.22882573163305037, 1.23174254119010480, -0.00291680955705449, + -0.01762544368426068, -0.09625702306122665, 1.11388246674548740 + ].freeze + + # The transformation matrix for converting linear-light a98-rgb colors to + # xyz-d50. + LINEAR_A98_RGB_TO_XYZ_D50 = [ + 0.60977504188618140, 0.20530000261929401, 0.14922063192409227, + 0.31112461220464155, 0.62565323083468560, 0.06322215696067286, + 0.01947059555648168, 0.06087908649415867, 0.74475492045981980 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to linear-light + # a98-rgb. + XYZ_D50_TO_LINEAR_A98_RGB = [ + 1.96246703637688060, -0.61074234048150730, -0.34135809808271540, + -0.97879547655577770, 1.91625437739598840, 0.03344287339036693, + 0.02870443944957101, -0.14067486633170680, 1.34891418141379370 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to xyz. + LINEAR_REC2020_TO_XYZ_D65 = [ + 0.63695804830129130, 0.14461690358620838, 0.16888097516417205, + 0.26270021201126703, 0.67799807151887100, 0.05930171646986194, + 0.00000000000000000, 0.02807269304908750, 1.06098505771079090 + ].freeze + + # The transformation matrix for converting xyz colors to linear-light rec2020. + XYZ_D65_TO_LINEAR_REC2020 = [ + 1.71665118797126760, -0.35567078377639240, -0.25336628137365980, + -0.66668435183248900, 1.61648123663493900, 0.01576854581391113, + 0.01763985744531091, -0.04277061325780865, 0.94210312123547400 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to lms. + LINEAR_REC2020_TO_LMS = [ + 0.61675578719908560, 0.36019839939276255, 0.02304581340815186, + 0.26513306398328140, 0.63583936407771060, 0.09902757183900800, + 0.10010263423281572, 0.20390651940192997, 0.69599084636525430 + ].freeze + + # The transformation matrix for converting lms colors to linear-light rec2020. + LMS_TO_LINEAR_REC2020 = [ + 2.13990673569556170, -1.24638950878469060, 0.10648277296448995, + -0.88473586245815630, 2.16323098210838260, -0.27849511943390290, + -0.04857375801465988, -0.45450314291725170, 1.50307690088646130 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to + # linear-light prophoto-rgb. + LINEAR_REC2020_TO_LINEAR_PROPHOTO_RGB = [ + 0.83518733312972350, 0.04886884858605698, 0.11594381828421951, + 0.05403324519953363, 0.92891840856920440, 0.01704834623126199, + -0.00234203897072539, 0.03633215316169465, 0.96600988580903070 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # linear-light rec2020. + LINEAR_PROPHOTO_RGB_TO_LINEAR_REC2020 = [ + 1.20065932951740800, -0.05756805370122346, -0.14309127581618444, + -0.06994154955888504, 1.08061789759721400, -0.01067634803832895, + 0.00554147334294746, -0.04078219298657951, 1.03524071964363200 + ].freeze + + # The transformation matrix for converting linear-light rec2020 colors to + # xyz-d50. + LINEAR_REC2020_TO_XYZ_D50 = [ + 0.67351546318827600, 0.16569726370390453, 0.12508294953738705, + 0.27905900514112060, 0.67531800574910980, 0.04562298910976962, + -0.00193242713400438, 0.02997782679282923, 0.79705920285163550 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to linear-light + # rec2020. + XYZ_D50_TO_LINEAR_REC2020 = [ + 1.64718490467176600, -0.39368189813164710, -0.23595963848828266, + -0.68266410741738180, 1.64771461274440760, 0.01281708338512084, + 0.02966887665275675, -0.06292589642970030, 1.25355782018657710 + ].freeze + + # The transformation matrix for converting xyz colors to lms. + XYZ_D65_TO_LMS = [ + 0.81902244321643190, 0.36190625628012210, -0.12887378261216414, + 0.03298366719802710, 0.92928684689655460, 0.03614466816999844, + 0.04817719956604625, 0.26423952494422764, 0.63354782581369370 + ].freeze + + # The transformation matrix for converting lms colors to xyz. + LMS_TO_XYZ_D65 = [ + 1.22687987337415570, -0.55781499655548140, 0.28139105017721590, + -0.04057576262431372, 1.11228682939705960, -0.07171106666151703, + -0.07637294974672143, -0.42149332396279143, 1.58692402442724180 + ].freeze + + # The transformation matrix for converting xyz colors to linear-light + # prophoto-rgb. + XYZ_D65_TO_LINEAR_PROPHOTO_RGB = [ + 1.40319046337749790, -0.22301514479051668, -0.10160668507413790, + -0.52623840216330720, 1.48163196292346440, 0.01701879027252688, + -0.01120226528622150, 0.01824640347962099, 0.91124722749150480 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # xyz. + LINEAR_PROPHOTO_RGB_TO_XYZ_D65 = [ + 0.75559074229692100, 0.11271984265940525, 0.08214534209534540, + 0.26832184357857190, 0.71511525666179120, 0.01656289975963685, + 0.00391597276242580, -0.01293344283684181, 1.09807522083429450 + ].freeze + + # The transformation matrix for converting xyz colors to xyz-d50. + XYZ_D65_TO_XYZ_D50 = [ + 1.04792979254499660, 0.02294687060160952, -0.05019226628920519, + 0.02962780877005567, 0.99043442675388000, -0.01707379906341879, + -0.00924304064620452, 0.01505519149029816, 0.75187428142813700 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to xyz. + XYZ_D50_TO_XYZ_D65 = [ + 0.95547342148807520, -0.02309845494876452, 0.06325924320057065, + -0.02836970933386358, 1.00999539808130410, 0.02104144119191730, + 0.01231401486448199, -0.02050764929889898, 1.33036592624212400 + ].freeze + + # The transformation matrix for converting lms colors to linear-light + # prophoto-rgb. + LMS_TO_LINEAR_PROPHOTO_RGB = [ + 1.73835514985815240, -0.98795095237343430, 0.24959580241648663, + -0.70704942624914860, 1.93437008438177620, -0.22732065793919040, + -0.08407883426424761, -0.35754059702097796, 1.44161943124947150 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # lms. + LINEAR_PROPHOTO_RGB_TO_LMS = [ + 0.71544846349294310, 0.35279154798172740, -0.06824001147467047, + 0.27441165509049420, 0.66779764080811480, 0.05779070400139092, + 0.10978443849083751, 0.18619828746596980, 0.70401727404319270 + ].freeze + + # The transformation matrix for converting lms colors to xyz-d50. + LMS_TO_XYZ_D50 = [ + 1.28858621583908840, -0.53787174651736210, 0.21358120705405403, + -0.00253389352489796, 1.09231682453266550, -0.08978293089853581, + -0.06937383312514489, -0.29500839218634667, 1.18948682779245090 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to lms. + XYZ_D50_TO_LMS = [ + 0.77070004712402500, 0.34924839871072740, -0.11202352004249890, + 0.00559650559780223, 0.93707232493333150, 0.06972569131301698, + 0.04633715253432816, 0.25277530868525870, 0.85145807371608350 + ].freeze + + # The transformation matrix for converting linear-light prophoto-rgb colors to + # xyz-d50. + LINEAR_PROPHOTO_RGB_TO_XYZ_D50 = [ + 0.79776664490064230, 0.13518129740053308, 0.03134773412839220, + 0.28807482881940130, 0.71183523424187300, 0.00008993693872564, + 0.00000000000000000, 0.00000000000000000, 0.82510460251046020 + ].freeze + + # The transformation matrix for converting xyz-d50 colors to linear-light + # prophoto-rgb. + XYZ_D50_TO_LINEAR_PROPHOTO_RGB = [ + 1.34578688164715830, -0.25557208737979464, -0.05110186497554526, + -0.54463070512490190, 1.50824774284514680, 0.02052744743642139, + 0.00000000000000000, 0.00000000000000000, 1.21196754563894520 + ].freeze + end + + private_constant :Conversions + end + end +end diff --git a/lib/sass/value/color/gamut_map_method.rb b/lib/sass/value/color/gamut_map_method.rb new file mode 100644 index 00000000..5742ffb7 --- /dev/null +++ b/lib/sass/value/color/gamut_map_method.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/gamut_map_method.dart + module GamutMapMethod + # @return [::String] + attr_reader :name + + # @param name [::String] + def initialize(name) + @name = name + end + + class << self + # @param name [::String] + # @param argument_name [::String] + # @return [GamutMapMethod] + def from_name(name, argument_name = nil) + case name + when 'clip' + CLIP + when 'local-minde' + LOCAL_MINDE + else + raise Sass::ScriptError.new("Unknown gamut map method \"#{name}\".", argument_name) + end + end + end + + # @param color [Color] + # @return [Color] + def map(color) + raise NotImplementedError, "[BUG] gamut map method #{name} doesn't implement map." + end + end + + private_constant :GamutMapMethod + end + end +end + +require_relative 'gamut_map_method/clip' +require_relative 'gamut_map_method/local_minde' diff --git a/lib/sass/value/color/gamut_map_method/clip.rb b/lib/sass/value/color/gamut_map_method/clip.rb new file mode 100644 index 00000000..c6a2b434 --- /dev/null +++ b/lib/sass/value/color/gamut_map_method/clip.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module GamutMapMethod + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/gamut_map_method/local_minde.dart + class Clip + include GamutMapMethod + + def initialize + super('clip') + end + + def map(color) + space = color.send(:_space) + Color.send(:for_space_internal, + space, + _clamp_channel(color.send(:channel0_or_nil), space.channels[0]), + _clamp_channel(color.send(:channel1_or_nil), space.channels[1]), + _clamp_channel(color.send(:channel2_or_nil), space.channels[2]), + color.send(:alpha_or_nil)) + end + + private + + def _clamp_channel(value, channel) + return nil if value.nil? + + case channel + when LinearChannel + FuzzyMath.clamp_like_css(value, channel.min, channel.max) + else + value + end + end + end + + private_constant :Clip + + CLIP = Clip.new + end + end + end +end diff --git a/lib/sass/value/color/gamut_map_method/local_minde.rb b/lib/sass/value/color/gamut_map_method/local_minde.rb new file mode 100644 index 00000000..19034b3d --- /dev/null +++ b/lib/sass/value/color/gamut_map_method/local_minde.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module GamutMapMethod + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/gamut_map_method/local_minde.dart + class LocalMinde + include GamutMapMethod + + # A constant from the gamut-mapping algorithm. + JND = 0.02 + + private_constant :JND + + # A constant from the gamut-mapping algorithm. + EPSILON = 0.0001 + + private_constant :EPSILON + + def initialize + super('local-minde') + end + + def map(color) + original_oklch = color.send(:_to_space, Space::OKLCH) + lightness = original_oklch.send(:channel0_or_nil) + hue = original_oklch.send(:channel2_or_nil) + alpha = original_oklch.send(:alpha_or_nil) + + if FuzzyMath.greater_than_or_equals(lightness.nil? ? 0 : lightness, 1) + if color.legacy? + return Color.send(:_for_space, + Space::RGB, 255, 255, 255, color.send(:alpha_or_nil)) + .send(:_to_space, color.send(:_space)) + else + return Color.send(:for_space_internal, + color.send(:_space), 1, 1, 1, color.send(:alpha_or_nil)) + end + elsif FuzzyMath.less_than_or_equals(lightness.nil? ? 0 : lightness, 0) + return Color.send(:_for_space, + Space::RGB, 0, 0, 0, color.send(:alpha_or_nil)) + .send(:_to_space, color.send(:_space)) + end + + clipped = color.send(:_to_gamut, CLIP) + return clipped if _delta_eok(clipped, color) < JND + + min = 0.0 + max = original_oklch.send(:channel1) + min_in_gamut = true + while max - min > EPSILON + chroma = (min + max) / 2 + + current = Space::OKLCH.convert(color.send(:_space), lightness, chroma, hue, alpha) + + if min_in_gamut && current.in_gamut? + min = chroma + next + end + + clipped = current.send(:_to_gamut, CLIP) + e = _delta_eok(clipped, current) + + if e < JND + return clipped if JND - e < EPSILON + + min_in_gamut = false + min = chroma + else + max = chroma + end + end + clipped + end + + private + + def _delta_eok(color1, color2) + lab1 = color1.send(:_to_space, Space::OKLAB) + lab2 = color2.send(:_to_space, Space::OKLAB) + Math.sqrt(((lab1.send(:channel0) - lab2.send(:channel0))**2) + + ((lab1.send(:channel1) - lab2.send(:channel1))**2) + + ((lab1.send(:channel2) - lab2.send(:channel2))**2)) + end + end + + private_constant :LocalMinde + + LOCAL_MINDE = LocalMinde.new + end + end + end +end diff --git a/lib/sass/value/color/interpolation_method.rb b/lib/sass/value/color/interpolation_method.rb new file mode 100644 index 00000000..a4cc1e0f --- /dev/null +++ b/lib/sass/value/color/interpolation_method.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/interpolation_method.dart + class InterpolationMethod + # @return [Space] + attr_reader :space + + # @return [Symbol, nil] + attr_reader :hue + + # @param space [Space] + # @param hue [Symbol] + def initialize(space, hue = nil) + @space = space + @hue = if space.polar? + hue.nil? ? :shorter : hue + end + + return unless !space.polar? && !hue.nil? + + raise Sass::ScriptError, + "Hue interpolation method may not be set for rectangular color space #{space.name}." + end + end + + private_constant :InterpolationMethod + + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/interpolation_method.dart + module HueInterpolationMethod + class << self + # @param name [::String] + # @param argument_name [::String] + # @return [Symbol] + def from_name(name, argument_name = nil) + case name + when 'decreasing', 'increasing', 'longer', 'shorter' + name.to_sym + else + raise Sass::ScriptError.new("Unknown hue interpolation method \"#{name}\".", argument_name) + end + end + end + end + + private_constant :HueInterpolationMethod + end + end +end diff --git a/lib/sass/value/color/space.rb b/lib/sass/value/color/space.rb new file mode 100644 index 00000000..741fa159 --- /dev/null +++ b/lib/sass/value/color/space.rb @@ -0,0 +1,198 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space.dart + module Space + # @return [::String] + attr_reader :name + + # @return [Array] + attr_reader :channels + + # @return [::Boolean] + def bounded? + raise NotImplementedError + end + + # @return [::Boolean] + def legacy? + false + end + + # @return [::Boolean] + def polar? + false + end + + # @param name [::String] + # @param channels [Array] + def initialize(name, channels) + @name = name + @channels = channels + end + + class << self + # @param name [::String] + # @param argument_name [::String] + # @return [Space] + def from_name(name, argument_name = nil) + case name.downcase + when 'rgb' + RGB + when 'hwb' + HWB + when 'hsl' + HSL + when 'srgb' + SRGB + when 'srgb-linear' + SRGB_LINEAR + when 'display-p3' + DISPLAY_P3 + when 'a98-rgb' + A98_RGB + when 'prophoto-rgb' + PROPHOTO_RGB + when 'rec2020' + REC2020 + when 'xyz', 'xyz-d65' + XYZ_D65 + when 'xyz-d50' + XYZ_D50 + when 'lab' + LAB + when 'lch' + LCH + when 'oklab' + OKLAB + when 'oklch' + OKLCH + else + raise Sass::ScriptError.new("Unknown color space \"#{name}\".", argument_name) + end + end + end + + # @param dest [Space] + # @param channel0 [Numeric] + # @param channel1 [Numeric] + # @param channel2 [Numeric] + # @param alpha [Numeric] + # @return [Color] + def convert(dest, channel0, channel1, channel2, alpha) + convert_linear(dest, channel0, channel1, channel2, alpha) + end + + protected + + def convert_linear(dest, red, green, blue, alpha, + missing_lightness: false, + missing_chroma: false, + missing_hue: false, + missing_a: false, + missing_b: false) + linear_dest = case dest + when HSL, HWB + SRGB + when LAB, LCH + XYZ_D50 + when OKLAB, OKLCH + LMS + else + dest + end + if linear_dest == self + transformed_red = red + transformed_green = green + transformed_blue = blue + else + linear_red = to_linear(red.nil? ? 0 : red) + linear_green = to_linear(green.nil? ? 0 : green) + linear_blue = to_linear(blue.nil? ? 0 : blue) + matrix = transformation_matrix(linear_dest) + + # (matrix * [linear_red, linear_green, linear_blue]).map(linear_dest.from_linear) + transformed_red = linear_dest.from_linear((matrix[0] * linear_red) + + (matrix[1] * linear_green) + + (matrix[2] * linear_blue)) + transformed_green = linear_dest.from_linear((matrix[3] * linear_red) + + (matrix[4] * linear_green) + + (matrix[5] * linear_blue)) + transformed_blue = linear_dest.from_linear((matrix[6] * linear_red) + + (matrix[7] * linear_green) + + (matrix[8] * linear_blue)) + end + + case dest + when HSL, HWB + SRGB.convert(dest, transformed_red, transformed_green, transformed_blue, alpha, + missing_lightness:, + missing_chroma:, + missing_hue:) + when LAB, LCH + XYZ_D50.convert(dest, transformed_red, transformed_green, transformed_blue, alpha, + missing_lightness:, + missing_chroma:, + missing_hue:, + missing_a:, + missing_b:) + when OKLAB, OKLCH + LMS.convert(dest, transformed_red, transformed_green, transformed_blue, alpha, + missing_lightness:, + missing_chroma:, + missing_hue:, + missing_a:, + missing_b:) + else + Color.send(:_for_space, + dest, + red.nil? ? nil : transformed_red, + green.nil? ? nil : transformed_green, + blue.nil? ? nil : transformed_blue, + alpha) + end + end + + # @param channel [Numeric] + # @return [Numeric] + def to_linear(channel) + raise NotImplementedError, "[BUG] Color space #{name} doesn't support linear conversions." + end + + # @param channel [Numeric] + # @return [Numeric] + def from_linear(channel) + raise NotImplementedError, "[BUG] Color space #{name} doesn't support linear conversions." + end + + # @param dest [Space] + # @return [Array] + def transformation_matrix(dest) + raise NotImplementedError, "[BUG] Color space conversion from #{name} to #{dest.name} not implemented." + end + end + + private_constant :Space + end + end +end + +require_relative 'space/utils' +require_relative 'space/a98_rgb' +require_relative 'space/display_p3' +require_relative 'space/hsl' +require_relative 'space/hwb' +require_relative 'space/lab' +require_relative 'space/lch' +require_relative 'space/lms' +require_relative 'space/oklab' +require_relative 'space/oklch' +require_relative 'space/prophoto_rgb' +require_relative 'space/rec2020' +require_relative 'space/rgb' +require_relative 'space/srgb' +require_relative 'space/srgb_linear' +require_relative 'space/xyz_d50' +require_relative 'space/xyz_d65' diff --git a/lib/sass/value/color/space/a98_rgb.rb b/lib/sass/value/color/space/a98_rgb.rb new file mode 100644 index 00000000..bdfe0d54 --- /dev/null +++ b/lib/sass/value/color/space/a98_rgb.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/a98_rgb.dart + class A98Rgb + include Space + + def bounded? + true + end + + def initialize + super('a98-rgb', Utils::RGB_CHANNELS) + end + + def to_linear(channel) + FuzzyMath.sign(channel) * (channel.abs**(563 / 256.0)) + end + + def from_linear(channel) + FuzzyMath.sign(channel) * (channel.abs**(256 / 563.0)) + end + + private + + def transformation_matrix(dest) + case dest + when DISPLAY_P3 + Conversions::LINEAR_A98_RGB_TO_LINEAR_DISPLAY_P3 + when LMS + Conversions::LINEAR_A98_RGB_TO_LMS + when PROPHOTO_RGB + Conversions::LINEAR_A98_RGB_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::LINEAR_A98_RGB_TO_LINEAR_REC2020 + when RGB, SRGB, SRGB_LINEAR + Conversions::LINEAR_A98_RGB_TO_LINEAR_SRGB + when XYZ_D50 + Conversions::LINEAR_A98_RGB_TO_XYZ_D50 + when XYZ_D65 + Conversions::LINEAR_A98_RGB_TO_XYZ_D65 + else + super + end + end + end + + private_constant :A98Rgb + + A98_RGB = A98Rgb.new + end + end + end +end diff --git a/lib/sass/value/color/space/display_p3.rb b/lib/sass/value/color/space/display_p3.rb new file mode 100644 index 00000000..ed7a1ccf --- /dev/null +++ b/lib/sass/value/color/space/display_p3.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/display_p3.dart + class DisplayP3 + include Space + + def bounded? + true + end + + def initialize + super('display-p3', Utils::RGB_CHANNELS) + end + + def to_linear(channel) + Utils.srgb_and_display_p3_to_linear(channel) + end + + def from_linear(channel) + Utils.srgb_and_display_p3_from_linear(channel) + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_A98_RGB + when LMS + Conversions::LINEAR_DISPLAY_P3_TO_LMS + when PROPHOTO_RGB + Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_REC2020 + when RGB, SRGB, SRGB_LINEAR + Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_SRGB + when XYZ_D50 + Conversions::LINEAR_DISPLAY_P3_TO_XYZ_D50 + when XYZ_D65 + Conversions::LINEAR_DISPLAY_P3_TO_XYZ_D65 + else + super + end + end + end + + private_constant :DisplayP3 + + DISPLAY_P3 = DisplayP3.new + end + end + end +end diff --git a/lib/sass/value/color/space/hsl.rb b/lib/sass/value/color/space/hsl.rb new file mode 100644 index 00000000..5135cdc2 --- /dev/null +++ b/lib/sass/value/color/space/hsl.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/hsl.dart + class Hsl + include Space + + def bounded? + true + end + + def legacy? + true + end + + def polar? + true + end + + def initialize + super('hsl', [ + Utils::HUE_CHANNEL, + LinearChannel.new('saturation', 0, 100, requires_percent: true, lower_clamped: true).freeze, + LinearChannel.new('lightness', 0, 100, requires_percent: true).freeze + ].freeze) + end + + def convert(dest, hue, saturation, lightness, alpha) + scaled_hue = ((hue.nil? ? 0 : hue) / 360.0) % 1 + scaled_saturation = (saturation.nil? ? 0 : saturation) / 100.0 + scaled_lightness = (lightness.nil? ? 0 : lightness) / 100.0 + + m2 = if scaled_lightness <= 0.5 + scaled_lightness * (scaled_saturation + 1) + else + scaled_lightness + scaled_saturation - (scaled_lightness * scaled_saturation) + end + m1 = (scaled_lightness * 2) - m2 + + SRGB.convert( + dest, + Utils.hue_to_rgb(m1, m2, scaled_hue + (1 / 3.0)), + Utils.hue_to_rgb(m1, m2, scaled_hue), + Utils.hue_to_rgb(m1, m2, scaled_hue - (1 / 3.0)), + alpha, + missing_lightness: lightness.nil?, + missing_chroma: saturation.nil?, + missing_hue: hue.nil? + ) + end + end + + private_constant :Hsl + + HSL = Hsl.new + end + end + end +end diff --git a/lib/sass/value/color/space/hwb.rb b/lib/sass/value/color/space/hwb.rb new file mode 100644 index 00000000..822135b2 --- /dev/null +++ b/lib/sass/value/color/space/hwb.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/hwb.dart + class Hwb + include Space + + def bounded? + true + end + + def legacy? + true + end + + def polar? + true + end + + def initialize + super('hwb', [ + Utils::HUE_CHANNEL, + LinearChannel.new('whiteness', 0, 100, requires_percent: true).freeze, + LinearChannel.new('blackness', 0, 100, requires_percent: true).freeze + ].freeze) + end + + def convert(dest, hue, whiteness, blackness, alpha) + scaled_hue = (hue.nil? ? 0 : hue) % 360 / 360.0 + scaled_whiteness = (whiteness.nil? ? 0 : whiteness) / 100.0 + scaled_blackness = (blackness.nil? ? 0 : blackness) / 100.0 + + sum = scaled_whiteness + scaled_blackness + if sum > 1 + scaled_whiteness /= sum + scaled_blackness /= sum + end + + factor = 1 - scaled_whiteness - scaled_blackness + + to_rgb = lambda do |hue_| + (Utils.hue_to_rgb(0, 1, hue_) * factor) + scaled_whiteness + end + + SRGB.convert(dest, + to_rgb.call(scaled_hue + (1 / 3.0)), + to_rgb.call(scaled_hue), + to_rgb.call(scaled_hue - (1 / 3.0)), + alpha, + missing_hue: hue.nil?) + end + end + + private_constant :Hwb + + HWB = Hwb.new + end + end + end +end diff --git a/lib/sass/value/color/space/lab.rb b/lib/sass/value/color/space/lab.rb new file mode 100644 index 00000000..164db01e --- /dev/null +++ b/lib/sass/value/color/space/lab.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/lab.dart + class Lab + include Space + + def bounded? + false + end + + def initialize + super('lab', [ + LinearChannel.new('lightness', 0, 100, lower_clamped: true, upper_clamped: true).freeze, + LinearChannel.new('a', -125, 125).freeze, + LinearChannel.new('b', -125, 125).freeze + ].freeze) + end + + def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParameterName + missing_chroma: false, missing_hue: false) + case dest + when LAB + powerless_ab = lightness.nil? || FuzzyMath.equals(lightness, 0) + Color.send( + :_for_space, + dest, + lightness, + a.nil? || powerless_ab ? nil : a, + b.nil? || powerless_ab ? nil : b, + alpha + ) + when LCH + Utils.lab_to_lch(dest, lightness, a, b, alpha) + else + missing_lightness = lightness.nil? + lightness = 0 if missing_lightness + + f1 = (lightness + 16) / 116.0 + + XYZ_D50.convert( + dest, + _convert_f_to_x_or_z(((a.nil? ? 0 : a) / 500.0) + f1) * Conversions::D50[0], + (if lightness > Utils::LAB_KAPPA * Utils::LAB_EPSILON + (((lightness + 16) / 116.0)**3) + else + lightness / Utils::LAB_KAPPA + end) * Conversions::D50[1], + _convert_f_to_x_or_z(f1 - ((b.nil? ? 0 : b) / 200.0)) * Conversions::D50[2], + alpha, + missing_lightness:, + missing_chroma:, + missing_hue:, + missing_a: a.nil?, + missing_b: b.nil? + ) + end + end + + private + + def _convert_f_to_x_or_z(component) + cubed = (component**3) + 0.0 + cubed > Utils::LAB_EPSILON ? cubed : ((116 * component) - 16) / Utils::LAB_KAPPA + end + end + + private_constant :Lab + + LAB = Lab.new + end + end + end +end diff --git a/lib/sass/value/color/space/lch.rb b/lib/sass/value/color/space/lch.rb new file mode 100644 index 00000000..b375deb7 --- /dev/null +++ b/lib/sass/value/color/space/lch.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/lch.dart + class Lch + include Space + + def bounded? + false + end + + def polar? + true + end + + def initialize + super('lch', [ + LinearChannel.new('lightness', 0, 100, lower_clamped: true, upper_clamped: true).freeze, + LinearChannel.new('chroma', 0, 150, lower_clamped: true).freeze, + Utils::HUE_CHANNEL + ].freeze) + end + + def convert(dest, lightness, chroma, hue, alpha) + missing_chroma = chroma.nil? + missing_hue = hue.nil? + chroma = 0 if missing_chroma + hue = 0 if missing_hue + + hue_radians = hue * Math::PI / 180 + LAB.convert( + dest, + lightness, + chroma * Math.cos(hue_radians), + chroma * Math.sin(hue_radians), + alpha, + missing_chroma:, + missing_hue: + ) + end + end + + private_constant :Lch + + LCH = Lch.new + end + end + end +end diff --git a/lib/sass/value/color/space/lms.rb b/lib/sass/value/color/space/lms.rb new file mode 100644 index 00000000..97444a9c --- /dev/null +++ b/lib/sass/value/color/space/lms.rb @@ -0,0 +1,133 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/lms.dart + class Lms + include Space + + def bounded? + false + end + + def initialize + super('lms', [ + LinearChannel.new('long', 0, 1).freeze, + LinearChannel.new('medium', 0, 1).freeze, + LinearChannel.new('short', 0, 1).freeze + ].freeze) + end + + def convert(dest, long, medium, short, alpha, + missing_lightness: false, + missing_chroma: false, + missing_hue: false, + missing_a: false, + missing_b: false) + case dest + when OKLAB + long_scaled = _cube_root_preserving_sign(long.nil? ? 0 : long) + medium_scaled = _cube_root_preserving_sign(medium.nil? ? 0 : medium) + short_scaled = _cube_root_preserving_sign(short.nil? ? 0 : short) + + Color.send( + :_for_space, + dest, + unless missing_lightness + (Conversions::LMS_TO_OKLAB[0] * long_scaled) + + (Conversions::LMS_TO_OKLAB[1] * medium_scaled) + + (Conversions::LMS_TO_OKLAB[2] * short_scaled) + end, + unless missing_a + (Conversions::LMS_TO_OKLAB[3] * long_scaled) + + (Conversions::LMS_TO_OKLAB[4] * medium_scaled) + + (Conversions::LMS_TO_OKLAB[5] * short_scaled) + end, + unless missing_b + (Conversions::LMS_TO_OKLAB[6] * long_scaled) + + (Conversions::LMS_TO_OKLAB[7] * medium_scaled) + + (Conversions::LMS_TO_OKLAB[8] * short_scaled) + end, + alpha + ) + when OKLCH + long_scaled = _cube_root_preserving_sign(long.nil? ? 0 : long) + medium_scaled = _cube_root_preserving_sign(medium.nil? ? 0 : medium) + short_scaled = _cube_root_preserving_sign(short.nil? ? 0 : short) + + Utils.lab_to_lch( + dest, + unless missing_lightness + (Conversions::LMS_TO_OKLAB[0] * long_scaled) + + (Conversions::LMS_TO_OKLAB[1] * medium_scaled) + + (Conversions::LMS_TO_OKLAB[2] * short_scaled) + end, + unless missing_a + (Conversions::LMS_TO_OKLAB[3] * long_scaled) + + (Conversions::LMS_TO_OKLAB[4] * medium_scaled) + + (Conversions::LMS_TO_OKLAB[5] * short_scaled) + end, + unless missing_b + (Conversions::LMS_TO_OKLAB[6] * long_scaled) + + (Conversions::LMS_TO_OKLAB[7] * medium_scaled) + + (Conversions::LMS_TO_OKLAB[8] * short_scaled) + end, + alpha + ) + else + convert_linear(dest, long, medium, short, alpha, + missing_lightness:, + missing_chroma:, + missing_hue:, + missing_a:, + missing_b:) + end + end + + def to_linear(channel) + channel + end + + def from_linear(channel) + channel + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::LMS_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::LMS_TO_LINEAR_DISPLAY_P3 + when PROPHOTO_RGB + Conversions::LMS_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::LMS_TO_LINEAR_REC2020 + when RGB, SRGB, SRGB_LINEAR + Conversions::LMS_TO_LINEAR_SRGB + when XYZ_D50 + Conversions::LMS_TO_XYZ_D50 + when XYZ_D65 + Conversions::LMS_TO_XYZ_D65 + else + super + end + end + + def _cube_root_preserving_sign(number) + (number.abs**(1 / 3.0)) * FuzzyMath.sign(number) + end + end + + private_constant :Lms + + LMS = Lms.new + + private_constant :LMS + end + end + end +end diff --git a/lib/sass/value/color/space/oklab.rb b/lib/sass/value/color/space/oklab.rb new file mode 100644 index 00000000..563e83aa --- /dev/null +++ b/lib/sass/value/color/space/oklab.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/oklab.dart + class Oklab + include Space + + def bounded? + false + end + + def initialize + super('oklab', [ + LinearChannel.new('lightness', 0, 1, + conventionally_percent: true, lower_clamped: true, upper_clamped: true).freeze, + LinearChannel.new('a', -0.4, 0.4).freeze, + LinearChannel.new('b', -0.4, 0.4).freeze + ].freeze) + end + + def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParameterName + missing_chroma: false, missing_hue: false) + case dest + when OKLCH + Utils.lab_to_lch(dest, lightness, a, b, alpha) + else + missing_lightness = lightness.nil? + missing_a = a.nil? + missing_b = b.nil? + lightness = 0 if missing_lightness + a = 0 if missing_a + b = 0 if missing_b + LMS.convert( + dest, + (( + (Conversions::OKLAB_TO_LMS[0] * lightness) + + (Conversions::OKLAB_TO_LMS[1] * a) + + (Conversions::OKLAB_TO_LMS[2] * b) + )**3) + 0.0, + (( + (Conversions::OKLAB_TO_LMS[3] * lightness) + + (Conversions::OKLAB_TO_LMS[4] * a) + + (Conversions::OKLAB_TO_LMS[5] * b) + )**3) + 0.0, + (( + (Conversions::OKLAB_TO_LMS[6] * lightness) + + (Conversions::OKLAB_TO_LMS[7] * a) + + (Conversions::OKLAB_TO_LMS[8] * b) + )**3) + 0.0, + alpha, + missing_lightness:, + missing_chroma:, + missing_hue:, + missing_a:, + missing_b: + ) + end + end + end + + private_constant :Oklab + + OKLAB = Oklab.new + end + end + end +end diff --git a/lib/sass/value/color/space/oklch.rb b/lib/sass/value/color/space/oklch.rb new file mode 100644 index 00000000..645f7118 --- /dev/null +++ b/lib/sass/value/color/space/oklch.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/oklch.dart + class Oklch + include Space + + def bounded? + false + end + + def polar? + true + end + + def initialize + super('oklch', [ + LinearChannel.new('lightness', 0, 1, + conventionally_percent: true, lower_clamped: true, upper_clamped: true).freeze, + LinearChannel.new('chroma', 0, 0.4, lower_clamped: true).freeze, + Utils::HUE_CHANNEL + ].freeze) + end + + def convert(dest, lightness, chroma, hue, alpha) + missing_chroma = chroma.nil? + missing_hue = hue.nil? + chroma = 0 if missing_chroma + hue = 0 if missing_hue + + hue_radians = hue * Math::PI / 180 + OKLAB.convert( + dest, + lightness, + chroma * Math.cos(hue_radians), + chroma * Math.sin(hue_radians), + alpha, + missing_chroma:, + missing_hue: + ) + end + end + + private_constant :Oklch + + OKLCH = Oklch.new + end + end + end +end diff --git a/lib/sass/value/color/space/prophoto_rgb.rb b/lib/sass/value/color/space/prophoto_rgb.rb new file mode 100644 index 00000000..88ac5947 --- /dev/null +++ b/lib/sass/value/color/space/prophoto_rgb.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/prophoto_rgb.dart + class ProphotoRgb + include Space + + def bounded? + true + end + + def initialize + super('prophoto-rgb', Utils::RGB_CHANNELS) + end + + def to_linear(channel) + abs = channel.abs + abs <= 16 / 512.0 ? channel / 16.0 : FuzzyMath.sign(channel) * (abs**1.8) + end + + def from_linear(channel) + abs = channel.abs + abs >= 1 / 512.0 ? FuzzyMath.sign(channel) * (abs**(1 / 1.8)) : 16 * channel + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::LINEAR_PROPHOTO_RGB_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::LINEAR_PROPHOTO_RGB_TO_LINEAR_DISPLAY_P3 + when LMS + Conversions::LINEAR_PROPHOTO_RGB_TO_LMS + when REC2020 + Conversions::LINEAR_PROPHOTO_RGB_TO_LINEAR_REC2020 + when RGB, SRGB, SRGB_LINEAR + Conversions::LINEAR_PROPHOTO_RGB_TO_LINEAR_SRGB + when XYZ_D50 + Conversions::LINEAR_PROPHOTO_RGB_TO_XYZ_D50 + when XYZ_D65 + Conversions::LINEAR_PROPHOTO_RGB_TO_XYZ_D65 + else + super + end + end + end + + private_constant :ProphotoRgb + + PROPHOTO_RGB = ProphotoRgb.new + end + end + end +end diff --git a/lib/sass/value/color/space/rec2020.rb b/lib/sass/value/color/space/rec2020.rb new file mode 100644 index 00000000..4d3febfa --- /dev/null +++ b/lib/sass/value/color/space/rec2020.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/rec2020.dart + class Rec2020 + include Space + + # A constant used in the rec2020 gamma encoding/decoding functions. + ALPHA = 1.09929682680944 + + private_constant :ALPHA + + # A constant used in the rec2020 gamma encoding/decoding functions. + BETA = 0.018053968510807 + + private_constant :BETA + + def bounded? + true + end + + def initialize + super('rec2020', Utils::RGB_CHANNELS) + end + + def to_linear(channel) + abs = channel.abs + abs < BETA * 4.5 ? channel / 4.5 : FuzzyMath.sign(channel) * (((abs + ALPHA - 1) / ALPHA)**(1 / 0.45)) + end + + def from_linear(channel) + abs = channel.abs + abs > BETA ? FuzzyMath.sign(channel) * ((ALPHA * (abs**0.45)) - (ALPHA - 1)) : 4.5 * channel + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::LINEAR_REC2020_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::LINEAR_REC2020_TO_LINEAR_DISPLAY_P3 + when LMS + Conversions::LINEAR_REC2020_TO_LMS + when PROPHOTO_RGB + Conversions::LINEAR_REC2020_TO_LINEAR_PROPHOTO_RGB + when RGB, SRGB, SRGB_LINEAR + Conversions::LINEAR_REC2020_TO_LINEAR_SRGB + when XYZ_D50 + Conversions::LINEAR_REC2020_TO_XYZ_D50 + when XYZ_D65 + Conversions::LINEAR_REC2020_TO_XYZ_D65 + else + super + end + end + end + + private_constant :Rec2020 + + REC2020 = Rec2020.new + end + end + end +end diff --git a/lib/sass/value/color/space/rgb.rb b/lib/sass/value/color/space/rgb.rb new file mode 100644 index 00000000..a872e0c3 --- /dev/null +++ b/lib/sass/value/color/space/rgb.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/rgb.dart + class Rgb + include Space + + def bounded? + true + end + + def legacy? + true + end + + def initialize + super('rgb', [ + LinearChannel.new('red', 0, 255, lower_clamped: true, upper_clamped: true).freeze, + LinearChannel.new('green', 0, 255, lower_clamped: true, upper_clamped: true).freeze, + LinearChannel.new('blue', 0, 255, lower_clamped: true, upper_clamped: true).freeze + ].freeze) + end + + def convert(dest, red, green, blue, alpha) + SRGB.convert( + dest, + red.nil? ? nil : red / 255.0, + green.nil? ? nil : green / 255.0, + blue.nil? ? nil : blue / 255.0, + alpha + ) + end + + def to_linear(channel) + Utils.srgb_and_display_p3_to_linear(channel / 255.0) + end + + def from_linear(channel) + Utils.srgb_and_display_p3_from_linear(channel) * 255 + end + end + + private_constant :Rgb + + RGB = Rgb.new + end + end + end +end diff --git a/lib/sass/value/color/space/srgb.rb b/lib/sass/value/color/space/srgb.rb new file mode 100644 index 00000000..624081d4 --- /dev/null +++ b/lib/sass/value/color/space/srgb.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/srgb.dart + class Srgb + include Space + + def bounded? + true + end + + def initialize + super('srgb', Utils::RGB_CHANNELS) + end + + def convert(dest, red, green, blue, alpha, + missing_lightness: false, + missing_chroma: false, + missing_hue: false) + case dest + when HSL, HWB + red = 0 if red.nil? + green = 0 if green.nil? + blue = 0 if blue.nil? + + max = [red, green, blue].max + min = [red, green, blue].min + delta = max - min + + hue = if max == min + 0.0 + elsif max == red + (60.0 * (green - blue) / delta) + 360 + elsif max == green + (60.0 * (blue - red) / delta) + 120 + else # max == blue + (60.0 * (red - green) / delta) + 240 + end + + if dest == HSL + lightness = (min + max) / 2.0 + + saturation = if [0, 1].include?(lightness) + 0.0 + else + 100.0 * (max - lightness) / [lightness, 1 - lightness].min + end + if saturation.negative? + hue += 180 + saturation = saturation.abs + end + + Color.send( + :for_space_internal, + dest, + missing_hue || FuzzyMath.equals(saturation, 0) ? nil : hue % 360, + missing_chroma ? nil : saturation, + missing_lightness ? nil : lightness * 100, + alpha + ) + else + whiteness = min * 100 + blackness = 100 - (max * 100) + + Color.send( + :for_space_internal, + dest, + missing_hue || FuzzyMath.greater_than_or_equals(whiteness + blackness, 100) ? nil : hue % 360, + whiteness, + blackness, + alpha + ) + end + when RGB + Color.send( + :_for_space, + dest, + red.nil? ? nil : red * 255, + green.nil? ? nil : green * 255, + blue.nil? ? nil : blue * 255, + alpha + ) + when SRGB_LINEAR + Color.send( + :_for_space, + dest, + red.nil? ? nil : to_linear(red), + green.nil? ? nil : to_linear(green), + blue.nil? ? nil : to_linear(blue), + alpha + ) + else + convert_linear(dest, red, green, blue, alpha, + missing_lightness:, + missing_chroma:, + missing_hue:) + end + end + + def to_linear(channel) + Utils.srgb_and_display_p3_to_linear(channel) + end + + def from_linear(channel) + Utils.srgb_and_display_p3_from_linear(channel) + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::LINEAR_SRGB_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 + when LMS + Conversions::LINEAR_SRGB_TO_LMS + when PROPHOTO_RGB + Conversions::LINEAR_SRGB_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::LINEAR_SRGB_TO_LINEAR_REC2020 + when XYZ_D50 + Conversions::LINEAR_SRGB_TO_XYZ_D50 + when XYZ_D65 + Conversions::LINEAR_SRGB_TO_XYZ_D65 + else + super + end + end + end + + private_constant :Srgb + + SRGB = Srgb.new + end + end + end +end diff --git a/lib/sass/value/color/space/srgb_linear.rb b/lib/sass/value/color/space/srgb_linear.rb new file mode 100644 index 00000000..6662342b --- /dev/null +++ b/lib/sass/value/color/space/srgb_linear.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/srgb_linear.dart + class SrgbLinear + include Space + + def bounded? + true + end + + def initialize + super('srgb-linear', Utils::RGB_CHANNELS) + end + + def convert(dest, red, green, blue, alpha) + case dest + when HSL, HWB, RGB, SRGB + SRGB.convert( + dest, + red.nil? ? nil : Utils.srgb_and_display_p3_from_linear(red), + green.nil? ? nil : Utils.srgb_and_display_p3_from_linear(green), + blue.nil? ? nil : Utils.srgb_and_display_p3_from_linear(blue), + alpha + ) + else + super + end + end + + def to_linear(channel) + channel + end + + def from_linear(channel) + channel + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::LINEAR_SRGB_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 + when PROPHOTO_RGB + Conversions::LINEAR_SRGB_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::LINEAR_SRGB_TO_LINEAR_REC2020 + when XYZ_D65 + Conversions::LINEAR_SRGB_TO_XYZ_D65 + when XYZ_D50 + Conversions::LINEAR_SRGB_TO_XYZ_D50 + when LMS + Conversions::LINEAR_SRGB_TO_LMS + else + super + end + end + end + + private_constant :SrgbLinear + + SRGB_LINEAR = SrgbLinear.new + end + end + end +end diff --git a/lib/sass/value/color/space/utils.rb b/lib/sass/value/color/space/utils.rb new file mode 100644 index 00000000..f91854c0 --- /dev/null +++ b/lib/sass/value/color/space/utils.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/utils.dart + module Utils + module_function + + # A constant used to convert Lab to/from XYZ. + LAB_KAPPA = Rational(24_389, 27) # 29^3/3^3 + + # A constant used to convert Lab to/from XYZ. + LAB_EPSILON = Rational(216, 24_389) # 6^3/29^3 + + # The hue channel shared across all polar color spaces. + HUE_CHANNEL = ColorChannel.new('hue', polar_angle: true, associated_unit: 'deg').freeze + + # The color channels shared across all RGB color spaces (except the legacy RGB space). + RGB_CHANNELS = [ + LinearChannel.new('red', 0, 1).freeze, + LinearChannel.new('green', 0, 1).freeze, + LinearChannel.new('blue', 0, 1).freeze + ].freeze + + # The color channels shared across both XYZ color spaces. + XYZ_CHANNELS = [ + LinearChannel.new('x', 0, 1).freeze, + LinearChannel.new('y', 0, 1).freeze, + LinearChannel.new('z', 0, 1).freeze + ].freeze + + # Converts a legacy HSL/HWB hue to an RGB channel. + # + # The algorithm comes from from the CSS3 spec: + # http://www.w3.org/TR/css3-color/#hsl-color. + # @param m1 [Numeric] + # @param m2 [Numeric] + # @param hue [Numeric] + # @return [Numeric] + def hue_to_rgb(m1, m2, hue) # rubocop:disable Naming/MethodParameterName + hue += 1 if hue.negative? + hue -= 1 if hue > 1 + + if hue < 1 / 6.0 + m1 + ((m2 - m1) * hue * 6) + elsif hue < 1 / 2.0 + m2 + elsif hue < 2 / 3.0 + m1 + ((m2 - m1) * ((2 / 3.0) - hue) * 6) + else + m1 + end + end + + # The algorithm for converting a single `srgb` or `display-p3` channel to + # linear-light form. + # @param [Numeric] + # @return [Numeric] + def srgb_and_display_p3_to_linear(channel) + abs = channel.abs + abs < 0.04045 ? channel / 12.92 : FuzzyMath.sign(channel) * (((abs + 0.055) / 1.055)**2.4) + end + + # The algorithm for converting a single `srgb` or `display-p3` channel to + # gamma-corrected form. + # @param [Numeric] + # @return [Numeric] + def srgb_and_display_p3_from_linear(channel) + abs = channel.abs + abs <= 0.0031308 ? channel * 12.92 : FuzzyMath.sign(channel) * ((1.055 * (abs**(1 / 2.4))) - 0.055) + end + + # Converts a Lab or OKLab color to LCH or OKLCH, respectively. + # + # The [missing_chroma] and [missing_hue] arguments indicate whether this came + # from a color that was missing its chroma or hue channels, respectively. + # @param dest [Space] + # @param lightness [Numeric] + # @param a [Numeric] + # @param b [Numeric] + # @param alpha [Numeric] + # @return [Color] + def lab_to_lch(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParameterName + missing_chroma: false, missing_hue: false) + chroma = Math.sqrt(((a.nil? ? 0 : a)**2) + ((b.nil? ? 0 : b)**2)) + hue = if missing_hue || FuzzyMath.equals(chroma, 0) + nil + else + Math.atan2(b.nil? ? 0 : b, a.nil? ? 0 : a) * 180 / Math::PI + end + + Color.send( + :for_space_internal, + dest, + lightness, + missing_chroma ? nil : chroma, + hue.nil? || hue >= 0 ? hue : hue + 360, + alpha + ) + end + end + + private_constant :Utils + end + end + end +end diff --git a/lib/sass/value/color/space/xyz_d50.rb b/lib/sass/value/color/space/xyz_d50.rb new file mode 100644 index 00000000..f6cc11c0 --- /dev/null +++ b/lib/sass/value/color/space/xyz_d50.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/xyz_d50.dart + class XyzD50 + include Space + + def bounded? + false + end + + def initialize + super('xyz-d50', Utils::XYZ_CHANNELS) + end + + def convert(dest, x, y, z, alpha, # rubocop:disable Naming/MethodParameterName + missing_lightness: false, + missing_chroma: false, + missing_hue: false, + missing_a: false, + missing_b: false) + case dest + when LAB, LCH + f0 = _convert_component_to_lab_f((x.nil? ? 0 : x) / Conversions::D50[0]) + f1 = _convert_component_to_lab_f((y.nil? ? 0 : y) / Conversions::D50[1]) + f2 = _convert_component_to_lab_f((z.nil? ? 0 : z) / Conversions::D50[2]) + lightness = missing_lightness ? nil : (116 * f1) - 16 + a = 500 * (f0 - f1) + b = 200 * (f1 - f2) + + if dest == LAB + Color.send(:_for_space, + dest, + lightness, + missing_a ? nil : a, + missing_b ? nil : b, + alpha) + else + Utils.lab_to_lch(dest, lightness, a, b, alpha, missing_chroma:, missing_hue:) + end + else + convert_linear(dest, x, y, z, alpha, + missing_lightness:, + missing_chroma:, + missing_hue:, + missing_a:, + missing_b:) + end + end + + def to_linear(channel) + channel + end + + def from_linear(channel) + channel + end + + private + + def _convert_component_to_lab_f(component) + if component > Utils::LAB_EPSILON + (component**(1 / 3.0)) + 0.0 + else + ((Utils::LAB_KAPPA * component) + 16) / 116.0 + end + end + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::XYZ_D50_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::XYZ_D50_TO_LINEAR_DISPLAY_P3 + when LMS + Conversions::XYZ_D50_TO_LMS + when PROPHOTO_RGB + Conversions::XYZ_D50_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::XYZ_D50_TO_LINEAR_REC2020 + when RGB, SRGB, SRGB_LINEAR + Conversions::XYZ_D50_TO_LINEAR_SRGB + when XYZ_D65 + Conversions::XYZ_D50_TO_XYZ_D65 + else + super + end + end + end + + private_constant :XyzD50 + + XYZ_D50 = XyzD50.new + end + end + end +end diff --git a/lib/sass/value/color/space/xyz_d65.rb b/lib/sass/value/color/space/xyz_d65.rb new file mode 100644 index 00000000..33a83dfd --- /dev/null +++ b/lib/sass/value/color/space/xyz_d65.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Sass + module Value + class Color + module Space + # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/xyz_d65.dart + class XyzD65 + include Space + + def bounded? + false + end + + def initialize + super('xyz', Utils::XYZ_CHANNELS) + end + + def to_linear(channel) + channel + end + + def from_linear(channel) + channel + end + + private + + def transformation_matrix(dest) + case dest + when A98_RGB + Conversions::XYZ_D65_TO_LINEAR_A98_RGB + when DISPLAY_P3 + Conversions::XYZ_D65_TO_LINEAR_DISPLAY_P3 + when LMS + Conversions::XYZ_D65_TO_LMS + when PROPHOTO_RGB + Conversions::XYZ_D65_TO_LINEAR_PROPHOTO_RGB + when REC2020 + Conversions::XYZ_D65_TO_LINEAR_REC2020 + when RGB, SRGB, SRGB_LINEAR + Conversions::XYZ_D65_TO_LINEAR_SRGB + when XYZ_D50 + Conversions::XYZ_D65_TO_XYZ_D50 + else + super + end + end + end + + private_constant :XyzD65 + + XYZ_D65 = XyzD65.new + end + end + end +end diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index 5fc6bc63..c4ada5dd 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -6,14 +6,27 @@ module Value module FuzzyMath PRECISION = 10 - EPSILON = 10.pow(-PRECISION - 1) + EPSILON = 10**(-PRECISION - 1) - INVERSE_EPSILON = 1 / EPSILON + INVERSE_EPSILON = 10**(PRECISION + 1) module_function def equals(number1, number2) - (number1 - number2).abs < EPSILON + return true if number1 == number2 + + (number1 - number2).abs <= EPSILON && + (number1 * INVERSE_EPSILON).round == + (number2 * INVERSE_EPSILON).round + end + + def equals_nilable(number1, number2) + return true if number1 == number2 + return false if number1.nil? || number2.nil? + + (number1 - number2).abs <= EPSILON && + (number1 * INVERSE_EPSILON).round == + (number2 * INVERSE_EPSILON).round end def less_than(number1, number2) @@ -51,6 +64,16 @@ def round(number) end end + def sign(number) + if number.positive? + 1 + elsif number.negative? + -1 + else + 0 + end + end + def between(number, min, max) return min if equals(number, min) return max if equals(number, max) @@ -66,6 +89,10 @@ def assert_between(number, min, max, name) raise Sass::ScriptError.new("#{number} must be between #{min} and #{max}.", name) end + def clamp_like_css(number, lower_bound, upper_bound) + number.to_f.nan? ? lower_bound : number.clamp(lower_bound, upper_bound) + end + def hash(number) if number.finite? (number * INVERSE_EPSILON).round.hash diff --git a/lib/sass/value/string.rb b/lib/sass/value/string.rb index 1738355d..618dc762 100644 --- a/lib/sass/value/string.rb +++ b/lib/sass/value/string.rb @@ -52,7 +52,7 @@ def sass_index_to_string_index(sass_index, name = nil) index.negative? ? text.length + index : index - 1 end - # @return [String] + # @return [::String] def to_s @quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text) end diff --git a/spec/sass/value/color/constructors.rb b/spec/sass/value/color/constructors.rb new file mode 100644 index 00000000..de084d72 --- /dev/null +++ b/spec/sass/value/color/constructors.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/constructors.ts +module ColorConstructors + module_function + + def _alpha_to_kwargs(*args) + case args.length + when 0 + {} + when 1 + { alpha: args[0] } + else + raise ArgumentError + end + end + + def legacy_rgb(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args)) + end + + def rgb(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'rgb') + end + + def legacy_hsl(hue, saturation, lightness, *args) + Sass::Value::Color.new(hue:, saturation:, lightness:, **_alpha_to_kwargs(*args)) + end + + def hsl(hue, saturation, lightness, *args) + Sass::Value::Color.new(hue:, saturation:, lightness:, **_alpha_to_kwargs(*args), space: 'hsl') + end + + def legacy_hwb(hue, whiteness, blackness, *args) + Sass::Value::Color.new(hue:, whiteness:, blackness:, **_alpha_to_kwargs(*args)) + end + + def hwb(hue, whiteness, blackness, *args) + Sass::Value::Color.new(hue:, whiteness:, blackness:, **_alpha_to_kwargs(*args), space: 'hwb') + end + + def lab(lightness, a, b, *args) # rubocop:disable Naming/MethodParameterName + Sass::Value::Color.new(lightness:, a:, b:, **_alpha_to_kwargs(*args), space: 'lab') + end + + def oklab(lightness, a, b, *args) # rubocop:disable Naming/MethodParameterName + Sass::Value::Color.new(lightness:, a:, b:, **_alpha_to_kwargs(*args), space: 'oklab') + end + + def lch(lightness, chroma, hue, *args) + Sass::Value::Color.new(lightness:, chroma:, hue:, **_alpha_to_kwargs(*args), space: 'lch') + end + + def oklch(lightness, chroma, hue, *args) + Sass::Value::Color.new(lightness:, chroma:, hue:, **_alpha_to_kwargs(*args), space: 'oklch') + end + + def srgb(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'srgb') + end + + def srgb_linear(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'srgb-linear') + end + + def rec2020(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'rec2020') + end + + def display_p3(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'display-p3') + end + + def a98_rgb(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'a98-rgb') + end + + def prophoto_rgb(red, green, blue, *args) + Sass::Value::Color.new(red:, green:, blue:, **_alpha_to_kwargs(*args), space: 'prophoto-rgb') + end + + def xyz(x, y, z, *args) # rubocop:disable Naming/MethodParameterName + Sass::Value::Color.new(x:, y:, z:, **_alpha_to_kwargs(*args), space: 'xyz') + end + + def xyz_d50(x, y, z, *args) # rubocop:disable Naming/MethodParameterName + Sass::Value::Color.new(x:, y:, z:, **_alpha_to_kwargs(*args), space: 'xyz-d50') + end + + def xyz_d65(x, y, z, *args) # rubocop:disable Naming/MethodParameterName + Sass::Value::Color.new(x:, y:, z:, **_alpha_to_kwargs(*args), space: 'xyz-d65') + end +end diff --git a/spec/sass/value/color/interpolation_examples.rb b/spec/sass/value/color/interpolation_examples.rb new file mode 100644 index 00000000..68467b1d --- /dev/null +++ b/spec/sass/value/color/interpolation_examples.rb @@ -0,0 +1,437 @@ +# frozen_string_literal: true + +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/interpolation-examples.ts +COLOR_INTERPOLATIONS = { + lab: [ + [ + { + weight: 0.5 + }, + [58.614201646094955, 10.016665992350433, -8.387820174394456] + ], + [ + { + weight: 1 + }, + [78.27047872644108, 35.20288139978972, 1.0168442562642044] + ], + [ + { + weight: 0 + }, + [38.95792456574883, -15.169549415088852, -17.792484605053115] + ] + ], + oklab: [ + [ + { + weight: 0.5 + }, + [0.6476500020040917, 0.02748550994678843, -0.023408287379941606] + ], + [ + { + weight: 1 + }, + [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446] + ], + [ + { + weight: 0 + }, + [0.47120000400818335, -0.05111706453373946, -0.048406651029280656] + ] + ], + lch: [ + [ + { + weight: 0.5 + }, + [58.61420164622054, 29.299459370089924, 295.6021177856686] + ], + [ + { + weight: 1 + }, + [78.27047872644108, 35.21756424128674, 1.6545432253797685] + ], + [ + { + weight: 0 + }, + [38.957924566, 23.38135449889311, 229.5496923459574] + ], + [ + { + weight: 0.5, + method: 'shorter' + }, + [58.61420164622054, 29.299459370089924, 295.6021177856686] + ], + [ + { + weight: 0.5, + method: 'longer' + }, + [58.61420164622054, 29.299459370089924, 115.60211778566858] + ], + [ + { + weight: 0.5, + method: 'increasing' + }, + [58.61420164622054, 29.299459370089924, 115.60211778566858] + ], + [ + { + weight: 0.5, + method: 'decreasing' + }, + [58.61420164622054, 29.299459370089924, 295.6021177856686] + ] + ], + oklch: [ + [ + { + weight: 0.5 + }, + [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + ], + [ + { + weight: 1 + }, + [0.8241, 0.1061, 0.8586999999999989] + ], + [ + { + weight: 0 + }, + [0.47120000400818335, 0.07039998686375618, 223.4400011847514] + ], + [ + { + weight: 0.5, + method: 'shorter' + }, + [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + ], + [ + { + weight: 0.5, + method: 'longer' + }, + [0.6476500020040917, 0.08824999343187809, 112.1493505923757] + ], + [ + { + weight: 0.5, + method: 'increasing' + }, + [0.6476500020040917, 0.08824999343187809, 112.1493505923757] + ], + [ + { + weight: 0.5, + method: 'decreasing' + }, + [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + ] + ], + srgb: [ + [ + { + weight: 0.5 + }, + [0.5744899843543774, 0.5252921410815925, 0.6147851204581418] + ], + [ + { + weight: 1 + }, + [0.9999785463111585, 0.6599448662991679, 0.758373017125016] + ], + [ + { + weight: 0 + }, + [0.14900142239759617, 0.39063941586401707, 0.47119722379126755] + ] + ], + 'srgb-linear': [ + [ + { + weight: 0.5 + }, + [0.5096647054609955, 0.25972630442483197, 0.36200193586790025] + ], + [ + { + weight: 1 + }, + [0.999951196094508, 0.3930503811476254, 0.5356603778005655] + ], + [ + { + weight: 0 + }, + [0.01937821482748292, 0.12640222770203852, 0.18834349393523497] + ] + ], + 'display-p3': [ + [ + { + weight: 0.5 + }, + [0.5836172975616658, 0.530184139982079, 0.609686907635745] + ], + [ + { + weight: 1 + }, + [0.9510333333617188, 0.6749909745845027, 0.7568568353546363] + ], + [ + { + weight: 0 + }, + [0.2162012617616128, 0.38537730537965537, 0.46251697991685353] + ] + ], + 'a98-rgb': [ + [ + { + weight: 0.5 + }, + [0.5865373142666512, 0.5222346343208055, 0.6071485436534567] + ], + [ + { + weight: 1 + }, + [0.9172837001828321, 0.6540226622083835, 0.7491144397116841] + ], + [ + { + weight: 0 + }, + [0.25579092835047035, 0.3904466064332277, 0.4651826475952292] + ] + ], + 'prophoto-rgb': [ + [ + { + weight: 0.5 + }, + [0.5427623847027483, 0.4757813439417372, 0.5419635636962455] + ], + [ + { + weight: 1 + }, + [0.842345736209146, 0.6470539622987257, 0.7003583323790157] + ], + [ + { + weight: 0 + }, + [0.2431790331963506, 0.3045087255847488, 0.38356879501347535] + ] + ], + rec2020: [ + [ + { + weight: 0.5 + }, + [0.5494120530883964, 0.4907232619435038, 0.5681615893671463] + ], + [ + { + weight: 1 + }, + [0.8837118321235519, 0.6578067923850563, 0.7273197917658354] + ], + [ + { + weight: 0 + }, + [0.21511227405324085, 0.32363973150195124, 0.4090033869684574] + ] + ], + xyz: [ + [ + { + weight: 0.5 + }, + [0.36838948901950813, 0.3202564721891328, 0.38490473490885063] + ], + [ + { + weight: 1 + }, + [0.6495957411726918, 0.5323965129525022, 0.575341840710865] + ], + [ + { + weight: 0 + }, + [0.08718323686632445, 0.10811643142576338, 0.19446762910683624] + ] + ], + 'xyz-d50': [ + [ + { + weight: 0.5 + }, + [0.3740759617070767, 0.3215358224064546, 0.2908164562135577] + ], + [ + { + weight: 1 + }, + [0.6640698533004002, 0.5367266625281085, 0.4345958246720296] + ], + [ + { + weight: 0 + }, + [0.08408207011375313, 0.10634498228480066, 0.14703708775508573] + ] + ], + rgb: [ + [ + { + weight: 0.5 + }, + [146.56944672156501, 134.1448156837381, 157.00580432872178] + ], + [ + { + weight: 1 + }, + [254.9945293093454, 168.28594090628783, 193.38511936687908] + ], + [ + { + weight: 0 + }, + [38.14436413378462, 100.00369046118837, 120.62648929056449] + ] + ], + hsl: [ + [ + { + weight: 0.5 + }, + [268.816848125996, 75.96890150160368, 57.00305146997975] + ], + [ + { + weight: 1 + }, + [342.6320467744765, 99.98738302509669, 82.99617063051632] + ], + [ + { + weight: 0 + }, + [195.00164947751546, 51.95041997811069, 31.009932309443187] + ], + [ + { + weight: 0.5, + method: 'shorter' + }, + [268.816848125996, 75.96890150160368, 57.00305146997975] + ], + [ + { + weight: 0.5, + method: 'longer' + }, + [88.816848125996, 75.96890150160368, 57.00305146997975] + ], + [ + { + weight: 0.5, + method: 'increasing' + }, + [88.816848125996, 75.96890150160368, 57.00305146997975] + ], + [ + { + weight: 0.5, + method: 'decreasing' + }, + [268.816848125996, 75.96890150160368, 57.00305146997975] + ] + ], + hwb: [ + [ + { + weight: 0.5 + }, + [268.816848125996, 40.447314434838205, 26.4412114948787] + ], + [ + { + weight: 1 + }, + [342.6320467744765, 65.99448662991679, 0.002145368884157506] + ], + [ + { + weight: 0 + }, + [195.00164947751546, 14.90014223975961, 52.880277620873244] + ], + [ + { + weight: 0.5, + method: 'shorter' + }, + [268.816848125996, 40.447314434838205, 26.4412114948787] + ], + [ + { + weight: 0.5, + method: 'longer' + }, + [88.816848125996, 40.447314434838205, 26.4412114948787] + ], + [ + { + weight: 0.5, + method: 'increasing' + }, + [88.816848125996, 40.447314434838205, 26.4412114948787] + ], + [ + { + weight: 0.5, + method: 'decreasing' + }, + [268.816848125996, 40.447314434838205, 26.4412114948787] + ] + ], + 'xyz-d65': [ + [ + { + weight: 0.5 + }, + [0.36838948901950813, 0.3202564721891328, 0.38490473490885063] + ], + [ + { + weight: 1 + }, + [0.6495957411726918, 0.5323965129525022, 0.575341840710865] + ], + [ + { + weight: 0 + }, + [0.08718323686632445, 0.10811643142576338, 0.19446762910683624] + ] + ] +}.freeze diff --git a/spec/sass/value/color/spaces.rb b/spec/sass/value/color/spaces.rb new file mode 100644 index 00000000..c5bcd9ed --- /dev/null +++ b/spec/sass/value/color/spaces.rb @@ -0,0 +1,346 @@ +# frozen_string_literal: true + +require_relative 'constructors' + +# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/spaces.ts +COLOR_SPACES = { + lab: { + constructor: :lab, + name: 'lab', + is_legacy: false, + is_polar: false, + pink: [78.27047872644108, 35.20288139978972, 1.0168442562642044], + blue: [38.95792456574883, -15.169549415088856, -17.792484605053115], + channels: %w[lightness a b], + ranges: [ + [0, 100], + [-125, 125], + [-125, 125] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [50, 150, 150], + [50, 150, 150] + ] + ] + }, + oklab: { + constructor: :oklab, + name: 'oklab', + is_legacy: false, + is_polar: false, + pink: [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446], + blue: [0.47120000400818335, -0.05111706453373946, -0.048406651029280656], + channels: %w[lightness a b], + ranges: [ + [0, 1], + [-0.4, 0.4], + [-0.4, 0.4] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [0.5, 1, 1], + [0.5, 1, 1] + ] + ] + }, + lch: { + constructor: :lch, + name: 'lch', + is_legacy: false, + is_polar: true, + pink: [78.27047872644108, 35.21756424128674, 1.6545432253797676], + blue: [38.957924566, 23.38135449889311, 229.54969234595737], + channels: %w[lightness chroma hue], + has_powerless: true, + ranges: [ + [0, 100], + [0, 150], + [0, 360] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [50, 200, 480], + [50, 200, 480] + ] + ] + }, + oklch: { + constructor: :oklch, + name: 'oklch', + is_legacy: false, + is_polar: true, + pink: [0.8241, 0.1061, 0.8587], + blue: [0.47120000400818335, 0.07039998686375618, 223.44000118475142], + channels: %w[lightness chroma hue], + has_powerless: true, + ranges: [ + [0, 1], + [0, 0.4], + [0, 360] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [0.5, 1, 480], + [0.5, 1, 480] + ] + ] + }, + srgb: { + constructor: :srgb, + name: 'srgb', + is_legacy: false, + is_polar: false, + pink: [0.9999785463111585, 0.6599448662991679, 0.758373017125016], + blue: [0.14900142239759614, 0.39063941586401707, 0.47119722379126755], + channels: %w[red green blue], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: true, + gamut_examples: [ + [[0.5, 2, 2], { clip: [0.5, 1, 1], 'local-minde': [1, 1, 1] }] + ] + }, + 'srgb-linear': { + constructor: :srgb_linear, + name: 'srgb-linear', + is_legacy: false, + is_polar: false, + pink: [0.999951196094508, 0.3930503811476254, 0.5356603778005655], + blue: [0.019378214827482948, 0.12640222770203852, 0.18834349393523495], + channels: %w[red green blue], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: true, + gamut_examples: [ + [[0.5, 2, 2], { clip: [0.5, 1, 1], 'local-minde': [1, 1, 1] }] + ] + }, + 'display-p3': { + constructor: :display_p3, + name: 'display-p3', + is_legacy: false, + is_polar: false, + pink: [0.9510333333617188, 0.6749909745845027, 0.7568568353546363], + blue: [0.21620126176161275, 0.38537730537965537, 0.46251697991685353], + channels: %w[red green blue], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: true, + gamut_examples: [ + [[0.5, 2, 2], { clip: [0.5, 1, 1], 'local-minde': [1, 1, 1] }] + ] + }, + 'a98-rgb': { + constructor: :a98_rgb, + name: 'a98-rgb', + is_legacy: false, + is_polar: false, + pink: [0.9172837001828321, 0.6540226622083835, 0.7491144397116841], + blue: [0.2557909283504703, 0.3904466064332277, 0.4651826475952292], + channels: %w[red green blue], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: true, + gamut_examples: [ + [[0.5, 2, 2], { clip: [0.5, 1, 1], 'local-minde': [1, 1, 1] }] + ] + }, + 'prophoto-rgb': { + constructor: :prophoto_rgb, + name: 'prophoto-rgb', + is_legacy: false, + is_polar: false, + pink: [0.842345736209146, 0.6470539622987257, 0.7003583323790157], + blue: [0.24317903319635056, 0.3045087255847488, 0.38356879501347535], + channels: %w[red green blue], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: true, + gamut_examples: [ + [[0.5, 2, 2], { clip: [0.5, 1, 1], 'local-minde': [1, 1, 1] }] + ] + }, + rec2020: { + constructor: :rec2020, + name: 'rec2020', + is_legacy: false, + is_polar: false, + pink: [0.8837118321235519, 0.6578067923850563, 0.7273197917658354], + blue: [0.2151122740532409, 0.32363973150195124, 0.4090033869684574], + channels: %w[red green blue], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: true, + gamut_examples: [ + [[0.5, 2, 2], { clip: [0.5, 1, 1], 'local-minde': [1, 1, 1] }] + ] + }, + xyz: { + constructor: :xyz, + name: 'xyz', + is_legacy: false, + is_polar: false, + pink: [0.6495957411726918, 0.5323965129525022, 0.575341840710865], + blue: [0.08718323686632441, 0.1081164314257634, 0.19446762910683627], + channels: %w[x y z], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [0.5, 2, 2], + [0.5, 2, 2] + ] + ] + }, + 'xyz-d50': { + constructor: :xyz_d50, + name: 'xyz-d50', + is_legacy: false, + is_polar: false, + pink: [0.6640698533004002, 0.5367266625281085, 0.4345958246720296], + blue: [0.08408207011375313, 0.10634498228480066, 0.1470370877550857], + channels: %w[x y z], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [0.5, 2, 2], + [0.5, 2, 2] + ] + ] + }, + 'xyz-d65': { + constructor: :xyz_d65, + name: 'xyz', + is_legacy: false, + is_polar: false, + pink: [0.6495957411726918, 0.5323965129525022, 0.575341840710865], + blue: [0.08718323686632441, 0.1081164314257634, 0.19446762910683627], + channels: %w[x y z], + ranges: [ + [0, 1], + [0, 1], + [0, 1] + ], + has_out_of_gamut: false, + gamut_examples: [ + [ + [0.5, 2, 2], + [0.5, 2, 2] + ] + ] + }, + rgb: { + constructor: :rgb, + name: 'rgb', + is_legacy: true, + is_polar: false, + pink: [254.9945293093454, 168.28594090628783, 193.38511936687908], + blue: [38.144364133784602, 100.003690461188378, 120.626489290564506], + channels: %w[red green blue], + ranges: [ + [0, 255], + [0, 255], + [0, 255] + ], + has_out_of_gamut: true, + gamut_examples: [ + [ + [300, 300, 300], + [255, 255, 255] + ] + ] + }, + hsl: { + constructor: :hsl, + name: 'hsl', + is_legacy: true, + is_polar: true, + pink: [342.63204677447646, 99.98738302509669, 82.99617063051632], + blue: [195.0016494775154, 51.95041997811069, 31.009932309443183], + channels: %w[hue saturation lightness], + has_powerless: true, + ranges: [ + [0, 360], + [0, 100], + [0, 100] + ], + has_out_of_gamut: true, + gamut_examples: [ + [ + [0.5, 110, 50], + { + clip: [0.5, 100, 50], + 'local-minde': [2.9140262667, 100, 52.0514687465] + } + ] + ] + }, + hwb: { + constructor: :hwb, + name: 'hwb', + is_legacy: true, + is_polar: true, + pink: [342.63204677447646, 65.99448662991679, 0.002145368884157506], + blue: [195.0016494775154, 14.900142239759612, 52.880277620873244], + channels: %w[hue whiteness blackness], + has_powerless: true, + ranges: [ + [0, 360], + [0, 100], + [0, 100] + ], + has_out_of_gamut: true, + gamut_examples: [ + [ + [0.5, -3, -7], + { clip: [0.5, 0, 0], 'local-minde': [3.4921217446, 11.2665189221, 0] } + ] + ] + } +}.freeze + +COLOR_SPACES.each_value do |value| + value.each_key do |key| + if key == :constructor + value.define_singleton_method(key) do |*args| + ColorConstructors.send(value[key], *args) + end + else + value.define_singleton_method(key) do + value[key] + end + end + end +end diff --git a/spec/sass/value/color/utils.rb b/spec/sass/value/color/utils.rb new file mode 100644 index 00000000..abb6cf95 --- /dev/null +++ b/spec/sass/value/color/utils.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module ColorUtils + module_function + + def channel_cases(ch1, ch2, ch3) + [ + [ch1, ch2, ch3], + [nil, ch2, ch3], + [nil, nil, ch3], + [ch1, nil, ch3], + [ch1, nil, nil], + [ch1, ch2, nil], + [nil, ch2, nil], + [nil, nil, nil] + ].flat_map do |channels| + [ + channels, + [*channels, 1], + [*channels, 0], + [*channels, 0.5], + [*channels, nil] + ] + end + end + + CHANNEL_NAMES = %w[ + red + green + blue + hue + saturation + lightness + whiteness + blackness + a + b + x + y + z + chroma + ].freeze +end diff --git a/spec/sass/value/color_4_channels_spec.rb b/spec/sass/value/color_4_channels_spec.rb new file mode 100644 index 00000000..fb3a8443 --- /dev/null +++ b/spec/sass/value/color_4_channels_spec.rb @@ -0,0 +1,211 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_relative 'color/spaces' +require_relative 'color/utils' + +describe Sass::Value::Color do + # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/color-4-channels.test.ts + describe 'Color 4 Channels' do + COLOR_SPACES.each_value do |space| + describe space.name do + subject(:color) do + space.constructor(*space.pink) + end + + describe 'channels_or_nil' do + it 'returns an array' do + expect(color.channels_or_nil).to fuzzy_match_array(space.pink) + end + + it 'returns channel value or nil, excluding alpha' do + pink_cases = ColorUtils.channel_cases(*space.pink) + pink_cases.each do |channels| + color = space.constructor(*channels) + expect(color.channels_or_nil).to fuzzy_match_array(channels.first(3)) + end + end + end + + describe 'channels' do + it 'returns an array' do + expect(color.channels).to fuzzy_match_array(space.pink) + end + + it 'returns channel value or nil, excluding alpha' do + pink_cases = ColorUtils.channel_cases(*space.pink) + pink_cases.each do |channels| + expected = channels.first(3).map do |channel| + channel || 0 + end + color = space.constructor(*channels) + expect(color.channels).to fuzzy_match_array(expected) + end + end + + it 'channel_missing?' do + pink_cases = ColorUtils.channel_cases(*space.pink) + pink_cases.each do |channels| + expected = channels.map(&:nil?) + expected << false if expected.length == 3 + color = space.constructor(*channels) + expect(color.channel_missing?(space.channels[0])).to be(expected[0]) + expect(color.channel_missing?(space.channels[1])).to be(expected[1]) + expect(color.channel_missing?(space.channels[2])).to be(expected[2]) + expect(color.channel_missing?('alpha')).to be(expected[3]) + end + end + end + + describe 'channel' do + describe 'without space specified' do + it 'throws an error if channel not in space' do + channels_not_in_space = ColorUtils::CHANNEL_NAMES.dup + space.channels.each do |channel| + channels_not_in_space.delete(channel) + end + channels_not_in_space.each do |channel| + expect { color.channel(channel) }.to raise_error(Sass::ScriptError) + end + end + + it 'returns value if no space specified' do + space.channels.each_with_index do |channel, index| + expect(color.channel(channel)).to fuzzy_eq(space.pink[index]) + end + expect(color.channel('alpha')).to eq(1) + end + + it 'returns 0 for missing channels' do + nil_color = space.constructor(nil, nil, nil, nil) + space.channels.each do |channel| + expect(nil_color.channel(channel)).to eq(0) + end + expect(nil_color.channel('alpha')).to eq(0) + end + end + + describe 'with space specified' do + COLOR_SPACES.each_value do |destination_space| + it "throws an error if channel not in #{destination_space.name}" do + channels_not_in_space = ColorUtils::CHANNEL_NAMES.dup + destination_space.channels.each do |channel| + channels_not_in_space.delete(channel) + end + channels_not_in_space.each do |channel| + expect do + color.channel(channel, space: destination_space.name) + end.to raise_error(Sass::ScriptError) + end + end + + it "returns value when #{destination_space.name} is specified" do + destination_space.channels.each_with_index do |channel, index| + expect(color.channel(channel, + space: destination_space.name)).to fuzzy_eq(destination_space.pink[index]) + end + expect(color.channel('alpha', space: destination_space.name)).to eq(1) + end + end + end + end + + describe 'alpha' do + it 'returns value if set' do + expect(space.constructor(*space.pink, 0).alpha).to eq(0) + expect(space.constructor(*space.pink, 1).alpha).to eq(1) + expect(space.constructor(*space.pink, 0.5).alpha).to eq(0.5) + end + + it 'returns 1 if not set' do + no_alpha_color = space.constructor(0, 0, 0) + expect(no_alpha_color.alpha).to eq(1) + end + + it 'returns 0 if missing' do + no_alpha_color = space.constructor(0, 0, 0, nil) + expect(no_alpha_color.alpha).to eq(0) + end + end + end + + next if %w[hsl hwb lch oklch].include?(space.name) + + describe 'channel_powerless?' do + range1, range2, range3 = space.ranges + [0, 1].repeated_permutation(3) do |i, j, k| + powerless = [false, false, false] + color = space.constructor(range1[i], range2[j], range3[k]) + it "#{color.space}(#{color.channels.join(',')}): #{powerless}" do + COLOR_SPACES[color.space.to_sym].channels.each_with_index do |channel, index| + expect(color.channel_powerless?(channel)).to be(powerless[index]) + end + end + end + end + end + + describe 'channel_powerless?' do + { + 'for HWB' => { + # If the combined `whiteness + blackness` is great than or equal to + # `100%`, then the `hue` channel is powerless. + described_class.new(hue: 0, whiteness: 0, blackness: 100, space: 'hwb') => [true, false, false], + described_class.new(hue: 0, whiteness: 100, blackness: 0, space: 'hwb') => [true, false, false], + described_class.new(hue: 0, whiteness: 50, blackness: 50, space: 'hwb') => [true, false, false], + described_class.new(hue: 0, whiteness: 60, blackness: 60, space: 'hwb') => [true, false, false], + described_class.new(hue: 0, whiteness: -100, blackness: 200, space: 'hwb') => [true, false, false], + described_class.new(hue: 0, whiteness: 200, blackness: -100, space: 'hwb') => [true, false, false], + described_class.new(hue: 100, whiteness: 0, blackness: 100, space: 'hwb') => [true, false, false], + described_class.new(hue: 0, whiteness: 0, blackness: 0, space: 'hwb') => nil, + described_class.new(hue: 0, whiteness: 49, blackness: 50, space: 'hwb') => nil, + described_class.new(hue: 0, whiteness: -1, blackness: 100, space: 'hwb') => nil, + described_class.new(hue: 100, whiteness: 0, blackness: 0, space: 'hwb') => nil + }, + 'for HSL' => { + # If the saturation of an HSL color is 0%, then the hue component is + # powerless. + described_class.new(hue: 0, saturation: 0, lightness: 0, space: 'hsl') => [true, false, false], + described_class.new(hue: 0, saturation: 0, lightness: 100, space: 'hsl') => [true, false, false], + described_class.new(hue: 100, saturation: 0, lightness: 0, space: 'hsl') => [true, false, false], + described_class.new(hue: 0, saturation: 100, lightness: 0, space: 'hsl') => nil, + described_class.new(hue: 0, saturation: 100, lightness: 100, space: 'hsl') => nil, + described_class.new(hue: 100, saturation: 100, lightness: 100, space: 'hsl') => nil, + described_class.new(hue: 100, saturation: 100, lightness: 0, space: 'hsl') => nil + }, + 'for LCH' => { + # If the `chroma` value is 0%, then the `hue` channel is powerless. + described_class.new(lightness: 0, chroma: 0, hue: 0, space: 'lch') => [false, false, true], + described_class.new(lightness: 0, chroma: 0, hue: 100, space: 'lch') => [false, false, true], + described_class.new(lightness: 100, chroma: 0, hue: 0, space: 'lch') => [false, false, true], + described_class.new(lightness: 0, chroma: 100, hue: 0, space: 'lch') => nil, + described_class.new(lightness: 0, chroma: 100, hue: 100, space: 'lch') => nil, + described_class.new(lightness: 100, chroma: 100, hue: 100, space: 'lch') => nil, + described_class.new(lightness: 100, chroma: 100, hue: 0, space: 'lch') => nil + }, + 'for OKLCH' => { + # If the `chroma` value is 0%, then the `hue` channel is powerless. + described_class.new(lightness: 0, chroma: 0, hue: 0, space: 'oklch') => [false, false, true], + described_class.new(lightness: 0, chroma: 0, hue: 100, space: 'oklch') => [false, false, true], + described_class.new(lightness: 100, chroma: 0, hue: 0, space: 'oklch') => [false, false, true], + described_class.new(lightness: 0, chroma: 100, hue: 0, space: 'oklch') => nil, + described_class.new(lightness: 0, chroma: 100, hue: 100, space: 'oklch') => nil, + described_class.new(lightness: 100, chroma: 100, hue: 100, space: 'oklch') => nil, + described_class.new(lightness: 100, chroma: 100, hue: 0, space: 'oklch') => nil + } + }.each do |name, group| + describe name do + group.each do |color, powerless| + powerless = [false, false, false] if powerless.nil? + it "#{color.space}(#{color.channels.join(', ')}): #{powerless}" do + COLOR_SPACES[color.space.to_sym].channels.each_with_index do |channel, index| + expect(color.channel_powerless?(channel)).to be(powerless[index]) + end + end + end + end + end + end + end +end diff --git a/spec/sass/value/color_4_conversions_spec.rb b/spec/sass/value/color_4_conversions_spec.rb new file mode 100644 index 00000000..6bb03fa4 --- /dev/null +++ b/spec/sass/value/color_4_conversions_spec.rb @@ -0,0 +1,159 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_relative 'color/spaces' +require_relative 'color/interpolation_examples' + +describe Sass::Value::Color do + # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/color-4-conversions.test.ts + describe 'Color 4 Conversions' do + COLOR_SPACES.each_value do |space| + describe space.name do + subject(:blue) do + space.constructor(*space.blue) + end + + let(:color) do + space.constructor(*space.pink) + end + + describe 'to_space' do + COLOR_SPACES.each_value do |destination_space| + it "converts pink to #{destination_space.name}" do + res = color.to_space(destination_space.name) + expect(res.space).to eq(destination_space.name) + expect(res).to fuzzy_eq(destination_space.constructor(*destination_space.pink)) + end + end + end + + describe 'interpolate' do + it 'interpolates examples' do + COLOR_INTERPOLATIONS[space.name.to_sym].each do |input, output| + res = color.interpolate(blue, **input) + output_color = space.constructor(*output) + expect(res).to fuzzy_eq(output_color) + end + end + end + + describe 'change' do + it 'changes all channels in own space' do + space.channels.each_with_index do |channel_name, index| + expected_channels = space.pink.dup + expected_channels[index] = 0 + expect(color.change(**{ channel_name.to_sym => 0 })).to fuzzy_eq(space.constructor(*expected_channels)) + end + expect(color.change(alpha: 0)).to fuzzy_eq(space.constructor(*space.pink, 0)) + end + + it 'change with explicit undefined makes no change' do + expect(color.change).to fuzzy_eq(space.constructor(*space.pink)) + expect(color.change).to fuzzy_eq(space.constructor(*space.pink, 1)) + end + + it 'explicit nil sets channel to missing' do + space.channels.each_with_index do |channel_name, index| + expected_channels = space.pink.dup + expected_channels[index] = nil + changed = color.change(**{ channel_name.to_sym => nil }, space: space.name) + expect(changed).to fuzzy_eq(space.constructor(*expected_channels)) + expect(changed.channel_missing?(channel_name)).to be(true) + end + expect(color.change(alpha: nil, space: space.name)).to fuzzy_eq(space.constructor(*space.pink, nil)) + end + + describe 'allows out-of-range channel values' do + base_color = space.constructor( + (space.ranges[0][0] + space.ranges[0][1]) / 2.0, + (space.ranges[1][0] + space.ranges[1][1]) / 2.0, + (space.ranges[2][0] + space.ranges[2][1]) / 2.0 + ) + + 3.times do |i| + channel = space.channels[i] + next if channel == 'hue' + + it "for #{channel}" do + above_range = space.ranges[i][1] + 10 + below_range = space.ranges[i][0] - 10 + above = base_color.change(**{ channel.to_sym => above_range }) + below = base_color.change(**{ channel.to_sym => below_range }) + + expect(above.channels[i]).to eq(above_range) + + case channel + when 'saturation' + expect(below.channels[i]).to eq(below_range.abs) + expect(below.channels[0]).to eq((base_color.channels[0] + 180) % 360) + when 'chroma' + expect(below.channels[i]).to eq(below_range.abs) + expect(below.channels[2]).to eq((base_color.channels[2] + 180) % 360) + else + expect(below.channels[i]).to eq(below_range) + end + end + end + end + + COLOR_SPACES.each_value do |destination_space| + it "changes all channels with space set to #{destination_space.name}" do + destination_space.channels.each_with_index do |channel, index| + destination_channels = destination_space.pink.dup + + # Certain channel values cause equality issues on 1-3 of 16*16*3 + # cases. 0.45 is a magic number that works around this until the + # root cause is determined. + scale = 0.45 + channel_value = destination_space.ranges[index][1] * scale + + destination_channels[index] = channel_value + expected = destination_space.constructor(*destination_channels).to_space(space.name) + + expect(color.change(**{ channel.to_sym => channel_value }, + space: destination_space.name)).to fuzzy_eq(expected) + end + end + end + + it 'throws on invalid alpha' do + expect { color.change(alpha: -1) }.to raise_error(Sass::ScriptError) + expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) + end + end + + describe 'in_gamut?' do + it 'is true for in gamut colors in own space' do + expect(color.in_gamut?).to be(true) + end + + COLOR_SPACES.each_value do |destination_space| + it "is true for in gamut colors in #{destination_space.name}" do + expect(color.in_gamut?(destination_space.name)).to be(true) + end + end + + it "is #{!space.has_out_of_gamut} for out of range colors in own space" do + out_of_gamut = space.constructor(*space.gamut_examples[0][0]) + expect(out_of_gamut.in_gamut?).to be(!space.has_out_of_gamut) + end + end + + describe 'to_gamut' do + space.gamut_examples.each do |input, outputs| + outputs = { clip: outputs, 'local-minde': outputs } if outputs.is_a?(Array) + outputs.each do |method, output| + describe method.to_s do + it "in own space, #{input} -> #{output}" do + res = space.constructor(*input).to_gamut(method: method.to_s) + expect(res).to fuzzy_eq(space.constructor(*output)) + end + end + end + end + end + end + end + end +end diff --git a/spec/sass/value/color_4_nonparametizable_spec.rb b/spec/sass/value/color_4_nonparametizable_spec.rb new file mode 100644 index 00000000..5ca5c459 --- /dev/null +++ b/spec/sass/value/color_4_nonparametizable_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_relative 'color/constructors' + +describe Sass::Value::Color do + # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/color-4-nonparametizable.test.ts + describe 'Color 4 Non-parametizable' do + describe 'to_gamut' do + [ + [ + ColorConstructors.oklch(0.8, 2, 150), + 'display-p3', + { + 'local-minde': ColorConstructors.oklch( + 0.80777568417, + 0.3262439045, + 148.1202740275 + ), + clip: ColorConstructors.oklch( + 0.848829286984, + 0.3685278106, + 145.6449503702 + ) + } + ], + [ + ColorConstructors.oklch(0.8, 2, 150), + 'srgb', + { + 'local-minde': ColorConstructors.oklch( + 0.809152570179, + 0.2379027576, + 147.4021477687 + ), + clip: ColorConstructors.oklch( + 0.866439611536, + 0.2948272403, + 142.4953388878 + ) + } + ] + ].each do |input, space, outputs| + describe "with space #{space}" do + outputs.each do |method, output| + it "with method #{method}" do + expect(input.to_gamut(space:, method: method.to_s)).to fuzzy_eq(output) + end + end + end + end + end + + it 'channel with space specified, missing returns 0' do + [ + [ColorConstructors.oklch(nil, nil, nil), 'lch', 'hue'], + [ColorConstructors.oklch(nil, nil, nil), 'lch', 'lightness'], + [ColorConstructors.oklch(nil, nil, nil), 'hsl', 'hue'], + [ColorConstructors.oklch(nil, nil, nil), 'hsl', 'lightness'], + [ColorConstructors.xyz(nil, nil, nil), 'lab', 'lightness'] + ].each do |color, space, channel| + expect(color.channel(channel, space:)).to eq(0) + end + end + end +end diff --git a/spec/sass/value/color_4_spaces_spec.rb b/spec/sass/value/color_4_spaces_spec.rb new file mode 100644 index 00000000..746eff10 --- /dev/null +++ b/spec/sass/value/color_4_spaces_spec.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_relative 'color/spaces' + +describe Sass::Value::Color do + # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/color-4-spaces.test.ts + describe 'Color 4 Spaces' do + COLOR_SPACES.each_value do |space| + describe space.name do + subject(:color) do + space.constructor(*space.pink) + end + + it 'is a value' do + expect(color).to be_a(Sass::Value) + end + + it 'is a color' do + expect(color).to be_a(described_class) + expect(color.assert_color).to be(color) + end + + it "isn't any other type" do + expect { color.assert_boolean }.to raise_error(Sass::ScriptError) + expect { color.assert_calculation }.to raise_error(Sass::ScriptError) + expect { color.assert_function }.to raise_error(Sass::ScriptError) + expect { color.assert_map }.to raise_error(Sass::ScriptError) + expect(color.to_map).to be_nil + expect { color.assert_mixin }.to raise_error(Sass::ScriptError) + expect { color.assert_number }.to raise_error(Sass::ScriptError) + expect { color.assert_string }.to raise_error(Sass::ScriptError) + end + + describe 'allows out-of-range channel values' do + average1 = (space.ranges[0][0] + space.ranges[0][1]) / 2.0 + average2 = (space.ranges[1][0] + space.ranges[1][1]) / 2.0 + average3 = (space.ranges[2][0] + space.ranges[2][1]) / 2.0 + + 3.times do |i| + channel = space.channels[i] + next if channel == 'hue' + + it "for #{channel}" do + above_range = space.ranges[i][1] + 10 + below_range = space.ranges[i][0] - 10 + above = space.constructor( + i == 0 ? above_range : average1, + i == 1 ? above_range : average2, + i == 2 ? above_range : average3 + ) + below = space.constructor( + i == 0 ? below_range : average1, + i == 1 ? below_range : average2, + i == 2 ? below_range : average3 + ) + + expect(above.channels[i]).to eq(above_range) + + case channel + when 'saturation' + expect(below.channels[i]).to eq(below_range.abs) + expect(below.channels[0]).to eq((average1 + 180) % 360) + when 'chroma' + expect(below.channels[i]).to eq(below_range.abs) + expect(below.channels[2]).to eq((average3 + 180) % 360) + else + expect(below.channels[i]).to eq(below_range) + end + end + end + end + + it 'throws on invalid alpha' do + expect { space.constructor(*space.pink, -1) }.to raise_error(Sass::ScriptError) + expect { space.constructor(*space.pink, 1.1) }.to raise_error(Sass::ScriptError) + end + + it "returns name for #{space.name}" do + expect(color.space).to eq(space.name) + end + + it "legacy? returns #{space.is_legacy} for #{space.name}" do + expect(color.legacy?).to be(space.is_legacy) + end + end + end + end +end diff --git a/spec/sass/value/color_legacy_spec.rb b/spec/sass/value/color_legacy_spec.rb new file mode 100644 index 00000000..e8e35b84 --- /dev/null +++ b/spec/sass/value/color_legacy_spec.rb @@ -0,0 +1,350 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_relative 'color/constructors' + +describe Sass::Value::Color do + # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/legacy.test.ts + describe 'Legacy Color' do + def legacy_rgb(...) + ColorConstructors.legacy_rgb(...) + end + + def legacy_hsl(...) + ColorConstructors.legacy_hsl(...) + end + + def legacy_hwb(...) + ColorConstructors.legacy_hwb(...) + end + + describe 'construction' do + describe 'type' do + subject(:color) do + legacy_rgb(18, 52, 86) + end + + it 'is a value' do + expect(color).to be_a(Sass::Value) + end + + it 'is a color' do + expect(color).to be_a(described_class) + expect(color.assert_color).to be(color) + end + + it "isn't any other type" do + expect { color.assert_boolean }.to raise_error(Sass::ScriptError) + expect { color.assert_calculation }.to raise_error(Sass::ScriptError) + expect { color.assert_function }.to raise_error(Sass::ScriptError) + expect { color.assert_map }.to raise_error(Sass::ScriptError) + expect(color.to_map).to be_nil + expect { color.assert_mixin }.to raise_error(Sass::ScriptError) + expect { color.assert_number }.to raise_error(Sass::ScriptError) + expect { color.assert_string }.to raise_error(Sass::ScriptError) + end + end + + describe 'rgb()' do + it 'allows valid values' do + expect { legacy_rgb(0, 0, 0, 0) }.not_to raise_error + expect { legacy_rgb(255, 255, 255, 1) }.not_to raise_error + end + + it 'disallows invalid alpha values' do + expect { legacy_rgb(0, 0, 0, -0.1) }.to raise_error(Sass::ScriptError) + expect { legacy_rgb(0, 0, 0, 1.1) }.to raise_error(Sass::ScriptError) + end + + it 'allows out-of-gamut values which were invalid before color 4' do + expect { legacy_rgb(-1, 0, 0, 0) }.not_to raise_error + expect { legacy_rgb(0, -1, 0, 0) }.not_to raise_error + expect { legacy_rgb(0, 0, -1, 0) }.not_to raise_error + expect { legacy_rgb(256, 0, 0, 0) }.not_to raise_error + expect { legacy_rgb(0, 256, 0, 0) }.not_to raise_error + expect { legacy_rgb(0, 0, 256, 0) }.not_to raise_error + end + + it 'does not round channels to the nearest integer' do + expect(legacy_rgb(0.1, 50.4, 90.3).channels).to fuzzy_match_array([0.1, 50.4, 90.3]) + expect(legacy_rgb(-0.1, 50.5, 90.7).channels).to fuzzy_match_array([-0.1, 50.5, 90.7]) + end + end + + describe 'hsl()' do + it 'allows valid values' do + expect { legacy_hsl(0, 0, 0, 0) }.not_to raise_error + expect { legacy_hsl(4320, 100, 100, 1) }.not_to raise_error + expect { legacy_hsl(0, -0.1, 0, 0) }.not_to raise_error + expect { legacy_hsl(0, 0, -0.1, 0) }.not_to raise_error + expect { legacy_hsl(0, 100.1, 0, 0) }.not_to raise_error + expect { legacy_hsl(0, 0, 100.1, 0) }.not_to raise_error + end + + it 'disallows invalid alpha values' do + expect { legacy_hsl(0, 0, 0, -0.1) }.to raise_error(Sass::ScriptError) + expect { legacy_hsl(0, 0, 0, 1.1) }.to raise_error(Sass::ScriptError) + end + end + + describe 'hwb()' do + it 'allows valid values' do + expect { legacy_hwb(0, 0, 0, 0) }.not_to raise_error + expect { legacy_hwb(4320, 100, 100, 1) }.not_to raise_error + expect { legacy_hwb(0, -0.1, 0, 0) }.not_to raise_error + expect { legacy_hwb(0, 0, -0.1, 0) }.not_to raise_error + expect { legacy_hwb(0, 100.1, 0, 0) }.not_to raise_error + expect { legacy_hwb(0, 0, 100.1, 0) }.not_to raise_error + end + + it 'disallows invalid alpha values' do + expect { legacy_hwb(0, 0, 0, -0.1) }.to raise_error(Sass::ScriptError) + expect { legacy_hwb(0, 0, 0, 1.1) }.to raise_error(Sass::ScriptError) + end + end + end + + describe 'an RGB color' do + subject(:color) do + legacy_rgb(18, 52, 86) + end + + it 'has RGB channels' do + expect(color.red).to eq(18) + expect(color.green).to eq(52) + expect(color.blue).to eq(86) + end + + it 'has HSL channels' do + expect(color.hue).to eq(210) + expect(color.saturation).to eq(65.3846153846154) + expect(color.lightness).to eq(20.392156862745097) + end + + it 'has HWB channels' do + expect(color.hue).to eq(210) + expect(color.whiteness).to eq(7.0588235294117645) + expect(color.blackness).to eq(66.27450980392157) + end + + it 'has an alpha channel' do + expect(color.alpha).to eq(1) + end + + it 'equals the same color even in a different color space' do + expect(color).to eq(legacy_rgb(18, 52, 86)) + expect(color).to eq(legacy_hsl(210, 65.3846153846154, 20.392156862745097)) + expect(color).to eq(legacy_hwb(210, 7.0588235294117645, 66.27450980392157)) + end + end + + describe 'an HSL color' do + subject(:color) do + legacy_hsl(120, 42, 42) + end + + it 'has RGB channels' do + expect(color.red).to eq(62) + expect(color.green).to eq(152) + expect(color.blue).to eq(62) + end + + it 'has HSL channels' do + expect(color.hue).to eq(120) + expect(color.saturation).to eq(42) + expect(color.lightness).to eq(42) + end + + it 'has HWB channels' do + expect(color.hue).to eq(120) + expect(color.whiteness).to eq(24.360000000000003) + expect(color.blackness).to eq(40.36000000000001) + end + + it 'has an alpha channel' do + expect(color.alpha).to eq(1) + end + + it 'equals the same color even in a different color space' do + expect(color).to eq(legacy_rgb(62.118, 152.082, 62.118)) + expect(color).to eq(legacy_hsl(120, 42, 42)) + expect(color).to eq(legacy_hwb(120, 24.36, 40.36)) + end + + it 'allows negative hue' do + expect(legacy_hsl(-240, 42, 42).hue).to be(120) + expect(legacy_hsl(-240, 42, 42)).to eq(color) + end + end + + describe 'an HWB color' do + subject(:color) do + legacy_hwb(120, 42, 42) + end + + it 'has RGB channels' do + expect(color.red).to eq(107) + expect(color.green).to eq(148) + expect(color.blue).to eq(107) + end + + it 'has HSL channels' do + expect(color.hue).to eq(120) + expect(color.saturation).to eq(16.000000000000014) + expect(color.lightness).to eq(50) + end + + it 'has HWB channels' do + expect(color.hue).to eq(120) + expect(color.whiteness).to eq(42) + expect(color.blackness).to eq(42) + end + + it 'has an alpha channel' do + expect(color.alpha).to eq(1) + end + + it 'equals the same color even in a different color space' do + expect(color).to eq(legacy_rgb(107.1, 147.9, 107.1)) + expect(color).to eq(legacy_hsl(120, 16, 50)) + expect(color).to eq(legacy_hwb(120, 42, 42)) + end + + it 'allows negative hue' do + expect(legacy_hwb(-240, 42, 42).hue).to eq(120) + expect(legacy_hwb(-240, 42, 42)).to eq(color) + end + end + + describe 'changing color values' do + describe 'change() for RGB' do + subject(:color) do + legacy_rgb(18, 52, 86) + end + + it 'changes RGB values' do + expect(color.change(red: 0)).to eq(legacy_rgb(0, 52, 86)) + expect(color.change(green: 0)).to eq(legacy_rgb(18, 0, 86)) + expect(color.change(blue: 0)).to eq(legacy_rgb(18, 52, 0)) + expect(color.change(alpha: 0.5)).to eq(legacy_rgb(18, 52, 86, 0.5)) + expect(color.change(red: 0, green: 0, blue: 0, alpha: 0.5)).to eq(legacy_rgb(0, 0, 0, 0.5)) + end + + it 'allows valid values' do + expect(color.change(red: 0).channel('red')).to eq(0) + expect(color.change(red: 255).channel('red')).to eq(255) + expect(color.change(green: 0).channel('green')).to eq(0) + expect(color.change(green: 255).channel('green')).to eq(255) + expect(color.change(blue: 0).channel('blue')).to eq(0) + expect(color.change(blue: 255).channel('blue')).to eq(255) + expect(color.change(alpha: 0).alpha).to eq(0) + expect(color.change(alpha: 1).alpha).to eq(1) + expect(color.change(red: nil).channel('red')).to eq(18) + end + + it 'allows out of range values which were invalid before color 4' do + expect { color.change(red: -1) }.not_to raise_error + expect { color.change(red: 256) }.not_to raise_error + expect { color.change(green: -1) }.not_to raise_error + expect { color.change(green: 256) }.not_to raise_error + expect { color.change(blue: -1) }.not_to raise_error + expect { color.change(blue: 256) }.not_to raise_error + end + + it 'disallows invalid alpha values' do + expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) + expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) + end + + it 'does not round channels to the nearest integer' do + expect(color.change(red: 0.1, green: 50.4, blue: 90.3).channels).to fuzzy_match_array([0.1, 50.4, 90.3]) + expect(color.change(red: -0.1, green: 50.5, blue: 90.9).channels).to fuzzy_match_array([-0.1, 50.5, 90.9]) + end + end + + describe 'change() for HSL' do + subject(:color) do + legacy_hsl(210, 65.3846153846154, 20.392156862745097) + end + + it 'changes HSL values' do + expect(color.change(hue: 120)).to eq(legacy_hsl(120, 65.3846153846154, 20.392156862745097)) + expect(color.change(hue: -120)).to eq(legacy_hsl(240, 65.3846153846154, 20.392156862745097)) + expect(color.change(saturation: 42)).to eq(legacy_hsl(210, 42, 20.392156862745097)) + expect(color.change(lightness: 42)).to eq(legacy_hsl(210, 65.3846153846154, 42)) + expect(color.change(alpha: 0.5)).to eq(legacy_hsl(210, 65.3846153846154, 20.392156862745097, 0.5)) + expect(color.change(hue: 120, saturation: 42, lightness: 42, alpha: 0.5)).to eq(legacy_hsl(120, 42, 42, 0.5)) + end + + it 'allows valid values' do + expect(color.change(saturation: 0).channel('saturation')).to eq(0) + expect(color.change(saturation: 100).channel('saturation')).to eq(100) + expect(color.change(lightness: 0).channel('lightness')).to eq(0) + expect(color.change(lightness: 100).channel('lightness')).to eq(100) + expect(color.change(alpha: 0).alpha).to eq(0) + expect(color.change(alpha: 1).alpha).to eq(1) + expect(color.change(lightness: -0.1).channel('lightness')).to eq(-0.1) + expect(color.change(lightness: 100.1).channel('lightness')).to eq(100.1) + expect(color.change(hue: nil).channel('hue')).to eq(210) + end + + it 'disallows invalid alpha values' do + expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) + expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) + end + end + + describe 'change() for HWB' do + subject(:color) do + legacy_hwb(210, 7.0588235294117645, 66.27450980392157) + end + + it 'changes HWB values' do + expect(color.change(hue: 120)).to eq(legacy_hwb(120, 7.0588235294117645, 66.27450980392157)) + expect(color.change(hue: -120)).to eq(legacy_hwb(240, 7.0588235294117645, 66.27450980392157)) + expect(color.change(whiteness: 42)).to eq(legacy_hwb(210, 42, 66.27450980392157)) + expect(color.change(whiteness: 50)).to eq(legacy_hwb(210, 50, 66.27450980392157)) + expect(color.change(blackness: 42)).to eq(legacy_hwb(210, 7.0588235294117645, 42)) + expect(color.change(alpha: 0.5)).to eq(legacy_hwb(210, 7.0588235294117645, 66.27450980392157, 0.5)) + expect(color.change(hue: 120, whiteness: 42, blackness: 42, alpha: 0.5)).to eq(legacy_hwb(120, 42, 42, 0.5)) + end + + it 'allows valid values' do + expect(color.change(whiteness: 0).channel('whiteness')).to eq(0) + expect(color.change(whiteness: 100).channel('whiteness')).to eq(100) + expect(color.change(blackness: 0).channel('blackness')).to eq(0) + expect(color.change(blackness: 100).channel('blackness')).to eq(100) + expect(color.change(alpha: 0).alpha).to eq(0) + expect(color.change(alpha: 1).alpha).to eq(1) + expect(color.change(hue: nil).channel('hue')).to eq(210) + end + + it 'disallows invalid alpha values' do + expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) + expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) + end + end + + describe 'change(alpha:)' do + subject(:color) do + legacy_rgb(18, 52, 86) + end + + it 'changes the alpha value' do + expect(color.change(alpha: 0.5)).to eq(legacy_rgb(18, 52, 86, 0.5)) + end + + it 'allows valid alphas' do + expect(color.change(alpha: 0).alpha).to eq(0) + expect(color.change(alpha: 1).alpha).to eq(1) + end + + it 'rejects invalid alphas' do + expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) + expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) + end + end + end + end +end diff --git a/spec/sass/value/color_spec.rb b/spec/sass/value/color_spec.rb deleted file mode 100644 index 0ad5b044..00000000 --- a/spec/sass/value/color_spec.rb +++ /dev/null @@ -1,331 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color.test.ts -describe Sass::Value::Color do - def rgb(red, green, blue, alpha = nil) - Sass::Value::Color.new(red:, green:, blue:, alpha:) - end - - def hsl(hue, saturation, lightness, alpha = nil) - Sass::Value::Color.new(hue:, saturation:, lightness:, alpha:) - end - - def hwb(hue, whiteness, blackness, alpha = nil) - Sass::Value::Color.new(hue:, whiteness:, blackness:, alpha:) - end - - describe 'construction' do - describe 'type' do - subject(:color) do - rgb(18, 52, 86) - end - - it 'is a value' do - expect(color).to be_a(Sass::Value) - end - - it 'is a color' do - expect(color).to be_a(described_class) - expect(color.assert_color).to be(color) - end - - it "isn't any other type" do - expect { color.assert_boolean }.to raise_error(Sass::ScriptError) - expect { color.assert_calculation }.to raise_error(Sass::ScriptError) - expect { color.assert_function }.to raise_error(Sass::ScriptError) - expect { color.assert_map }.to raise_error(Sass::ScriptError) - expect(color.to_map).to be_nil - expect { color.assert_mixin }.to raise_error(Sass::ScriptError) - expect { color.assert_number }.to raise_error(Sass::ScriptError) - expect { color.assert_string }.to raise_error(Sass::ScriptError) - end - end - - describe 'rgb()' do - it 'allows valid values' do - expect { rgb(0, 0, 0, 0) }.not_to raise_error - expect { rgb(255, 255, 255, 1) }.not_to raise_error - end - - it 'disallows invalid values' do - expect { rgb(-1, 0, 0, 0) }.to raise_error(Sass::ScriptError) - expect { rgb(0, -1, 0, 0) }.to raise_error(Sass::ScriptError) - expect { rgb(0, 0, -1, 0) }.to raise_error(Sass::ScriptError) - expect { rgb(0, 0, 0, -0.1) }.to raise_error(Sass::ScriptError) - expect { rgb(256, 0, 0, 0) }.to raise_error(Sass::ScriptError) - expect { rgb(0, 256, 0, 0) }.to raise_error(Sass::ScriptError) - expect { rgb(0, 0, 256, 0) }.to raise_error(Sass::ScriptError) - expect { rgb(0, 0, 0, 1.1) }.to raise_error(Sass::ScriptError) - end - - it 'rounds channels to the nearest integer' do - expect(rgb(0.1, 50.4, 90.3)).to eq(rgb(0, 50, 90)) - expect(rgb(-0.1, 50.5, 90.7)).to eq(rgb(0, 51, 91)) - end - end - - describe 'hsl()' do - it 'allows valid values' do - expect { hsl(0, 0, 0, 0) }.not_to raise_error - expect { hsl(4320, 100, 100, 1) }.not_to raise_error - end - - it 'disallows invalid values' do - expect { hsl(0, -0.1, 0, 0) }.to raise_error(Sass::ScriptError) - expect { hsl(0, 0, -0.1, 0) }.to raise_error(Sass::ScriptError) - expect { hsl(0, 0, 0, -0.1) }.to raise_error(Sass::ScriptError) - expect { hsl(0, 100.1, 0, 0) }.to raise_error(Sass::ScriptError) - expect { hsl(0, 0, 100.1, 0) }.to raise_error(Sass::ScriptError) - expect { hsl(0, 0, 0, 1.1) }.to raise_error(Sass::ScriptError) - end - end - - describe 'hwb()' do - it 'allows valid values' do - expect { hwb(0, 0, 0, 0) }.not_to raise_error - expect { hwb(4320, 100, 100, 1) }.not_to raise_error - end - - it 'disallows invalid values' do - expect { hwb(0, -0.1, 0, 0) }.to raise_error(Sass::ScriptError) - expect { hwb(0, 0, -0.1, 0) }.to raise_error(Sass::ScriptError) - expect { hwb(0, 0, 0, -0.1) }.to raise_error(Sass::ScriptError) - expect { hwb(0, 100.1, 0, 0) }.to raise_error(Sass::ScriptError) - expect { hwb(0, 0, 100.1, 0) }.to raise_error(Sass::ScriptError) - expect { hwb(0, 0, 0, 1.1) }.to raise_error(Sass::ScriptError) - end - end - end - - describe 'an RGB color' do - subject(:color) do - rgb(18, 52, 86) - end - - it 'has RGB channels' do - expect(color.red).to eq(18) - expect(color.green).to eq(52) - expect(color.blue).to eq(86) - end - - it 'has HSL channels' do - expect(color.hue).to eq(210) - expect(color.saturation).to eq(65.38461538461539) - expect(color.lightness).to eq(20.392156862745097) - end - - it 'has HWB channels' do - expect(color.hue).to eq(210) - expect(color.whiteness).to eq(7.0588235294117645) - expect(color.blackness).to eq(66.27450980392157) - end - - it 'has an alpha channel' do - expect(color.alpha).to eq(1) - end - - it 'equals the same color' do - expect(color).to eq(rgb(18, 52, 86)) - expect(color).to eq(hsl(210, 65.38461538461539, 20.392156862745097)) - expect(color).to eq(hwb(210, 7.0588235294117645, 66.27450980392157)) - end - end - - describe 'an HSL color' do - subject(:color) do - hsl(120, 42, 42) - end - - it 'has RGB channels' do - expect(color.red).to eq(62) - expect(color.green).to eq(152) - expect(color.blue).to eq(62) - end - - it 'has HSL channels' do - expect(color.hue).to eq(120) - expect(color.saturation).to eq(42) - expect(color.lightness).to eq(42) - end - - it 'has HWB channels' do - expect(color.hue).to eq(120) - expect(color.whiteness).to eq(24.313725490196077) - expect(color.blackness).to eq(40.3921568627451) - end - - it 'has an alpha channel' do - expect(color.alpha).to eq(1) - end - - it 'equals the same color' do - expect(color).to eq(rgb(62, 152, 62)) - expect(color).to eq(hsl(120, 42, 42)) - expect(color).to eq(hwb(120, 24.313725490196077, 40.3921568627451)) - end - - it 'allows negative hue' do - expect(hsl(-240, 42, 42).hue).to be(120) - expect(hsl(-240, 42, 42)).to eq(color) - end - end - - describe 'an HWB color' do - subject(:color) do - hwb(120, 42, 42) - end - - it 'has RGB channels' do - expect(color.red).to eq(107) - expect(color.green).to eq(148) - expect(color.blue).to eq(107) - end - - it 'has HSL channels' do - expect(color.hue).to eq(120) - expect(color.saturation).to eq(16.07843137254902) - expect(color.lightness).to eq(50) - end - - it 'has HWB channels' do - expect(color.hue).to eq(120) - expect(color.whiteness).to eq(41.96078431372549) - expect(color.blackness).to eq(41.96078431372549) - end - - it 'has an alpha channel' do - expect(color.alpha).to eq(1) - end - - it 'equals the same color' do - expect(color).to eq(rgb(107, 148, 107)) - expect(color).to eq(hsl(120, 16.078431372549026, 50)) - expect(color).to eq(hwb(120, 41.96078431372549, 41.96078431372549)) - end - - it 'allows negative hue' do - expect(hwb(-240, 42, 42).hue).to eq(120) - expect(hwb(-240, 42, 42)).to eq(color) - end - end - - describe 'changing color values' do - subject(:color) do - rgb(18, 52, 86) - end - - describe 'change() for RGB' do - it 'changes RGB values' do - expect(color.change(red: 0)).to eq(rgb(0, 52, 86)) - expect(color.change(green: 0)).to eq(rgb(18, 0, 86)) - expect(color.change(blue: 0)).to eq(rgb(18, 52, 0)) - expect(color.change(alpha: 0.5)).to eq(rgb(18, 52, 86, 0.5)) - expect(color.change(red: 0, green: 0, blue: 0, alpha: 0.5)).to eq(rgb(0, 0, 0, 0.5)) - end - - it 'allows valid values' do - expect(color.change(red: 0).red).to eq(0) - expect(color.change(red: 255).red).to eq(255) - expect(color.change(green: 0).green).to eq(0) - expect(color.change(green: 255).green).to eq(255) - expect(color.change(blue: 0).blue).to eq(0) - expect(color.change(blue: 255).blue).to eq(255) - expect(color.change(alpha: 0).alpha).to eq(0) - expect(color.change(alpha: 1).alpha).to eq(1) - end - - it 'disallows invalid values' do - expect { color.change(red: -1) }.to raise_error(Sass::ScriptError) - expect { color.change(red: 256) }.to raise_error(Sass::ScriptError) - expect { color.change(green: -1) }.to raise_error(Sass::ScriptError) - expect { color.change(green: 256) }.to raise_error(Sass::ScriptError) - expect { color.change(blue: -1) }.to raise_error(Sass::ScriptError) - expect { color.change(blue: 256) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) - end - - it 'rounds channels to the nearest integer' do - expect(color.change(red: 0.1, green: 50.4, blue: 90.3)).to eq(rgb(0, 50, 90)) - expect(color.change(red: -0.1, green: 50.5, blue: 90.9)).to eq(rgb(0, 51, 91)) - end - end - - describe 'change() for HSL' do - it 'changes HSL values' do - expect(color.change(hue: 120)).to eq(hsl(120, 65.3846153846154, 20.392156862745097)) - expect(color.change(hue: -120)).to eq(hsl(240, 65.3846153846154, 20.392156862745097)) - expect(color.change(saturation: 42)).to eq(hsl(210, 42, 20.392156862745097)) - expect(color.change(lightness: 42)).to eq(hsl(210, 65.3846153846154, 42)) - expect(color.change(alpha: 0.5)).to eq(hsl(210, 65.3846153846154, 20.392156862745097, 0.5)) - expect(color.change(hue: 120, saturation: 42, lightness: 42, alpha: 0.5)).to eq(hsl(120, 42, 42, 0.5)) - end - - it 'allows valid values' do - expect(color.change(saturation: 0).saturation).to eq(0) - expect(color.change(saturation: 100).saturation).to eq(100) - expect(color.change(lightness: 0).lightness).to eq(0) - expect(color.change(lightness: 100).lightness).to eq(100) - expect(color.change(alpha: 0).alpha).to eq(0) - expect(color.change(alpha: 1).alpha).to eq(1) - end - - it 'disallows invalid values' do - expect { color.change(saturation: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(saturation: 100.1) }.to raise_error(Sass::ScriptError) - expect { color.change(lightness: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(lightness: 100.1) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) - end - end - - describe 'change() for HWB' do - it 'changes HWB values' do - expect(color.change(hue: 120)).to eq(hwb(120, 7.0588235294117645, 66.27450980392157)) - expect(color.change(hue: -120)).to eq(hwb(240, 7.0588235294117645, 66.27450980392157)) - expect(color.change(whiteness: 42)).to eq(hwb(210, 42, 66.27450980392157)) - expect(color.change(whiteness: 50)).to eq(hwb(210, 50, 66.27450980392157)) - expect(color.change(blackness: 42)).to eq(hwb(210, 7.0588235294117645, 42)) - expect(color.change(alpha: 0.5)).to eq(hwb(210, 7.0588235294117645, 66.27450980392157, 0.5)) - expect(color.change(hue: 120, whiteness: 42, blackness: 42, alpha: 0.5)).to eq(hwb(120, 42, 42, 0.5)) - end - - it 'allows valid values' do - expect(color.change(whiteness: 0).whiteness).to eq(0) - expect(color.change(whiteness: 100).whiteness).to eq(60.0) - expect(color.change(blackness: 0).blackness).to eq(0) - expect(color.change(blackness: 100).blackness).to eq(93.33333333333333) - expect(color.change(alpha: 0).alpha).to eq(0) - expect(color.change(alpha: 1).alpha).to eq(1) - end - - it 'disallows invalid values' do - expect { color.change(whiteness: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(whiteness: 100.1) }.to raise_error(Sass::ScriptError) - expect { color.change(blackness: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(blackness: 100.1) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) - end - end - - describe 'changeAlpha()' do - it 'changes the alpha value' do - expect(color.change(alpha: 0.5)).to eq(rgb(18, 52, 86, 0.5)) - end - - it 'allows valid alphas' do - expect(color.change(alpha: 0).alpha).to eq(0) - expect(color.change(alpha: 1).alpha).to eq(1) - end - - it 'rejects invalid alphas' do - expect { color.change(alpha: -0.1) }.to raise_error(Sass::ScriptError) - expect { color.change(alpha: 1.1) }.to raise_error(Sass::ScriptError) - end - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 078f5f82..82106479 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -43,3 +43,33 @@ supports_block_expectations end + +epsilon = Sass::Value.const_get(:FuzzyMath)::EPSILON + +RSpec::Matchers.matcher :fuzzy_eq do |expected| + match do |actual| + case expected + when Sass::Value::Color + expect { actual.assert_color }.not_to raise_error + expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil) + expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) + expect(actual.alpha).to fuzzy_eq(expected.alpha) + when Numeric + expect(actual).to be_within(epsilon).of(expected) + else + expect(actual).to eq(expected) + end + end +end + +RSpec::Matchers.matcher :fuzzy_match_array do |expected| + match do |actual| + expect(actual).to match_array(expected.map do |obj| + if obj.is_a?(Numeric) + a_value_within(epsilon * 10).of(obj) + else + obj + end + end) + end +end From 6e0f46fe63a5bd18b33b2d9cf24c9c822741c2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 13:02:05 -0700 Subject: [PATCH 519/700] Update hsl/hwb to rgb --- lib/sass/value/color/space/hsl.rb | 33 +++++++++++---------- lib/sass/value/color/space/hwb.rb | 43 ++++++++++++++++------------ lib/sass/value/color/space/lch.rb | 1 + lib/sass/value/color/space/oklab.rb | 2 ++ lib/sass/value/color/space/oklch.rb | 1 + lib/sass/value/color/space/utils.rb | 23 --------------- spec/sass/value/color_legacy_spec.rb | 2 +- 7 files changed, 48 insertions(+), 57 deletions(-) diff --git a/lib/sass/value/color/space/hsl.rb b/lib/sass/value/color/space/hsl.rb index 5135cdc2..78b47022 100644 --- a/lib/sass/value/color/space/hsl.rb +++ b/lib/sass/value/color/space/hsl.rb @@ -29,26 +29,29 @@ def initialize end def convert(dest, hue, saturation, lightness, alpha) - scaled_hue = ((hue.nil? ? 0 : hue) / 360.0) % 1 - scaled_saturation = (saturation.nil? ? 0 : saturation) / 100.0 - scaled_lightness = (lightness.nil? ? 0 : lightness) / 100.0 + missing_lightness = lightness.nil? + missing_chroma = saturation.nil? + missing_hue = hue.nil? - m2 = if scaled_lightness <= 0.5 - scaled_lightness * (scaled_saturation + 1) - else - scaled_lightness + scaled_saturation - (scaled_lightness * scaled_saturation) - end - m1 = (scaled_lightness * 2) - m2 + hue = ((hue.nil? ? 0 : hue) % 360) / 30.0 + saturation = (saturation.nil? ? 0 : saturation) / 100.0 + lightness = (lightness.nil? ? 0 : lightness) / 100.0 + + a = saturation * [lightness, 1 - lightness].min + f = lambda do |n| + k = (n + hue) % 12 + lightness - (a * [-1, [k - 3, 9 - k, 1].min].max) + end SRGB.convert( dest, - Utils.hue_to_rgb(m1, m2, scaled_hue + (1 / 3.0)), - Utils.hue_to_rgb(m1, m2, scaled_hue), - Utils.hue_to_rgb(m1, m2, scaled_hue - (1 / 3.0)), + f.call(0), + f.call(8), + f.call(4), alpha, - missing_lightness: lightness.nil?, - missing_chroma: saturation.nil?, - missing_hue: hue.nil? + missing_lightness:, + missing_chroma:, + missing_hue: ) end end diff --git a/lib/sass/value/color/space/hwb.rb b/lib/sass/value/color/space/hwb.rb index 822135b2..76d141a4 100644 --- a/lib/sass/value/color/space/hwb.rb +++ b/lib/sass/value/color/space/hwb.rb @@ -29,28 +29,35 @@ def initialize end def convert(dest, hue, whiteness, blackness, alpha) - scaled_hue = (hue.nil? ? 0 : hue) % 360 / 360.0 - scaled_whiteness = (whiteness.nil? ? 0 : whiteness) / 100.0 - scaled_blackness = (blackness.nil? ? 0 : blackness) / 100.0 + missing_hue = hue.nil? - sum = scaled_whiteness + scaled_blackness - if sum > 1 - scaled_whiteness /= sum - scaled_blackness /= sum - end + hue = ((hue.nil? ? 0 : hue) % 360) / 30.0 + whiteness = (whiteness.nil? ? 0 : whiteness) / 100.0 + blackness = (blackness.nil? ? 0 : blackness) / 100.0 - factor = 1 - scaled_whiteness - scaled_blackness + sum = whiteness + blackness + if sum > 1 + gray = whiteness / sum + SRGB.convert(dest, + gray, + gray, + gray, + alpha, + missing_hue:) + else + f = lambda do |n| + k = (n + hue) % 12 + 0.5 - ([-1, [k - 3, 9 - k, 1].min].max / 2.0) + end - to_rgb = lambda do |hue_| - (Utils.hue_to_rgb(0, 1, hue_) * factor) + scaled_whiteness + factor = 1 - sum + SRGB.convert(dest, + (f.call(0) * factor) + whiteness, + (f.call(8) * factor) + whiteness, + (f.call(4) * factor) + whiteness, + alpha, + missing_hue:) end - - SRGB.convert(dest, - to_rgb.call(scaled_hue + (1 / 3.0)), - to_rgb.call(scaled_hue), - to_rgb.call(scaled_hue - (1 / 3.0)), - alpha, - missing_hue: hue.nil?) end end diff --git a/lib/sass/value/color/space/lch.rb b/lib/sass/value/color/space/lch.rb index b375deb7..7731902e 100644 --- a/lib/sass/value/color/space/lch.rb +++ b/lib/sass/value/color/space/lch.rb @@ -27,6 +27,7 @@ def initialize def convert(dest, lightness, chroma, hue, alpha) missing_chroma = chroma.nil? missing_hue = hue.nil? + chroma = 0 if missing_chroma hue = 0 if missing_hue diff --git a/lib/sass/value/color/space/oklab.rb b/lib/sass/value/color/space/oklab.rb index 563e83aa..c13686e5 100644 --- a/lib/sass/value/color/space/oklab.rb +++ b/lib/sass/value/color/space/oklab.rb @@ -30,9 +30,11 @@ def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParamet missing_lightness = lightness.nil? missing_a = a.nil? missing_b = b.nil? + lightness = 0 if missing_lightness a = 0 if missing_a b = 0 if missing_b + LMS.convert( dest, (( diff --git a/lib/sass/value/color/space/oklch.rb b/lib/sass/value/color/space/oklch.rb index 645f7118..3096320d 100644 --- a/lib/sass/value/color/space/oklch.rb +++ b/lib/sass/value/color/space/oklch.rb @@ -28,6 +28,7 @@ def initialize def convert(dest, lightness, chroma, hue, alpha) missing_chroma = chroma.nil? missing_hue = hue.nil? + chroma = 0 if missing_chroma hue = 0 if missing_hue diff --git a/lib/sass/value/color/space/utils.rb b/lib/sass/value/color/space/utils.rb index f91854c0..4f611c13 100644 --- a/lib/sass/value/color/space/utils.rb +++ b/lib/sass/value/color/space/utils.rb @@ -31,29 +31,6 @@ module Utils LinearChannel.new('z', 0, 1).freeze ].freeze - # Converts a legacy HSL/HWB hue to an RGB channel. - # - # The algorithm comes from from the CSS3 spec: - # http://www.w3.org/TR/css3-color/#hsl-color. - # @param m1 [Numeric] - # @param m2 [Numeric] - # @param hue [Numeric] - # @return [Numeric] - def hue_to_rgb(m1, m2, hue) # rubocop:disable Naming/MethodParameterName - hue += 1 if hue.negative? - hue -= 1 if hue > 1 - - if hue < 1 / 6.0 - m1 + ((m2 - m1) * hue * 6) - elsif hue < 1 / 2.0 - m2 - elsif hue < 2 / 3.0 - m1 + ((m2 - m1) * ((2 / 3.0) - hue) * 6) - else - m1 - end - end - # The algorithm for converting a single `srgb` or `display-p3` channel to # linear-light form. # @param [Numeric] diff --git a/spec/sass/value/color_legacy_spec.rb b/spec/sass/value/color_legacy_spec.rb index e8e35b84..940a6c89 100644 --- a/spec/sass/value/color_legacy_spec.rb +++ b/spec/sass/value/color_legacy_spec.rb @@ -158,7 +158,7 @@ def legacy_hwb(...) it 'has HWB channels' do expect(color.hue).to eq(120) - expect(color.whiteness).to eq(24.360000000000003) + expect(color.whiteness).to eq(24.36000000000000) expect(color.blackness).to eq(40.36000000000001) end From 67c4abc3af38ac2519bd56567612fa0e9e3fe106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 13:27:20 -0700 Subject: [PATCH 520/700] Use built-in Math.cbrt --- lib/sass/value/color/space/lms.rb | 16 ++++++---------- lib/sass/value/color/space/xyz_d50.rb | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/sass/value/color/space/lms.rb b/lib/sass/value/color/space/lms.rb index 97444a9c..0fdd843c 100644 --- a/lib/sass/value/color/space/lms.rb +++ b/lib/sass/value/color/space/lms.rb @@ -28,9 +28,9 @@ def convert(dest, long, medium, short, alpha, missing_b: false) case dest when OKLAB - long_scaled = _cube_root_preserving_sign(long.nil? ? 0 : long) - medium_scaled = _cube_root_preserving_sign(medium.nil? ? 0 : medium) - short_scaled = _cube_root_preserving_sign(short.nil? ? 0 : short) + long_scaled = Math.cbrt(long.nil? ? 0 : long) + medium_scaled = Math.cbrt(medium.nil? ? 0 : medium) + short_scaled = Math.cbrt(short.nil? ? 0 : short) Color.send( :_for_space, @@ -53,9 +53,9 @@ def convert(dest, long, medium, short, alpha, alpha ) when OKLCH - long_scaled = _cube_root_preserving_sign(long.nil? ? 0 : long) - medium_scaled = _cube_root_preserving_sign(medium.nil? ? 0 : medium) - short_scaled = _cube_root_preserving_sign(short.nil? ? 0 : short) + long_scaled = Math.cbrt(long.nil? ? 0 : long) + medium_scaled = Math.cbrt(medium.nil? ? 0 : medium) + short_scaled = Math.cbrt(short.nil? ? 0 : short) Utils.lab_to_lch( dest, @@ -116,10 +116,6 @@ def transformation_matrix(dest) super end end - - def _cube_root_preserving_sign(number) - (number.abs**(1 / 3.0)) * FuzzyMath.sign(number) - end end private_constant :Lms diff --git a/lib/sass/value/color/space/xyz_d50.rb b/lib/sass/value/color/space/xyz_d50.rb index f6cc11c0..dacb6171 100644 --- a/lib/sass/value/color/space/xyz_d50.rb +++ b/lib/sass/value/color/space/xyz_d50.rb @@ -63,7 +63,7 @@ def from_linear(channel) def _convert_component_to_lab_f(component) if component > Utils::LAB_EPSILON - (component**(1 / 3.0)) + 0.0 + Math.cbrt(component) else ((Utils::LAB_KAPPA * component) + 16) / 116.0 end From 1d4aab5b90c0578b9bde1b0c7d7624cdc2522b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 14:30:34 -0700 Subject: [PATCH 521/700] Update ELF spec --- spec/sass/elf_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb index bf761c27..024b2611 100644 --- a/spec/sass/elf_spec.rb +++ b/spec/sass/elf_spec.rb @@ -2,10 +2,8 @@ require 'spec_helper' -RSpec.describe 'Sass::ELF', skip: (File.exist?('/proc/self/exe') ? false : '/proc/self/exe is not available') do +RSpec.describe 'Sass::ELF', skip: (Sass.const_defined?(:ELF) ? false : 'Sass::ELF is not available') do let(:described_class) do - require 'sass/elf' - Sass.const_get(:ELF) end From 3297ec8dad67938d0e1bd3459cd08bbcfe02cee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 17:10:07 -0700 Subject: [PATCH 522/700] Increase test precision --- spec/sass/value/color/spaces.rb | 7 ++++-- .../value/color_4_nonparametizable_spec.rb | 24 +++++++++---------- spec/spec_helper.rb | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/spec/sass/value/color/spaces.rb b/spec/sass/value/color/spaces.rb index c5bcd9ed..6cca4744 100644 --- a/spec/sass/value/color/spaces.rb +++ b/spec/sass/value/color/spaces.rb @@ -302,7 +302,7 @@ [0.5, 110, 50], { clip: [0.5, 100, 50], - 'local-minde': [2.9140262667, 100, 52.0514687465] + 'local-minde': [2.9140262667138472, 100, 52.05146874647547] } ] ] @@ -325,7 +325,10 @@ gamut_examples: [ [ [0.5, -3, -7], - { clip: [0.5, 0, 0], 'local-minde': [3.4921217446, 11.2665189221, 0] } + { + clip: [0.5, 0, 0], + 'local-minde': [3.492121744609392, 11.26651892207301, 0] + } ] ] } diff --git a/spec/sass/value/color_4_nonparametizable_spec.rb b/spec/sass/value/color_4_nonparametizable_spec.rb index 5ca5c459..1cdf2865 100644 --- a/spec/sass/value/color_4_nonparametizable_spec.rb +++ b/spec/sass/value/color_4_nonparametizable_spec.rb @@ -14,14 +14,14 @@ 'display-p3', { 'local-minde': ColorConstructors.oklch( - 0.80777568417, - 0.3262439045, - 148.1202740275 + 0.8077756841698541, + 0.3262439045095262, + 148.12027402754507 ), clip: ColorConstructors.oklch( - 0.848829286984, - 0.3685278106, - 145.6449503702 + 0.848829286984103, + 0.3685278106366152, + 145.64495037017775 ) } ], @@ -30,14 +30,14 @@ 'srgb', { 'local-minde': ColorConstructors.oklch( - 0.809152570179, - 0.2379027576, - 147.4021477687 + 0.809152570178515, + 0.23790275760347995, + 147.40214776873552 ), clip: ColorConstructors.oklch( - 0.866439611536, - 0.2948272403, - 142.4953388878 + 0.8664396115356694, + 0.2948272403370167, + 142.49533888780996 ) } ] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 82106479..3cdea87d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -66,7 +66,7 @@ match do |actual| expect(actual).to match_array(expected.map do |obj| if obj.is_a?(Numeric) - a_value_within(epsilon * 10).of(obj) + a_value_within(epsilon).of(obj) else obj end From b877d6d643be5c9f8c7df96234522191bad02ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 17:41:56 -0700 Subject: [PATCH 523/700] Avoid unnecessary float conversion --- lib/sass/value/color/space/lab.rb | 2 +- lib/sass/value/color/space/oklab.rb | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/sass/value/color/space/lab.rb b/lib/sass/value/color/space/lab.rb index 164db01e..3f88acfa 100644 --- a/lib/sass/value/color/space/lab.rb +++ b/lib/sass/value/color/space/lab.rb @@ -63,7 +63,7 @@ def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParamet private def _convert_f_to_x_or_z(component) - cubed = (component**3) + 0.0 + cubed = component**3 cubed > Utils::LAB_EPSILON ? cubed : ((116 * component) - 16) / Utils::LAB_KAPPA end end diff --git a/lib/sass/value/color/space/oklab.rb b/lib/sass/value/color/space/oklab.rb index c13686e5..d3179c84 100644 --- a/lib/sass/value/color/space/oklab.rb +++ b/lib/sass/value/color/space/oklab.rb @@ -37,21 +37,15 @@ def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParamet LMS.convert( dest, - (( - (Conversions::OKLAB_TO_LMS[0] * lightness) + - (Conversions::OKLAB_TO_LMS[1] * a) + - (Conversions::OKLAB_TO_LMS[2] * b) - )**3) + 0.0, - (( - (Conversions::OKLAB_TO_LMS[3] * lightness) + - (Conversions::OKLAB_TO_LMS[4] * a) + - (Conversions::OKLAB_TO_LMS[5] * b) - )**3) + 0.0, - (( - (Conversions::OKLAB_TO_LMS[6] * lightness) + - (Conversions::OKLAB_TO_LMS[7] * a) + - (Conversions::OKLAB_TO_LMS[8] * b) - )**3) + 0.0, + ((Conversions::OKLAB_TO_LMS[0] * lightness) + + (Conversions::OKLAB_TO_LMS[1] * a) + + (Conversions::OKLAB_TO_LMS[2] * b))**3, + ((Conversions::OKLAB_TO_LMS[3] * lightness) + + (Conversions::OKLAB_TO_LMS[4] * a) + + (Conversions::OKLAB_TO_LMS[5] * b))**3, + ((Conversions::OKLAB_TO_LMS[6] * lightness) + + (Conversions::OKLAB_TO_LMS[7] * a) + + (Conversions::OKLAB_TO_LMS[8] * b))**3, alpha, missing_lightness:, missing_chroma:, From 6fab03d75c5f105a37593cb1e9e02dadfe587971 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:29:37 -0700 Subject: [PATCH 524/700] Bump sass from 1.79.3 to 1.79.4 in /ext/sass (#237) Bumps [sass](https://github.com/sass/dart-sass) from 1.79.3 to 1.79.4. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.79.3...1.79.4) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 45fdfe11..e06069be 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.79.3" + "sass": "1.79.4" } } From 845b7fe5c41a62ef239f8599120b3f677fa7bd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 20:38:03 -0700 Subject: [PATCH 525/700] v1.79.4 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 4e22c20d..85aaab65 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.79.3' + VERSION = '1.79.4' end end From 7ad347ba67154a6f2e64a91792ddd437c896fbd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 21:20:28 -0700 Subject: [PATCH 526/700] Fix doc --- lib/sass/value/color.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 1b057fb6..8273507b 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -101,7 +101,7 @@ def to_gamut(method:, space: nil) _to_gamut(GamutMapMethod.from_name(method, 'method')) end - # @return [Array] + # @return [Array] def channels_or_nil [channel0_or_nil, channel1_or_nil, channel2_or_nil].freeze end From aa8884d666a74474f261c622c7cdfc582751f51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 00:22:04 -0700 Subject: [PATCH 527/700] Use safe navigation operator (#238) --- ext/sass/Rakefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 0f6a65d7..f2cbc687 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -83,9 +83,7 @@ file 'cli.rb' => %w[dart-sass] do |t| INTERPRETER = '#{interpreter}' COMMAND = [ - *(ELF::INTERPRETER unless ELF::INTERPRETER.nil? || - ELF::INTERPRETER == INTERPRETER || - !ELF::INTERPRETER.end_with?(INTERPRETER)), + *(ELF::INTERPRETER if ELF::INTERPRETER != INTERPRETER && ELF::INTERPRETER&.end_with?(INTERPRETER)), #{command_source} ].freeze end From c2a682149332d626743a970b2db58f5814a532e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 01:30:08 -0700 Subject: [PATCH 528/700] Fix doc --- lib/sass/value/color.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 8273507b..0ffb1662 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -254,12 +254,12 @@ def change(**options) changed_color._to_space(_space) end - # return [Numeric] + # @return [Numeric] def alpha @alpha_or_nil.nil? ? 0 : @alpha_or_nil end - # return [::Boolean] + # @return [::Boolean] def legacy? _space.legacy? end From 414516f6c5bc978385b3b57fae11e6862ef00767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 09:55:57 -0700 Subject: [PATCH 529/700] Update spec --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3cdea87d..42cc37fc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,6 +51,7 @@ case expected when Sass::Value::Color expect { actual.assert_color }.not_to raise_error + expect(actual.space).to eq(expected.space) expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil) expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) expect(actual.alpha).to fuzzy_eq(expected.alpha) From b0f70d9e25b9f83c41ff4b2a25d3fd61eb7fbb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 12:33:41 -0700 Subject: [PATCH 530/700] Use native round (#240) --- lib/sass/value/color.rb | 26 +++++----- lib/sass/value/color/gamut_map_method/clip.rb | 2 +- lib/sass/value/color/space/a98_rgb.rb | 4 +- lib/sass/value/color/space/prophoto_rgb.rb | 4 +- lib/sass/value/color/space/rec2020.rb | 4 +- lib/sass/value/color/space/utils.rb | 4 +- lib/sass/value/fuzzy_math.rb | 51 +++---------------- lib/sass/value/number.rb | 2 +- spec/spec_helper.rb | 6 +-- 9 files changed, 32 insertions(+), 71 deletions(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 0ffb1662..cb3a7217 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -318,32 +318,32 @@ def ==(other) if legacy? return false unless other.legacy? - return false unless FuzzyMath.equals_nilable(other.alpha_or_nil, alpha_or_nil) + return false unless FuzzyMath.equals(other.alpha_or_nil, alpha_or_nil) if _space == other._space - FuzzyMath.equals_nilable(other.channel0_or_nil, channel0_or_nil) && - FuzzyMath.equals_nilable(other.channel1_or_nil, channel1_or_nil) && - FuzzyMath.equals_nilable(other.channel2_or_nil, channel2_or_nil) + FuzzyMath.equals(other.channel0_or_nil, channel0_or_nil) && + FuzzyMath.equals(other.channel1_or_nil, channel1_or_nil) && + FuzzyMath.equals(other.channel2_or_nil, channel2_or_nil) else _to_space(Space::RGB) == other._to_space(Space::RGB) end else other._space == _space && - FuzzyMath.equals_nilable(other.channel0_or_nil, channel0_or_nil) && - FuzzyMath.equals_nilable(other.channel1_or_nil, channel1_or_nil) && - FuzzyMath.equals_nilable(other.channel2_or_nil, channel2_or_nil) && - FuzzyMath.equals_nilable(other.alpha_or_nil, alpha_or_nil) + FuzzyMath.equals(other.channel0_or_nil, channel0_or_nil) && + FuzzyMath.equals(other.channel1_or_nil, channel1_or_nil) && + FuzzyMath.equals(other.channel2_or_nil, channel2_or_nil) && + FuzzyMath.equals(other.alpha_or_nil, alpha_or_nil) end end # @return [Integer] def hash @hash ||= [ - _space, - channel0_or_nil&.finite? ? (channel0_or_nil * FuzzyMath::INVERSE_EPSILON).round : channel0_or_nil, # rubocop:disable Security/CompoundHash - channel1_or_nil&.finite? ? (channel1_or_nil * FuzzyMath::INVERSE_EPSILON).round : channel1_or_nil, # rubocop:disable Security/CompoundHash - channel2_or_nil&.finite? ? (channel2_or_nil * FuzzyMath::INVERSE_EPSILON).round : channel2_or_nil, # rubocop:disable Security/CompoundHash - alpha_or_nil&.finite? ? (alpha_or_nil * FuzzyMath::INVERSE_EPSILON).round : alpha_or_nil # rubocop:disable Security/CompoundHash + _space.name, + FuzzyMath._round(channel0_or_nil), + FuzzyMath._round(channel1_or_nil), + FuzzyMath._round(channel2_or_nil), + FuzzyMath._round(alpha_or_nil) ].hash end diff --git a/lib/sass/value/color/gamut_map_method/clip.rb b/lib/sass/value/color/gamut_map_method/clip.rb index c6a2b434..81978b3c 100644 --- a/lib/sass/value/color/gamut_map_method/clip.rb +++ b/lib/sass/value/color/gamut_map_method/clip.rb @@ -29,7 +29,7 @@ def _clamp_channel(value, channel) case channel when LinearChannel - FuzzyMath.clamp_like_css(value, channel.min, channel.max) + FuzzyMath._clamp_like_css(value, channel.min, channel.max) else value end diff --git a/lib/sass/value/color/space/a98_rgb.rb b/lib/sass/value/color/space/a98_rgb.rb index bdfe0d54..cb85f228 100644 --- a/lib/sass/value/color/space/a98_rgb.rb +++ b/lib/sass/value/color/space/a98_rgb.rb @@ -17,11 +17,11 @@ def initialize end def to_linear(channel) - FuzzyMath.sign(channel) * (channel.abs**(563 / 256.0)) + (channel <=> 0) * (channel.abs**(563 / 256.0)) end def from_linear(channel) - FuzzyMath.sign(channel) * (channel.abs**(256 / 563.0)) + (channel <=> 0) * (channel.abs**(256 / 563.0)) end private diff --git a/lib/sass/value/color/space/prophoto_rgb.rb b/lib/sass/value/color/space/prophoto_rgb.rb index 88ac5947..a0a5760f 100644 --- a/lib/sass/value/color/space/prophoto_rgb.rb +++ b/lib/sass/value/color/space/prophoto_rgb.rb @@ -18,12 +18,12 @@ def initialize def to_linear(channel) abs = channel.abs - abs <= 16 / 512.0 ? channel / 16.0 : FuzzyMath.sign(channel) * (abs**1.8) + abs <= 16 / 512.0 ? channel / 16.0 : (channel <=> 0) * (abs**1.8) end def from_linear(channel) abs = channel.abs - abs >= 1 / 512.0 ? FuzzyMath.sign(channel) * (abs**(1 / 1.8)) : 16 * channel + abs >= 1 / 512.0 ? (channel <=> 0) * (abs**(1 / 1.8)) : 16 * channel end private diff --git a/lib/sass/value/color/space/rec2020.rb b/lib/sass/value/color/space/rec2020.rb index 4d3febfa..f7dfcd5f 100644 --- a/lib/sass/value/color/space/rec2020.rb +++ b/lib/sass/value/color/space/rec2020.rb @@ -28,12 +28,12 @@ def initialize def to_linear(channel) abs = channel.abs - abs < BETA * 4.5 ? channel / 4.5 : FuzzyMath.sign(channel) * (((abs + ALPHA - 1) / ALPHA)**(1 / 0.45)) + abs < BETA * 4.5 ? channel / 4.5 : (channel <=> 0) * (((abs + ALPHA - 1) / ALPHA)**(1 / 0.45)) end def from_linear(channel) abs = channel.abs - abs > BETA ? FuzzyMath.sign(channel) * ((ALPHA * (abs**0.45)) - (ALPHA - 1)) : 4.5 * channel + abs > BETA ? (channel <=> 0) * ((ALPHA * (abs**0.45)) - (ALPHA - 1)) : 4.5 * channel end private diff --git a/lib/sass/value/color/space/utils.rb b/lib/sass/value/color/space/utils.rb index 4f611c13..77453bd0 100644 --- a/lib/sass/value/color/space/utils.rb +++ b/lib/sass/value/color/space/utils.rb @@ -37,7 +37,7 @@ module Utils # @return [Numeric] def srgb_and_display_p3_to_linear(channel) abs = channel.abs - abs < 0.04045 ? channel / 12.92 : FuzzyMath.sign(channel) * (((abs + 0.055) / 1.055)**2.4) + abs < 0.04045 ? channel / 12.92 : (channel <=> 0) * (((abs + 0.055) / 1.055)**2.4) end # The algorithm for converting a single `srgb` or `display-p3` channel to @@ -46,7 +46,7 @@ def srgb_and_display_p3_to_linear(channel) # @return [Numeric] def srgb_and_display_p3_from_linear(channel) abs = channel.abs - abs <= 0.0031308 ? channel * 12.92 : FuzzyMath.sign(channel) * ((1.055 * (abs**(1 / 2.4))) - 0.055) + abs <= 0.0031308 ? channel * 12.92 : (channel <=> 0) * ((1.055 * (abs**(1 / 2.4))) - 0.055) end # Converts a Lab or OKLab color to LCH or OKLCH, respectively. diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index c4ada5dd..1566e34f 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -4,29 +4,12 @@ module Sass module Value # Sass's {FuzzyMath} module. module FuzzyMath - PRECISION = 10 - - EPSILON = 10**(-PRECISION - 1) - - INVERSE_EPSILON = 10**(PRECISION + 1) + PRECISION = 11 module_function def equals(number1, number2) - return true if number1 == number2 - - (number1 - number2).abs <= EPSILON && - (number1 * INVERSE_EPSILON).round == - (number2 * INVERSE_EPSILON).round - end - - def equals_nilable(number1, number2) - return true if number1 == number2 - return false if number1.nil? || number2.nil? - - (number1 - number2).abs <= EPSILON && - (number1 * INVERSE_EPSILON).round == - (number2 * INVERSE_EPSILON).round + number1 == number2 || number1.round(PRECISION) == number2.round(PRECISION) end def less_than(number1, number2) @@ -49,31 +32,13 @@ def integer?(number) return false unless number.finite? return true if number.integer? - equals((number - 0.5).abs % 1, 0.5) + number.round == number.round(PRECISION) end def to_i(number) integer?(number) ? number.round : nil end - def round(number) - if number.positive? - less_than(number % 1, 0.5) ? number.floor : number.ceil - else - less_than_or_equals(number % 1, 0.5) ? number.floor : number.ceil - end - end - - def sign(number) - if number.positive? - 1 - elsif number.negative? - -1 - else - 0 - end - end - def between(number, min, max) return min if equals(number, min) return max if equals(number, max) @@ -89,16 +54,12 @@ def assert_between(number, min, max, name) raise Sass::ScriptError.new("#{number} must be between #{min} and #{max}.", name) end - def clamp_like_css(number, lower_bound, upper_bound) + def _clamp_like_css(number, lower_bound, upper_bound) number.to_f.nan? ? lower_bound : number.clamp(lower_bound, upper_bound) end - def hash(number) - if number.finite? - (number * INVERSE_EPSILON).round.hash - else - number.hash - end + def _round(number) + number&.finite? ? number.round(PRECISION).to_f : number end end diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index f3d91ae3..46db9a99 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -99,7 +99,7 @@ def ==(other) # @return [Integer] def hash - @hash ||= FuzzyMath.hash(canonical_units_value) + @hash ||= FuzzyMath._round(canonical_units_value).hash end # @return [::Boolean] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 42cc37fc..afdaeb52 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,7 +44,7 @@ supports_block_expectations end -epsilon = Sass::Value.const_get(:FuzzyMath)::EPSILON +precision = Sass::Value.const_get(:FuzzyMath)::PRECISION - 1 RSpec::Matchers.matcher :fuzzy_eq do |expected| match do |actual| @@ -56,7 +56,7 @@ expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) expect(actual.alpha).to fuzzy_eq(expected.alpha) when Numeric - expect(actual).to be_within(epsilon).of(expected) + expect(actual).to be_within(((10**-precision) / 2)).of(expected.round(precision)) else expect(actual).to eq(expected) end @@ -67,7 +67,7 @@ match do |actual| expect(actual).to match_array(expected.map do |obj| if obj.is_a?(Numeric) - a_value_within(epsilon).of(obj) + a_value_within((10**-precision) / 2).of(obj.round(precision)) else obj end From dbe6edd478ee35c2ad123d0da64d30942b5c6ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 14:13:42 -0700 Subject: [PATCH 531/700] Partially revert #240 (#241) --- lib/sass/value/color.rb | 16 ++++++++-------- lib/sass/value/fuzzy_math.rb | 23 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index cb3a7217..d5858f53 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -318,21 +318,21 @@ def ==(other) if legacy? return false unless other.legacy? - return false unless FuzzyMath.equals(other.alpha_or_nil, alpha_or_nil) + return false unless FuzzyMath.equals_nilable(other.alpha_or_nil, alpha_or_nil) if _space == other._space - FuzzyMath.equals(other.channel0_or_nil, channel0_or_nil) && - FuzzyMath.equals(other.channel1_or_nil, channel1_or_nil) && - FuzzyMath.equals(other.channel2_or_nil, channel2_or_nil) + FuzzyMath.equals_nilable(other.channel0_or_nil, channel0_or_nil) && + FuzzyMath.equals_nilable(other.channel1_or_nil, channel1_or_nil) && + FuzzyMath.equals_nilable(other.channel2_or_nil, channel2_or_nil) else _to_space(Space::RGB) == other._to_space(Space::RGB) end else other._space == _space && - FuzzyMath.equals(other.channel0_or_nil, channel0_or_nil) && - FuzzyMath.equals(other.channel1_or_nil, channel1_or_nil) && - FuzzyMath.equals(other.channel2_or_nil, channel2_or_nil) && - FuzzyMath.equals(other.alpha_or_nil, alpha_or_nil) + FuzzyMath.equals_nilable(other.channel0_or_nil, channel0_or_nil) && + FuzzyMath.equals_nilable(other.channel1_or_nil, channel1_or_nil) && + FuzzyMath.equals_nilable(other.channel2_or_nil, channel2_or_nil) && + FuzzyMath.equals_nilable(other.alpha_or_nil, alpha_or_nil) end end diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index 1566e34f..b88b9a54 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -6,10 +6,27 @@ module Value module FuzzyMath PRECISION = 11 + EPSILON = 10**-PRECISION + + INVERSE_EPSILON = 10**PRECISION + module_function def equals(number1, number2) - number1 == number2 || number1.round(PRECISION) == number2.round(PRECISION) + return true if number1 == number2 + + (number1 - number2).abs <= EPSILON && + (number1 * INVERSE_EPSILON).round == + (number2 * INVERSE_EPSILON).round + end + + def equals_nilable(number1, number2) + return true if number1 == number2 + return false if number1.nil? || number2.nil? + + (number1 - number2).abs <= EPSILON && + (number1 * INVERSE_EPSILON).round == + (number2 * INVERSE_EPSILON).round end def less_than(number1, number2) @@ -32,7 +49,7 @@ def integer?(number) return false unless number.finite? return true if number.integer? - number.round == number.round(PRECISION) + (number.round - number.round(PRECISION)).abs < EPSILON end def to_i(number) @@ -59,7 +76,7 @@ def _clamp_like_css(number, lower_bound, upper_bound) end def _round(number) - number&.finite? ? number.round(PRECISION).to_f : number + number&.finite? ? (number * INVERSE_EPSILON).round : number end end From 2f4ba1c04af57e1730eea51878898e4148d8cb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 15:52:58 -0700 Subject: [PATCH 532/700] Update number.integer? --- lib/sass/value/fuzzy_math.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index b88b9a54..4d69e0a1 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -47,9 +47,8 @@ def greater_than_or_equals(number1, number2) def integer?(number) return false unless number.finite? - return true if number.integer? - (number.round - number.round(PRECISION)).abs < EPSILON + equals(number.round, number.round(PRECISION)) end def to_i(number) From 5be339d6f2f1eeed173d197c7005a9d60239bbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 15:57:17 -0700 Subject: [PATCH 533/700] Rename hash code helper method --- lib/sass/value/color.rb | 8 ++++---- lib/sass/value/fuzzy_math.rb | 2 +- lib/sass/value/number.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index d5858f53..8eb0662b 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -340,10 +340,10 @@ def ==(other) def hash @hash ||= [ _space.name, - FuzzyMath._round(channel0_or_nil), - FuzzyMath._round(channel1_or_nil), - FuzzyMath._round(channel2_or_nil), - FuzzyMath._round(alpha_or_nil) + FuzzyMath._hash(channel0_or_nil), + FuzzyMath._hash(channel1_or_nil), + FuzzyMath._hash(channel2_or_nil), + FuzzyMath._hash(alpha_or_nil) ].hash end diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index 4d69e0a1..d1e19bcc 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -74,7 +74,7 @@ def _clamp_like_css(number, lower_bound, upper_bound) number.to_f.nan? ? lower_bound : number.clamp(lower_bound, upper_bound) end - def _round(number) + def _hash(number) number&.finite? ? (number * INVERSE_EPSILON).round : number end end diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index 46db9a99..aac588c0 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -99,7 +99,7 @@ def ==(other) # @return [Integer] def hash - @hash ||= FuzzyMath._round(canonical_units_value).hash + @hash ||= FuzzyMath._hash(canonical_units_value).hash end # @return [::Boolean] From 6e34139fe4bbec8aae6ea432ea02e5644f08921a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 28 Sep 2024 16:34:08 -0700 Subject: [PATCH 534/700] Align fuzzy equality with format precision (#239) --- lib/sass/value/fuzzy_math.rb | 2 +- spec/sass/value/number_spec.rb | 10 +++++----- spec/spec_helper.rb | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index d1e19bcc..f00aa34d 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -4,7 +4,7 @@ module Sass module Value # Sass's {FuzzyMath} module. module FuzzyMath - PRECISION = 11 + PRECISION = 10 EPSILON = 10**-PRECISION diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index a5cfc51c..aa204b19 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -5,7 +5,7 @@ # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/number.test.ts describe Sass::Value::Number do let(:precision) do - 10 + Sass::Value.const_get(:FuzzyMath)::PRECISION end describe 'unitless' do @@ -74,15 +74,15 @@ end it 'equals the same number within precision tolerance' do - expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) - expect(number).to eq(described_class.new(123 - 10.pow(-precision - 2))) + expect(number).to eq(described_class.new(123 + 10.pow(-precision - 1))) + expect(number).to eq(described_class.new(123 - 10.pow(-precision - 1))) end it "doesn't equal a different number" do expect(number).not_to eq(described_class.new(122)) expect(number).not_to eq(described_class.new(124)) - expect(number).not_to eq(described_class.new(123 + 10.pow(-precision - 1))) - expect(number).not_to eq(described_class.new(123 - 10.pow(-precision - 1))) + expect(number).not_to eq(described_class.new(123 + 10.pow(-precision))) + expect(number).not_to eq(described_class.new(123 - 10.pow(-precision))) end it "doesn't equal a number with units" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index afdaeb52..d89947b7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,7 +44,7 @@ supports_block_expectations end -precision = Sass::Value.const_get(:FuzzyMath)::PRECISION - 1 +precision = Sass::Value.const_get(:FuzzyMath)::PRECISION RSpec::Matchers.matcher :fuzzy_eq do |expected| match do |actual| @@ -55,8 +55,9 @@ expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil) expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) expect(actual.alpha).to fuzzy_eq(expected.alpha) + expect(actual).to eq(expected) when Numeric - expect(actual).to be_within(((10**-precision) / 2)).of(expected.round(precision)) + expect(actual).to be_within((10**-precision) / 2).of(expected.round(precision)) else expect(actual).to eq(expected) end From 5baf3d8b170ac6be281d44b39201b7e29b55106e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 30 Sep 2024 20:45:16 -0700 Subject: [PATCH 535/700] Revert fuzzy equal precision --- lib/sass/value/fuzzy_math.rb | 4 ++-- spec/sass/value/number_spec.rb | 8 ++++---- spec/spec_helper.rb | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index f00aa34d..019cef70 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -6,9 +6,9 @@ module Value module FuzzyMath PRECISION = 10 - EPSILON = 10**-PRECISION + EPSILON = 10**(-PRECISION - 1) - INVERSE_EPSILON = 10**PRECISION + INVERSE_EPSILON = 10**(PRECISION + 1) module_function diff --git a/spec/sass/value/number_spec.rb b/spec/sass/value/number_spec.rb index aa204b19..6017ba6a 100644 --- a/spec/sass/value/number_spec.rb +++ b/spec/sass/value/number_spec.rb @@ -74,15 +74,15 @@ end it 'equals the same number within precision tolerance' do - expect(number).to eq(described_class.new(123 + 10.pow(-precision - 1))) - expect(number).to eq(described_class.new(123 - 10.pow(-precision - 1))) + expect(number).to eq(described_class.new(123 + 10.pow(-precision - 2))) + expect(number).to eq(described_class.new(123 - 10.pow(-precision - 2))) end it "doesn't equal a different number" do expect(number).not_to eq(described_class.new(122)) expect(number).not_to eq(described_class.new(124)) - expect(number).not_to eq(described_class.new(123 + 10.pow(-precision))) - expect(number).not_to eq(described_class.new(123 - 10.pow(-precision))) + expect(number).not_to eq(described_class.new(123 + 10.pow(-precision - 1))) + expect(number).not_to eq(described_class.new(123 - 10.pow(-precision - 1))) end it "doesn't equal a number with units" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d89947b7..1f9a83d5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -55,9 +55,9 @@ expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil) expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) expect(actual.alpha).to fuzzy_eq(expected.alpha) - expect(actual).to eq(expected) + # expect(actual).to eq(expected) when Numeric - expect(actual).to be_within((10**-precision) / 2).of(expected.round(precision)) + expect(actual).to be_within(10**-precision).of(expected) else expect(actual).to eq(expected) end @@ -68,7 +68,7 @@ match do |actual| expect(actual).to match_array(expected.map do |obj| if obj.is_a?(Numeric) - a_value_within((10**-precision) / 2).of(obj.round(precision)) + a_value_within(10**-precision).of(obj) else obj end From 30cf99418de25fc9db31561c4b836a19df9a228e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 30 Sep 2024 20:48:37 -0700 Subject: [PATCH 536/700] Fix number.integer? --- lib/sass/value/fuzzy_math.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/fuzzy_math.rb b/lib/sass/value/fuzzy_math.rb index 019cef70..7717863a 100644 --- a/lib/sass/value/fuzzy_math.rb +++ b/lib/sass/value/fuzzy_math.rb @@ -48,7 +48,7 @@ def greater_than_or_equals(number1, number2) def integer?(number) return false unless number.finite? - equals(number.round, number.round(PRECISION)) + equals(number, number.round) end def to_i(number) From 3ea7e07a606d652c303fca11bbe98b61412dcb88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 09:28:34 -0700 Subject: [PATCH 537/700] Update rubocop-rspec requirement from ~> 3.0.1 to ~> 3.1.0 (#242) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.0.1...v3.1.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f0b90c92..18dab3d2 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do gem 'rubocop', '~> 1.66.0' gem 'rubocop-performance', '~> 1.22.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 3.0.1' + gem 'rubocop-rspec', '~> 3.1.0' end From 217ba922512226abd6dacd410405860faf71e4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 1 Oct 2024 11:04:10 -0700 Subject: [PATCH 538/700] Fix srgb to linear --- lib/sass/value/color/space/utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/value/color/space/utils.rb b/lib/sass/value/color/space/utils.rb index 77453bd0..54cc2334 100644 --- a/lib/sass/value/color/space/utils.rb +++ b/lib/sass/value/color/space/utils.rb @@ -37,7 +37,7 @@ module Utils # @return [Numeric] def srgb_and_display_p3_to_linear(channel) abs = channel.abs - abs < 0.04045 ? channel / 12.92 : (channel <=> 0) * (((abs + 0.055) / 1.055)**2.4) + abs <= 0.04045 ? channel / 12.92 : (channel <=> 0) * (((abs + 0.055) / 1.055)**2.4) end # The algorithm for converting a single `srgb` or `display-p3` channel to From eb64b608c1df6b890d91135228fc87550a50f688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 1 Oct 2024 11:36:37 -0700 Subject: [PATCH 539/700] Use [].minmax instead of [].min and [].max --- lib/sass/value/color/space/srgb.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/value/color/space/srgb.rb b/lib/sass/value/color/space/srgb.rb index 624081d4..8ec42904 100644 --- a/lib/sass/value/color/space/srgb.rb +++ b/lib/sass/value/color/space/srgb.rb @@ -26,8 +26,7 @@ def convert(dest, red, green, blue, alpha, green = 0 if green.nil? blue = 0 if blue.nil? - max = [red, green, blue].max - min = [red, green, blue].min + min, max = [red, green, blue].minmax delta = max - min hue = if max == min From f223e67af67c7cb8f154ea79d1621e5433f1cbc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 6 Oct 2024 12:15:31 -0700 Subject: [PATCH 540/700] Compare only basename of ELF interpreter (#243) --- ext/sass/Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index f2cbc687..ce2fd2a0 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -82,8 +82,10 @@ file 'cli.rb' => %w[dart-sass] do |t| module CLI INTERPRETER = '#{interpreter}' + INTERPRETER_SUFFIX = '/#{File.basename(interpreter)}' + COMMAND = [ - *(ELF::INTERPRETER if ELF::INTERPRETER != INTERPRETER && ELF::INTERPRETER&.end_with?(INTERPRETER)), + *(ELF::INTERPRETER if ELF::INTERPRETER != INTERPRETER && ELF::INTERPRETER&.end_with?(INTERPRETER_SUFFIX)), #{command_source} ].freeze end From 6f8e1adf4b09590a42104425250b1351e1513da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 10 Oct 2024 16:59:08 -0700 Subject: [PATCH 541/700] Update LMS matrices (#244) --- lib/sass/value/color/conversions.rb | 115 +++++++++++++++------------- spec/spec_helper.rb | 3 +- 2 files changed, 64 insertions(+), 54 deletions(-) diff --git a/lib/sass/value/color/conversions.rb b/lib/sass/value/color/conversions.rb index 927212b7..331d218d 100644 --- a/lib/sass/value/color/conversions.rb +++ b/lib/sass/value/color/conversions.rb @@ -7,28 +7,35 @@ class Color # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/conversions.dart module Conversions # The D50 white point. + # + # Definition from https://www.w3.org/TR/css-color-4/#color-conversion-code. D50 = [0.3457 / 0.3585, 1.00000, (1.0 - 0.3457 - 0.3585) / 0.3585].freeze + # Matrix values from https://www.w3.org/TR/css-color-4/#color-conversion-code. + # The transformation matrix for converting LMS colors to OKLab. # - # Note that this can't be directly multiplied with {XYZ_D65_TO_LMS}; see Color + # Note that this can't be directly multiplied with [XYZ_D65_TO_LMS]; see Color # Level 4 spec for details on how to convert between XYZ and OKLab. LMS_TO_OKLAB = [ - 0.2104542553, 0.7936177850, -0.0040720468, - 1.9779984951, -2.4285922050, 0.4505937099, - 0.0259040371, 0.7827717662, -0.8086757660 + 0.21045426830931400, 0.79361777470230540, -0.00407204301161930, + 1.97799853243116840, -2.42859224204858000, 0.45059370961741100, + 0.02590404246554780, 0.78277171245752960, -0.80867575492307740 ].freeze # The transformation matrix for converting OKLab colors to LMS. # - # Note that this can't be directly multiplied with {LMS_TO_XYZ_D65}; see Color + # Note that this can't be directly multiplied with [LMS_TO_XYZ_D65]; see Color # Level 4 spec for details on how to convert between XYZ and OKLab. OKLAB_TO_LMS = [ - 0.99999999845051981432, 0.396337792173767856780, 0.215803758060758803390, - 1.00000000888176077670, -0.105561342323656349400, -0.063854174771705903402, - 1.00000005467241091770, -0.089484182094965759684, -1.291485537864091739900 + 1.00000000000000020, 0.39633777737617490, 0.21580375730991360, + 0.99999999999999980, -0.10556134581565854, -0.06385417282581334, + 0.99999999999999990, -0.08948417752981180, -1.29148554801940940 ].freeze + # The following matrices were precomputed using + # https://gist.github.com/nex3/3d7ecfef467b22e02e7a666db1b8a316. + # The transformation matrix for converting linear-light srgb colors to # linear-light display-p3. LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = [ @@ -38,7 +45,7 @@ module Conversions ].freeze # The transformation matrix for converting linear-light display-p3 colors to - # linear-light srgb. + # linear-light srgb. LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = [ 1.22494017628055980, -0.22494017628055996, 0.00000000000000000, -0.04205695470968816, 1.04205695470968800, 0.00000000000000000, @@ -93,16 +100,16 @@ module Conversions # The transformation matrix for converting linear-light srgb colors to lms. LINEAR_SRGB_TO_LMS = [ - 0.41222147080000016, 0.53633253629999990, 0.05144599290000001, - 0.21190349820000007, 0.68069954509999990, 0.10739695660000000, - 0.08830246190000005, 0.28171883759999994, 0.62997870050000000 + 0.41222146947076300, 0.53633253726173480, 0.05144599326750220, + 0.21190349581782520, 0.68069955064523420, 0.10739695353694050, + 0.08830245919005641, 0.28171883913612150, 0.62997870167382210 ].freeze # The transformation matrix for converting lms colors to linear-light srgb. LMS_TO_LINEAR_SRGB = [ - 4.07674166134799300, -3.30771159040819240, 0.23096992872942781, - -1.26843800409217660, 2.60975740066337240, -0.34131939631021974, - -0.00419608654183720, -0.70341861445944950, 1.70761470093094480 + 4.07674163607595800, -3.30771153925806200, 0.23096990318210417, + -1.26843797328503200, 2.60975734928768900, -0.34131937600265710, + -0.00419607613867551, -0.70341861793593630, 1.70761469407461200 ].freeze # The transformation matrix for converting linear-light srgb colors to @@ -121,14 +128,16 @@ module Conversions -0.00855882878391742, -0.15326670213803720, 1.16182553092195470 ].freeze - # The transformation matrix for converting linear-light srgb colors to xyz-d50. + # The transformation matrix for converting linear-light srgb colors to + # xyz-d50. LINEAR_SRGB_TO_XYZ_D50 = [ 0.43606574687426936, 0.38515150959015960, 0.14307841996513868, 0.22249317711056518, 0.71688701309448240, 0.06061980979495235, 0.01392392146316939, 0.09708132423141015, 0.71409935681588070 ].freeze - # The transformation matrix for converting xyz-d50 colors to linear-light srgb. + # The transformation matrix for converting xyz-d50 colors to linear-light + # srgb. XYZ_D50_TO_LINEAR_SRGB = [ 3.13413585290011780, -1.61738599801804200, -0.49066221791109754, -0.97879547655577770, 1.91625437739598840, 0.03344287339036693, @@ -186,17 +195,17 @@ module Conversions # The transformation matrix for converting linear-light display-p3 colors to # lms. LINEAR_DISPLAY_P3_TO_LMS = [ - 0.48137985442585490, 0.46211836973903553, 0.05650177583510960, - 0.22883194490233110, 0.65321681282840370, 0.11795124216926511, - 0.08394575573016760, 0.22416526885956980, 0.69188897541026260 + 0.48137985274995443, 0.46211837101131803, 0.05650177623872756, + 0.22883194181124472, 0.65321681938356760, 0.11795123880518774, + 0.08394575232299319, 0.22416527097756642, 0.69188897669944040 ].freeze # The transformation matrix for converting lms colors to linear-light # display-p3. LMS_TO_LINEAR_DISPLAY_P3 = [ - 3.12776898667772140, -2.25713579553953770, 0.12936680863610234, - -1.09100904738343900, 2.41333175827934370, -0.32232271065457110, - -0.02601081320950207, -0.50804132569306730, 1.53405213885176520 + 3.12776897136187370, -2.25713576259163860, 0.12936679122976494, + -1.09100901843779790, 2.41333171030692250, -0.32232269186912466, + -0.02601080193857045, -0.50804133170416700, 1.53405213364273730 ].freeze # The transformation matrix for converting linear-light display-p3 colors to @@ -263,16 +272,16 @@ module Conversions # The transformation matrix for converting linear-light a98-rgb colors to lms. LINEAR_A98_RGB_TO_LMS = [ - 0.57643226147714040, 0.36991322114441194, 0.05365451737844765, - 0.29631647387335260, 0.59167612662650690, 0.11200739940014041, - 0.12347825480374285, 0.21949869580674647, 0.65702304938951070 + 0.57643225961839410, 0.36991322261987963, 0.05365451776172635, + 0.29631647054222465, 0.59167613325218850, 0.11200739620558686, + 0.12347825101427760, 0.21949869837199862, 0.65702305061372380 ].freeze # The transformation matrix for converting lms colors to linear-light a98-rgb. LMS_TO_LINEAR_A98_RGB = [ - 2.55403684790806950, -1.62197620262602140, 0.06793935455575403, - -1.26843800409217660, 2.60975740066337240, -0.34131939631021974, - -0.05623474718052319, -0.56704183411879500, 1.62327658124261400 + 2.55403683861155660, -1.62197618068286990, 0.06793934207131327, + -1.26843797328503200, 2.60975734928768900, -0.34131937600265710, + -0.05623473593749381, -0.56704183956690610, 1.62327657550439990 ].freeze # The transformation matrix for converting linear-light a98-rgb colors to @@ -323,16 +332,16 @@ module Conversions # The transformation matrix for converting linear-light rec2020 colors to lms. LINEAR_REC2020_TO_LMS = [ - 0.61675578719908560, 0.36019839939276255, 0.02304581340815186, - 0.26513306398328140, 0.63583936407771060, 0.09902757183900800, - 0.10010263423281572, 0.20390651940192997, 0.69599084636525430 + 0.61675578486544440, 0.36019840122646335, 0.02304581390809228, + 0.26513305939263670, 0.63583937206784910, 0.09902756853951408, + 0.10010262952034828, 0.20390652261661452, 0.69599084786303720 ].freeze # The transformation matrix for converting lms colors to linear-light rec2020. LMS_TO_LINEAR_REC2020 = [ - 2.13990673569556170, -1.24638950878469060, 0.10648277296448995, - -0.88473586245815630, 2.16323098210838260, -0.27849511943390290, - -0.04857375801465988, -0.45450314291725170, 1.50307690088646130 + 2.13990673043465130, -1.24638949376061800, 0.10648276332596668, + -0.88473583575776740, 2.16323093836120070, -0.27849510260343340, + -0.04857374640044396, -0.45450314971409640, 1.50307689611454040 ].freeze # The transformation matrix for converting linear-light rec2020 colors to @@ -369,16 +378,16 @@ module Conversions # The transformation matrix for converting xyz colors to lms. XYZ_D65_TO_LMS = [ - 0.81902244321643190, 0.36190625628012210, -0.12887378261216414, - 0.03298366719802710, 0.92928684689655460, 0.03614466816999844, - 0.04817719956604625, 0.26423952494422764, 0.63354782581369370 + 0.81902243799670300, 0.36190626005289034, -0.12887378152098788, + 0.03298365393238846, 0.92928686158634330, 0.03614466635064235, + 0.04817718935962420, 0.26423953175273080, 0.63354782846943080 ].freeze # The transformation matrix for converting lms colors to xyz. LMS_TO_XYZ_D65 = [ - 1.22687987337415570, -0.55781499655548140, 0.28139105017721590, - -0.04057576262431372, 1.11228682939705960, -0.07171106666151703, - -0.07637294974672143, -0.42149332396279143, 1.58692402442724180 + 1.22687987584592430, -0.55781499446021710, 0.28139104566596460, + -0.04057574521480084, 1.11228680328031730, -0.07171105806551635, + -0.07637293667466007, -0.42149333240224324, 1.58692401983678180 ].freeze # The transformation matrix for converting xyz colors to linear-light @@ -414,31 +423,31 @@ module Conversions # The transformation matrix for converting lms colors to linear-light # prophoto-rgb. LMS_TO_LINEAR_PROPHOTO_RGB = [ - 1.73835514985815240, -0.98795095237343430, 0.24959580241648663, - -0.70704942624914860, 1.93437008438177620, -0.22732065793919040, - -0.08407883426424761, -0.35754059702097796, 1.44161943124947150 + 1.73835514811572070, -0.98795094275144580, 0.24959579463572504, + -0.70704940153292660, 1.93437004444013820, -0.22732064290721150, + -0.08407882206239634, -0.35754060521141334, 1.44161942727380970 ].freeze # The transformation matrix for converting linear-light prophoto-rgb colors to # lms. LINEAR_PROPHOTO_RGB_TO_LMS = [ - 0.71544846349294310, 0.35279154798172740, -0.06824001147467047, - 0.27441165509049420, 0.66779764080811480, 0.05779070400139092, - 0.10978443849083751, 0.18619828746596980, 0.70401727404319270 + 0.71544846056555340, 0.35279155007721186, -0.06824001064276530, + 0.27441164900156710, 0.66779764984123670, 0.05779070115719616, + 0.10978443261622942, 0.18619829115002018, 0.70401727623375040 ].freeze # The transformation matrix for converting lms colors to xyz-d50. LMS_TO_XYZ_D50 = [ - 1.28858621583908840, -0.53787174651736210, 0.21358120705405403, - -0.00253389352489796, 1.09231682453266550, -0.08978293089853581, - -0.06937383312514489, -0.29500839218634667, 1.18948682779245090 + 1.28858621817270600, -0.53787174449737450, 0.21358120275423640, + -0.00253387643187372, 1.09231679887191650, -0.08978292244004273, + -0.06937382305734124, -0.29500839894431263, 1.18948682451211420 ].freeze # The transformation matrix for converting xyz-d50 colors to lms. XYZ_D50_TO_LMS = [ - 0.77070004712402500, 0.34924839871072740, -0.11202352004249890, - 0.00559650559780223, 0.93707232493333150, 0.06972569131301698, - 0.04633715253432816, 0.25277530868525870, 0.85145807371608350 + 0.77070004204311720, 0.34924840261939616, -0.11202351884164681, + 0.00559649248368848, 0.93707234011367690, 0.06972568836252771, + 0.04633714262191069, 0.25277531574310524, 0.85145807674679600 ].freeze # The transformation matrix for converting linear-light prophoto-rgb colors to diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1f9a83d5..b281b287 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,7 +44,8 @@ supports_block_expectations end -precision = Sass::Value.const_get(:FuzzyMath)::PRECISION +# TODO: test with higher precision +precision = Sass::Value.const_get(:FuzzyMath)::PRECISION - 6 RSpec::Matchers.matcher :fuzzy_eq do |expected| match do |actual| From 60def2e4c7e457fa12c3bd70e7d1349bc2ae8066 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:31:46 -0700 Subject: [PATCH 542/700] Bump sass from 1.79.4 to 1.79.5 in /ext/sass (#245) Bumps [sass](https://github.com/sass/dart-sass) from 1.79.4 to 1.79.5. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.79.4...1.79.5) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index e06069be..75e1c56e 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.79.4" + "sass": "1.79.5" } } From d25744eb3508187f4658e0d62032ba693228ef0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 11 Oct 2024 19:42:20 -0700 Subject: [PATCH 543/700] Support missing channels across the embedded protocol (#246) --- lib/sass/compiler/host/protofier.rb | 9 +++++---- spec/sass_proto_spec.rb | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 3140f211..fcf487c9 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -112,13 +112,14 @@ def from_proto(proto) when :number Number.from_proto(obj) when :color + obj.to_s # TODO: https://github.com/protocolbuffers/protobuf/issues/18807 Sass::Value::Color.send( :for_space, obj.space, - obj.channel1, - obj.channel2, - obj.channel3, - obj.alpha + obj.has_channel1? ? obj.channel1 : nil, + obj.has_channel2? ? obj.channel2 : nil, + obj.has_channel3? ? obj.channel3 : nil, + obj.has_alpha? ? obj.alpha : nil ) when :argument_list Sass::Value::ArgumentList.new( diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 2f836b00..a2c43e19 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -63,9 +63,9 @@ def remote_eq(lhs, rhs) ]) ]), __LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)), - __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), - __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), - __LINE__ => Sass::Value::Color.new(hue: 0, whiteness: 0, blackness: 0, alpha: 1), + __LINE__ => Sass::Value::Color.new(red: 0.1, green: 0.2, blue: nil, alpha: 1, space: 'rgb'), + __LINE__ => Sass::Value::Color.new(hue: 0.4, saturation: nil, lightness: 0.6, alpha: 1, space: 'hsl'), + __LINE__ => Sass::Value::Color.new(hue: nil, whiteness: 0.8, blackness: 0.9, alpha: 1, space: 'hwb'), __LINE__ => Sass::Value::List.new, __LINE__ => Sass::Value::List.new([Sass::Value::String.new('a')]), __LINE__ => Sass::Value::List.new([Sass::Value::String.new('a')], separator: ','), From c9ce2433fd0a9f6a71b59b49222fba50be68bd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 11 Oct 2024 19:48:55 -0700 Subject: [PATCH 544/700] v1.79.5 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 85aaab65..6daf7333 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.79.4' + VERSION = '1.79.5' end end From 91cbebec6379937f3b2c5c11c7fe104b69ec3328 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:32:47 -0700 Subject: [PATCH 545/700] Update rubocop requirement from ~> 1.66.0 to ~> 1.67.0 (#247) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.66.0...v1.67.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 18dab3d2..632f6c7f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.66.0' + gem 'rubocop', '~> 1.67.0' gem 'rubocop-performance', '~> 1.22.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.1.0' From 6605643248d0dc9ca72b3ec2af65a7e41da215dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 15 Oct 2024 13:21:01 -0700 Subject: [PATCH 546/700] Apply protobuf workaround only on jruby --- lib/sass/compiler/host/protofier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index fcf487c9..f53f9edf 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -112,7 +112,7 @@ def from_proto(proto) when :number Number.from_proto(obj) when :color - obj.to_s # TODO: https://github.com/protocolbuffers/protobuf/issues/18807 + obj.to_s if RUBY_ENGINE == 'jruby' # TODO: https://github.com/protocolbuffers/protobuf/issues/18807 Sass::Value::Color.send( :for_space, obj.space, From 48140baf49f8fd91068a1e3d2ba9cd3561934547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 15 Oct 2024 17:49:08 -0700 Subject: [PATCH 547/700] Increase test data precision (#248) --- lib/sass/value/color.rb | 4 +- .../value/color/interpolation_examples.rb | 48 +++++++++---------- spec/sass/value/color/spaces.rb | 46 +++++++++--------- spec/sass/value/color_4_conversions_spec.rb | 16 +++++++ .../value/color_4_nonparametizable_spec.rb | 24 +++++----- spec/spec_helper.rb | 5 +- 6 files changed, 79 insertions(+), 64 deletions(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 8eb0662b..75f06d04 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -569,8 +569,8 @@ def _analogous_channel_missing?(original, output, output_channel_index) return false if original.equal?(output) - output_channel = output.space.channels[output_channel_index] - original_channel = original.space.channels.find do |channel| + output_channel = output._space.channels[output_channel_index] + original_channel = original._space.channels.find do |channel| output_channel.analogous?(channel) end diff --git a/spec/sass/value/color/interpolation_examples.rb b/spec/sass/value/color/interpolation_examples.rb index 68467b1d..ff4b507e 100644 --- a/spec/sass/value/color/interpolation_examples.rb +++ b/spec/sass/value/color/interpolation_examples.rb @@ -7,7 +7,7 @@ { weight: 0.5 }, - [58.614201646094955, 10.016665992350433, -8.387820174394456] + [58.614201693004674, 10.016667522478151, -8.387819651868517] ], [ { @@ -19,7 +19,7 @@ { weight: 0 }, - [38.95792456574883, -15.169549415088852, -17.792484605053115] + [38.957924659568256, -15.169546354833418, -17.792483560001216] ] ], oklab: [ @@ -27,19 +27,19 @@ { weight: 0.5 }, - [0.6476500020040917, 0.02748550994678843, -0.023408287379941606] + [0.6476500060804854, 0.027485511076670896, -0.023408311310399166] ], [ { weight: 1 }, - [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446] + [0.8241000051752044, 0.10608808769190603, 0.0015900461037656743] ], [ { weight: 0 }, - [0.47120000400818335, -0.05111706453373946, -0.048406651029280656] + [0.47120000698576636, -0.05111706553856424, -0.048406668724564006] ] ], lch: [ @@ -47,7 +47,7 @@ { weight: 0.5 }, - [58.61420164622054, 29.299459370089924, 295.6021177856686] + [58.614201693004674, 29.299457976259603, 295.6021198088788] ], [ { @@ -59,35 +59,35 @@ { weight: 0 }, - [38.957924566, 23.38135449889311, 229.5496923459574] + [38.957924659568256, 23.381351711232465, 229.54969639237788] ], [ { weight: 0.5, method: 'shorter' }, - [58.61420164622054, 29.299459370089924, 295.6021177856686] + [58.614201693004674, 29.299457976259603, 295.6021198088788] ], [ { weight: 0.5, method: 'longer' }, - [58.61420164622054, 29.299459370089924, 115.60211778566858] + [58.614201693004674, 29.299457976259603, 115.6021198088788] ], [ { weight: 0.5, method: 'increasing' }, - [58.61420164622054, 29.299459370089924, 115.60211778566858] + [58.614201693004674, 29.299457976259603, 115.6021198088788] ], [ { weight: 0.5, method: 'decreasing' }, - [58.61420164622054, 29.299459370089924, 295.6021177856686] + [58.614201693004674, 29.299457976259603, 295.6021198088788] ] ], oklch: [ @@ -95,47 +95,47 @@ { weight: 0.5 }, - [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + [0.6476500060804854, 0.0882500012863419, 292.1493473823782] ], [ { weight: 1 }, - [0.8241, 0.1061, 0.8586999999999989] + [0.8241000051752044, 0.1061000028121472, 0.8586836854624949] ], [ { weight: 0 }, - [0.47120000400818335, 0.07039998686375618, 223.4400011847514] + [0.47120000698576636, 0.07039999976053661, 223.44001107929404] ], [ { weight: 0.5, method: 'shorter' }, - [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + [0.6476500060804854, 0.0882500012863419, 292.1493473823782] ], [ { weight: 0.5, method: 'longer' }, - [0.6476500020040917, 0.08824999343187809, 112.1493505923757] + [0.6476500060804854, 0.0882500012863419, 112.14934738237824] ], [ { weight: 0.5, method: 'increasing' }, - [0.6476500020040917, 0.08824999343187809, 112.1493505923757] + [0.6476500060804854, 0.0882500012863419, 112.14934738237824] ], [ { weight: 0.5, method: 'decreasing' }, - [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + [0.6476500060804854, 0.0882500012863419, 292.1493473823782] ] ], srgb: [ @@ -223,7 +223,7 @@ { weight: 0.5 }, - [0.5427623847027483, 0.4757813439417372, 0.5419635636962455] + [0.5427628071521571, 0.4757810859208764, 0.5419635611723659] ], [ { @@ -235,7 +235,7 @@ { weight: 0 }, - [0.2431790331963506, 0.3045087255847488, 0.38356879501347535] + [0.24317987809516806, 0.304508209543027, 0.3835687899657161] ] ], rec2020: [ @@ -283,7 +283,7 @@ { weight: 0.5 }, - [0.3740759617070767, 0.3215358224064546, 0.2908164562135577] + [0.37407596368010154, 0.32153582267804004, 0.29081645447205257] ], [ { @@ -295,7 +295,7 @@ { weight: 0 }, - [0.08408207011375313, 0.10634498228480066, 0.14703708775508573] + [0.08408207405980274, 0.10634498282797152, 0.14703708427207543] ] ], rgb: [ @@ -303,7 +303,7 @@ { weight: 0.5 }, - [146.56944672156501, 134.1448156837381, 157.00580432872178] + [146.49494601036622, 133.9494959758061, 156.77020571682615] ], [ { @@ -315,7 +315,7 @@ { weight: 0 }, - [38.14436413378462, 100.00369046118837, 120.62648929056449] + [37.99536271138702, 99.61305104532435, 120.15529206677323] ] ], hsl: [ diff --git a/spec/sass/value/color/spaces.rb b/spec/sass/value/color/spaces.rb index 6cca4744..b18da243 100644 --- a/spec/sass/value/color/spaces.rb +++ b/spec/sass/value/color/spaces.rb @@ -9,8 +9,8 @@ name: 'lab', is_legacy: false, is_polar: false, - pink: [78.27047872644108, 35.20288139978972, 1.0168442562642044], - blue: [38.95792456574883, -15.169549415088856, -17.792484605053115], + pink: [78.27047872644108, 35.20288139978972, 1.0168442562641822], + blue: [38.957924659568256, -15.169546354833418, -17.792483560001216], channels: %w[lightness a b], ranges: [ [0, 100], @@ -30,8 +30,8 @@ name: 'oklab', is_legacy: false, is_polar: false, - pink: [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446], - blue: [0.47120000400818335, -0.05111706453373946, -0.048406651029280656], + pink: [0.8241000051752044, 0.10608808769190603, 0.0015900461037656743], + blue: [0.47120000698576636, -0.05111706553856424, -0.048406668724564006], channels: %w[lightness a b], ranges: [ [0, 1], @@ -51,8 +51,8 @@ name: 'lch', is_legacy: false, is_polar: true, - pink: [78.27047872644108, 35.21756424128674, 1.6545432253797676], - blue: [38.957924566, 23.38135449889311, 229.54969234595737], + pink: [78.27047872644108, 35.21756424128674, 1.6545432253797117], + blue: [38.957924659568256, 23.381351711232465, 229.54969639237788], channels: %w[lightness chroma hue], has_powerless: true, ranges: [ @@ -73,8 +73,8 @@ name: 'oklch', is_legacy: false, is_polar: true, - pink: [0.8241, 0.1061, 0.8587], - blue: [0.47120000400818335, 0.07039998686375618, 223.44000118475142], + pink: [0.8241000051752044, 0.1061000028121472, 0.8586836854624949], + blue: [0.47120000698576636, 0.07039999976053661, 223.44001107929404], channels: %w[lightness chroma hue], has_powerless: true, ranges: [ @@ -95,7 +95,7 @@ name: 'srgb', is_legacy: false, is_polar: false, - pink: [0.9999785463111585, 0.6599448662991679, 0.758373017125016], + pink: [0.9999785463111587, 0.6599448662991679, 0.7583730171250161], blue: [0.14900142239759614, 0.39063941586401707, 0.47119722379126755], channels: %w[red green blue], ranges: [ @@ -113,7 +113,7 @@ name: 'srgb-linear', is_legacy: false, is_polar: false, - pink: [0.999951196094508, 0.3930503811476254, 0.5356603778005655], + pink: [0.9999511960945082, 0.39305038114762536, 0.5356603778005656], blue: [0.019378214827482948, 0.12640222770203852, 0.18834349393523495], channels: %w[red green blue], ranges: [ @@ -149,7 +149,7 @@ name: 'a98-rgb', is_legacy: false, is_polar: false, - pink: [0.9172837001828321, 0.6540226622083835, 0.7491144397116841], + pink: [0.9172837001828322, 0.6540226622083833, 0.749114439711684], blue: [0.2557909283504703, 0.3904466064332277, 0.4651826475952292], channels: %w[red green blue], ranges: [ @@ -167,8 +167,8 @@ name: 'prophoto-rgb', is_legacy: false, is_polar: false, - pink: [0.842345736209146, 0.6470539622987257, 0.7003583323790157], - blue: [0.24317903319635056, 0.3045087255847488, 0.38356879501347535], + pink: [0.842345736209146, 0.6470539622987259, 0.7003583323790157], + blue: [0.24317987809516806, 0.304508209543027, 0.3835687899657161], channels: %w[red green blue], ranges: [ [0, 1], @@ -185,8 +185,8 @@ name: 'rec2020', is_legacy: false, is_polar: false, - pink: [0.8837118321235519, 0.6578067923850563, 0.7273197917658354], - blue: [0.2151122740532409, 0.32363973150195124, 0.4090033869684574], + pink: [0.883711832123552, 0.6578067923850561, 0.7273197917658352], + blue: [0.21511227405324085, 0.3236397315019512, 0.4090033869684574], channels: %w[red green blue], ranges: [ [0, 1], @@ -224,8 +224,8 @@ name: 'xyz-d50', is_legacy: false, is_polar: false, - pink: [0.6640698533004002, 0.5367266625281085, 0.4345958246720296], - blue: [0.08408207011375313, 0.10634498228480066, 0.1470370877550857], + pink: [0.6640698533004004, 0.5367266625281086, 0.43459582467202973], + blue: [0.08408207405980274, 0.10634498282797152, 0.14703708427207543], channels: %w[x y z], ranges: [ [0, 1], @@ -266,8 +266,8 @@ name: 'rgb', is_legacy: true, is_polar: false, - pink: [254.9945293093454, 168.28594090628783, 193.38511936687908], - blue: [38.144364133784602, 100.003690461188378, 120.626489290564506], + pink: [254.99452930934547, 168.28594090628783, 193.3851193668791], + blue: [37.99536271138702, 99.61305104532435, 120.15529206677323], channels: %w[red green blue], ranges: [ [0, 255], @@ -287,7 +287,7 @@ name: 'hsl', is_legacy: true, is_polar: true, - pink: [342.63204677447646, 99.98738302509669, 82.99617063051632], + pink: [342.63204677447646, 99.98738302509679, 82.99617063051633], blue: [195.0016494775154, 51.95041997811069, 31.009932309443183], channels: %w[hue saturation lightness], has_powerless: true, @@ -302,7 +302,7 @@ [0.5, 110, 50], { clip: [0.5, 100, 50], - 'local-minde': [2.9140262667138472, 100, 52.05146874647547] + 'local-minde': [2.9140266584158057, 100, 52.05146824961835] } ] ] @@ -312,7 +312,7 @@ name: 'hwb', is_legacy: true, is_polar: true, - pink: [342.63204677447646, 65.99448662991679, 0.002145368884157506], + pink: [342.63204677447646, 65.9944866299168, 0.002145368884129084], blue: [195.0016494775154, 14.900142239759612, 52.880277620873244], channels: %w[hue whiteness blackness], has_powerless: true, @@ -327,7 +327,7 @@ [0.5, -3, -7], { clip: [0.5, 0, 0], - 'local-minde': [3.492121744609392, 11.26651892207301, 0] + 'local-minde': [3.492122559065345, 11.266517197307957, 0] } ] ] diff --git a/spec/sass/value/color_4_conversions_spec.rb b/spec/sass/value/color_4_conversions_spec.rb index 6bb03fa4..a341a641 100644 --- a/spec/sass/value/color_4_conversions_spec.rb +++ b/spec/sass/value/color_4_conversions_spec.rb @@ -155,5 +155,21 @@ end end end + + describe 'interpolate()' do + it 'interpolates a rectangular space without options' do + expect( + described_class.new(red: 100, green: 200, blue: 50) + .interpolate(described_class.new(red: 255, green: 255, blue: 255)) + ).to eq(described_class.new(red: 177.5, green: 227.5, blue: 152.5)) + end + + it 'interpolates a polar space without options' do + expect( + described_class.new(hue: 180, saturation: 100, lightness: 50) + .interpolate(described_class.new(red: 100, green: 200, blue: 50)) + ).to eq(described_class.new(hue: 140, saturation: 80, lightness: 49.509803921568626)) + end + end end end diff --git a/spec/sass/value/color_4_nonparametizable_spec.rb b/spec/sass/value/color_4_nonparametizable_spec.rb index 1cdf2865..ffd02336 100644 --- a/spec/sass/value/color_4_nonparametizable_spec.rb +++ b/spec/sass/value/color_4_nonparametizable_spec.rb @@ -14,14 +14,14 @@ 'display-p3', { 'local-minde': ColorConstructors.oklch( - 0.8077756841698541, - 0.3262439045095262, - 148.12027402754507 + 0.8077756760084225, + 0.32624391948277537, + 148.1202761637585 ), clip: ColorConstructors.oklch( - 0.848829286984103, - 0.3685278106366152, - 145.64495037017775 + 0.8488292928532466, + 0.3685277976813825, + 145.64495558662838 ) } ], @@ -30,14 +30,14 @@ 'srgb', { 'local-minde': ColorConstructors.oklch( - 0.809152570178515, - 0.23790275760347995, - 147.40214776873552 + 0.809152561530627, + 0.23790276994468387, + 147.40215048389234 ), clip: ColorConstructors.oklch( - 0.8664396115356694, - 0.2948272403370167, - 142.49533888780996 + 0.8664396175234368, + 0.2948272245426958, + 142.4953450414439 ) } ] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b281b287..c056fe7d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,8 +44,7 @@ supports_block_expectations end -# TODO: test with higher precision -precision = Sass::Value.const_get(:FuzzyMath)::PRECISION - 6 +precision = Sass::Value.const_get(:FuzzyMath)::PRECISION + 1 RSpec::Matchers.matcher :fuzzy_eq do |expected| match do |actual| @@ -56,7 +55,7 @@ expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil) expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) expect(actual.alpha).to fuzzy_eq(expected.alpha) - # expect(actual).to eq(expected) + expect(actual).to eq(expected) when Numeric expect(actual).to be_within(10**-precision).of(expected) else From c4c8ea7078f9935ff9543138d647752c20a444aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 16 Oct 2024 00:48:46 -0700 Subject: [PATCH 548/700] Enable rubocop GitHub Actions formatter (#249) --- Rakefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index e0be435d..d8782f9b 100644 --- a/Rakefile +++ b/Rakefile @@ -23,4 +23,7 @@ end RSpec::Core::RakeTask.new -RuboCop::RakeTask.new +RuboCop::RakeTask.new do |task| + task.formatters = ['progress'] + task.formatters << 'github' if ENV.key?('GITHUB_ACTIONS') +end From 6c11f606d9b0ea0aa8b53d53158b9dac915dedfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 16 Oct 2024 08:26:02 -0700 Subject: [PATCH 549/700] Update spec_helper.rb --- spec/spec_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c056fe7d..2adf0d58 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,7 +44,7 @@ supports_block_expectations end -precision = Sass::Value.const_get(:FuzzyMath)::PRECISION + 1 +epsilon = Sass::Value.const_get(:FuzzyMath)::EPSILON RSpec::Matchers.matcher :fuzzy_eq do |expected| match do |actual| @@ -57,7 +57,7 @@ expect(actual.alpha).to fuzzy_eq(expected.alpha) expect(actual).to eq(expected) when Numeric - expect(actual).to be_within(10**-precision).of(expected) + expect(actual).to be_within(epsilon).of(expected) else expect(actual).to eq(expected) end @@ -68,7 +68,7 @@ match do |actual| expect(actual).to match_array(expected.map do |obj| if obj.is_a?(Numeric) - a_value_within(10**-precision).of(obj) + a_value_within(epsilon).of(obj) else obj end From d731b1e8eb45f1294381d178fc2cf0ae702725cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:42:38 -0700 Subject: [PATCH 550/700] Bump sass from 1.79.5 to 1.79.6 in /ext/sass (#250) Bumps [sass](https://github.com/sass/dart-sass) from 1.79.5 to 1.79.6. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.79.5...1.79.6) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 75e1c56e..65078548 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.79.5" + "sass": "1.79.6" } } From ca74de6bd52b36035cf5fb8863880965fb2d2dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 16 Oct 2024 16:57:07 -0700 Subject: [PATCH 551/700] v1.79.6 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 6daf7333..36605c87 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.79.5' + VERSION = '1.79.6' end end From a3a04d069faa8c32ebe955206f2b03e7d8a91ad1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:31:22 -0700 Subject: [PATCH 552/700] Bump sass from 1.79.6 to 1.80.0 in /ext/sass (#251) Bumps [sass](https://github.com/sass/dart-sass) from 1.79.6 to 1.80.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.79.6...1.80.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 65078548..461977a4 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.79.6" + "sass": "1.80.0" } } From 929b860c925eb9c2d0db991eea54dae96116cf56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 16 Oct 2024 17:36:16 -0700 Subject: [PATCH 553/700] Update google-protobuf requirement from ~> 4.27 to ~> 4.28 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 89b46abf..e365ded9 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_dependency 'google-protobuf', '~> 4.27' + spec.add_dependency 'google-protobuf', '~> 4.28' end From 1422bc3c3e42328ce43d07c13fa3c6ffc5c07172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 16 Oct 2024 17:44:26 -0700 Subject: [PATCH 554/700] v1.80.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 36605c87..1ea9fcd2 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.79.6' + VERSION = '1.80.0' end end From 724a179330dad197a84d1922fb561297dc7f51e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:25:33 -0700 Subject: [PATCH 555/700] Bump sass from 1.80.0 to 1.80.1 in /ext/sass (#252) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.0 to 1.80.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.0...1.80.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 461977a4..be69bfe0 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.0" + "sass": "1.80.1" } } From 15857266b418296a7a8fdeb962e1a17f43b24aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 16 Oct 2024 20:30:16 -0700 Subject: [PATCH 556/700] v1.80.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 1ea9fcd2..98589a25 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.0' + VERSION = '1.80.1' end end From 2bbab0b7600919991fc867d0ad78473c4737739b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 17 Oct 2024 10:38:52 -0700 Subject: [PATCH 557/700] Replace `.to_h { block }` with `.each.with_object({}) { block }` --- lib/sass/compiler/host/protofier.rb | 10 +++++----- lib/sass/serializer.rb | 16 +++++----------- lib/sass/value/number/unit.rb | 9 +++++---- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index f53f9edf..219f7776 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -39,7 +39,7 @@ def to_proto(obj) argument_list: EmbeddedProtocol::Value::ArgumentList.new( id: obj.instance_eval { @id }, contents: obj.to_a.map { |element| to_proto(element) }, - keywords: obj.keywords.to_h { |key, value| [key.to_s, to_proto(value)] }, + keywords: obj.keywords.each.with_object({}) { |(key, value), hash| hash[key.to_s] = to_proto(value) }, separator: ListSeparator.to_proto(obj.separator) ) ) @@ -126,8 +126,8 @@ def from_proto(proto) obj.contents.map do |element| from_proto(element) end, - obj.keywords.entries.to_h do |key, value| - [key.to_sym, from_proto(value)] + obj.keywords.to_enum.with_object({}) do |(key, value), hash| + hash[key.to_sym] = from_proto(value) end, ListSeparator.from_proto(obj.separator) ).instance_eval do @@ -144,8 +144,8 @@ def from_proto(proto) ) when :map Sass::Value::Map.new( - obj.entries.to_h do |entry| - [from_proto(entry.key), from_proto(entry.value)] + obj.entries.to_enum.with_object({}) do |entry, hash| + hash[from_proto(entry.key)] = from_proto(entry.value) end ) when :compiler_function diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index 8216eeb8..12ae70f6 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -5,17 +5,11 @@ module Sass module Serializer module_function - CSS_ESCAPE = { - "\0" => "\uFFFD", - '\\' => '\\\\', - '"' => '\\"', - "'" => "\\'", - **[*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"].product( - [*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil] - ).to_h do |c, x| - ["#{c}#{x}".freeze, "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze] - end - }.freeze + CSS_ESCAPE = [*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"] + .product([*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil]) + .each.with_object({ "\0" => "\uFFFD", '\\' => '\\\\', '"' => '\\"', "'" => "\\'" }) do |(c, x), h| + h["#{c}#{x}".freeze] = "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze + end.freeze private_constant :CSS_ESCAPE diff --git a/lib/sass/value/number/unit.rb b/lib/sass/value/number/unit.rb index bb0a418a..c3c90969 100644 --- a/lib/sass/value/number/unit.rb +++ b/lib/sass/value/number/unit.rb @@ -141,10 +141,11 @@ module Unit 'pixel density': %w[dpi dpcm dppx] }.freeze - TYPES_BY_UNIT = UNITS_BY_TYPE.invert - .to_a - .flat_map { |pair| pair[0].map { |key| [key, pair[1]] } } - .to_h + TYPES_BY_UNIT = UNITS_BY_TYPE.each.with_object({}) do |(key, values), hash| + values.each do |value| + hash[value] = key + end + end module_function From acdcd49da20a7ecf79726bbd44c153aa58e32d15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:09:26 -0700 Subject: [PATCH 558/700] Bump sass from 1.80.1 to 1.80.2 in /ext/sass (#253) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.1 to 1.80.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.1...1.80.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index be69bfe0..042a0e7b 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.1" + "sass": "1.80.2" } } From 95d4afbb0b2b51f26ba12bec67e8d54ece5f62a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 17 Oct 2024 14:11:34 -0700 Subject: [PATCH 559/700] v1.80.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 98589a25..2a174743 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.1' + VERSION = '1.80.2' end end From 7ae055c4f1b05c96b2310f74422dfda1457e3867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 17 Oct 2024 14:46:11 -0700 Subject: [PATCH 560/700] Use each_with_object instead of each.with_object --- lib/sass/compiler/host/protofier.rb | 2 +- lib/sass/serializer.rb | 2 +- lib/sass/value/number/unit.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 219f7776..72ec4c3f 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -39,7 +39,7 @@ def to_proto(obj) argument_list: EmbeddedProtocol::Value::ArgumentList.new( id: obj.instance_eval { @id }, contents: obj.to_a.map { |element| to_proto(element) }, - keywords: obj.keywords.each.with_object({}) { |(key, value), hash| hash[key.to_s] = to_proto(value) }, + keywords: obj.keywords.each_with_object({}) { |(key, value), hash| hash[key.to_s] = to_proto(value) }, separator: ListSeparator.to_proto(obj.separator) ) ) diff --git a/lib/sass/serializer.rb b/lib/sass/serializer.rb index 12ae70f6..6a3bc983 100644 --- a/lib/sass/serializer.rb +++ b/lib/sass/serializer.rb @@ -7,7 +7,7 @@ module Serializer CSS_ESCAPE = [*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"] .product([*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil]) - .each.with_object({ "\0" => "\uFFFD", '\\' => '\\\\', '"' => '\\"', "'" => "\\'" }) do |(c, x), h| + .each_with_object({ "\0" => "\uFFFD", '\\' => '\\\\', '"' => '\\"', "'" => "\\'" }) do |(c, x), h| h["#{c}#{x}".freeze] = "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze end.freeze diff --git a/lib/sass/value/number/unit.rb b/lib/sass/value/number/unit.rb index c3c90969..7d7c7764 100644 --- a/lib/sass/value/number/unit.rb +++ b/lib/sass/value/number/unit.rb @@ -141,7 +141,7 @@ module Unit 'pixel density': %w[dpi dpcm dppx] }.freeze - TYPES_BY_UNIT = UNITS_BY_TYPE.each.with_object({}) do |(key, values), hash| + TYPES_BY_UNIT = UNITS_BY_TYPE.each_with_object({}) do |(key, values), hash| values.each do |value| hash[value] = key end From ef6f794af3f6746bd769057fb23aff3d01f17328 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:03:30 -0700 Subject: [PATCH 561/700] Bump sass from 1.80.2 to 1.80.3 in /ext/sass (#254) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.2 to 1.80.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.2...1.80.3) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 042a0e7b..e2e74bb5 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.2" + "sass": "1.80.3" } } From 1f38adbc3b123ef7bab8e24735c3ce5d4bf29d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 18 Oct 2024 17:10:50 -0700 Subject: [PATCH 562/700] v1.80.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 2a174743..9e92f13f 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.2' + VERSION = '1.80.3' end end From d0f666a0a89a6e54f0fe24f29074263a999891c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:01:21 -0700 Subject: [PATCH 563/700] Bump sass from 1.80.3 to 1.80.4 in /ext/sass (#255) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.3 to 1.80.4. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.3...1.80.4) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index e2e74bb5..a09b1f0c 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.3" + "sass": "1.80.4" } } From a01fca43b87211aaa40c53a25b266a6327efc486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 23 Oct 2024 16:02:00 -0700 Subject: [PATCH 564/700] v1.80.4 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 9e92f13f..9fda2699 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.3' + VERSION = '1.80.4' end end From 1f6a2c76ffcf5db2e843729ec077ff7ce6d0124d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 26 Oct 2024 11:28:52 -0700 Subject: [PATCH 565/700] Raise Gem::UnsatisfiableDependencyError when native gem is not available --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ce2fd2a0..7035a4f0 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -231,7 +231,7 @@ module FileUtils s.platform == platform end - raise if resolver_spec.nil? + raise Gem::UnsatisfiableDependencyError, dependency_request if resolver_spec.nil? options = { force: true, install_dir: } if Rake::FileUtilsExt.nowrite_flag From 7804b0f2bc1d5652d0d5d952313a451365b6cd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 26 Oct 2024 12:31:42 -0700 Subject: [PATCH 566/700] Support JS version of `sass --embedded` (#256) --- ext/sass/.gitignore | 2 ++ ext/sass/Rakefile | 74 ++++++++++++++++++++++++++------------- lib/sass/compiler/host.rb | 2 +- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/ext/sass/.gitignore b/ext/sass/.gitignore index 23f2a2c0..a4e59778 100644 --- a/ext/sass/.gitignore +++ b/ext/sass/.gitignore @@ -4,5 +4,7 @@ /dart-sass/ /embedded_sass.proto /embedded_sass_pb.rb +/package-lock.json +/node_modules/ /protoc.exe /ruby/ diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 7035a4f0..f2fd2dc0 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -10,14 +10,14 @@ end CLEAN.include %w[protoc.exe ruby *.proto *.tar.gz *.zip] -CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb] +CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb node_modules package-lock.json] file 'protoc.exe' do |t| fetch(ENV.fetch('PROTOC_BIN') { SassConfig.default_protoc }, t.name) chmod 'a+x', t.name end -file 'dart-sass' do |t| +file 'dart-sass/sass' do |t| raise if ENV.key?('DART_SASS') gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| @@ -29,34 +29,58 @@ rescue StandardError rm archive end +file 'node_modules/sass' do + sh 'npm', 'install' +end + +task 'dart-sass' do + Rake::Task['dart-sass/sass'].invoke +rescue NotImplementedError + Rake::Task['node_modules/sass'].invoke +end + file 'cli.rb' => %w[dart-sass] do |t| require_relative '../../lib/sass/elf' - exe = 'dart-sass/sass' - exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" + begin + exe = 'dart-sass/sass' + exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" - raise "#{exe} not found" unless File.exist?(exe) + raise Errno::ENOENT, exe unless File.exist?(exe) - runtime = 'dart-sass/src/dart' - runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}" - snapshot = 'dart-sass/src/sass.snapshot' + runtime = 'dart-sass/src/dart' + runtime = "#{runtime}#{['', '.exe'].find { |ext| File.exist?("#{runtime}#{ext}") }}" + snapshot = 'dart-sass/src/sass.snapshot' - command = if File.exist?(runtime) && File.exist?(snapshot) - [runtime, snapshot] - else - [exe] - end + command = if File.exist?(runtime) && File.exist?(snapshot) + [runtime, snapshot] + else + [exe] + end - interpreter = File.open(command[0], 'rb') do |file| - Sass.const_get(:ELF).new(file).interpreter - rescue ArgumentError - nil - end + interpreter = File.open(command[0], 'rb') do |file| + Sass.const_get(:ELF).new(file).interpreter + rescue ArgumentError + nil + end + + command_source = command.map do |argument| + "File.absolute_path('#{argument}', __dir__).freeze" + end.join(', + ') + rescue Errno::ENOENT + package = 'node_modules/sass' + + script = File.join(package, SassConfig.package_json(package)['bin']['sass']) - command_source = command.map do |argument| - "File.absolute_path('#{argument}', __dir__).freeze" - end.join(', + interpreter = nil + + command_source = [ + "'node'", + "File.absolute_path('#{script}', __dir__).freeze" + ].join(', ') + end if interpreter.nil? File.write(t.name, <<~CLI_RB) @@ -290,12 +314,14 @@ module SassConfig module_function - def dart_sass_version + def package_json(path = '.') require 'json' - spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__))) + JSON.parse(File.read(File.absolute_path('package.json', path))) + end - spec['dependencies']['sass'] + def dart_sass_version + package_json['dependencies']['sass'] end def default_dart_sass diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index b1506c0b..1677f466 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -116,7 +116,7 @@ def version_request case version_response.implementation_name when 'dart-sass' - info << '[Dart]' + info << (CLI::COMMAND.first == 'node' ? '[JavaScript]' : '[Dart]') end info From 3e1c633ac19da3e937c16c029ed72f91dbc7f9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 26 Oct 2024 12:53:37 -0700 Subject: [PATCH 567/700] Support alternative node package managers --- ext/sass/.gitignore | 5 ++++- ext/sass/Rakefile | 31 ++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ext/sass/.gitignore b/ext/sass/.gitignore index a4e59778..07e5fcad 100644 --- a/ext/sass/.gitignore +++ b/ext/sass/.gitignore @@ -1,10 +1,13 @@ /*.tar.gz /*.zip +/bun.lockb /cli.rb /dart-sass/ /embedded_sass.proto /embedded_sass_pb.rb -/package-lock.json /node_modules/ +/package-lock.json +/pnpm-lock.yaml /protoc.exe /ruby/ +/yarn.lock diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index f2fd2dc0..d7719f32 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -8,9 +8,24 @@ task install: %w[cli.rb] do Rake::Task['embedded_sass_pb.rb'].invoke unless File.exist?('embedded_sass_pb.rb') end -CLEAN.include %w[protoc.exe ruby *.proto *.tar.gz *.zip] - -CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb node_modules package-lock.json] +CLEAN.include %w[ + protoc.exe + ruby + *.proto + *.tar.gz + *.zip +] + +CLOBBER.include %w[ + dart-sass + cli.rb + embedded_sass_pb.rb + node_modules + bun.lockb + package-lock.json + pnpm-lock.yaml + yarn.lock +] file 'protoc.exe' do |t| fetch(ENV.fetch('PROTOC_BIN') { SassConfig.default_protoc }, t.name) @@ -31,6 +46,16 @@ end file 'node_modules/sass' do sh 'npm', 'install' +rescue StandardError + begin + sh 'yarn', 'install' + rescue StandardError + begin + sh 'pnpm', 'install' + rescue StandardError + sh 'bun', 'install' + end + end end task 'dart-sass' do From a6c50a4e8255824e86480217315468ef084c8855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 26 Oct 2024 18:20:58 -0700 Subject: [PATCH 568/700] Raise errors with explict types --- ext/sass/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index d7719f32..1905e797 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -33,7 +33,7 @@ file 'protoc.exe' do |t| end file 'dart-sass/sass' do |t| - raise if ENV.key?('DART_SASS') + raise RuntimeError if ENV.key?('DART_SASS') gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| mv File.absolute_path("ext/sass/#{t.name}", dir), t.name @@ -184,7 +184,7 @@ module FileUtils entry = entries.nextElement name = entry.getName path = dest_path.resolve(name).normalize - raise unless path.startsWith(dest_path) + raise SecurityError unless path.startsWith(dest_path) Rake.rake_output_message " inflating: #{name}" if Rake::FileUtilsExt.verbose_flag From 2612a5a1271b7f0a98b68a0974f91217e50faf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 27 Oct 2024 01:15:20 -0700 Subject: [PATCH 569/700] Use official protoc static binaries on all linux platforms --- .github/workflows/build.yml | 5 +---- ext/sass/Rakefile | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 565d6a8d..3dc42c42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -79,9 +79,6 @@ jobs: container: image: docker.io/library/ruby:${{ matrix.ruby-version }}-alpine - env: - PROTOC_BIN: /usr/bin/protoc - strategy: fail-fast: false matrix: @@ -95,7 +92,7 @@ jobs: uses: actions/checkout@v4 - name: Install dependencies - run: apk add alpine-sdk protoc + run: apk add build-base - name: Bundle run: bundle install diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 1905e797..2be251cb 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -410,7 +410,7 @@ module SassConfig os = case Platform::OS when 'darwin' 'osx' - when 'linux' + when 'linux', 'linux-android', 'linux-musl', 'linux-uclibc' 'linux' when 'windows' 'windows' From 2fe74f081df0e5aa2ed05f6052fb02a583667e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 27 Oct 2024 01:29:04 -0700 Subject: [PATCH 570/700] Force platform ruby google-protobuf on aarch64-linux-musl --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 632f6c7f..7824aa91 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,9 @@ source 'https://rubygems.org' gemspec group :development do + # TODO: https://github.com/protocolbuffers/protobuf/issues/16853 + gem 'google-protobuf', force_ruby_platform: true if RUBY_PLATFORM == 'aarch64-linux-musl' + gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.67.0' From 02bbcba52133e0d5b2c7bc16d88da23de2814426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 27 Oct 2024 04:29:34 -0700 Subject: [PATCH 571/700] Test FreeBSD and OpenBSD --- .github/workflows/build.yml | 65 +++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dc42c42..3f062c85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,7 @@ jobs: - name: Install run: rake -f -r bundler/gem_tasks install - spec-musl: + spec-container: name: spec (alpine-latest, ${{ matrix.ruby-version }}) @@ -106,11 +106,72 @@ jobs: - name: Spec run: bundle exec rake spec + spec-vm: + + name: spec (${{ matrix.vm }}-latest) + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - vm: freebsd + install-dependencies: | + pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake + - vm: openbsd + install-dependencies: | + ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1) + pkg_add node protobuf $ruby + pkg_info $ruby | grep 'ln -sf' | $SHELL + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup vm + if: matrix.vm == 'freebsd' + uses: vmactions/freebsd-vm@v1 + + - name: Setup vm + if: matrix.vm == 'openbsd' + uses: vmactions/openbsd-vm@v1 + + - name: Setup vmshell + run: | + _osname=${{ matrix.vm }} + tee /home/runner/.local/bin/vmshell < Date: Mon, 28 Oct 2024 08:22:59 -0700 Subject: [PATCH 572/700] Update rubocop-rspec requirement from ~> 3.1.0 to ~> 3.2.0 (#257) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.1.0...v3.2.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7824aa91..47c62059 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,5 @@ group :development do gem 'rubocop', '~> 1.67.0' gem 'rubocop-performance', '~> 1.22.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 3.1.0' + gem 'rubocop-rspec', '~> 3.2.0' end From cda80f3244d4f69a76e2984f8af9f17e718cac78 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:47:18 -0700 Subject: [PATCH 573/700] Bump sass from 1.80.4 to 1.80.5 in /ext/sass (#258) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.4 to 1.80.5. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.4...1.80.5) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index a09b1f0c..84e9764f 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.4" + "sass": "1.80.5" } } From dd6dd72f7546c66d76f958557e7cd95acaade7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 29 Oct 2024 15:51:58 -0700 Subject: [PATCH 574/700] v1.80.5 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 9fda2699..7c222cd4 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.4' + VERSION = '1.80.5' end end From 2919348138b9cf2b112e3546329985a8dd498732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 31 Oct 2024 01:33:23 -0700 Subject: [PATCH 575/700] Test NixOS --- .github/workflows/build.yml | 57 ++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f062c85..e2c74b12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,7 @@ jobs: - name: Install run: rake -f -r bundler/gem_tasks install - spec-container: + spec-musl: name: spec (alpine-latest, ${{ matrix.ruby-version }}) @@ -106,7 +106,43 @@ jobs: - name: Spec run: bundle exec rake spec - spec-vm: + spec-nix: + + name: spec (nix-latest) + + runs-on: ubuntu-latest + + services: + nix: + image: docker.io/nixos/nix:latest + options: --tty + volumes: + - ${{ github.workspace }}:${{ github.workspace }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup shell + run: | + mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" + #!/bin/bash -- + exec docker exec -i -w "$PWD" ${{ job.services.nix.id }} nix-shell --packages ruby --run "exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" + EOF + + - name: Bundle + run: bundle install + + - name: Compile + run: bundle exec rake compile + + - name: Install + run: rake -f -r bundler/gem_tasks install + + - name: Spec + run: bundle exec rake spec + + spec-bsd: name: spec (${{ matrix.vm }}-latest) @@ -137,41 +173,34 @@ jobs: if: matrix.vm == 'openbsd' uses: vmactions/openbsd-vm@v1 - - name: Setup vmshell + - name: Setup shell run: | - _osname=${{ matrix.vm }} - tee /home/runner/.local/bin/vmshell < Date: Thu, 31 Oct 2024 10:01:46 -0700 Subject: [PATCH 576/700] Refactor CI with matrix build --- .github/workflows/build.yml | 186 +++++++++++++----------------------- 1 file changed, 67 insertions(+), 119 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2c74b12..216dc48e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,6 +31,8 @@ jobs: runs-on: ${{ matrix.os }} + container: ${{ matrix.container.image != 'docker.io/nixos/nix:latest' && matrix.container || null }} + strategy: fail-fast: false matrix: @@ -38,6 +40,10 @@ jobs: - macos-latest - ubuntu-latest - windows-latest + container: + - + vm: + - ruby-version: - '3.1' - '3.2' @@ -50,157 +56,99 @@ jobs: ruby-version: truffleruby - os: windows-latest ruby-version: truffleruby+graalvm - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true - - - name: Compile - run: bundle exec rake compile - - - name: Spec - run: bundle exec rake spec - - - name: Install - run: rake -f -r bundler/gem_tasks install - - spec-musl: - - name: spec (alpine-latest, ${{ matrix.ruby-version }}) - - runs-on: ubuntu-latest - - container: - image: docker.io/library/ruby:${{ matrix.ruby-version }}-alpine - - strategy: - fail-fast: false - matrix: - ruby-version: - - '3.1' - - '3.2' - - '3.3' - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install dependencies - run: apk add build-base - - - name: Bundle - run: bundle install - - - name: Compile - run: bundle exec rake compile - - - name: Install - run: rake -f -r bundler/gem_tasks install - - - name: Spec - run: bundle exec rake spec - - spec-nix: - - name: spec (nix-latest) - - runs-on: ubuntu-latest - - services: - nix: - image: docker.io/nixos/nix:latest - options: --tty - volumes: - - ${{ github.workspace }}:${{ github.workspace }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup shell - run: | - mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" - #!/bin/bash -- - exec docker exec -i -w "$PWD" ${{ job.services.nix.id }} nix-shell --packages ruby --run "exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" - EOF - - - name: Bundle - run: bundle install - - - name: Compile - run: bundle exec rake compile - - - name: Install - run: rake -f -r bundler/gem_tasks install - - - name: Spec - run: bundle exec rake spec - - spec-bsd: - - name: spec (${{ matrix.vm }}-latest) - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: include: - - vm: freebsd - install-dependencies: | - pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake - - vm: openbsd - install-dependencies: | - ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1) - pkg_add node protobuf $ruby - pkg_info $ruby | grep 'ln -sf' | $SHELL + - os: ubuntu-latest + container: + image: docker.io/library/ruby:3.1-alpine + - os: ubuntu-latest + container: + image: docker.io/library/ruby:3.2-alpine + - os: ubuntu-latest + container: + image: docker.io/library/ruby:3.3-alpine + - os: ubuntu-latest + container: + image: docker.io/nixos/nix:latest + - os: ubuntu-latest + vm: freebsd + - os: ubuntu-latest + vm: openbsd steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup vm + - name: Setup vm (freebsd) if: matrix.vm == 'freebsd' uses: vmactions/freebsd-vm@v1 - - name: Setup vm + - name: Setup vm (openbsd) if: matrix.vm == 'openbsd' uses: vmactions/openbsd-vm@v1 - - name: Setup shell + - name: Setup vm shell + if: matrix.vm run: | mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" #!/bin/bash -- exec ssh ${{ matrix.vm }} "cd $(printf %q "$PWD") && exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" EOF - - name: Install dependencies - run: ${{ matrix.install-dependencies }} + - name: Setup nix-shell + if: matrix.container.image == 'docker.io/nixos/nix:latest' + run: | + docker run --rm -d --name nix --volume "$PWD:$PWD" --entrypoint sleep ${{ matrix.container.image }} infinity + mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" + #!/bin/bash -- + exec docker exec -i -w "$PWD" nix nix-shell --packages ruby --run "exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" + EOF + + - name: Install dependencies (freebsd) + if: matrix.vm == 'freebsd' + run: pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake + + - name: Install dependencies (openbsd) + if: matrix.vm == 'openbsd' + run: | + ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1) + pkg_add node protobuf "$ruby" + pkg_info "$ruby" | grep 'ln -sf' | $SHELL + + - name: Install dependencies (alpine) + if: endsWith(matrix.container.image, ':alpine') || endsWith(matrix.container.image, '-alpine') + run: apk add build-base + + - name: Setup ruby + if: matrix.ruby-version + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true - name: Bundle + if: "!matrix.ruby-version" run: bundle install - name: Compile + if: "!matrix.vm" + run: bundle exec rake compile + + - name: Compile + if: matrix.vm run: EMBEDDED_SASS_PROTOCOL=https://github.com/sass/sass/raw/HEAD/spec/embedded_sass.proto PROTOC_BIN=$(which protoc) bundle exec rake compile + - name: Spec + if: "!matrix.vm" # TODO: https://github.com/sass/dart-sass/pull/2413 + run: bundle exec rake spec + - name: Install run: rake -f -r bundler/gem_tasks install - # TODO: https://github.com/sass/dart-sass/pull/2413 - # - name: Spec - # run: bundle exec rake spec - release: if: github.event.repository.fork == false && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - needs: [lint, spec, spec-musl, spec-nix, spec-bsd] + needs: [lint, spec] runs-on: ubuntu-latest From 87d4190a8ef9051849c33a01c57a0d26a7c86fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 31 Oct 2024 22:57:51 -0700 Subject: [PATCH 577/700] Refactor CI with composite action --- .github/actions/setup-nix/action.yml | 39 ++++++++++++++++++++ .github/actions/setup-vm/action.yml | 38 +++++++++++++++++++ .github/dependabot.yml | 4 +- .github/workflows/build.yml | 55 ++++++++++------------------ 4 files changed, 100 insertions(+), 36 deletions(-) create mode 100644 .github/actions/setup-nix/action.yml create mode 100644 .github/actions/setup-vm/action.yml diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml new file mode 100644 index 00000000..5d96f3ce --- /dev/null +++ b/.github/actions/setup-nix/action.yml @@ -0,0 +1,39 @@ +name: Setup Nix +description: Initialize nixos/nix container +inputs: + image: + description: 'Set up an environment with specified nix container image' + required: false + default: 'docker.io/nixos/nix:latest' + packages: + description: 'Set up an environment in which the specified packages are present' + required: false + default: '' +runs: + using: composite + steps: + - run: /usr/bin/docker pull ${{ inputs.image }} + shell: bash + + - id: container + run: echo "id=$(/usr/bin/docker create --workdir "$GITHUB_WORKSPACE" -e GITHUB_ACTIONS=true -e CI=true -v /var/run/docker.sock:/var/run/docker.sock -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --entrypoint sleep ${{ inputs.image }} infinity)" | tee -a "$GITHUB_OUTPUT" + shell: bash + + - run: /usr/bin/docker start ${{ steps.container.outputs.id }} + shell: bash + + - run: /usr/bin/docker ps --all --filter id=${{ steps.container.outputs.id }} --filter status=running --no-trunc --format "{{.ID}} {{.Status}}" + shell: bash + + - run: /usr/bin/docker inspect --format "{{range .Config.Env}}{{println .}}{{end}}" ${{ steps.container.outputs.id }} + shell: bash + + - run: | + mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" + #!/bin/bash -- + exec /usr/bin/docker exec -i -w "$PWD" ${{ steps.container.outputs.id }} nix-shell --packages ${{ inputs.packages }} --run "exec bash$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" + EOF + shell: bash + + - run: env + shell: bash diff --git a/.github/actions/setup-vm/action.yml b/.github/actions/setup-vm/action.yml new file mode 100644 index 00000000..15301e24 --- /dev/null +++ b/.github/actions/setup-vm/action.yml @@ -0,0 +1,38 @@ +name: Setup vm +description: Initialize virtual machine +inputs: + os: + description: 'Set up an environment with specified os' + required: true + run: + description: 'Set up an environment with specified run command' + required: false + default: '' +runs: + using: composite + steps: + - uses: vmactions/freebsd-vm@v1 + if: inputs.os == 'freebsd' + with: + copyback: false + usesh: true + prepare: pkg install -y bash + run: set -e; ${{ inputs.run }} + + - uses: vmactions/openbsd-vm@v1 + if: inputs.os == 'openbsd' + with: + copyback: false + usesh: true + prepare: pkg_add bash + run: set -e; ${{ inputs.run }} + + - run: | + mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" + #!/bin/bash -- + exec ssh ${{ inputs.os }} "cd $(printf %q "$PWD") && exec bash$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" + EOF + shell: bash + + - run: env + shell: bash diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 95a87a69..052d23ad 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,9 @@ version: 2 updates: - package-ecosystem: "github-actions" - directory: "/" + directories: + - "/" + - "/.github/actions/*/" schedule: interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 216dc48e..9936bdc0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,51 +70,36 @@ jobs: container: image: docker.io/nixos/nix:latest - os: ubuntu-latest - vm: freebsd + vm: + os: freebsd + run: pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake - os: ubuntu-latest - vm: openbsd + vm: + os: openbsd + run: | + ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1) + pkg_add node protobuf "$ruby" + pkg_info "$ruby" | grep 'ln -sf' | $SHELL steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup vm (freebsd) - if: matrix.vm == 'freebsd' - uses: vmactions/freebsd-vm@v1 - - - name: Setup vm (openbsd) - if: matrix.vm == 'openbsd' - uses: vmactions/openbsd-vm@v1 - - - name: Setup vm shell + - name: Initialize vm if: matrix.vm - run: | - mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" - #!/bin/bash -- - exec ssh ${{ matrix.vm }} "cd $(printf %q "$PWD") && exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" - EOF + uses: ./.github/actions/setup-vm + with: + os: ${{ matrix.vm.os }} + run: ${{ matrix.vm.run }} - - name: Setup nix-shell + - name: Initialize nix if: matrix.container.image == 'docker.io/nixos/nix:latest' - run: | - docker run --rm -d --name nix --volume "$PWD:$PWD" --entrypoint sleep ${{ matrix.container.image }} infinity - mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" - #!/bin/bash -- - exec docker exec -i -w "$PWD" nix nix-shell --packages ruby --run "exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" - EOF - - - name: Install dependencies (freebsd) - if: matrix.vm == 'freebsd' - run: pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake - - - name: Install dependencies (openbsd) - if: matrix.vm == 'openbsd' - run: | - ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1) - pkg_add node protobuf "$ruby" - pkg_info "$ruby" | grep 'ln -sf' | $SHELL + uses: ./.github/actions/setup-nix + with: + image: ${{ matrix.container.image }} + packages: ruby - - name: Install dependencies (alpine) + - name: Install dependencies if: endsWith(matrix.container.image, ':alpine') || endsWith(matrix.container.image, '-alpine') run: apk add build-base From 79a2f1c2c1b6dc5de8fd812e65ec0d2189bef82a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 00:20:37 -0700 Subject: [PATCH 578/700] Update rubocop requirement from ~> 1.67.0 to ~> 1.68.0 (#260) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.67.0...v1.68.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 47c62059..24c01bff 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.67.0' + gem 'rubocop', '~> 1.68.0' gem 'rubocop-performance', '~> 1.22.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.2.0' From 727d1c07d33bc169713fbdd9c43012fe63343962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Nov 2024 00:24:01 -0700 Subject: [PATCH 579/700] Test rare operating systems --- .github/actions/setup-vm/action.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/build.yml | 19 ++++++++++++++++--- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-vm/action.yml b/.github/actions/setup-vm/action.yml index 15301e24..e5cd4643 100644 --- a/.github/actions/setup-vm/action.yml +++ b/.github/actions/setup-vm/action.yml @@ -27,6 +27,35 @@ runs: prepare: pkg_add bash run: set -e; ${{ inputs.run }} + - uses: vmactions/netbsd-vm@v1 + if: inputs.os == 'netbsd' + with: + copyback: false + usesh: true + run: set -e; ${{ inputs.run }} + + - uses: vmactions/dragonflybsd-vm@v1 + if: inputs.os == 'dragonflybsd' + with: + copyback: false + usesh: true + prepare: pkg install -y bash + run: set -e; ${{ inputs.run }} + + - uses: vmactions/solaris-vm@v1 + if: inputs.os == 'solaris' + with: + copyback: false + usesh: true + run: set -e; ${{ inputs.run }} + + - uses: vmactions/omnios-vm@v1 + if: inputs.os == 'omnios' + with: + copyback: false + usesh: true + run: set -e; ${{ inputs.run }} + - run: | mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" #!/bin/bash -- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9936bdc0..b38c39da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,9 +77,22 @@ jobs: vm: os: openbsd run: | - ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1) - pkg_add node protobuf "$ruby" - pkg_info "$ruby" | grep 'ln -sf' | $SHELL + pkg_add node protobuf ruby%3.3 ruby-shims + echo 3.3 | tee /etc/ruby-version + - os: ubuntu-latest + vm: + os: netbsd + run: /usr/sbin/pkg_add nodejs protobuf ruby + - os: ubuntu-latest + vm: + os: dragonflybsd + run: pkg install -y libnghttp2 libuv node npm protobuf ruby rubygem-bundler rubygem-rake + - os: ubuntu-latest + vm: + os: omnios + run: | + pkg install build-essential node-22 protobuf ruby-33 + pkg install "$(pkg search -HI -o pkg.name "$(ruby -e 'puts RbConfig::CONFIG["CC"]')")" steps: - name: Checkout From c939e9ea256e19f54dcf2349f5ec15b9c5d30a8f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:38:01 -0700 Subject: [PATCH 580/700] Bump sass from 1.80.5 to 1.80.6 in /ext/sass (#261) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.5 to 1.80.6. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.5...1.80.6) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 84e9764f..01b0413c 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.5" + "sass": "1.80.6" } } From 837977669a8c1745d0f85b47f974392f8d82dbb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 1 Nov 2024 16:47:11 -0700 Subject: [PATCH 581/700] v1.80.6 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 7c222cd4..ac7752c4 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.5' + VERSION = '1.80.6' end end From bb5471e9f10661b31653a44bc5a3311f7b3e8144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 3 Nov 2024 01:01:19 -0700 Subject: [PATCH 582/700] Remove overrides from Rakefile --- .github/workflows/build.yml | 7 +------ ext/sass/Rakefile | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b38c39da..7f0df98e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -128,15 +128,10 @@ jobs: run: bundle install - name: Compile - if: "!matrix.vm" run: bundle exec rake compile - - name: Compile - if: matrix.vm - run: EMBEDDED_SASS_PROTOCOL=https://github.com/sass/sass/raw/HEAD/spec/embedded_sass.proto PROTOC_BIN=$(which protoc) bundle exec rake compile - - name: Spec - if: "!matrix.vm" # TODO: https://github.com/sass/dart-sass/pull/2413 + if: "!matrix.vm" # TODO: remove after https://github.com/sass/dart-sass/pull/2413 run: bundle exec rake spec - name: Install diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 2be251cb..ab5b3d64 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -28,18 +28,23 @@ CLOBBER.include %w[ ] file 'protoc.exe' do |t| - fetch(ENV.fetch('PROTOC_BIN') { SassConfig.default_protoc }, t.name) + fetch(SassConfig.protoc, t.name) + chmod 'a+x', t.name +rescue NotImplementedError + File.write(t.name, <<~PROTOC_EXE) + #!#{RbConfig.ruby} + # frozen_string_literal: true + Kernel.exec('protoc', *ARGV) + PROTOC_EXE chmod 'a+x', t.name end file 'dart-sass/sass' do |t| - raise RuntimeError if ENV.key?('DART_SASS') - gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| mv File.absolute_path("ext/sass/#{t.name}", dir), t.name end rescue StandardError - archive = fetch(ENV.fetch('DART_SASS') { SassConfig.default_dart_sass }) + archive = fetch(SassConfig.dart_sass) unarchive archive rm archive end @@ -146,7 +151,7 @@ file 'cli.rb' => %w[dart-sass] do |t| end file 'embedded_sass.proto' => %w[cli.rb] do |t| - fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') { SassConfig.default_embedded_sass_protocol }, t.name) + fetch(SassConfig.embedded_sass_protocol, t.name) end rule '_pb.rb' => %w[.proto protoc.exe] do |t| @@ -349,7 +354,7 @@ module SassConfig package_json['dependencies']['sass'] end - def default_dart_sass + def dart_sass repo = 'https://github.com/sass/dart-sass' tag_name = dart_sass_version @@ -394,7 +399,7 @@ module SassConfig "#{repo}/releases/download/#{tag_name}/dart-sass-#{tag_name}-#{os}-#{cpu}#{env}.#{ext}" end - def default_protoc + def protoc require 'rubygems/remote_fetcher' repo = 'https://repo.maven.apache.org/maven2/com/google/protobuf/protoc' @@ -458,7 +463,7 @@ module SassConfig raise NotImplementedError, message end - def default_embedded_sass_protocol + def embedded_sass_protocol require 'json' require 'open3' @@ -472,6 +477,8 @@ module SassConfig tag_name = JSON.parse(stdout)['protocolVersion'] "https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto" + rescue StandardError # TODO: remove after https://github.com/sass/dart-sass/pull/2413 + 'https://github.com/sass/sass/raw/HEAD/spec/embedded_sass.proto' end def development? From 4e0dd041e21f5b820fc6ed0c9994d20f2028776c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 4 Nov 2024 19:24:31 -0800 Subject: [PATCH 583/700] Export environment and share $RUNNER_TEMP with nix and vm --- .github/actions/setup-nix/action.yml | 8 ++++++-- .github/actions/setup-vm/action.yml | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml index 5d96f3ce..8e51a2b6 100644 --- a/.github/actions/setup-nix/action.yml +++ b/.github/actions/setup-nix/action.yml @@ -16,7 +16,7 @@ runs: shell: bash - id: container - run: echo "id=$(/usr/bin/docker create --workdir "$GITHUB_WORKSPACE" -e GITHUB_ACTIONS=true -e CI=true -v /var/run/docker.sock:/var/run/docker.sock -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --entrypoint sleep ${{ inputs.image }} infinity)" | tee -a "$GITHUB_OUTPUT" + run: echo "id=$(/usr/bin/docker create -v /var/run/docker.sock:/var/run/docker.sock -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" -v "$RUNNER_TEMP:$RUNNER_TEMP" --entrypoint sleep ${{ inputs.image }} infinity)" | tee -a "$GITHUB_OUTPUT" shell: bash - run: /usr/bin/docker start ${{ steps.container.outputs.id }} @@ -28,10 +28,14 @@ runs: - run: /usr/bin/docker inspect --format "{{range .Config.Env}}{{println .}}{{end}}" ${{ steps.container.outputs.id }} shell: bash + - id: env + run: echo "env=$(env -0 | grep -z -v '^CI=\|^GITHUB_\|^RUNNER_' | sort -z | base64 -w 0)" | tee -a "$GITHUB_OUTPUT" + shell: bash + - run: | mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" #!/bin/bash -- - exec /usr/bin/docker exec -i -w "$PWD" ${{ steps.container.outputs.id }} nix-shell --packages ${{ inputs.packages }} --run "exec bash$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" + exec /usr/bin/docker exec -i ${{ steps.container.outputs.id }} nix-shell --packages ${{ inputs.packages }} --run "$(comm -23z <(env -0 -u PATH | sort -z) <(base64 -d <<< ${{ steps.env.outputs.env }}) | xargs -0 /bin/bash -c 'printf "export %q; " "$@"' --)cd $(printf %q "$PWD") && exec bash$(printf ' %q' "${@:1:$#-1}")" <"${@:$#}" EOF shell: bash diff --git a/.github/actions/setup-vm/action.yml b/.github/actions/setup-vm/action.yml index e5cd4643..5e395991 100644 --- a/.github/actions/setup-vm/action.yml +++ b/.github/actions/setup-vm/action.yml @@ -15,51 +15,58 @@ runs: if: inputs.os == 'freebsd' with: copyback: false - usesh: true - prepare: pkg install -y bash + prepare: pkg install -y bash && chsh -s `which bash` root run: set -e; ${{ inputs.run }} - uses: vmactions/openbsd-vm@v1 if: inputs.os == 'openbsd' with: copyback: false - usesh: true - prepare: pkg_add bash + prepare: pkg_add bash && chsh -s `which bash` root run: set -e; ${{ inputs.run }} - uses: vmactions/netbsd-vm@v1 if: inputs.os == 'netbsd' with: copyback: false - usesh: true + prepare: chsh -s `which bash` root run: set -e; ${{ inputs.run }} - uses: vmactions/dragonflybsd-vm@v1 if: inputs.os == 'dragonflybsd' with: copyback: false - usesh: true - prepare: pkg install -y bash + prepare: pkg install -y bash && chsh -s `which bash` root run: set -e; ${{ inputs.run }} - uses: vmactions/solaris-vm@v1 if: inputs.os == 'solaris' with: copyback: false - usesh: true run: set -e; ${{ inputs.run }} - uses: vmactions/omnios-vm@v1 if: inputs.os == 'omnios' with: copyback: false - usesh: true run: set -e; ${{ inputs.run }} + - run: | + sudo apt-get update + sudo apt-get install -y sshfs + shell: bash + + - run: /bin/bash -c 'set -e; while test $# -gt 0; do rm -rf "$1"; mkdir -p "$1"; sshfs -o idmap=user,reconnect,cache=no,dir_cache=no,direct_io,default_permissions "${{ inputs.os }}:$1" "$1"; shift; done' -- "$GITHUB_WORKSPACE" "$RUNNER_TEMP" + shell: bash + + - id: env + run: echo "env=$(env -0 | grep -z -v '^CI=\|^GITHUB_\|^RUNNER_' | sort -z | base64 -w 0)" | tee -a "$GITHUB_OUTPUT" + shell: bash + - run: | mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash" #!/bin/bash -- - exec ssh ${{ inputs.os }} "cd $(printf %q "$PWD") && exec bash$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}" + exec ssh ${{ inputs.os }} "$(comm -23z <(env -0 -u PATH | sort -z) <(base64 -d <<< ${{ steps.env.outputs.env }}) | xargs -0 /bin/bash -c 'printf "export %q; " "$@"' --)cd $(printf %q "$PWD") && exec bash$(printf ' %q' "${@:1:$#-1}")" <"${@:$#}" EOF shell: bash From c5a8603b8a2814d23202bda09c1ec285d633ee05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:17:54 -0800 Subject: [PATCH 584/700] Bump sass from 1.80.6 to 1.80.7 in /ext/sass (#262) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.6 to 1.80.7. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.6...1.80.7) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 01b0413c..14357369 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.6" + "sass": "1.80.7" } } From 846147df7b2eedb960bd87a9f6db79c7bca829d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 12 Nov 2024 16:28:23 -0800 Subject: [PATCH 585/700] v1.80.7 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index ac7752c4..fdba3da1 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.6' + VERSION = '1.80.7' end end From 365e81bdd8eaa3326c32ff75e0fa7028b1935c89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:19:08 -0800 Subject: [PATCH 586/700] Update rubocop-performance requirement from ~> 1.22.0 to ~> 1.23.0 (#263) Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.22.0...v1.23.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 24c01bff..48508a87 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.68.0' - gem 'rubocop-performance', '~> 1.22.0' + gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.2.0' end From ed7da859eaec08ac52d385d830fdd80eb706f2ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:24:17 -0800 Subject: [PATCH 587/700] Bump sass from 1.80.7 to 1.81.0 in /ext/sass (#264) Bumps [sass](https://github.com/sass/dart-sass) from 1.80.7 to 1.81.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.80.7...1.81.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 14357369..2668ff1e 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.80.7" + "sass": "1.81.0" } } From 9452af57ef1b2a0f9057c0a1654b58ea720a2fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 14 Nov 2024 18:25:12 -0800 Subject: [PATCH 588/700] v1.81.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index fdba3da1..5ad68c2e 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.80.7' + VERSION = '1.81.0' end end From 85863efb8e3b3ec91ef9d7685c39de16a0247b62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:03:12 -0800 Subject: [PATCH 589/700] Update rubocop requirement from ~> 1.68.0 to ~> 1.69.0 (#266) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.68.0...v1.69.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 48508a87..5a55da24 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.68.0' + gem 'rubocop', '~> 1.69.0' gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.2.0' From 6883c241eec6cb4af1efeaa14c2c378fe9a6d095 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:43:48 -0800 Subject: [PATCH 590/700] Bump sass from 1.81.0 to 1.81.1 in /ext/sass (#267) Bumps [sass](https://github.com/sass/dart-sass) from 1.81.0 to 1.81.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.81.0...1.81.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 2668ff1e..7cf54cbc 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.81.0" + "sass": "1.81.1" } } From bc0c4fefb5c88429ea7647742e675b98853cd67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 2 Dec 2024 17:45:53 -0800 Subject: [PATCH 591/700] v1.81.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 5ad68c2e..3b330708 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.81.0' + VERSION = '1.81.1' end end From aae11c081600d71ca307929c50f39c4bae2759b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:18:52 -0800 Subject: [PATCH 592/700] Bump sass from 1.81.1 to 1.82.0 in /ext/sass (#268) Bumps [sass](https://github.com/sass/dart-sass) from 1.81.1 to 1.82.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.81.1...1.82.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 7cf54cbc..a113cbe7 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.81.1" + "sass": "1.82.0" } } From fbe4e32d40e7e1fc8802b9d5f667e4ea381ec0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 3 Dec 2024 16:19:31 -0800 Subject: [PATCH 593/700] v1.82.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 3b330708..5352a9b7 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.81.1' + VERSION = '1.82.0' end end From e1bd443262f1f3ffe7b50b9f905ae3e78422e558 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:45:47 -0800 Subject: [PATCH 594/700] Update rubocop-rspec requirement from ~> 3.2.0 to ~> 3.3.0 (#270) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.2.0...v3.3.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5a55da24..e2d358a5 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,5 @@ group :development do gem 'rubocop', '~> 1.69.0' gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 3.2.0' + gem 'rubocop-rspec', '~> 3.3.0' end From f8995e3dd7f9cb1c89ad4ccb77c5e43e406b5f77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:57:31 -0800 Subject: [PATCH 595/700] Bump sass from 1.82.0 to 1.83.0 in /ext/sass (#271) Bumps [sass](https://github.com/sass/dart-sass) from 1.82.0 to 1.83.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.82.0...1.83.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index a113cbe7..610e4125 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.82.0" + "sass": "1.83.0" } } From 1aee7797616f51774ad6885889f811a400f03e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 12 Dec 2024 14:58:04 -0800 Subject: [PATCH 596/700] v1.83.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 5352a9b7..54130a01 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.82.0' + VERSION = '1.83.0' end end From feeccd2ceeb850c851afd40b7e98edf4a4ebc173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 18 Dec 2024 04:18:26 -0800 Subject: [PATCH 597/700] Remove ia32 prebuilt gems --- .github/workflows/release.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e18bf224..9fb665c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,8 +28,6 @@ jobs: platform: arm-linux-androideabi - os: ubuntu-latest platform: riscv64-linux-android - - os: ubuntu-latest - platform: x86-linux-android - os: ubuntu-latest platform: x86_64-linux-android - os: ubuntu-latest @@ -38,8 +36,6 @@ jobs: platform: arm-linux-gnueabihf - os: ubuntu-latest platform: riscv64-linux-gnu - - os: ubuntu-latest - platform: x86-linux-gnu - os: ubuntu-latest platform: x86_64-linux-gnu - os: ubuntu-latest @@ -48,28 +44,18 @@ jobs: platform: arm-linux-musleabihf - os: ubuntu-latest platform: riscv64-linux-musl - - os: ubuntu-latest - platform: x86-linux-musl - os: ubuntu-latest platform: x86_64-linux-musl - - os: windows-latest - platform: x86-cygwin - os: windows-latest platform: x86_64-cygwin - os: windows-latest platform: aarch64-mingw-ucrt - os: windows-latest platform: x64-mingw-ucrt - - os: windows-latest - platform: x86-mingw-ucrt - os: windows-latest platform: x64-mingw32 - - os: windows-latest - platform: x86-mingw32 - os: windows-latest platform: x64-mswin64 - - os: windows-latest - platform: x86-mswin32 steps: - name: Checkout From 45cd8f415666957867882e05c3ed50684f7f5e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 19 Dec 2024 15:52:55 -0800 Subject: [PATCH 598/700] Update google-protobuf requirement from ~> 4.28 to ~> 4.29 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index e365ded9..9d4a5fd4 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_dependency 'google-protobuf', '~> 4.28' + spec.add_dependency 'google-protobuf', '~> 4.29' end From 2a26fbe14aa67878f4c4f43a8873b5ee15ad041b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 30 Dec 2024 15:45:09 -0800 Subject: [PATCH 599/700] Test ruby 3.4 (#273) --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f0df98e..9048e3b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,6 +48,7 @@ jobs: - '3.1' - '3.2' - '3.3' + - '3.4' - jruby - truffleruby - truffleruby+graalvm @@ -66,6 +67,9 @@ jobs: - os: ubuntu-latest container: image: docker.io/library/ruby:3.3-alpine + - os: ubuntu-latest + container: + image: docker.io/library/ruby:3.4-alpine - os: ubuntu-latest container: image: docker.io/nixos/nix:latest From 22e8d1f845a8ff96fbc7e270b9570dde52b8dff3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:53:24 -0800 Subject: [PATCH 600/700] Bump sass from 1.83.0 to 1.83.1 in /ext/sass (#274) Bumps [sass](https://github.com/sass/dart-sass) from 1.83.0 to 1.83.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.83.0...1.83.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 610e4125..5b5ffacb 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.83.0" + "sass": "1.83.1" } } From e5d389f08878595d6167e1cf34e18568366bbaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 3 Jan 2025 17:54:45 -0800 Subject: [PATCH 601/700] v1.83.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 54130a01..6a68b5d4 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.83.0' + VERSION = '1.83.1' end end From 015dee60d621ec268261c2e1af5c35a68792468b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 10 Jan 2025 08:00:29 -0800 Subject: [PATCH 602/700] Update Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e2d358a5..cf938ec6 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gemspec group :development do # TODO: https://github.com/protocolbuffers/protobuf/issues/16853 - gem 'google-protobuf', force_ruby_platform: true if RUBY_PLATFORM == 'aarch64-linux-musl' + gem 'google-protobuf', force_ruby_platform: true if RUBY_PLATFORM.include?('linux-musl') gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' From f48f39b1bc152add6f3554814aeb67a33afbc582 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:20:10 -0800 Subject: [PATCH 603/700] Update rubocop requirement from ~> 1.69.0 to ~> 1.70.0 (#275) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.69.0...v1.70.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index cf938ec6..756e977c 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.69.0' + gem 'rubocop', '~> 1.70.0' gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.3.0' From e89c4fca5d44e7ff02a77343676c8568f5c17abe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 17:11:25 -0800 Subject: [PATCH 604/700] Bump sass from 1.83.1 to 1.83.2 in /ext/sass (#276) Bumps [sass](https://github.com/sass/dart-sass) from 1.83.1 to 1.83.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.83.1...1.83.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 5b5ffacb..23e17828 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.83.1" + "sass": "1.83.2" } } From 302c17b618cf5425971b550044679f9d3ec944aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 13 Jan 2025 17:11:59 -0800 Subject: [PATCH 605/700] v1.83.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 6a68b5d4..91a59534 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.83.1' + VERSION = '1.83.2' end end From d1448c7bca2d519547023e09356e3801452e1328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 13 Jan 2025 17:55:26 -0800 Subject: [PATCH 606/700] Fix Rakefile --- ext/sass/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index ab5b3d64..59f1a65e 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -39,9 +39,9 @@ rescue NotImplementedError chmod 'a+x', t.name end -file 'dart-sass/sass' do |t| +file 'dart-sass/sass' do gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| - mv File.absolute_path("ext/sass/#{t.name}", dir), t.name + mv File.absolute_path('ext/sass/dart-sass', dir), 'dart-sass' end rescue StandardError archive = fetch(SassConfig.dart_sass) From e5a976585846450cf7d32bfa4f033bdd3ea79af1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:11:33 -0800 Subject: [PATCH 607/700] Bump sass from 1.83.2 to 1.83.3 in /ext/sass (#277) Bumps [sass](https://github.com/sass/dart-sass) from 1.83.2 to 1.83.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.83.2...1.83.3) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 23e17828..e187db66 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.83.2" + "sass": "1.83.3" } } From 423132c2a09f455932b0178fd2cf5ce0821bdd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 13 Jan 2025 18:19:15 -0800 Subject: [PATCH 608/700] v1.83.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 91a59534..9a60af30 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.83.2' + VERSION = '1.83.3' end end From 25de1a67ab53cb62175998c8eec6c8bf8df0c20d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:49:41 -0800 Subject: [PATCH 609/700] Bump sass from 1.83.3 to 1.83.4 in /ext/sass (#278) Bumps [sass](https://github.com/sass/dart-sass) from 1.83.3 to 1.83.4. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.83.3...1.83.4) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index e187db66..1b336dff 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.83.3" + "sass": "1.83.4" } } From 247a9dccafd8390f942979127066ee605050d33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 13 Jan 2025 22:50:34 -0800 Subject: [PATCH 610/700] v1.83.4 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 9a60af30..24137b0f 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.83.3' + VERSION = '1.83.4' end end From 59cb2c4a8a3de21117dbdeaf04399ce08464127a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 16 Jan 2025 14:07:54 -0800 Subject: [PATCH 611/700] Test nix arm64 --- .github/actions/setup-nix/action.yml | 1 + .github/workflows/build.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml index 8e51a2b6..61166aa8 100644 --- a/.github/actions/setup-nix/action.yml +++ b/.github/actions/setup-nix/action.yml @@ -37,6 +37,7 @@ runs: #!/bin/bash -- exec /usr/bin/docker exec -i ${{ steps.container.outputs.id }} nix-shell --packages ${{ inputs.packages }} --run "$(comm -23z <(env -0 -u PATH | sort -z) <(base64 -d <<< ${{ steps.env.outputs.env }}) | xargs -0 /bin/bash -c 'printf "export %q; " "$@"' --)cd $(printf %q "$PWD") && exec bash$(printf ' %q' "${@:1:$#-1}")" <"${@:$#}" EOF + echo "$HOME/.local/bin" | tee -a "$GITHUB_PATH" shell: bash - run: env diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9048e3b2..5d98cdc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,9 @@ jobs: - os: ubuntu-latest container: image: docker.io/nixos/nix:latest + - os: ubuntu-24.04-arm + container: + image: docker.io/nixos/nix:latest - os: ubuntu-latest vm: os: freebsd From c3c789fef16180a4d2699ee2d01ac8bca47fe9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 18 Jan 2025 16:05:34 -0800 Subject: [PATCH 612/700] Test linux arm64 (#279) --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d98cdc5..301e4d6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,7 @@ jobs: os: - macos-latest - ubuntu-latest + - ubuntu-24.04-arm - windows-latest container: - From 21d677c81f340d65fce81ce528de56bc58340889 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 08:38:19 -0800 Subject: [PATCH 613/700] Update rubocop-rspec requirement from ~> 3.3.0 to ~> 3.4.0 (#280) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.3.0...v3.4.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 756e977c..50066ec4 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,5 @@ group :development do gem 'rubocop', '~> 1.70.0' gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 3.3.0' + gem 'rubocop-rspec', '~> 3.4.0' end From 880d4be5fef0df5e737e037924dfc2c0171fea14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 05:45:43 -0800 Subject: [PATCH 614/700] Update rubocop requirement from ~> 1.70.0 to ~> 1.71.0 (#281) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.70.0...v1.71.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 50066ec4..d1751791 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.70.0' + gem 'rubocop', '~> 1.71.0' gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.4.0' From 8f0a57a601beac0ac05765221966042cd1824ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 23 Jan 2025 07:32:38 -0800 Subject: [PATCH 615/700] Fix flaky tests --- spec/sass/value/calculation_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/sass/value/calculation_spec.rb b/spec/sass/value/calculation_spec.rb index 99b82a36..e69d9443 100644 --- a/spec/sass/value/calculation_spec.rb +++ b/spec/sass/value/calculation_spec.rb @@ -46,7 +46,7 @@ describe 'calc' do it 'correctly stores name and arguments' do result = described_class.calc(Sass::Value::Number.new(1)) - expect(result.name).to be('calc') + expect(result.name).to eq('calc') expect(result.arguments).to eq([Sass::Value::Number.new(1)]) end @@ -69,7 +69,7 @@ Sass::Value::Number.new(1), Sass::Value::Number.new(2) ]) - expect(result.name).to be('min') + expect(result.name).to eq('min') expect(result.arguments).to eq([ Sass::Value::Number.new(1), Sass::Value::Number.new(2) @@ -97,7 +97,7 @@ Sass::Value::Number.new(1), Sass::Value::Number.new(2) ]) - expect(result.name).to be('max') + expect(result.name).to eq('max') expect(result.arguments).to eq([ Sass::Value::Number.new(1), Sass::Value::Number.new(2) @@ -126,7 +126,7 @@ Sass::Value::Number.new(2), Sass::Value::Number.new(3) ) - expect(result.name).to be('clamp') + expect(result.name).to eq('clamp') expect(result.arguments).to eq([ Sass::Value::Number.new(1), Sass::Value::Number.new(2), From 8a0a358f9806e833008cf923e9ebe80eca354b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 24 Jan 2025 09:56:08 -0800 Subject: [PATCH 616/700] Fix dependabot --- ext/sass/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 1b336dff..7ac3b921 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,6 @@ { "dependencies": { "sass": "1.83.4" - } + }, + "packageManager": "npm@11.0.0+sha512.11dff29565d2297c74e7c594a9762581bde969f0aa5cbe6f5b3644bf008a16c065ece61094d9ffbb81125be38df8e1ba43eb8244b3d30c61eb797e9a2440e3ec" } From b2e380ff6ee6827d066cb8bc2138dbb428f00538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 26 Jan 2025 11:40:12 -0800 Subject: [PATCH 617/700] Enhance Sass::ELF (#283) --- lib/sass/elf.rb | 351 +++++++++++++++++++++++++++++++----------- spec/sass/elf_spec.rb | 8 + 2 files changed, 267 insertions(+), 92 deletions(-) diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index 775deb41..4fb1aa3b 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -7,73 +7,30 @@ module Sass # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c class ELF - module PackInfo - PACK_MAP = { - Elf32_Ehdr: 'S<2L<5S<6', - Elf64_Ehdr: 'S<2L').freeze + @sizeof = sizeof.freeze + @struct = struct.freeze + end + + attr_reader :sizeof + + def pack(io, data, little_endian) + raise ArgumentError if io.write(data.values_at(*@struct).pack(format(little_endian))) != @sizeof + end + + def unpack(io, little_endian) + @struct.zip(io.read(@sizeof).unpack(format(little_endian))).to_h + end + + private + + def format(little_endian) + little_endian ? @format_le : @format_be + end end private_constant :PackInfo @@ -92,6 +49,8 @@ module PackInfo PT_LOPROC = 0x70000000 PT_HIPROC = 0x7fffffff + PN_XNUM = 0xffff + # These constants define the different elf file types ET_NONE = 0 ET_REL = 1 @@ -103,6 +62,154 @@ module PackInfo EI_NIDENT = 16 + Elf32_Ehdr = PackInfo.new( + format: "a#{EI_NIDENT}S<2L<5S<6", + sizeof: 52, + struct: %i[ + e_ident + e_type + e_machine + e_version + e_entry + e_phoff + e_shoff + e_flags + e_ehsize + e_phentsize + e_phnum + e_shentsize + e_shnum + e_shstrndx + ] + ).freeze + + Elf64_Ehdr = PackInfo.new( + format: "a#{EI_NIDENT}S<2L') - [PackInfo::STRUCT_MAP[type], @buffer.read(size).unpack(format)].transpose.to_h - end - INTERPRETER = begin proc_self_exe = '/proc/self/exe' if File.exist?(proc_self_exe) diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb index 024b2611..f6b20fa2 100644 --- a/spec/sass/elf_spec.rb +++ b/spec/sass/elf_spec.rb @@ -27,4 +27,12 @@ .to eq(File.basename(described_class::INTERPRETER)) end end + + it 'dumps elf headers' do + input = StringIO.new(File.binread('/proc/self/exe')) + output = StringIO.new.binmode + + described_class.new(input).dump(output) + expect(output.string).to eq(input.string.slice(0, output.length)) + end end From 7902be76534f06f6416a7ca595ea3dfc1181c6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 27 Jan 2025 08:51:10 -0800 Subject: [PATCH 618/700] Update platform normalization --- ext/sass/Rakefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 59f1a65e..2cb4e76b 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -326,13 +326,13 @@ module SassConfig when /amd64|x86_64|x64/ 'x86_64' when /i\d86|x86|i86pc/ - 'x86' + 'i386' when /arm64|aarch64/ 'aarch64' when /arm/ 'arm' when /ppc64le|powerpc64le/ - 'powerpc64le' + 'ppc64le' else RbConfig::CONFIG['host_cpu'] end @@ -380,7 +380,7 @@ module SassConfig end cpu = case Platform::CPU - when 'x86' + when 'i386' 'ia32' when 'x86_64' 'x64' @@ -424,13 +424,13 @@ module SassConfig end cpu = case Platform::CPU - when 'x86' + when 'i386' 'x86_32' when 'x86_64' 'x86_64' when 'aarch64' 'aarch_64' - when 'powerpc64le' + when 'ppc64le' 'ppcle_64' when 's390x' 's390_64' From e5bc37bd98bb42c491195c9b6ffcfe0f75cffd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 28 Jan 2025 20:39:06 -0800 Subject: [PATCH 619/700] Support Linuxulator on FreeBSD (#284) --- .github/workflows/build.yml | 49 +++++- ext/sass/.gitignore | 1 + ext/sass/Rakefile | 290 +++++++++++++++++++++++++++++++----- spec/sass/elf_spec.rb | 33 ++-- 4 files changed, 314 insertions(+), 59 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 301e4d6a..7b55aaa2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,7 +80,46 @@ jobs: - os: ubuntu-latest vm: os: freebsd - run: pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake + run: | + pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake + - os: ubuntu-latest + vm: + os: freebsd + run: | + pkg install -y node npm ruby rubygem-bundler rubygem-rake + sysrc linux_enable="YES" + service linux start + - os: ubuntu-latest + vm: + os: freebsd + run: | + pkg install -y ruby rubygem-bundler rubygem-rake + sysrc linux_enable="YES" + service linux start + pkg install -y linux_base-rl9 + - os: ubuntu-latest + vm: + os: freebsd + run: | + pkg install -y node npm ruby rubygem-bundler rubygem-rake + sysrc linux_enable="YES" + service linux start + pkg install -y debootstrap + debootstrap jammy /compat/ubuntu + ln -sf ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /compat/ubuntu/lib64/ld-linux-x86-64.so.2 + sysctl compat.linux.emul_path=/compat/ubuntu + - os: ubuntu-latest + vm: + os: freebsd + run: | + pkg install -y ruby rubygem-bundler rubygem-rake + sysrc linux_enable="YES" + service linux start + pkg install -y debootstrap + debootstrap jammy /compat/ubuntu + ln -sf ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /compat/ubuntu/lib64/ld-linux-x86-64.so.2 + sysctl compat.linux.emul_path=/compat/ubuntu + mount -t linprocfs linproc /compat/ubuntu/proc - os: ubuntu-latest vm: os: openbsd @@ -90,11 +129,13 @@ jobs: - os: ubuntu-latest vm: os: netbsd - run: /usr/sbin/pkg_add nodejs protobuf ruby + run: | + /usr/sbin/pkg_add nodejs protobuf ruby - os: ubuntu-latest vm: os: dragonflybsd - run: pkg install -y libnghttp2 libuv node npm protobuf ruby rubygem-bundler rubygem-rake + run: | + pkg install -y libnghttp2 libuv node npm protobuf ruby rubygem-bundler rubygem-rake - os: ubuntu-latest vm: os: omnios @@ -139,7 +180,7 @@ jobs: run: bundle exec rake compile - name: Spec - if: "!matrix.vm" # TODO: remove after https://github.com/sass/dart-sass/pull/2413 + if: "!matrix.vm || contains(matrix.vm.run, 'linux_base') || contains(matrix.vm.run, '/proc')" # TODO: remove after https://github.com/sass/dart-sass/pull/2413 run: bundle exec rake spec - name: Install diff --git a/ext/sass/.gitignore b/ext/sass/.gitignore index 07e5fcad..c302c57a 100644 --- a/ext/sass/.gitignore +++ b/ext/sass/.gitignore @@ -10,4 +10,5 @@ /pnpm-lock.yaml /protoc.exe /ruby/ +/true /yarn.lock diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 2cb4e76b..79423ddc 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -2,6 +2,10 @@ require 'rake/clean' +require_relative '../../lib/sass/elf' + +ELF = Sass.const_get(:ELF) + task default: %i[install clean] task install: %w[cli.rb] do @@ -11,6 +15,7 @@ end CLEAN.include %w[ protoc.exe ruby + true *.proto *.tar.gz *.zip @@ -70,8 +75,6 @@ rescue NotImplementedError end file 'cli.rb' => %w[dart-sass] do |t| - require_relative '../../lib/sass/elf' - begin exe = 'dart-sass/sass' exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}" @@ -89,7 +92,7 @@ file 'cli.rb' => %w[dart-sass] do |t| end interpreter = File.open(command[0], 'rb') do |file| - Sass.const_get(:ELF).new(file).interpreter + ELF.new(file).interpreter rescue ArgumentError nil end @@ -158,6 +161,119 @@ rule '_pb.rb' => %w[.proto protoc.exe] do |t| sh './protoc.exe', '--proto_path=.', '--ruby_out=.', t.source end +file 'true' do |t| + case Platform::CPU + when 'aarch64' + ei_class = ELF::ELFCLASS64 + ei_data = ELF::ELFDATA2LSB + e_machine = 0xb7 + e_flags = 0 + + # 0x0000000000000078: A8 0B 80 D2 mov x8, #0x5d + # 0x000000000000007c: 00 00 80 D2 mov x0, #0 + # 0x0000000000000080: 01 00 00 D4 svc #0 + entry_point = ['a80b80d2000080d2010000d4'].pack('H*') + when 'arm' + ei_class = ELF::ELFCLASS32 + ei_data = ELF::ELFDATA2LSB + e_machine = 0x28 + e_flags = 0x5000400 + + # 0x0000000000000054: 00 00 A0 E3 mov r0, #0 + # 0x0000000000000058: 01 70 A0 E3 mov r7, #1 + # 0x000000000000005c: 00 00 00 EF svc #0 + entry_point = ['0000a0e30170a0e3000000ef'].pack('H*') + when 'riscv64' + ei_class = ELF::ELFCLASS64 + ei_data = ELF::ELFDATA2LSB + e_machine = 0xf3 + e_flags = 0x5 + + # 0x0000000000000078: 93 08 D0 05 addi a7, x0, 93 + # 0x000000000000007c: 01 45 c.li a0, 0 + # 0x000000000000007e: 73 00 00 00 ecall + entry_point = ['9308d005014573000000'].pack('H*') + when 'x86_64' + ei_class = ELF::ELFCLASS64 + ei_data = ELF::ELFDATA2LSB + e_machine = 0x3e + e_flags = 0 + + # 0x0000000000000078: 31 FF xor edi, edi + # 0x000000000000007a: B8 3C 00 00 00 mov eax, 0x3c + # 0x000000000000007f: 0F 05 syscall + entry_point = ['31ffb83c0000000f05'].pack('H*') + when 'i386' + ei_class = ELF::ELFCLASS32 + ei_data = ELF::ELFDATA2LSB + e_machine = 0x03 + e_flags = 0 + + # 0x0000000000000054: 31 DB xor ebx, ebx + # 0x0000000000000056: B8 01 00 00 00 mov eax, 1 + # 0x000000000000005b: CD 80 int 0x80 + entry_point = ['31dbb801000000cd80'].pack('H*') + else + raise NotImplementedError + end + + File.open(t.name, 'wb', 0o755) do |file| + ELF.allocate.instance_eval do + case ei_class + when ELF::ELFCLASS32 + e_ehsize = ELF::Elf32_Ehdr.sizeof + e_phentsize = ELF::Elf32_Phdr.sizeof + e_shentsize = ELF::Elf32_Shdr.sizeof + when ELF::ELFCLASS64 + e_ehsize = ELF::Elf64_Ehdr.sizeof + e_phentsize = ELF::Elf64_Phdr.sizeof + e_shentsize = ELF::Elf64_Shdr.sizeof + else + raise EncodingError + end + e_phoff = e_ehsize + p_offset = e_phoff + e_phentsize + e_entry = (2**22) + p_offset + p_vaddr = e_entry + p_filesz = entry_point.length + p_memsz = p_filesz + + @ehdr = { + e_ident: [127, 69, 76, 70, ei_class, ei_data, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + e_type: ELF::ET_EXEC, + e_machine:, + e_version: 1, + e_entry:, + e_phoff:, + e_shoff: 0, + e_flags:, + e_ehsize:, + e_phentsize:, + e_phnum: 1, + e_shentsize:, + e_shnum: 0, + e_shstrndx: 0 + } + @phdrs = [ + { + p_type: ELF::PT_LOAD, + p_flags: ELF::PF_R | ELF::PF_X, + p_offset:, + p_vaddr:, + p_paddr: 0, + p_filesz:, + p_memsz:, + p_align: 4096 + } + ] + @shdrs = [] + + dump(file) + end + file.write(entry_point) + end +end + # This is a FileUtils extension that defines several additional commands to be # added to the FileUtils utility functions. module FileUtils @@ -302,46 +418,140 @@ module FileUtils end end -# The {SassConfig} module. -module SassConfig - module Platform - OS = case RbConfig::CONFIG['host_os'].downcase - when /darwin/ - 'darwin' - when /linux-android/ - 'linux-android' - when /linux-musl/ - 'linux-musl' - when /linux-uclibc/ - 'linux-uclibc' - when /linux/ - 'linux' - when *Gem::WIN_PATTERNS - 'windows' - else - RbConfig::CONFIG['host_os'].downcase - end +# The {Platform} module. +module Platform + # @see https://docs.freebsd.org/en/articles/linux-emulation/ + # @see https://docs.freebsd.org/en/books/handbook/linuxemu/ + module Linuxulator + module_function - CPU = case RbConfig::CONFIG['host_cpu'].downcase - when /amd64|x86_64|x64/ - 'x86_64' - when /i\d86|x86|i86pc/ - 'i386' - when /arm64|aarch64/ - 'aarch64' - when /arm/ - 'arm' - when /ppc64le|powerpc64le/ - 'ppc64le' - else - RbConfig::CONFIG['host_cpu'] - end + def enabled? + return false unless RbConfig::CONFIG['host_os'].include?('freebsd') + + return true if defined?(Platform::OS) && Platform::OS.include?('linux') + + begin + Rake::Task['true'].invoke unless File.exist?('true') + rescue NotImplementedError + # do nothing + end - ARCH = "#{CPU}-#{OS}".freeze + system('./true') == true + end + + def host_os(root = compat_linux_emul_path) + return 'linux-none' unless File.exist?(File.absolute_path('proc/self/exe', root)) + + if (Platform::CPU == 'aarch64' && + File.exist?(File.absolute_path('lib/ld-linux-aarch64.so.1', root))) || + (Platform::CPU == 'riscv64' && + File.exist?(File.absolute_path('lib/ld-linux-riscv64-lp64d.so.1', root))) || + (Platform::CPU == 'x86_64' && + File.exist?(File.absolute_path('lib64/ld-linux-x86-64.so.2', root))) || + (Platform::CPU == 'i386' && + File.exist?(File.absolute_path('lib/ld-linux.so.2', root))) + return 'linux-gnu' + end + + if Platform::CPU == 'arm' && + File.exist?(File.absolute_path('lib/ld-linux-armhf.so.3', root)) + return 'linux-gnueabihf' + end + + if %w[aarch64 riscv64 x86_64 i386].include?(Platform::CPU) && + File.exist?(File.absolute_path("lib/ld-musl-#{Platform::CPU}.so.1", root)) + return 'linux-musl' + end + + if Platform::CPU == 'arm' && + File.exist?(File.absolute_path('lib/ld-musl-armhf.so.1', root)) + return 'linux-musleabihf' + end + + if (%w[aarch64 riscv64 x86_64].include?(Platform::CPU) && + File.exist?(File.absolute_path('system/bin/linker64', root))) || + (Platform::CPU == 'i386' && + File.exist?(File.absolute_path('system/bin/linker', root))) + return 'linux-android' + end + + if Platform::CPU == 'arm' && + File.exist?(File.absolute_path('system/bin/linker', root)) + return 'linux-androideabi' + end + + 'linux-none' + end + + def compat_linux_emul_path + require 'fiddle' + + lib = Fiddle.dlopen(nil) + sysctlbyname = Fiddle::Function.new( + lib['sysctlbyname'], + [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_SIZE_T], + Fiddle::TYPE_INT + ) + + name = Fiddle::Pointer.to_ptr('compat.linux.emul_path') + oldp = Fiddle::NULL + oldlenp = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SIZE_T, Fiddle::RUBY_FREE) + newp = Fiddle::NULL + newlen = 0 + raise SystemCallError.new(nil, Fiddle.last_error) if sysctlbyname.call(name, oldp, oldlenp, newp, newlen) == -1 + + oldp = Fiddle::Pointer.malloc(oldlenp.ptr.to_i, Fiddle::RUBY_FREE) + raise SystemCallError.new(nil, Fiddle.last_error) if sysctlbyname.call(name, oldp, oldlenp, newp, newlen) == -1 + + oldp.to_s + rescue SystemCallError + nil + end end - private_constant :Platform + HOST_CPU = RbConfig::CONFIG['host_cpu'].downcase + + CPU = case HOST_CPU + when /amd64|x86_64|x64/ + 'x86_64' + when /i\d86|x86|i86pc/ + 'i386' + when /arm64|aarch64/ + 'aarch64' + when /arm/ + 'arm' + when /ppc64le|powerpc64le/ + 'ppc64le' + else + HOST_CPU + end + + HOST_OS = (Linuxulator.enabled? ? Linuxulator.host_os : RbConfig::CONFIG['host_os']).downcase + + OS = case HOST_OS + when /darwin/ + 'darwin' + when /linux-android/ + 'linux-android' + when /linux-musl/ + 'linux-musl' + when /linux-none/ + 'linux-none' + when /linux-uclibc/ + 'linux-uclibc' + when /linux/ + 'linux' + when *Gem::WIN_PATTERNS + 'windows' + else + HOST_OS + end + + ARCH = "#{CPU}-#{OS}".freeze +end +# The {SassConfig} module. +module SassConfig module_function def package_json(path = '.') @@ -415,7 +625,7 @@ module SassConfig os = case Platform::OS when 'darwin' 'osx' - when 'linux', 'linux-android', 'linux-musl', 'linux-uclibc' + when 'linux', 'linux-android', 'linux-musl', 'linux-none', 'linux-uclibc' 'linux' when 'windows' 'windows' @@ -492,7 +702,7 @@ module SassConfig end def gem_platform - platform = Gem::Platform.new("#{Platform::CPU}-#{RbConfig::CONFIG['host_os']}") + platform = Gem::Platform.new("#{Platform::CPU}-#{Platform::HOST_OS}") case Platform::OS when 'darwin' case platform.cpu diff --git a/spec/sass/elf_spec.rb b/spec/sass/elf_spec.rb index f6b20fa2..6fd5c9c5 100644 --- a/spec/sass/elf_spec.rb +++ b/spec/sass/elf_spec.rb @@ -7,32 +7,35 @@ Sass.const_get(:ELF) end - describe 'ruby program interpreter' do - it 'starts with ld-' do + describe 'ruby', skip: (File.exist?('/proc/self/exe') ? false : 'procfs is not available') do + it 'extracts program interpreter' do expect(File.basename(described_class::INTERPRETER)).to start_with('ld-') end + + it 'dumps elf headers' do + input = StringIO.new(File.binread('/proc/self/exe')) + output = StringIO.new.binmode + + described_class.new(input).dump(output) + expect(output.string).to eq(input.string.slice(0, output.length)) + end end - describe 'dart program interpreter' do + describe 'dart' do subject(:interpreter) do Sass.const_get(:CLI)::INTERPRETER end - it 'starts with ld-' do + it 'extracts program interpreter' do expect(File.basename(interpreter)).to start_with('ld-') end - it 'is the same as ruby' do - expect(File.basename(interpreter)) - .to eq(File.basename(described_class::INTERPRETER)) - end - end - - it 'dumps elf headers' do - input = StringIO.new(File.binread('/proc/self/exe')) - output = StringIO.new.binmode + it 'dumps elf headers' do + input = StringIO.new(File.binread(Sass.const_get(:CLI)::COMMAND[0])) + output = StringIO.new.binmode - described_class.new(input).dump(output) - expect(output.string).to eq(input.string.slice(0, output.length)) + described_class.new(input).dump(output) + expect(output.string).to eq(input.string.slice(0, output.length)) + end end end From 99b0d795f9e7f96614163aa6cf15dfb464fa4a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 29 Jan 2025 10:33:19 -0800 Subject: [PATCH 620/700] Reformat disassembly with llvm-objdump --- ext/sass/Rakefile | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 79423ddc..699612c9 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -169,9 +169,10 @@ file 'true' do |t| e_machine = 0xb7 e_flags = 0 - # 0x0000000000000078: A8 0B 80 D2 mov x8, #0x5d - # 0x000000000000007c: 00 00 80 D2 mov x0, #0 - # 0x0000000000000080: 01 00 00 D4 svc #0 + # 0000000000400078 : + # 400078: d2800ba8 mov x8, #0x5d // =93 + # 40007c: d2800000 mov x0, #0x0 // =0 + # 400080: d4000001 svc #0 entry_point = ['a80b80d2000080d2010000d4'].pack('H*') when 'arm' ei_class = ELF::ELFCLASS32 @@ -179,9 +180,10 @@ file 'true' do |t| e_machine = 0x28 e_flags = 0x5000400 - # 0x0000000000000054: 00 00 A0 E3 mov r0, #0 - # 0x0000000000000058: 01 70 A0 E3 mov r7, #1 - # 0x000000000000005c: 00 00 00 EF svc #0 + # 00400054 : + # 400054: e3a00000 mov r0, #0 + # 400058: e3a07001 mov r7, #1 + # 40005c: ef000000 svc #0x0 entry_point = ['0000a0e30170a0e3000000ef'].pack('H*') when 'riscv64' ei_class = ELF::ELFCLASS64 @@ -189,9 +191,10 @@ file 'true' do |t| e_machine = 0xf3 e_flags = 0x5 - # 0x0000000000000078: 93 08 D0 05 addi a7, x0, 93 - # 0x000000000000007c: 01 45 c.li a0, 0 - # 0x000000000000007e: 73 00 00 00 ecall + # 0000000000400078 : + # 400078: 05d00893 li a7, 0x5d + # 40007c: 4501 li a0, 0x0 + # 40007e: 00000073 ecall entry_point = ['9308d005014573000000'].pack('H*') when 'x86_64' ei_class = ELF::ELFCLASS64 @@ -199,9 +202,10 @@ file 'true' do |t| e_machine = 0x3e e_flags = 0 - # 0x0000000000000078: 31 FF xor edi, edi - # 0x000000000000007a: B8 3C 00 00 00 mov eax, 0x3c - # 0x000000000000007f: 0F 05 syscall + # 0000000000400078 : + # 400078: 31 ff xorl %edi, %edi + # 40007a: b8 3c 00 00 00 movl $0x3c, %eax + # 40007f: 0f 05 syscall entry_point = ['31ffb83c0000000f05'].pack('H*') when 'i386' ei_class = ELF::ELFCLASS32 @@ -209,9 +213,10 @@ file 'true' do |t| e_machine = 0x03 e_flags = 0 - # 0x0000000000000054: 31 DB xor ebx, ebx - # 0x0000000000000056: B8 01 00 00 00 mov eax, 1 - # 0x000000000000005b: CD 80 int 0x80 + # 00400054 : + # 400054: 31 db xorl %ebx, %ebx + # 400056: b8 01 00 00 00 movl $0x1, %eax + # 40005b: cd 80 int $0x80 entry_point = ['31dbb801000000cd80'].pack('H*') else raise NotImplementedError From 2240d995818a3c1ee0b4722f54bd6619b43fc098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 29 Jan 2025 13:03:46 -0800 Subject: [PATCH 621/700] Improve code readability --- ext/sass/Rakefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 699612c9..238f6fdd 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -173,7 +173,7 @@ file 'true' do |t| # 400078: d2800ba8 mov x8, #0x5d // =93 # 40007c: d2800000 mov x0, #0x0 // =0 # 400080: d4000001 svc #0 - entry_point = ['a80b80d2000080d2010000d4'].pack('H*') + entry_point = [0xd2800ba8, 0xd2800000, 0xd4000001].pack('L<3') when 'arm' ei_class = ELF::ELFCLASS32 ei_data = ELF::ELFDATA2LSB @@ -184,7 +184,7 @@ file 'true' do |t| # 400054: e3a00000 mov r0, #0 # 400058: e3a07001 mov r7, #1 # 40005c: ef000000 svc #0x0 - entry_point = ['0000a0e30170a0e3000000ef'].pack('H*') + entry_point = [0xe3a00000, 0xe3a07001, 0xef000000].pack('L<3') when 'riscv64' ei_class = ELF::ELFCLASS64 ei_data = ELF::ELFDATA2LSB @@ -195,7 +195,7 @@ file 'true' do |t| # 400078: 05d00893 li a7, 0x5d # 40007c: 4501 li a0, 0x0 # 40007e: 00000073 ecall - entry_point = ['9308d005014573000000'].pack('H*') + entry_point = [0x05d00893, 0x4501, 0x00000073].pack('L Date: Wed, 29 Jan 2025 17:36:43 -0800 Subject: [PATCH 622/700] Rewrite ARM instructions in Thumb --- ext/sass/Rakefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 238f6fdd..0e502615 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -181,10 +181,10 @@ file 'true' do |t| e_flags = 0x5000400 # 00400054 : - # 400054: e3a00000 mov r0, #0 - # 400058: e3a07001 mov r7, #1 - # 40005c: ef000000 svc #0x0 - entry_point = [0xe3a00000, 0xe3a07001, 0xef000000].pack('L<3') + # 400054: 2701 movs r7, #0x1 + # 400056: 2000 movs r0, #0x0 + # 400058: df00 svc #0x0 + entry_point = [0x2701, 0x2000, 0xdf00].pack('S<3') when 'riscv64' ei_class = ELF::ELFCLASS64 ei_data = ELF::ELFDATA2LSB @@ -236,12 +236,15 @@ file 'true' do |t| else raise EncodingError end - e_phoff = e_ehsize - p_offset = e_phoff + e_phentsize - e_entry = (2**22) + p_offset - p_vaddr = e_entry + + p_offset = e_ehsize + e_phentsize + p_vaddr = (2**22) + p_offset p_filesz = entry_point.length p_memsz = p_filesz + e_phoff = e_ehsize + + e_entry = p_vaddr + e_entry += 1 if Platform::CPU == 'arm' @ehdr = { e_ident: [127, 69, 76, 70, ei_class, ei_data, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], From febd25cc8212eda02fe3b0d57c2bbe6b1f826eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 29 Jan 2025 22:11:43 -0800 Subject: [PATCH 623/700] Reduce nesting blocks --- ext/sass/Rakefile | 109 +++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 0e502615..2e9040da 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -206,7 +206,7 @@ file 'true' do |t| # 400078: 31 ff xorl %edi, %edi # 40007a: b8 3c 00 00 00 movl $0x3c, %eax # 40007f: 0f 05 syscall - entry_point = %w[31ff b83c000000 0f05].pack('H*H*H*') + entry_point = %w[31ffb83c0000000f05].pack('H*') when 'i386' ei_class = ELF::ELFCLASS32 ei_data = ELF::ELFDATA2LSB @@ -217,68 +217,69 @@ file 'true' do |t| # 400054: 31 db xorl %ebx, %ebx # 400056: b8 01 00 00 00 movl $0x1, %eax # 40005b: cd 80 int $0x80 - entry_point = %w[31db b801000000 cd80].pack('H*H*H*') + entry_point = %w[31dbb801000000cd80].pack('H*') else raise NotImplementedError end - File.open(t.name, 'wb', 0o755) do |file| - ELF.allocate.instance_eval do - case ei_class - when ELF::ELFCLASS32 - e_ehsize = ELF::Elf32_Ehdr.sizeof - e_phentsize = ELF::Elf32_Phdr.sizeof - e_shentsize = ELF::Elf32_Shdr.sizeof - when ELF::ELFCLASS64 - e_ehsize = ELF::Elf64_Ehdr.sizeof - e_phentsize = ELF::Elf64_Phdr.sizeof - e_shentsize = ELF::Elf64_Shdr.sizeof - else - raise EncodingError - end + case ei_class + when ELF::ELFCLASS32 + e_ehsize = ELF::Elf32_Ehdr.sizeof + e_phentsize = ELF::Elf32_Phdr.sizeof + e_shentsize = ELF::Elf32_Shdr.sizeof + when ELF::ELFCLASS64 + e_ehsize = ELF::Elf64_Ehdr.sizeof + e_phentsize = ELF::Elf64_Phdr.sizeof + e_shentsize = ELF::Elf64_Shdr.sizeof + else + raise EncodingError + end - p_offset = e_ehsize + e_phentsize - p_vaddr = (2**22) + p_offset - p_filesz = entry_point.length - p_memsz = p_filesz - e_phoff = e_ehsize - - e_entry = p_vaddr - e_entry += 1 if Platform::CPU == 'arm' - - @ehdr = { - e_ident: [127, 69, 76, 70, ei_class, ei_data, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], - e_type: ELF::ET_EXEC, - e_machine:, - e_version: 1, - e_entry:, - e_phoff:, - e_shoff: 0, - e_flags:, - e_ehsize:, - e_phentsize:, - e_phnum: 1, - e_shentsize:, - e_shnum: 0, - e_shstrndx: 0 + e_phoff = e_ehsize + + p_offset = e_phoff + e_phentsize + p_vaddr = (2**22) + p_offset + p_filesz = entry_point.length + p_memsz = p_filesz + + e_entry = p_vaddr + e_entry += 1 if Platform::CPU == 'arm' + + ELF.allocate.instance_eval do + @ehdr = { + e_ident: [127, 69, 76, 70, ei_class, ei_data, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + e_type: ELF::ET_EXEC, + e_machine:, + e_version: 1, + e_entry:, + e_phoff:, + e_shoff: 0, + e_flags:, + e_ehsize:, + e_phentsize:, + e_phnum: 1, + e_shentsize:, + e_shnum: 0, + e_shstrndx: 0 + } + @phdrs = [ + { + p_type: ELF::PT_LOAD, + p_flags: ELF::PF_R | ELF::PF_X, + p_offset:, + p_vaddr:, + p_paddr: 0, + p_filesz:, + p_memsz:, + p_align: 4096 } - @phdrs = [ - { - p_type: ELF::PT_LOAD, - p_flags: ELF::PF_R | ELF::PF_X, - p_offset:, - p_vaddr:, - p_paddr: 0, - p_filesz:, - p_memsz:, - p_align: 4096 - } - ] - @shdrs = [] + ] + @shdrs = [] + File.open(t.name, 'wb', 0o755) do |file| dump(file) + file.write(entry_point) end - file.write(entry_point) end end From 9b657a080367a74d5e10862b5ac14bc3e68c61c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 3 Feb 2025 08:18:51 -0800 Subject: [PATCH 624/700] Check if /proc/self/exe is a symlink in linuxulator --- ext/sass/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 2e9040da..e2457832 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -449,7 +449,7 @@ module Platform end def host_os(root = compat_linux_emul_path) - return 'linux-none' unless File.exist?(File.absolute_path('proc/self/exe', root)) + return 'linux-none' unless File.symlink?(File.absolute_path('proc/self/exe', root)) if (Platform::CPU == 'aarch64' && File.exist?(File.absolute_path('lib/ld-linux-aarch64.so.1', root))) || From 7bbd4f61e073c10d81138c2dea46498b1651772a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 17:05:51 -0800 Subject: [PATCH 625/700] Bump sass from 1.83.4 to 1.85.0 in /ext/sass (#288) Bumps [sass](https://github.com/sass/dart-sass) from 1.83.4 to 1.85.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.83.4...1.85.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 7ac3b921..8baa9074 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "sass": "1.83.4" + "sass": "1.85.0" }, "packageManager": "npm@11.0.0+sha512.11dff29565d2297c74e7c594a9762581bde969f0aa5cbe6f5b3644bf008a16c065ece61094d9ffbb81125be38df8e1ba43eb8244b3d30c61eb797e9a2440e3ec" } From 9dfb0819d27dfadd309eea916ad8fef2749033e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 13 Feb 2025 17:18:46 -0800 Subject: [PATCH 626/700] v1.85.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 24137b0f..ec7ce5f2 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.83.4' + VERSION = '1.85.0' end end From e8f38417915996757ee45a3a3d8e325972dda6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 13 Feb 2025 17:50:18 -0800 Subject: [PATCH 627/700] Workaround https://github.com/rubygems/rubygems/pull/6490 --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b55aaa2..4277e83d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -174,7 +174,10 @@ jobs: - name: Bundle if: "!matrix.ruby-version" - run: bundle install + run: | + bundle config --local path vendor/bundle + bundle lock + bundle install --jobs 4 - name: Compile run: bundle exec rake compile From 339cf5ec7a0254ac036a4bb20e45fc5b1d6e8a7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Feb 2025 08:56:52 -0800 Subject: [PATCH 628/700] Update rubocop requirement from ~> 1.71.0 to ~> 1.72.0 (#289) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.71.0 to ~> 1.72.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.71.0...v1.72.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Fix lint --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- Gemfile | 2 +- lib/sass/elf.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index d1751791..5da520cf 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.71.0' + gem 'rubocop', '~> 1.72.0' gem 'rubocop-performance', '~> 1.23.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.4.0' diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index 4fb1aa3b..9e46bcdc 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -329,12 +329,12 @@ def dump(io) io.rewind elf_ehdr.pack(io, ehdr, little_endian) - io.seek(ehdr[:e_phoff], IO::SEEK_SET) if (ehdr[:e_phnum]).positive? + io.seek(ehdr[:e_phoff], IO::SEEK_SET) if ehdr[:e_phnum].positive? phdrs.each do |phdr| elf_phdr.pack(io, phdr, little_endian) end - io.seek(ehdr[:e_shoff], IO::SEEK_SET) if (ehdr[:e_shnum]).positive? + io.seek(ehdr[:e_shoff], IO::SEEK_SET) if ehdr[:e_shnum].positive? shdrs.each do |shdr| elf_shdr.pack(io, shdr, little_endian) end From 4a072df7f341cc45f845bb383514596e12a0a445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 14 Feb 2025 09:51:05 -0800 Subject: [PATCH 629/700] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4277e83d..884b4c08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -149,6 +149,7 @@ jobs: - name: Initialize vm if: matrix.vm + timeout-minutes: 5 uses: ./.github/actions/setup-vm with: os: ${{ matrix.vm.os }} From 18dc572a612e0c9af7a6a62df63ce7efe7b2538e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 14 Feb 2025 10:29:46 -0800 Subject: [PATCH 630/700] Remove prebuilt gems for unpopular windows ruby platforms --- .github/workflows/release.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fb665c2..9a1ce148 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,16 +46,10 @@ jobs: platform: riscv64-linux-musl - os: ubuntu-latest platform: x86_64-linux-musl - - os: windows-latest - platform: x86_64-cygwin - os: windows-latest platform: aarch64-mingw-ucrt - os: windows-latest platform: x64-mingw-ucrt - - os: windows-latest - platform: x64-mingw32 - - os: windows-latest - platform: x64-mswin64 steps: - name: Checkout From 248c77003599d0009e0549a5b703d593e9b92166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 14 Feb 2025 16:27:53 -0800 Subject: [PATCH 631/700] Increase vm setup timeout --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 884b4c08..bad03151 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -149,7 +149,7 @@ jobs: - name: Initialize vm if: matrix.vm - timeout-minutes: 5 + timeout-minutes: 10 uses: ./.github/actions/setup-vm with: os: ${{ matrix.vm.os }} From 6a8b89557d4fc5589ebcc9fb612131e2a5a9cc14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 08:06:43 -0800 Subject: [PATCH 632/700] Update rubocop-performance requirement from ~> 1.23.0 to ~> 1.24.0 (#290) Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.23.0...v1.24.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5da520cf..d6813ed4 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.72.0' - gem 'rubocop-performance', '~> 1.23.0' + gem 'rubocop-performance', '~> 1.24.0' gem 'rubocop-rake', '~> 0.6.0' gem 'rubocop-rspec', '~> 3.4.0' end From 476a525e9efdcfebd9077fa93014bc135d3b0700 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 08:17:33 -0800 Subject: [PATCH 633/700] Update rubocop-rspec requirement from ~> 3.4.0 to ~> 3.5.0 (#291) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.4.0...v3.5.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d6813ed4..7e54c567 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,5 @@ group :development do gem 'rubocop', '~> 1.72.0' gem 'rubocop-performance', '~> 1.24.0' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 3.4.0' + gem 'rubocop-rspec', '~> 3.5.0' end From c1faecfe1d1e7527809ad375412173b9a063b9c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 08:54:09 -0800 Subject: [PATCH 634/700] Update rubocop-rake requirement from ~> 0.6.0 to ~> 0.7.1 (#292) Updates the requirements on [rubocop-rake](https://github.com/rubocop/rubocop-rake) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rake/releases) - [Changelog](https://github.com/rubocop/rubocop-rake/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rake/compare/v0.6.0...v0.7.1) --- updated-dependencies: - dependency-name: rubocop-rake dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7e54c567..ba991af0 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,6 @@ group :development do gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.72.0' gem 'rubocop-performance', '~> 1.24.0' - gem 'rubocop-rake', '~> 0.6.0' + gem 'rubocop-rake', '~> 0.7.1' gem 'rubocop-rspec', '~> 3.5.0' end From 5b76237426e40e8957094d748275c1e1a80ec691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 19 Feb 2025 10:36:50 -0800 Subject: [PATCH 635/700] Generate artifact attestation --- .github/workflows/release.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a1ce148..042fd872 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,10 @@ jobs: runs-on: ${{ matrix.os }} + permissions: + id-token: write + attestations: write + strategy: fail-fast: false matrix: @@ -68,6 +72,11 @@ jobs: - name: Build run: rake -f -r bundler/gem_tasks build gem_platform=${{ matrix.platform }} + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-path: pkg/*.gem + - name: Upload Artifact uses: actions/upload-artifact@v4 with: From d719d42f56627dedfdd3140fd33f3cd5eec12e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Feb 2025 16:25:11 -0800 Subject: [PATCH 636/700] Update .rubocop.yml --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8673806f..e06f38de 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,4 @@ -require: +plugins: - rubocop-performance - rubocop-rake - rubocop-rspec From c505c80a6ad5c4b82e05eec5036dc5fe7e42eb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 20 Feb 2025 16:31:45 -0800 Subject: [PATCH 637/700] Update release.yml --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 042fd872..661baffc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -105,6 +105,8 @@ jobs: - name: Download Artifact uses: actions/download-artifact@v4 + with: + pattern: pkg-* - name: Configure trusted publishing credentials uses: rubygems/configure-rubygems-credentials@v1.0.0 From eb5202246fe1a8128776df80e90c2396f04cfa0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 21 Feb 2025 01:43:49 -0800 Subject: [PATCH 638/700] Update schedule.yml --- .github/workflows/schedule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index 0541b16a..59f91e40 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -2,7 +2,7 @@ name: schedule on: schedule: - - cron: '0 0 * * 0' + - cron: '0 0 * * *' workflow_dispatch: jobs: From 1e5f904fc3daa2787b84a730379729f4289c8ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 24 Feb 2025 18:02:16 -0800 Subject: [PATCH 639/700] Revert "Fix dependabot" This reverts commit 8a0a358f9806e833008cf923e9ebe80eca354b63. --- ext/sass/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 8baa9074..3a210e91 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,6 +1,5 @@ { "dependencies": { "sass": "1.85.0" - }, - "packageManager": "npm@11.0.0+sha512.11dff29565d2297c74e7c594a9762581bde969f0aa5cbe6f5b3644bf008a16c065ece61094d9ffbb81125be38df8e1ba43eb8244b3d30c61eb797e9a2440e3ec" + } } From 199faf39674572b680d480c59dbdc11c6a6a8f07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:19:39 -0800 Subject: [PATCH 640/700] Bump sass from 1.85.0 to 1.85.1 in /ext/sass (#293) Bumps [sass](https://github.com/sass/dart-sass) from 1.85.0 to 1.85.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.85.0...1.85.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 3a210e91..54449d27 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.85.0" + "sass": "1.85.1" } } From 4c8581f524b12119c9e3ee43ceb9948164486f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 24 Feb 2025 18:20:24 -0800 Subject: [PATCH 641/700] v1.85.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index ec7ce5f2..e36bc3c6 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.85.0' + VERSION = '1.85.1' end end From f988966136f21a0d13923f7f685a51370e9caafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Feb 2025 11:07:04 -0800 Subject: [PATCH 642/700] Strict hash to struct conversion (#294) --- lib/sass/compiler/host.rb | 2 +- lib/sass/compiler/host/importer_registry.rb | 6 ++- lib/sass/compiler/host/logger_registry.rb | 2 +- lib/sass/compiler/host/struct.rb | 46 +++++++++++++++++++++ lib/sass/compiler/host/structifier.rb | 37 ----------------- 5 files changed, 52 insertions(+), 41 deletions(-) create mode 100644 lib/sass/compiler/host/struct.rb delete mode 100644 lib/sass/compiler/host/structifier.rb diff --git a/lib/sass/compiler/host.rb b/lib/sass/compiler/host.rb index 1677f466..83814201 100644 --- a/lib/sass/compiler/host.rb +++ b/lib/sass/compiler/host.rb @@ -4,7 +4,7 @@ require_relative 'host/importer_registry' require_relative 'host/logger_registry' require_relative 'host/protofier' -require_relative 'host/structifier' +require_relative 'host/struct' module Sass class Compiler diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index 4ebc3dd2..a3950f57 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -33,7 +33,8 @@ def register(importer) ) ) else - importer = Structifier.to_struct(importer, :canonicalize, :load, :non_canonical_scheme, :find_file_url) + importer = Struct.from_hash(importer, attrs: %i[non_canonical_scheme], + methods: %i[canonicalize load find_file_url]) is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load) is_file_importer = importer.respond_to?(:find_file_url) @@ -86,7 +87,8 @@ def canonicalize(canonicalize_request) def import(import_request) importer = @importers_by_id[import_request.importer_id] - importer_result = Structifier.to_struct importer.load(import_request.url), :contents, :syntax, :source_map_url + importer_result = Struct.from_hash(importer.load(import_request.url), + attrs: %i[contents syntax source_map_url]) EmbeddedProtocol::InboundMessage::ImportResponse.new( id: import_request.id, diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index e216c190..9f8a4fbb 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -8,7 +8,7 @@ class Host # It stores logger and handles log events. class LoggerRegistry def initialize(logger) - logger = Structifier.to_struct(logger, :debug, :warn) + logger = Struct.from_hash(logger, methods: %i[debug warn]) { debug: DebugContext, warn: WarnContext }.each do |symbol, context_class| next unless logger.respond_to?(symbol) diff --git a/lib/sass/compiler/host/struct.rb b/lib/sass/compiler/host/struct.rb new file mode 100644 index 00000000..1e4f93c1 --- /dev/null +++ b/lib/sass/compiler/host/struct.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Sass + class Compiler + class Host + # The {Struct} module. + # + # It creates {Struct}-like objects from {::Hash}. + class Struct + def initialize(hash, attrs: nil, methods: nil) + @hash = hash + @attrs = attrs + @methods = methods + end + + def method_missing(symbol, ...) + return super unless @hash.key?(symbol) + + if @attrs&.include?(symbol) + @hash.send(:[], symbol, ...) + elsif @methods&.include?(symbol) + @hash[symbol].call(...) + else + super + end + end + + def respond_to_missing?(symbol, _include_all) + @hash.key?(symbol) && (@attrs&.include?(symbol) || @methods&.include?(symbol)) + end + + class << self + def from_hash(object, ...) + if object.is_a?(Hash) + new(object, ...) + else + object + end + end + end + end + + private_constant :Struct + end + end +end diff --git a/lib/sass/compiler/host/structifier.rb b/lib/sass/compiler/host/structifier.rb deleted file mode 100644 index 80b21575..00000000 --- a/lib/sass/compiler/host/structifier.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -module Sass - class Compiler - class Host - # The {Structifier} module. - # - # It converts {::Hash} to {Struct}-like objects. - module Structifier - module_function - - def to_struct(obj, *symbols) - return obj unless obj.is_a?(Hash) - - struct = Object.new - symbols.each do |key| - next unless obj.key?(key) - - value = obj[key] - if value.respond_to?(:call) - struct.define_singleton_method key do |*args, **kwargs| - value.call(*args, **kwargs) - end - else - struct.define_singleton_method key do - value - end - end - end - struct - end - end - - private_constant :Structifier - end - end -end From cb1cad3d0506f6d153e0f1a0e38377443d4f7530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Feb 2025 11:09:50 -0800 Subject: [PATCH 643/700] Fast non-array to array conversion --- lib/sass/compiler/host/importer_registry.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index a3950f57..f35dfdf1 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -49,12 +49,7 @@ def register(importer) EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( importer_id: id, non_canonical_scheme: if importer.respond_to?(:non_canonical_scheme) - non_canonical_scheme = importer.non_canonical_scheme - if non_canonical_scheme.is_a?(String) - [non_canonical_scheme] - else - non_canonical_scheme || [] - end + Array(importer.non_canonical_scheme) else [] end From 20b12aff671db036e873fd6362ae25a8d7c583f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Feb 2025 11:24:38 -0800 Subject: [PATCH 644/700] Avoid using define_singleton_method --- lib/sass/compiler/host/logger_registry.rb | 32 ++++++++--------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index 9f8a4fbb..224d5b73 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -8,38 +8,28 @@ class Host # It stores logger and handles log events. class LoggerRegistry def initialize(logger) - logger = Struct.from_hash(logger, methods: %i[debug warn]) - - { debug: DebugContext, warn: WarnContext }.each do |symbol, context_class| - next unless logger.respond_to?(symbol) - - define_singleton_method(symbol) do |event| - logger.public_send(symbol, event.message, context_class.new(event)) - end - end + @logger = Struct.from_hash(logger, methods: %i[debug warn]) end def log(event) case event.type when :DEBUG - debug(event) + if @logger.respond_to?(:debug) + @logger.debug(event.message, DebugContext.new(event)) + else + Kernel.warn(event.formatted) + end when :DEPRECATION_WARNING, :WARNING - warn(event) + if @logger.respond_to?(:warn) + @logger.warn(event.message, WarnContext.new(event)) + else + Kernel.warn(event.formatted) + end else raise ArgumentError, "Unknown LogEvent.type #{event.type}" end end - private - - def debug(event) - Kernel.warn(event.formatted) - end - - def warn(event) - Kernel.warn(event.formatted) - end - # Contextual information passed to `debug`. class DebugContext # @return [Logger::SourceSpan, nil] From 770f1413f645b6ffe0b3bd7c84d511e9f23623c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Feb 2025 11:53:46 -0800 Subject: [PATCH 645/700] Cache repeated calls to respond_to? --- lib/sass/compiler/host/logger_registry.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index 224d5b73..f975a9e8 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -9,18 +9,20 @@ class Host class LoggerRegistry def initialize(logger) @logger = Struct.from_hash(logger, methods: %i[debug warn]) + @respond_to_debug = @logger.respond_to?(:debug) + @respond_to_warn = @logger.respond_to?(:warn) end def log(event) case event.type when :DEBUG - if @logger.respond_to?(:debug) + if @respond_to_debug @logger.debug(event.message, DebugContext.new(event)) else Kernel.warn(event.formatted) end when :DEPRECATION_WARNING, :WARNING - if @logger.respond_to?(:warn) + if @respond_to_warn @logger.warn(event.message, WarnContext.new(event)) else Kernel.warn(event.formatted) From d1df8f2b609f8709f824db6444aa3e91fe6302d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 25 Feb 2025 13:58:44 -0800 Subject: [PATCH 646/700] Use constant array --- lib/sass/compiler/host/importer_registry.rb | 17 +++++++++++++---- lib/sass/compiler/host/logger_registry.rb | 15 ++++++++++----- lib/sass/compiler/host/struct.rb | 14 ++------------ lib/sass/value/number.rb | 4 ++-- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index f35dfdf1..c51986eb 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -25,6 +25,12 @@ def initialize(importers, load_paths, alert_color:) @highlight = alert_color end + IMPORTER_ATTRS = %i[non_canonical_scheme].freeze + + IMPORTER_METHODS = %i[canonicalize load find_file_url].freeze + + private_constant :IMPORTER_ATTRS, :IMPORTER_METHODS + def register(importer) if importer.is_a?(Sass::NodePackageImporter) EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( @@ -33,8 +39,7 @@ def register(importer) ) ) else - importer = Struct.from_hash(importer, attrs: %i[non_canonical_scheme], - methods: %i[canonicalize load find_file_url]) + importer = Struct.new(importer, attrs: IMPORTER_ATTRS, methods: IMPORTER_METHODS) if importer.is_a?(::Hash) is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load) is_file_importer = importer.respond_to?(:find_file_url) @@ -80,10 +85,14 @@ def canonicalize(canonicalize_request) ) end + IMPORTER_RESULT_ATTRS = %i[contents syntax source_map_url].freeze + + private_constant :IMPORTER_RESULT_ATTRS + def import(import_request) importer = @importers_by_id[import_request.importer_id] - importer_result = Struct.from_hash(importer.load(import_request.url), - attrs: %i[contents syntax source_map_url]) + importer_result = importer.load(import_request.url) + importer_result = Struct.new(importer_result, attrs: IMPORTER_RESULT_ATTRS) if importer_result.is_a?(::Hash) EmbeddedProtocol::InboundMessage::ImportResponse.new( id: import_request.id, diff --git a/lib/sass/compiler/host/logger_registry.rb b/lib/sass/compiler/host/logger_registry.rb index f975a9e8..0f79050b 100644 --- a/lib/sass/compiler/host/logger_registry.rb +++ b/lib/sass/compiler/host/logger_registry.rb @@ -7,22 +7,27 @@ class Host # # It stores logger and handles log events. class LoggerRegistry + LOGGER_METHODS = %i[debug warn].freeze + + private_constant :LOGGER_METHODS + def initialize(logger) - @logger = Struct.from_hash(logger, methods: %i[debug warn]) - @respond_to_debug = @logger.respond_to?(:debug) - @respond_to_warn = @logger.respond_to?(:warn) + logger = Struct.new(logger, methods: LOGGER_METHODS) if logger.is_a?(::Hash) + @logger = logger + @logger_respond_to_debug = logger.respond_to?(:debug) + @logger_respond_to_warn = logger.respond_to?(:warn) end def log(event) case event.type when :DEBUG - if @respond_to_debug + if @logger_respond_to_debug @logger.debug(event.message, DebugContext.new(event)) else Kernel.warn(event.formatted) end when :DEPRECATION_WARNING, :WARNING - if @respond_to_warn + if @logger_respond_to_warn @logger.warn(event.message, WarnContext.new(event)) else Kernel.warn(event.formatted) diff --git a/lib/sass/compiler/host/struct.rb b/lib/sass/compiler/host/struct.rb index 1e4f93c1..75a7399d 100644 --- a/lib/sass/compiler/host/struct.rb +++ b/lib/sass/compiler/host/struct.rb @@ -3,9 +3,9 @@ module Sass class Compiler class Host - # The {Struct} module. + # The {Struct} class. # - # It creates {Struct}-like objects from {::Hash}. + # It creates {::Struct}-like objects from {::Hash}. class Struct def initialize(hash, attrs: nil, methods: nil) @hash = hash @@ -28,16 +28,6 @@ def method_missing(symbol, ...) def respond_to_missing?(symbol, _include_all) @hash.key?(symbol) && (@attrs&.include?(symbol) || @methods&.include?(symbol)) end - - class << self - def from_hash(object, ...) - if object.is_a?(Hash) - new(object, ...) - else - object - end - end - end end private_constant :Struct diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index aac588c0..a31f8c7a 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -25,12 +25,12 @@ def initialize(value, unit = nil) denominator_units = [] when ::Hash numerator_units = unit.fetch(:numerator_units, []) - unless numerator_units.is_a?(Array) + unless numerator_units.is_a?(::Array) raise Sass::ScriptError, "invalid numerator_units #{numerator_units.inspect}" end denominator_units = unit.fetch(:denominator_units, []) - unless denominator_units.is_a?(Array) + unless denominator_units.is_a?(::Array) raise Sass::ScriptError, "invalid denominator_units #{denominator_units.inspect}" end else From c01b30dbf8b4f5dd6999d2bc23332ee0008f60ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 26 Feb 2025 02:23:35 -0800 Subject: [PATCH 647/700] Avoid using define_singleton_method --- spec/sass/value/color/spaces.rb | 36 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/spec/sass/value/color/spaces.rb b/spec/sass/value/color/spaces.rb index b18da243..4f1d2ab5 100644 --- a/spec/sass/value/color/spaces.rb +++ b/spec/sass/value/color/spaces.rb @@ -2,6 +2,26 @@ require_relative 'constructors' +class ColorSpace + def initialize(hash) + @hash = hash + end + + def method_missing(symbol, ...) + return super unless @hash.key?(symbol) + + if symbol == :constructor + ColorConstructors.send(@hash[symbol], ...) + else + @hash[symbol] + end + end + + def respond_to_missing?(symbol, _include_all) + @hash.key?(symbol) + end +end + # @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/color/spaces.ts COLOR_SPACES = { lab: { @@ -332,18 +352,4 @@ ] ] } -}.freeze - -COLOR_SPACES.each_value do |value| - value.each_key do |key| - if key == :constructor - value.define_singleton_method(key) do |*args| - ColorConstructors.send(value[key], *args) - end - else - value.define_singleton_method(key) do - value[key] - end - end - end -end +}.transform_values! { |value| ColorSpace.new(value) }.freeze From 89a236decbb51df327bf2dd7d4b1133635107650 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2025 08:12:56 -0800 Subject: [PATCH 648/700] Update rubocop requirement from ~> 1.72.0 to ~> 1.73.0 (#295) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.72.0...v1.73.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ba991af0..a86b17cf 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.72.0' + gem 'rubocop', '~> 1.73.0' gem 'rubocop-performance', '~> 1.24.0' gem 'rubocop-rake', '~> 0.7.1' gem 'rubocop-rspec', '~> 3.5.0' From 70cb90f16bf724e620d029d871b1dbd5e3f40c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 26 Feb 2025 12:13:28 -0800 Subject: [PATCH 649/700] Avoid Class.new --- lib/sass/compiler.rb | 2 +- lib/sass/compiler/channel.rb | 10 +++++--- lib/sass/compiler/dispatcher.rb | 27 +++++++++++++++++++- lib/sass/embedded.rb | 45 +++------------------------------ 4 files changed, 37 insertions(+), 47 deletions(-) diff --git a/lib/sass/compiler.rb b/lib/sass/compiler.rb index f5ffba20..0d118152 100644 --- a/lib/sass/compiler.rb +++ b/lib/sass/compiler.rb @@ -30,7 +30,7 @@ module Sass # @see https://sass-lang.com/documentation/js-api/classes/compiler/ class Compiler def initialize - @channel = Channel.new(Dispatcher) + @channel = Channel.new end # Compiles the Sass file at +path+ to CSS. diff --git a/lib/sass/compiler/channel.rb b/lib/sass/compiler/channel.rb index 174f495c..254732bd 100644 --- a/lib/sass/compiler/channel.rb +++ b/lib/sass/compiler/channel.rb @@ -6,9 +6,11 @@ class Compiler # # It manages the lifecycle of {Dispatcher}. class Channel - def initialize(dispatcher_class) - @dispatcher_class = dispatcher_class - @dispatcher = @dispatcher_class.new + def initialize(*args, **kwargs, &block) + @args = args + @kwargs = kwargs + @block = block + @dispatcher = Dispatcher.new(*@args, **@kwargs, &@block) @mutex = Mutex.new end @@ -33,7 +35,7 @@ def stream(host) Stream.new(@dispatcher, host) rescue Errno::EBUSY - @dispatcher = @dispatcher_class.new + @dispatcher = Dispatcher.new(*@args, **@kwargs, &@block) Stream.new(@dispatcher, host) end end diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index 9fda6df9..6ba985e7 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -6,13 +6,33 @@ class Compiler # # It dispatches messages between multiple instances of {Host} and a single {Connection} to the compiler. class Dispatcher - def initialize + def initialize(idle_timeout: 0) @id = 1 + @last_accessed_time = current_time @observers = {}.compare_by_identity @mutex = Mutex.new @connection = Connection.new @connection.listen(self) ForkTracker.add(self) + + return unless idle_timeout.positive? + + Thread.new do + Thread.current.name = "sass-embedded-connection-reaper-#{@connection.id}" + duration = idle_timeout + loop do + sleep(duration.negative? ? idle_timeout : duration) + break if @mutex.synchronize do + raise Errno::EBUSY if _closed? + + duration = idle_timeout - (current_time - @last_accessed_time) + duration.negative? && _idle? && _close + end + end + close + rescue Errno::EBUSY + # do nothing + end end def subscribe(observer) @@ -94,6 +114,10 @@ def send_proto(...) private + def current_time + Process.clock_gettime(Process::CLOCK_MONOTONIC) + end + def _close @id = 0xffffffff end @@ -104,6 +128,7 @@ def _closed? def _idle @id = 1 + @last_accessed_time = current_time end def _idle? diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 714e864b..15cc4572 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -53,47 +53,10 @@ def compiler @mutex.synchronize do return @compiler if @compiler - compiler = Class.new(Compiler) do - def initialize - @channel = Compiler.const_get(:Channel).new(Class.new(Compiler.const_get(:Dispatcher)) do - def initialize - super - - idle_timeout = 10 - @last_accessed_time = current_time - - Thread.new do - Thread.current.name = "sass-embedded-connection-reaper-#{@connection.id}" - duration = idle_timeout - loop do - sleep(duration.negative? ? idle_timeout : duration) - break if @mutex.synchronize do - raise Errno::EBUSY if _closed? - - duration = idle_timeout - (current_time - @last_accessed_time) - duration.negative? && _idle? && _close - end - end - close - rescue Errno::EBUSY - # do nothing - end - end - - private - - def _idle - super - - @last_accessed_time = current_time - end - - def current_time - Process.clock_gettime(Process::CLOCK_MONOTONIC) - end - end) - end - end.new + compiler = Compiler.allocate + compiler.instance_eval do + @channel = Compiler.const_get(:Channel).new(idle_timeout: 10) + end at_exit do compiler.close From fca69482165f8e12fa1ec1f7efd44f4d5e54cb51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 27 Feb 2025 13:38:57 -0800 Subject: [PATCH 650/700] Do not track last idle time on indefinitely persisted compiler --- lib/sass/compiler/dispatcher.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/sass/compiler/dispatcher.rb b/lib/sass/compiler/dispatcher.rb index 6ba985e7..bf353d6f 100644 --- a/lib/sass/compiler/dispatcher.rb +++ b/lib/sass/compiler/dispatcher.rb @@ -8,7 +8,6 @@ class Compiler class Dispatcher def initialize(idle_timeout: 0) @id = 1 - @last_accessed_time = current_time @observers = {}.compare_by_identity @mutex = Mutex.new @connection = Connection.new @@ -17,6 +16,7 @@ def initialize(idle_timeout: 0) return unless idle_timeout.positive? + @last_accessed_time = current_time Thread.new do Thread.current.name = "sass-embedded-connection-reaper-#{@connection.id}" duration = idle_timeout @@ -127,8 +127,9 @@ def _closed? end def _idle + @last_accessed_time = current_time if defined?(@last_accessed_time) + @id = 1 - @last_accessed_time = current_time end def _idle? From ca207bae4fd1d3793e94228c5adcaba0896eb032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 09:09:39 -0700 Subject: [PATCH 651/700] Run test on windows-2025 --- .github/workflows/build.yml | 6 +++--- .github/workflows/schedule.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bad03151..ae2473ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: - macos-latest - ubuntu-latest - ubuntu-24.04-arm - - windows-latest + - windows-2025 container: - vm: @@ -54,9 +54,9 @@ jobs: - truffleruby - truffleruby+graalvm exclude: - - os: windows-latest + - os: windows-2025 ruby-version: truffleruby - - os: windows-latest + - os: windows-2025 ruby-version: truffleruby+graalvm include: - os: ubuntu-latest diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index 59f91e40..eeac15d6 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -16,16 +16,16 @@ jobs: os: - macos-latest - ubuntu-latest - - windows-latest + - windows-2025 ruby-version: - ruby-head - jruby-head - truffleruby-head - truffleruby+graalvm-head exclude: - - os: windows-latest + - os: windows-2025 ruby-version: truffleruby-head - - os: windows-latest + - os: windows-2025 ruby-version: truffleruby+graalvm-head steps: From fd0f3cc36bdc52d7008f1104dead25605a8deda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 10:30:57 -0700 Subject: [PATCH 652/700] Remove netbsd and dragonflybsd from test matrix due to protobuf dropping old gcc --- .github/workflows/build.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae2473ea..50b306af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,16 +126,6 @@ jobs: run: | pkg_add node protobuf ruby%3.3 ruby-shims echo 3.3 | tee /etc/ruby-version - - os: ubuntu-latest - vm: - os: netbsd - run: | - /usr/sbin/pkg_add nodejs protobuf ruby - - os: ubuntu-latest - vm: - os: dragonflybsd - run: | - pkg install -y libnghttp2 libuv node npm protobuf ruby rubygem-bundler rubygem-rake - os: ubuntu-latest vm: os: omnios From 258c27d90c7fa48e8ca3e88fe5c421fa9e30efbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 10:51:51 -0700 Subject: [PATCH 653/700] Update google-protobuf requirement from ~> 4.29 to ~> 4.30 (#296) * Remove workaround for https://github.com/protocolbuffers/protobuf/issues/18807 --- lib/sass/compiler/host/protofier.rb | 1 - sass-embedded.gemspec | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 72ec4c3f..5759609a 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -112,7 +112,6 @@ def from_proto(proto) when :number Number.from_proto(obj) when :color - obj.to_s if RUBY_ENGINE == 'jruby' # TODO: https://github.com/protocolbuffers/protobuf/issues/18807 Sass::Value::Color.send( :for_space, obj.space, diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 9d4a5fd4..2cc64938 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_dependency 'google-protobuf', '~> 4.29' + spec.add_dependency 'google-protobuf', '~> 4.30' end From fd6d8be3921b1370984ab51541508fa871f56fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 11:36:45 -0700 Subject: [PATCH 654/700] Use instance_variable_get instead of instance_eval when possible --- lib/sass/compiler/host/function_registry.rb | 4 ++-- lib/sass/compiler/host/importer_registry.rb | 6 +++--- lib/sass/compiler/host/protofier.rb | 12 ++++++------ lib/sass/embedded.rb | 4 +--- lib/sass/value/function.rb | 2 -- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 75fbb7ee..29e2c119 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -57,8 +57,8 @@ def function_call(function_call_request) success = protofier.to_proto(function.call(arguments)) accessed_argument_lists = arguments.filter_map do |argument| - if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed } - argument.instance_eval { @id } + if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_variable_get(:@keywords_accessed) + argument.instance_variable_get(:@id) end end diff --git a/lib/sass/compiler/host/importer_registry.rb b/lib/sass/compiler/host/importer_registry.rb index c51986eb..472ea4c6 100644 --- a/lib/sass/compiler/host/importer_registry.rb +++ b/lib/sass/compiler/host/importer_registry.rb @@ -35,7 +35,7 @@ def register(importer) if importer.is_a?(Sass::NodePackageImporter) EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new( node_package_importer: EmbeddedProtocol::NodePackageImporter.new( - entry_point_directory: importer.instance_eval { @entry_point_directory } + entry_point_directory: importer.instance_variable_get(:@entry_point_directory) ) ) else @@ -76,7 +76,7 @@ def canonicalize(canonicalize_request) EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( id: canonicalize_request.id, url:, - containing_url_unused: canonicalize_context.instance_eval { @containing_url_unused } + containing_url_unused: canonicalize_context.instance_variable_get(:@containing_url_unused) ) rescue StandardError => e EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new( @@ -118,7 +118,7 @@ def file_import(file_import_request) EmbeddedProtocol::InboundMessage::FileImportResponse.new( id: file_import_request.id, file_url:, - containing_url_unused: canonicalize_context.instance_eval { @containing_url_unused } + containing_url_unused: canonicalize_context.instance_variable_get(:@containing_url_unused) ) rescue StandardError => e EmbeddedProtocol::InboundMessage::FileImportResponse.new( diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 5759609a..610e3f7e 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -37,7 +37,7 @@ def to_proto(obj) when Sass::Value::ArgumentList EmbeddedProtocol::Value.new( argument_list: EmbeddedProtocol::Value::ArgumentList.new( - id: obj.instance_eval { @id }, + id: obj.instance_variable_get(:@id), contents: obj.to_a.map { |element| to_proto(element) }, keywords: obj.keywords.each_with_object({}) { |(key, value), hash| hash[key.to_s] = to_proto(value) }, separator: ListSeparator.to_proto(obj.separator) @@ -63,10 +63,10 @@ def to_proto(obj) ) ) when Sass::Value::Function - if obj.instance_eval { @id } + if obj.instance_variable_defined?(:@id) EmbeddedProtocol::Value.new( compiler_function: EmbeddedProtocol::Value::CompilerFunction.new( - id: obj.instance_eval { @id } + id: obj.instance_variable_get(:@id) ) ) else @@ -80,7 +80,7 @@ def to_proto(obj) when Sass::Value::Mixin EmbeddedProtocol::Value.new( compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new( - id: obj.instance_eval { @id } + id: obj.instance_variable_get(:@id) ) ) when Sass::Value::Calculation @@ -148,14 +148,14 @@ def from_proto(proto) end ) when :compiler_function - Sass::Value::Function.new(nil).instance_eval do + Sass::Value::Function.allocate.instance_eval do @id = obj.id self end when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :compiler_mixin - Sass::Value::Mixin.send(:new).instance_eval do + Sass::Value::Mixin.allocate.instance_eval do @id = obj.id self end diff --git a/lib/sass/embedded.rb b/lib/sass/embedded.rb index 15cc4572..4ecd8a75 100644 --- a/lib/sass/embedded.rb +++ b/lib/sass/embedded.rb @@ -54,9 +54,7 @@ def compiler return @compiler if @compiler compiler = Compiler.allocate - compiler.instance_eval do - @channel = Compiler.const_get(:Channel).new(idle_timeout: 10) - end + compiler.instance_variable_set(:@channel, Compiler.const_get(:Channel).new(idle_timeout: 10)) at_exit do compiler.close diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 0e5e998a..eef91034 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -11,8 +11,6 @@ class Function # @param signature [::String] # @param callback [Proc] def initialize(signature, &callback) - raise Sass::ScriptError, 'no block given' unless signature.nil? || callback - @signature = signature.freeze @callback = callback.freeze end From c05a8f54a1eaddd70cd7d6278cf111c938a4e93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 15:44:41 -0700 Subject: [PATCH 655/700] Fix a typo --- lib/sass/value/number.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index a31f8c7a..364c4327 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -276,8 +276,8 @@ def coerce_or_convert_value(new_numerator_units, new_denominator_units, other: nil, other_name: nil) if other && (other.numerator_units != new_denominator_units && other.denominator_units != new_denominator_units) - raise Sass::ScriptError, "Expect #{other} to have units #{unit_string(new_numerator_units, - new_denominator_units).inspect}" + raise Sass::ScriptError, "Expected #{other} to have units #{unit_string(new_numerator_units, + new_denominator_units).inspect}" end return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units From f1ff432dd3193e6d86d7f16ae0df62b57edad2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 16:46:28 -0700 Subject: [PATCH 656/700] Fix comparing and disallow passing functions/mixins across compilations (#297) --- lib/sass/compiler/host/function_registry.rb | 3 +- lib/sass/compiler/host/protofier.rb | 31 +++++++++++++++------ lib/sass/value/function.rb | 9 ++++-- lib/sass/value/mixin.rb | 5 +++- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 29e2c119..9f8786a3 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -7,11 +7,12 @@ class Host # # It stores sass custom functions and handles function calls. class FunctionRegistry - attr_reader :global_functions + attr_reader :environment, :global_functions def initialize(functions, alert_color:) functions = functions.transform_keys(&:to_s) + @environment = BasicObject.new @global_functions = functions.keys @functions_by_name = functions.transform_keys do |signature| index = signature.index('(') diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 610e3f7e..04497fcc 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -64,6 +64,8 @@ def to_proto(obj) ) when Sass::Value::Function if obj.instance_variable_defined?(:@id) + assert_compiler_value(obj) + EmbeddedProtocol::Value.new( compiler_function: EmbeddedProtocol::Value::CompilerFunction.new( id: obj.instance_variable_get(:@id) @@ -78,6 +80,8 @@ def to_proto(obj) ) end when Sass::Value::Mixin + assert_compiler_value(obj) + EmbeddedProtocol::Value.new( compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new( id: obj.instance_variable_get(:@id) @@ -148,17 +152,11 @@ def from_proto(proto) end ) when :compiler_function - Sass::Value::Function.allocate.instance_eval do - @id = obj.id - self - end + compiler_value(Sass::Value::Function, obj.id) when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :compiler_mixin - Sass::Value::Mixin.allocate.instance_eval do - @id = obj.id - self - end + compiler_value(Sass::Value::Mixin, obj.id) when :calculation Calculation.from_proto(obj) when :singleton @@ -177,6 +175,23 @@ def from_proto(proto) end end + private + + def assert_compiler_value(value) + unless value.instance_variable_get(:@environment) == @function_registry.environment + raise Sass::ScriptError, "Returned #{value} does not belong to this compilation" + end + + value + end + + def compiler_value(klass, id) + value = klass.allocate + value.instance_variable_set(:@environment, @function_registry.environment) + value.instance_variable_set(:@id, id) + value + end + # The {Number} Protofier. module Number module_function diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index eef91034..82a10464 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -15,6 +15,9 @@ def initialize(signature, &callback) @callback = callback.freeze end + # @return [Object, nil] + protected attr_reader :environment + # @return [Integer, nil] protected attr_reader :id @@ -26,10 +29,10 @@ def initialize(signature, &callback) # @return [::Boolean] def ==(other) - if id.nil? - other.equal?(self) + if defined?(@id) + other.is_a?(Sass::Value::Function) && other.environment == environment && other.id == id else - other.is_a?(Sass::Value::Function) && other.id == id + other.equal?(self) end end diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index 2f65fdb3..469eb75c 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -12,12 +12,15 @@ class << self private :new end + # @return [Object] + protected attr_reader :environment + # @return [Integer] protected attr_reader :id # @return [::Boolean] def ==(other) - other.is_a?(Sass::Value::Mixin) && other.id == id + other.is_a?(Sass::Value::Mixin) && other.environment == environment && other.id == id end # @return [Integer] From 0378284e42b304409ef48ce7ef9c9e4dae48a77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 17:40:54 -0700 Subject: [PATCH 657/700] Fix passing argument lists across compilations (#298) --- lib/sass/compiler/host/protofier.rb | 52 ++++++++++++++++------------- lib/sass/value/argument_list.rb | 8 ----- spec/sass_proto_spec.rb | 12 ++----- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 04497fcc..2c8be7e0 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -35,14 +35,21 @@ def to_proto(obj) ) ) when Sass::Value::ArgumentList - EmbeddedProtocol::Value.new( - argument_list: EmbeddedProtocol::Value::ArgumentList.new( - id: obj.instance_variable_get(:@id), - contents: obj.to_a.map { |element| to_proto(element) }, - keywords: obj.keywords.each_with_object({}) { |(key, value), hash| hash[key.to_s] = to_proto(value) }, - separator: ListSeparator.to_proto(obj.separator) + if obj.instance_variable_get(:@environment) == @function_registry.environment + EmbeddedProtocol::Value.new( + argument_list: EmbeddedProtocol::Value::ArgumentList.new( + id: obj.instance_variable_get(:@id) + ) ) - ) + else + EmbeddedProtocol::Value.new( + argument_list: EmbeddedProtocol::Value::ArgumentList.new( + contents: obj.to_a.map { |element| to_proto(element) }, + keywords: obj.keywords.each_with_object({}) { |(key, value), hash| hash[key.to_s] = to_proto(value) }, + separator: ListSeparator.to_proto(obj.separator) + ) + ) + end when Sass::Value::List EmbeddedProtocol::Value.new( list: EmbeddedProtocol::Value::List.new( @@ -125,18 +132,18 @@ def from_proto(proto) obj.has_alpha? ? obj.alpha : nil ) when :argument_list - Sass::Value::ArgumentList.new( - obj.contents.map do |element| - from_proto(element) - end, - obj.keywords.to_enum.with_object({}) do |(key, value), hash| - hash[key.to_sym] = from_proto(value) - end, - ListSeparator.from_proto(obj.separator) - ).instance_eval do - @id = obj.id - self - end + compiler_value( + Sass::Value::ArgumentList.new( + obj.contents.map do |element| + from_proto(element) + end, + obj.keywords.to_enum.with_object({}) do |(key, value), hash| + hash[key.to_sym] = from_proto(value) + end, + ListSeparator.from_proto(obj.separator) + ), + obj.id + ) when :list Sass::Value::List.new( obj.contents.map do |element| @@ -152,11 +159,11 @@ def from_proto(proto) end ) when :compiler_function - compiler_value(Sass::Value::Function, obj.id) + compiler_value(Sass::Value::Function.allocate, obj.id) when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :compiler_mixin - compiler_value(Sass::Value::Mixin, obj.id) + compiler_value(Sass::Value::Mixin.allocate, obj.id) when :calculation Calculation.from_proto(obj) when :singleton @@ -185,8 +192,7 @@ def assert_compiler_value(value) value end - def compiler_value(klass, id) - value = klass.allocate + def compiler_value(value, id) value.instance_variable_set(:@environment, @function_registry.environment) value.instance_variable_set(:@id, id) value diff --git a/lib/sass/value/argument_list.rb b/lib/sass/value/argument_list.rb index 80550118..34d0f948 100644 --- a/lib/sass/value/argument_list.rb +++ b/lib/sass/value/argument_list.rb @@ -15,7 +15,6 @@ class ArgumentList < List def initialize(contents = [], keywords = {}, separator = ',') super(contents, separator:) - @id = 0 @keywords_accessed = false @keywords = keywords.freeze end @@ -25,13 +24,6 @@ def keywords @keywords_accessed = true @keywords end - - private - - def initialize_dup(orig) - @id = 0 - super - end end end end diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index a2c43e19..f582d9e1 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -4,14 +4,6 @@ RSpec.describe Sass do def remote_eq(lhs, rhs) - to_host_value = lambda { |value| - if value.is_a?(Sass::Value::ArgumentList) - value.dup - else - value - end - } - result = nil Sass.compile_string( '$_: yield(lhs()==rhs());', @@ -21,10 +13,10 @@ def remote_eq(lhs, rhs) Sass::Value::Null::NULL }, 'lhs()' => lambda { |*| - to_host_value.call lhs + lhs }, 'rhs()' => lambda { |*| - to_host_value.call rhs + rhs } } ) From da67d858e341e73ca122c9ea5604677a6c8844e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 10 Mar 2025 20:10:33 -0700 Subject: [PATCH 658/700] Update error message --- lib/sass/compiler/host/protofier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 2c8be7e0..c02bad9f 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -186,7 +186,7 @@ def from_proto(proto) def assert_compiler_value(value) unless value.instance_variable_get(:@environment) == @function_registry.environment - raise Sass::ScriptError, "Returned #{value} does not belong to this compilation" + raise Sass::ScriptError, "Value #{value} does not belong to this compilation" end value From 94d11cb7dda322a5f9b547ea29842591459387f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 11 Mar 2025 10:42:01 -0700 Subject: [PATCH 659/700] Include compilation in compiler funtions/mixins hash code --- lib/sass/compiler/host/function_registry.rb | 2 +- lib/sass/value/function.rb | 8 +++++--- lib/sass/value/mixin.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 9f8786a3..5c3e121b 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -12,7 +12,7 @@ class FunctionRegistry def initialize(functions, alert_color:) functions = functions.transform_keys(&:to_s) - @environment = BasicObject.new + @environment = Object.new @global_functions = functions.keys @functions_by_name = functions.transform_keys do |signature| index = signature.index('(') diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 82a10464..4bb08ec8 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -29,16 +29,18 @@ def initialize(signature, &callback) # @return [::Boolean] def ==(other) + return false unless other.is_a?(Sass::Value::Function) + if defined?(@id) - other.is_a?(Sass::Value::Function) && other.environment == environment && other.id == id + other.environment == environment && other.id == id else - other.equal?(self) + other.signature == signature && other.callback == callback end end # @return [Integer] def hash - @hash ||= id.nil? ? signature.hash : id.hash + @hash ||= defined?(@id) ? [environment, id].hash : [signature, callback].hash end # @return [Function] diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index 469eb75c..8a1c4c12 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -25,7 +25,7 @@ def ==(other) # @return [Integer] def hash - @hash ||= id.hash + @hash ||= [environment, id].hash end # @return [Mixin] From 00475df26edba0b662255b563c161ac532a4560e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 11 Mar 2025 11:01:49 -0700 Subject: [PATCH 660/700] Inline assertions for compiler value --- lib/sass/compiler/host/protofier.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index c02bad9f..08198b42 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -71,11 +71,9 @@ def to_proto(obj) ) when Sass::Value::Function if obj.instance_variable_defined?(:@id) - assert_compiler_value(obj) - EmbeddedProtocol::Value.new( compiler_function: EmbeddedProtocol::Value::CompilerFunction.new( - id: obj.instance_variable_get(:@id) + id: assert_compiler_value(obj).instance_variable_get(:@id) ) ) else @@ -87,11 +85,9 @@ def to_proto(obj) ) end when Sass::Value::Mixin - assert_compiler_value(obj) - EmbeddedProtocol::Value.new( compiler_mixin: EmbeddedProtocol::Value::CompilerMixin.new( - id: obj.instance_variable_get(:@id) + id: assert_compiler_value(obj).instance_variable_get(:@id) ) ) when Sass::Value::Calculation From 3de9b9c5f17558d0f5d5b5611035e3161523b7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 11 Mar 2025 11:37:04 -0700 Subject: [PATCH 661/700] Use setup-java action for jruby tests --- .github/workflows/build.yml | 13 ++++++++++--- .github/workflows/schedule.yml | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50b306af..b17063c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: - macos-latest - ubuntu-latest - ubuntu-24.04-arm - - windows-2025 + - windows-latest container: - vm: @@ -54,9 +54,9 @@ jobs: - truffleruby - truffleruby+graalvm exclude: - - os: windows-2025 + - os: windows-latest ruby-version: truffleruby - - os: windows-2025 + - os: windows-latest ruby-version: truffleruby+graalvm include: - os: ubuntu-latest @@ -156,6 +156,13 @@ jobs: if: endsWith(matrix.container.image, ':alpine') || endsWith(matrix.container.image, '-alpine') run: apk add build-base + - name: Setup java + if: matrix.ruby-version == 'jruby' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - name: Setup ruby if: matrix.ruby-version uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index eeac15d6..7067409a 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -16,22 +16,29 @@ jobs: os: - macos-latest - ubuntu-latest - - windows-2025 + - windows-latest ruby-version: - ruby-head - jruby-head - truffleruby-head - truffleruby+graalvm-head exclude: - - os: windows-2025 + - os: windows-latest ruby-version: truffleruby-head - - os: windows-2025 + - os: windows-latest ruby-version: truffleruby+graalvm-head steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup java + if: matrix.ruby-version == 'jruby-head' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - name: Setup ruby uses: ruby/setup-ruby@v1 with: From 1d79d13a2883b5312cf5915cbcf4112eb8e689a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 11 Mar 2025 16:17:27 -0700 Subject: [PATCH 662/700] Rename an internal variable --- lib/sass/compiler/host/function_registry.rb | 4 ++-- lib/sass/compiler/host/protofier.rb | 6 +++--- lib/sass/value/function.rb | 6 +++--- lib/sass/value/mixin.rb | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 5c3e121b..545444af 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -7,12 +7,12 @@ class Host # # It stores sass custom functions and handles function calls. class FunctionRegistry - attr_reader :environment, :global_functions + attr_reader :compile_context, :global_functions def initialize(functions, alert_color:) functions = functions.transform_keys(&:to_s) - @environment = Object.new + @compile_context = Object.new @global_functions = functions.keys @functions_by_name = functions.transform_keys do |signature| index = signature.index('(') diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 08198b42..3ab65190 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -35,7 +35,7 @@ def to_proto(obj) ) ) when Sass::Value::ArgumentList - if obj.instance_variable_get(:@environment) == @function_registry.environment + if obj.instance_variable_get(:@compile_context) == @function_registry.compile_context EmbeddedProtocol::Value.new( argument_list: EmbeddedProtocol::Value::ArgumentList.new( id: obj.instance_variable_get(:@id) @@ -181,7 +181,7 @@ def from_proto(proto) private def assert_compiler_value(value) - unless value.instance_variable_get(:@environment) == @function_registry.environment + unless value.instance_variable_get(:@compile_context) == @function_registry.compile_context raise Sass::ScriptError, "Value #{value} does not belong to this compilation" end @@ -189,7 +189,7 @@ def assert_compiler_value(value) end def compiler_value(value, id) - value.instance_variable_set(:@environment, @function_registry.environment) + value.instance_variable_set(:@compile_context, @function_registry.compile_context) value.instance_variable_set(:@id, id) value end diff --git a/lib/sass/value/function.rb b/lib/sass/value/function.rb index 4bb08ec8..7e926d49 100644 --- a/lib/sass/value/function.rb +++ b/lib/sass/value/function.rb @@ -16,7 +16,7 @@ def initialize(signature, &callback) end # @return [Object, nil] - protected attr_reader :environment + protected attr_reader :compile_context # @return [Integer, nil] protected attr_reader :id @@ -32,7 +32,7 @@ def ==(other) return false unless other.is_a?(Sass::Value::Function) if defined?(@id) - other.environment == environment && other.id == id + other.compile_context == compile_context && other.id == id else other.signature == signature && other.callback == callback end @@ -40,7 +40,7 @@ def ==(other) # @return [Integer] def hash - @hash ||= defined?(@id) ? [environment, id].hash : [signature, callback].hash + @hash ||= defined?(@id) ? [compile_context, id].hash : [signature, callback].hash end # @return [Function] diff --git a/lib/sass/value/mixin.rb b/lib/sass/value/mixin.rb index 8a1c4c12..13b72ff7 100644 --- a/lib/sass/value/mixin.rb +++ b/lib/sass/value/mixin.rb @@ -13,19 +13,19 @@ class << self end # @return [Object] - protected attr_reader :environment + protected attr_reader :compile_context # @return [Integer] protected attr_reader :id # @return [::Boolean] def ==(other) - other.is_a?(Sass::Value::Mixin) && other.environment == environment && other.id == id + other.is_a?(Sass::Value::Mixin) && other.compile_context == compile_context && other.id == id end # @return [Integer] def hash - @hash ||= [environment, id].hash + @hash ||= [compile_context, id].hash end # @return [Mixin] From d2173a131b7405aea4eaaf064a6c34e499b24701 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Mar 2025 08:47:22 -0700 Subject: [PATCH 663/700] Update rubocop requirement from ~> 1.73.0 to ~> 1.74.0 (#299) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.73.0...v1.74.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a86b17cf..c7c634e9 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.73.0' + gem 'rubocop', '~> 1.74.0' gem 'rubocop-performance', '~> 1.24.0' gem 'rubocop-rake', '~> 0.7.1' gem 'rubocop-rspec', '~> 3.5.0' From 3a365dacc4bb1511bfe028b621df1ba214682965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 13 Mar 2025 10:08:01 -0700 Subject: [PATCH 664/700] Optimize FuncitonRegistry --- lib/sass/compiler/host/function_registry.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/sass/compiler/host/function_registry.rb b/lib/sass/compiler/host/function_registry.rb index 545444af..108451ac 100644 --- a/lib/sass/compiler/host/function_registry.rb +++ b/lib/sass/compiler/host/function_registry.rb @@ -10,11 +10,10 @@ class FunctionRegistry attr_reader :compile_context, :global_functions def initialize(functions, alert_color:) - functions = functions.transform_keys(&:to_s) - @compile_context = Object.new - @global_functions = functions.keys + @global_functions = functions.keys.map!(&:to_s) @functions_by_name = functions.transform_keys do |signature| + signature = signature.to_s index = signature.index('(') if index signature.slice(0, index) From b7dfb5e52934d78e5a994d1b3bcd13b4a1611a65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:03:00 -0700 Subject: [PATCH 665/700] Bump sass from 1.85.1 to 1.86.0 in /ext/sass (#300) Bumps [sass](https://github.com/sass/dart-sass) from 1.85.1 to 1.86.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.85.1...1.86.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 54449d27..f90bf25a 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.85.1" + "sass": "1.86.0" } } From ec39abbcc1842590c6ae2700186b04bc8dcb6eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 17 Mar 2025 16:14:37 -0700 Subject: [PATCH 666/700] v1.86.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index e36bc3c6..29361b38 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.85.1' + VERSION = '1.86.0' end end From 40abebbf263aa06f419a36326e0da4e6ac59c0a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Mar 2025 09:17:08 -0700 Subject: [PATCH 667/700] Update rubocop requirement from ~> 1.74.0 to ~> 1.75.0 (#301) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update rubocop requirement from ~> 1.74.0 to ~> 1.75.0 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.74.0...v1.75.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] * Fix coerce_or_convert_value --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: なつき --- Gemfile | 2 +- lib/sass/value/number.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index c7c634e9..d6d086df 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' - gem 'rubocop', '~> 1.74.0' + gem 'rubocop', '~> 1.75.0' gem 'rubocop-performance', '~> 1.24.0' gem 'rubocop-rake', '~> 0.7.1' gem 'rubocop-rspec', '~> 3.5.0' diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index 364c4327..414e74a0 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -275,17 +275,15 @@ def coerce_or_convert_value(new_numerator_units, new_denominator_units, name: nil, other: nil, other_name: nil) - if other && (other.numerator_units != new_denominator_units && other.denominator_units != new_denominator_units) - raise Sass::ScriptError, "Expected #{other} to have units #{unit_string(new_numerator_units, - new_denominator_units).inspect}" + unless other.nil? || + (other.numerator_units == new_numerator_units && other.denominator_units == new_denominator_units) + raise Sass::ScriptError, + "Expected #{other} to have units #{unit_string(new_numerator_units, new_denominator_units).inspect}" end return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units - return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units - other_unitless = new_numerator_units.empty? && new_denominator_units.empty? - return value if coerce_unitless && (unitless? || other_unitless) compatibility_error = lambda { From e2cd1707a0e742e24e3681bd4ffe56c3eeb4763d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:27:35 -0700 Subject: [PATCH 668/700] Bump sass from 1.86.0 to 1.86.1 in /ext/sass (#302) Bumps [sass](https://github.com/sass/dart-sass) from 1.86.0 to 1.86.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.86.0...1.86.1) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index f90bf25a..740ab683 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.86.0" + "sass": "1.86.1" } } From e9cd0bb4ca6e6db330c4c2a1262359bcf1808ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 31 Mar 2025 15:04:45 -0700 Subject: [PATCH 669/700] Verify artifact attestations for dart-sass --- .github/workflows/build.yml | 2 ++ .github/workflows/release.yml | 2 ++ ext/sass/Rakefile | 3 +++ 3 files changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b17063c5..4f503386 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -179,6 +179,8 @@ jobs: - name: Compile run: bundle exec rake compile + env: + GH_TOKEN: ${{ github.token }} - name: Spec if: "!matrix.vm || contains(matrix.vm.run, 'linux_base') || contains(matrix.vm.run, '/proc')" # TODO: remove after https://github.com/sass/dart-sass/pull/2413 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 661baffc..e5d4ea40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,6 +68,8 @@ jobs: - name: Compile run: bundle exec rake compile ext_platform=${{ matrix.platform }} + env: + GH_TOKEN: ${{ github.token }} - name: Build run: rake -f -r bundler/gem_tasks build gem_platform=${{ matrix.platform }} diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index e2457832..a0d13317 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -50,6 +50,9 @@ file 'dart-sass/sass' do end rescue StandardError archive = fetch(SassConfig.dart_sass) + if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', 'github.com', %i[out err] => File::NULL) + sh 'gh', 'attestation', 'verify', archive, '--hostname', 'github.com', '--repo', 'sass/dart-sass' + end unarchive archive rm archive end From f3fa5a1c13eb50db6e760df4470d9f7e12901d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 31 Mar 2025 15:54:20 -0700 Subject: [PATCH 670/700] Improve Linuxulator detection --- ext/sass/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index a0d13317..52cb56a0 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -445,10 +445,10 @@ module Platform begin Rake::Task['true'].invoke unless File.exist?('true') rescue NotImplementedError - # do nothing + return false end - system('./true') == true + system('./true', %i[out err] => File::NULL) == true end def host_os(root = compat_linux_emul_path) From 8e19eaa90f555d8e842b03abf285e6c3d4a2eb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 31 Mar 2025 16:02:51 -0700 Subject: [PATCH 671/700] v1.86.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 29361b38..3bdeab43 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.86.0' + VERSION = '1.86.1' end end From 54720b213f8797fdbf2537469db61d599e66e058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 31 Mar 2025 16:42:14 -0700 Subject: [PATCH 672/700] Verify artifact attestations for sass-embedded prebuilt gems --- ext/sass/Rakefile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 52cb56a0..42c0f6bf 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -45,14 +45,13 @@ rescue NotImplementedError end file 'dart-sass/sass' do - gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir| - mv File.absolute_path('ext/sass/dart-sass', dir), 'dart-sass' + gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |installer| + gh_attestation_verify(installer.gem, 'sass-contrib/sass-embedded-host-ruby') + mv File.absolute_path('ext/sass/dart-sass', installer.gem_dir), 'dart-sass' end rescue StandardError archive = fetch(SassConfig.dart_sass) - if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', 'github.com', %i[out err] => File::NULL) - sh 'gh', 'attestation', 'verify', archive, '--hostname', 'github.com', '--repo', 'sass/dart-sass' - end + gh_attestation_verify(archive, 'sass/dart-sass') unarchive archive rm archive end @@ -424,10 +423,16 @@ module FileUtils installer.install end - yield installer.dir + yield installer ensure rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag end + + def gh_attestation_verify(path, repo) + if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', 'github.com', %i[out err] => File::NULL) + sh 'gh', 'attestation', 'verify', path, '--hostname', 'github.com', '--repo', repo + end + end end # The {Platform} module. From 5baa508b250dabd59ea64d50fc73a4bd520cc657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 1 Apr 2025 00:02:46 -0700 Subject: [PATCH 673/700] Update Rakefile --- ext/sass/Rakefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 42c0f6bf..3a558a91 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -46,12 +46,12 @@ end file 'dart-sass/sass' do gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |installer| - gh_attestation_verify(installer.gem, 'sass-contrib/sass-embedded-host-ruby') + gh_attestation_verify(installer.gem, repo: 'sass-contrib/sass-embedded-host-ruby') mv File.absolute_path('ext/sass/dart-sass', installer.gem_dir), 'dart-sass' end rescue StandardError archive = fetch(SassConfig.dart_sass) - gh_attestation_verify(archive, 'sass/dart-sass') + gh_attestation_verify(archive, repo: 'sass/dart-sass') unarchive archive rm archive end @@ -428,9 +428,9 @@ module FileUtils rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag end - def gh_attestation_verify(path, repo) - if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', 'github.com', %i[out err] => File::NULL) - sh 'gh', 'attestation', 'verify', path, '--hostname', 'github.com', '--repo', repo + def gh_attestation_verify(path, repo:, hostname: 'github.com') + if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', hostname, %i[out err] => File::NULL) + sh 'gh', 'attestation', 'verify', path, '--hostname', hostname, '--repo', repo end end end From 76174917a5014d992bbb6dda2075f5410093f555 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 09:07:14 -0700 Subject: [PATCH 674/700] Update rubocop-performance requirement from ~> 1.24.0 to ~> 1.25.0 (#303) Updates the requirements on [rubocop-performance](https://github.com/rubocop/rubocop-performance) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-performance/releases) - [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.24.0...v1.25.0) --- updated-dependencies: - dependency-name: rubocop-performance dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d6d086df..156352ce 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ group :development do gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.75.0' - gem 'rubocop-performance', '~> 1.24.0' + gem 'rubocop-performance', '~> 1.25.0' gem 'rubocop-rake', '~> 0.7.1' gem 'rubocop-rspec', '~> 3.5.0' end From 2955ae5683415d969fa66f02a5d2ec724c98067e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 2 Apr 2025 09:28:14 -0700 Subject: [PATCH 675/700] Update schedule.yml --- .github/workflows/schedule.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index 7067409a..7bf1aa84 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -47,6 +47,8 @@ jobs: - name: Compile run: bundle exec rake compile + env: + GH_TOKEN: ${{ github.token }} - name: Spec run: bundle exec rake spec From 71e9f3a4709079b081ff710d94f59a9892973f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 2 Apr 2025 10:33:18 -0700 Subject: [PATCH 676/700] Explictly check if ENV['GITHUB_ACTIONS'] is true --- Rakefile | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index d8782f9b..08dcbf48 100644 --- a/Rakefile +++ b/Rakefile @@ -25,5 +25,5 @@ RSpec::Core::RakeTask.new RuboCop::RakeTask.new do |task| task.formatters = ['progress'] - task.formatters << 'github' if ENV.key?('GITHUB_ACTIONS') + task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2adf0d58..18358a18 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ require_relative 'sandbox' RSpec.configure do |config| - config.color_mode = :on if ENV.key?('GITHUB_ACTIONS') + config.color_mode = :on if ENV['GITHUB_ACTIONS'] == 'true' config.formatter = :documentation config.include Console From 76b89807590fc0cf72b63442b737c0663271f3fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 17:03:55 -0700 Subject: [PATCH 677/700] Bump sass from 1.86.1 to 1.86.2 in /ext/sass (#304) Bumps [sass](https://github.com/sass/dart-sass) from 1.86.1 to 1.86.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.86.1...1.86.2) --- updated-dependencies: - dependency-name: sass dependency-version: 1.86.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 740ab683..10dac9d7 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.86.1" + "sass": "1.86.2" } } From 2320513d54ec106d6003bde0d0ec9c122d464349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 2 Apr 2025 17:12:42 -0700 Subject: [PATCH 678/700] v1.86.2 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 3bdeab43..e0e30f8c 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.86.1' + VERSION = '1.86.2' end end From 41eb2f2f9c8cc340f28972106668fc8b4d899515 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Apr 2025 17:42:06 -0700 Subject: [PATCH 679/700] Bump sass from 1.86.2 to 1.86.3 in /ext/sass (#306) Bumps [sass](https://github.com/sass/dart-sass) from 1.86.2 to 1.86.3. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.86.2...1.86.3) --- updated-dependencies: - dependency-name: sass dependency-version: 1.86.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 10dac9d7..abadfd5e 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.86.2" + "sass": "1.86.3" } } From 3aeb619c59e1672d9d83f6cb660aaa6b399b57b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 3 Apr 2025 17:43:55 -0700 Subject: [PATCH 680/700] v1.86.3 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index e0e30f8c..d2136b2d 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.86.2' + VERSION = '1.86.3' end end From f5d04333169fb04a8ca831084fc2b3020653c516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 14 Apr 2025 11:08:16 -0700 Subject: [PATCH 681/700] Improve handling of null terminated ELF segment --- lib/sass/elf.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/sass/elf.rb b/lib/sass/elf.rb index 9e46bcdc..1305caa0 100644 --- a/lib/sass/elf.rb +++ b/lib/sass/elf.rb @@ -363,10 +363,7 @@ def interpreter return if phdr.nil? @io.seek(phdr[:p_offset], IO::SEEK_SET) - interpreter = @io.read(phdr[:p_filesz]) - raise EncodingError unless interpreter.end_with?("\0") - - interpreter.chomp!("\0") + @io.read(phdr[:p_filesz]).unpack1('Z*') end INTERPRETER = begin From 7feba94ec1cedc6248a092fe370a9a54cac6c960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 18 Apr 2025 07:59:16 -0700 Subject: [PATCH 682/700] Test jruby-10 --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f503386..86329ecb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,8 @@ jobs: - '3.2' - '3.3' - '3.4' - - jruby + - jruby-9 + - jruby-10 - truffleruby - truffleruby+graalvm exclude: @@ -157,7 +158,7 @@ jobs: run: apk add build-base - name: Setup java - if: matrix.ruby-version == 'jruby' + if: matrix.ruby-version == 'jruby' || startsWith(matrix.ruby-version, 'jruby-') uses: actions/setup-java@v4 with: distribution: temurin From 1ff22688e20a1a39e9a021c3d3c4e699a367a04f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 10:28:46 -0700 Subject: [PATCH 683/700] Update rubocop-rspec requirement from ~> 3.5.0 to ~> 3.6.0 (#307) Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.5.0...v3.6.0) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-version: 3.6.0 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 156352ce..8b872581 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,5 @@ group :development do gem 'rubocop', '~> 1.75.0' gem 'rubocop-performance', '~> 1.25.0' gem 'rubocop-rake', '~> 0.7.1' - gem 'rubocop-rspec', '~> 3.5.0' + gem 'rubocop-rspec', '~> 3.6.0' end From 1cddccf506b85ad3f936c66de60a764b19a4d9ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 16:49:48 -0700 Subject: [PATCH 684/700] Bump sass from 1.86.3 to 1.87.0 in /ext/sass (#308) Bumps [sass](https://github.com/sass/dart-sass) from 1.86.3 to 1.87.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.86.3...1.87.0) --- updated-dependencies: - dependency-name: sass dependency-version: 1.87.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index abadfd5e..84bb108d 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.86.3" + "sass": "1.87.0" } } From 8642a368ae57f1032595a42f340381b5c8850b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Mon, 21 Apr 2025 16:50:32 -0700 Subject: [PATCH 685/700] v1.87.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index d2136b2d..5415bb21 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.86.3' + VERSION = '1.87.0' end end From 99c7d9f2afadefa66490982a0618098a51ea0c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 24 Apr 2025 10:41:59 -0700 Subject: [PATCH 686/700] Fix lint --- lib/sass/value/number.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sass/value/number.rb b/lib/sass/value/number.rb index 414e74a0..4d1d1349 100644 --- a/lib/sass/value/number.rb +++ b/lib/sass/value/number.rb @@ -88,12 +88,12 @@ def ==(other) end FuzzyMath.equals( - (value * + value * Unit.canonical_multiplier(numerator_units) / - Unit.canonical_multiplier(denominator_units)), - (other.value * + Unit.canonical_multiplier(denominator_units), + other.value * Unit.canonical_multiplier(other.numerator_units) / - Unit.canonical_multiplier(other.denominator_units)) + Unit.canonical_multiplier(other.denominator_units) ) end From d3d996c97b32ada825df1f44cde4add131f1ce9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 26 Apr 2025 09:56:30 -0700 Subject: [PATCH 687/700] Test on windows-11-arm --- .github/workflows/build.yml | 15 +++++++++++++++ .github/workflows/schedule.yml | 8 ++++++++ ext/sass/Rakefile | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86329ecb..32f72b64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,7 @@ jobs: - ubuntu-latest - ubuntu-24.04-arm - windows-latest + - windows-11-arm container: - vm: @@ -59,6 +60,20 @@ jobs: ruby-version: truffleruby - os: windows-latest ruby-version: truffleruby+graalvm + - os: windows-11-arm + ruby-version: '3.1' + - os: windows-11-arm + ruby-version: '3.2' + - os: windows-11-arm + ruby-version: '3.3' + - os: windows-11-arm + ruby-version: jruby-9 + - os: windows-11-arm + ruby-version: jruby-10 + - os: windows-11-arm + ruby-version: truffleruby + - os: windows-11-arm + ruby-version: truffleruby+graalvm include: - os: ubuntu-latest container: diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index 7bf1aa84..cad7bc08 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -16,7 +16,9 @@ jobs: os: - macos-latest - ubuntu-latest + - ubuntu-24.04-arm - windows-latest + - windows-11-arm ruby-version: - ruby-head - jruby-head @@ -27,6 +29,12 @@ jobs: ruby-version: truffleruby-head - os: windows-latest ruby-version: truffleruby+graalvm-head + - os: windows-11-arm + ruby-version: jruby-head + - os: windows-11-arm + ruby-version: truffleruby-head + - os: windows-11-arm + ruby-version: truffleruby+graalvm-head steps: - name: Checkout diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index 3a558a91..a8a9a88f 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -656,7 +656,7 @@ module SassConfig when 'x86_64' 'x86_64' when 'aarch64' - 'aarch_64' + Platform::OS == 'windows' ? 'x86_64' : 'aarch_64' when 'ppc64le' 'ppcle_64' when 's390x' From b10d42ee33c12bf7ffe262de1d2616e487942e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 4 May 2025 00:51:13 -0700 Subject: [PATCH 688/700] Update LICENSE --- LICENSE | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index d3857dcb..acbabf45 100644 --- a/LICENSE +++ b/LICENSE @@ -1,20 +1,21 @@ -Copyright (c) 2022, なつき +MIT License -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Copyright (c) 2025 なつき -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 419d792c2dace3236451e1236e32e543b98c1824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 4 May 2025 23:45:52 -0700 Subject: [PATCH 689/700] Update release.yml --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5d4ea40..71bc58f4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -109,9 +109,10 @@ jobs: uses: actions/download-artifact@v4 with: pattern: pkg-* + merge-multiple: true - name: Configure trusted publishing credentials uses: rubygems/configure-rubygems-credentials@v1.0.0 - name: Release - run: find . -name '*.gem' -print0 | sort -rz -t / -k 3 | xargs -0 -n 1 -- gem push + run: find . -name '*.gem' -print0 | sort -rz | xargs -0 -n 1 -- gem push From 988d9c7b6d8dd9402d367d45cdfae4b74bd8e9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sun, 4 May 2025 23:47:30 -0700 Subject: [PATCH 690/700] Fix lint --- lib/sass/value/color.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 75f06d04..67fde903 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -51,11 +51,11 @@ class Color def initialize(**options) unless options.key?(:space) options[:space] = case options - in {red: _, green: _, blue: _} + in { red: _, green: _, blue: _ } 'rgb' - in {hue: _, saturation: _, lightness: _} + in { hue: _, saturation: _, lightness: _ } 'hsl' - in {hue: _, whiteness: _, blackness: _} + in { hue: _, whiteness: _, blackness: _ } 'hwb' else raise Sass::ScriptError.new('No color space found', 'space') @@ -207,17 +207,17 @@ def change(**options) if legacy? && !space_set_explictly case options - in {whiteness: _} | {blackness: _} + in { whiteness: _ } | { blackness: _ } space = Space::HWB - in {saturation: _} | {lightness: _} + in { saturation: _ } | { lightness: _ } space = Space::HSL - in {hue: _} + in { hue: _ } space = if _space == Space::HWB Space::HWB else Space::HSL end - in {red: _} | {blue: _} | {green: _} + in { red: _ } | { blue: _ } | { green: _ } space = Space::RGB else end From 4ffb67c3b1153a03a2524ae3908368cac2009c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 8 May 2025 16:08:13 -0700 Subject: [PATCH 691/700] Add specs from https://github.com/sass/sass-spec/pull/2053 --- spec/sass/value/function_spec.rb | 35 +++++++++++++++++++++++++ spec/sass/value/mixin_spec.rb | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/spec/sass/value/function_spec.rb b/spec/sass/value/function_spec.rb index 79e1bb70..41391a98 100644 --- a/spec/sass/value/function_spec.rb +++ b/spec/sass/value/function_spec.rb @@ -100,4 +100,39 @@ end end end + + it 'rejects a compiler function from a different compilation' do + plus_one = nil + Sass.compile_string( + " + @use 'sass:meta'; + + @function plusOne($n) {@return $n + 1} + a {b: meta.call(foo(meta.get-function('plusOne')), 2)} + ", + functions: { + 'foo($arg)': ->(args) { plus_one = args[0] } + } + ) + + plus_two = nil + expect do + Sass.compile_string( + " + @use 'sass:meta'; + + @function plusTwo($n) {@return $n + 2} + a {b: meta.call(foo(meta.get-function('plusTwo')), 2)} + ", + functions: { + 'foo($arg)': lambda { |args| + plus_two = args[0] + plus_one + } + } + ) + end.to raise_sass_compile_error.with_line(4) + + expect(plus_one).not_to eq(plus_two) + end end diff --git a/spec/sass/value/mixin_spec.rb b/spec/sass/value/mixin_spec.rb index 5c3fa66a..d531a63e 100644 --- a/spec/sass/value/mixin_spec.rb +++ b/spec/sass/value/mixin_spec.rb @@ -45,4 +45,49 @@ expect(fn).to have_received(:call) end + + it 'rejects a compiler mixin from a different compilation' do + a = nil + Sass.compile_string( + " + @use 'sass:meta'; + + @mixin a() { + a { + b: c; + } + } + + @include meta.apply(foo(meta.get-mixin('a'))); + ", + functions: { + 'foo($arg)': ->(args) { a = args[0] } + } + ) + + b = nil + expect do + Sass.compile_string( + " + @use 'sass:meta'; + + @mixin b() { + c { + d: e; + } + } + + @include meta.apply(foo(meta.get-mixin('b'))); + ", + functions: { + 'foo($arg)': lambda { |args| + b = args[0] + a + } + } + ) + end.to raise_sass_compile_error.with_line(9) + + expect(a).not_to eq(b) + end end From c26e87a0a48728e9d1c0e21b116b5f7d222d3acf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 10 May 2025 16:19:16 -0700 Subject: [PATCH 692/700] Bump sass from 1.87.0 to 1.88.0 in /ext/sass (#310) Bumps [sass](https://github.com/sass/dart-sass) from 1.87.0 to 1.88.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.87.0...1.88.0) --- updated-dependencies: - dependency-name: sass dependency-version: 1.88.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 84bb108d..7e03ecee 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.87.0" + "sass": "1.88.0" } } From 9c2f05851539265ca4c6903a0aacd294c32cdb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 10 May 2025 16:20:51 -0700 Subject: [PATCH 693/700] v1.88.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 5415bb21..3e6ad821 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.87.0' + VERSION = '1.88.0' end end From 108b31c12a016aa32f8da53ffc51340e7a49022c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 14 May 2025 12:27:52 -0700 Subject: [PATCH 694/700] Remove google-protobuf workaround for musl --- Gemfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile b/Gemfile index 8b872581..03b7a807 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,6 @@ source 'https://rubygems.org' gemspec group :development do - # TODO: https://github.com/protocolbuffers/protobuf/issues/16853 - gem 'google-protobuf', force_ruby_platform: true if RUBY_PLATFORM.include?('linux-musl') - gem 'rake', '>= 13' gem 'rspec', '~> 3.13.0' gem 'rubocop', '~> 1.75.0' From c36d9c0461e241bfa9496c608f158bd99cf58c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 15 May 2025 17:46:25 -0700 Subject: [PATCH 695/700] Update google-protobuf requirement from ~> 4.30 to ~> 4.31 --- sass-embedded.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sass-embedded.gemspec b/sass-embedded.gemspec index 2cc64938..57674789 100644 --- a/sass-embedded.gemspec +++ b/sass-embedded.gemspec @@ -42,5 +42,5 @@ Gem::Specification.new do |spec| '>= 3.2' end - spec.add_dependency 'google-protobuf', '~> 4.30' + spec.add_dependency 'google-protobuf', '~> 4.31' end From f9fc38849c9d8cd787dd183d69b52bb244b00ff0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 18:28:35 -0700 Subject: [PATCH 696/700] Bump sass from 1.88.0 to 1.89.0 in /ext/sass (#311) Bumps [sass](https://github.com/sass/dart-sass) from 1.88.0 to 1.89.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.88.0...1.89.0) --- updated-dependencies: - dependency-name: sass dependency-version: 1.89.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index 7e03ecee..c8a215c7 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.88.0" + "sass": "1.89.0" } } From 9e8808595d912549056907aa0e38b722ff25583f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 15 May 2025 18:29:10 -0700 Subject: [PATCH 697/700] v1.89.0 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 3e6ad821..832f3c58 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.88.0' + VERSION = '1.89.0' end end From dec8e544e10e78dfc5aada893ee77a429fcc73b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 21 May 2025 16:34:19 -0700 Subject: [PATCH 698/700] Drop ia32 --- ext/sass/Rakefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/sass/Rakefile b/ext/sass/Rakefile index a8a9a88f..c1901b5b 100644 --- a/ext/sass/Rakefile +++ b/ext/sass/Rakefile @@ -607,8 +607,6 @@ module SassConfig end cpu = case Platform::CPU - when 'i386' - 'ia32' when 'x86_64' 'x64' when 'aarch64' From 92f771d7404c717d7237052db45586b945a254c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 17:22:12 -0700 Subject: [PATCH 699/700] Bump sass from 1.89.0 to 1.89.1 in /ext/sass (#312) Bumps [sass](https://github.com/sass/dart-sass) from 1.89.0 to 1.89.1. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.89.0...1.89.1) --- updated-dependencies: - dependency-name: sass dependency-version: 1.89.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ext/sass/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/sass/package.json b/ext/sass/package.json index c8a215c7..0e967d6f 100644 --- a/ext/sass/package.json +++ b/ext/sass/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "sass": "1.89.0" + "sass": "1.89.1" } } From e231a76b5316bc6c430c6db4dae4436f62d8f9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 30 May 2025 17:22:38 -0700 Subject: [PATCH 700/700] v1.89.1 --- lib/sass/embedded/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sass/embedded/version.rb b/lib/sass/embedded/version.rb index 832f3c58..f0243965 100644 --- a/lib/sass/embedded/version.rb +++ b/lib/sass/embedded/version.rb @@ -2,6 +2,6 @@ module Sass module Embedded - VERSION = '1.89.0' + VERSION = '1.89.1' end end