sass-embedded 1.69.6 → 1.69.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f5aca7429ea164cf789851aadd9cf704c044e32a47283ad5a6f0ad39e535f7c
4
- data.tar.gz: 8f0b68119c27970e5013d147e12ee9fecebc7e28b169e1d6be5cb170cc17d901
3
+ metadata.gz: 5ddf58c29aaacc85fb79d2f70cccf60ef11566a7dd961ce4d1b6753580e63be7
4
+ data.tar.gz: 3f94c4fc1435af31542aba4af84997a0e3628372ead2fe0e61a5eafd35270d76
5
5
  SHA512:
6
- metadata.gz: 2f95ca5d66e45a2f8928465824de7fb9c5830c84fcab7b00a2c0fb520e9c0cd8cb1c2112c24b08f0f978e0e4c9d88206fcab209a97e3875a948fb034da4ac006
7
- data.tar.gz: dd63a5e0eec736eef021087120a5d03a8b60c17189380d466c7467fc989859a173c57480d4490dfb6d8fc82e61dd08bcc7703adf098a846f81e79f7742fec11b
6
+ metadata.gz: 91a8794f30f711b9e5f3c23e93aeff8e2849c194f1774a3125c69d06f71b5e0a195a8b8114701ee27089b7bd5b6ecd922aaaabcc3886577aab0e0c2668c2ddac
7
+ data.tar.gz: b51d8a8acd12db57a88293a9f8a4b6c0efebc8591e167ae7e3ce56dbf776d1cc0d2e64c980ceb78802356659afc142a9f6128e11e1e3264340074d0aef664acc
data/ext/sass/Rakefile CHANGED
@@ -41,12 +41,12 @@ file 'cli.rb' => %w[dart-sass] do |t|
41
41
 
42
42
  command = if File.exist?(runtime) && File.exist?(snapshot)
43
43
  "
44
- File.absolute_path('#{runtime}', __dir__),
45
- File.absolute_path('#{snapshot}', __dir__)
44
+ File.absolute_path('#{runtime}', __dir__).freeze,
45
+ File.absolute_path('#{snapshot}', __dir__).freeze
46
46
  "
47
47
  else
48
48
  "
49
- File.absolute_path('#{exe}', __dir__)
49
+ File.absolute_path('#{exe}', __dir__).freeze
50
50
  "
51
51
  end
52
52
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "dependencies": {
3
- "sass": "1.69.6"
3
+ "sass": "1.69.7"
4
4
  }
5
5
  }
@@ -18,12 +18,9 @@ module Sass
18
18
  def initialize(operator, left, right)
19
19
  raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator)
20
20
 
21
- left.assert_calculation_value
22
- right.assert_calculation_value
23
-
24
21
  @operator = operator.freeze
25
- @left = left.freeze
26
- @right = right.freeze
22
+ @left = assert_calculation_value(left, 'left')
23
+ @right = assert_calculation_value(right, 'right')
27
24
  end
28
25
 
29
26
  # @return [::String]
@@ -5,10 +5,16 @@ module Sass
5
5
  #
6
6
  # @see https://sass-lang.com/documentation/js-api/types/calculationvalue/
7
7
  module CalculationValue
8
- # @return [CalculationValue]
9
- # @raise [ScriptError]
10
- def assert_calculation_value(_name = nil)
11
- self
8
+ private
9
+
10
+ def assert_calculation_value(value, name = nil)
11
+ if !value.is_a?(Sass::CalculationValue) || (value.is_a?(Sass::Value::String) && value.quoted?)
12
+ raise Sass::ScriptError.new(
13
+ "#{value} must be one of SassNumber, unquoted SassString, SassCalculation, CalculationOperation", name
14
+ )
15
+ end
16
+
17
+ value
12
18
  end
13
19
  end
14
20
  end
@@ -123,7 +123,7 @@ module Sass
123
123
  end
124
124
 
125
125
  def disconnect
126
- @dispatcher.unsubscribe(id)
126
+ @dispatcher.unsubscribe(@id)
127
127
  end
128
128
 
129
129
  def error(...)
@@ -2,32 +2,35 @@
2
2
 
3
3
  module Sass
4
4
  class Compiler
5
- # The {ResilientDispatcher} class.
5
+ # The {DispatcherManager} class.
6
6
  #
7
- # It recovers from failures and continues to function.
8
- class ResilientDispatcher
7
+ # It manages the lifecycle of {Dispatcher}.
8
+ class DispatcherManager
9
9
  def initialize(dispatcher_class)
10
10
  @dispatcher_class = dispatcher_class
11
11
  @dispatcher = @dispatcher_class.new
12
12
  @mutex = Mutex.new
13
13
  end
14
14
 
15
- def close(...)
15
+ def close
16
16
  @mutex.synchronize do
17
- @dispatcher.close(...)
17
+ unless @dispatcher.nil?
18
+ @dispatcher.close
19
+ @dispatcher = nil
20
+ end
18
21
  end
19
22
  end
20
23
 
21
- def closed?(...)
24
+ def closed?
22
25
  @mutex.synchronize do
23
- @dispatcher.closed?(...)
26
+ @dispatcher.nil?
24
27
  end
25
28
  end
26
29
 
27
30
  def connect(...)
28
- @dispatcher.connect(...)
29
- rescue Errno::EBUSY
30
31
  @mutex.synchronize do
32
+ raise IOError, 'closed compiler' if @dispatcher.nil?
33
+
31
34
  @dispatcher.connect(...)
32
35
  rescue Errno::EBUSY
33
36
  @dispatcher = @dispatcher_class.new
@@ -36,6 +39,6 @@ module Sass
36
39
  end
37
40
  end
38
41
 
39
- private_constant :ResilientDispatcher
42
+ private_constant :DispatcherManager
40
43
  end
41
44
  end
@@ -81,7 +81,7 @@ module Sass
81
81
  EmbeddedProtocol::InboundMessage::ImportResponse.new(
82
82
  id: import_request.id,
83
83
  success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
84
- contents: importer_result.contents,
84
+ contents: importer_result.contents.to_str,
85
85
  syntax: Protofier.to_proto_syntax(importer_result.syntax),
86
86
  source_map_url: (importer_result.source_map_url&.to_s if importer_result.respond_to?(:source_map_url))
87
87
  )
@@ -16,7 +16,7 @@ module Sass
16
16
  when Sass::Value::String
17
17
  EmbeddedProtocol::Value.new(
18
18
  string: EmbeddedProtocol::Value::String.new(
19
- text: obj.text,
19
+ text: obj.text.to_str,
20
20
  quoted: obj.quoted?
21
21
  )
22
22
  )
@@ -179,7 +179,7 @@ module Sass
179
179
  end
180
180
  )
181
181
  when :compiler_function
182
- Sass::Value::Function.new(nil, nil).instance_eval do
182
+ Sass::Value::Function.new(nil).instance_eval do
183
183
  @id = obj.id
184
184
  self
185
185
  end
@@ -44,7 +44,7 @@ module Sass
44
44
  send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new(
45
45
  string: unless source.nil?
46
46
  EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
47
- source:,
47
+ source: source.to_str,
48
48
  url: url&.to_s,
49
49
  syntax: Protofier.to_proto_syntax(syntax),
50
50
  importer: (@importer_registry.register(importer) unless importer.nil?)
@@ -74,7 +74,14 @@ module Sass
74
74
  ))
75
75
  end
76
76
 
77
- "sass-embedded\t#{version_response.implementation_version}"
77
+ lang = case version_response.implementation_name
78
+ when /\bdart\b/i
79
+ '[Dart]'
80
+ else
81
+ '[?]'
82
+ end
83
+
84
+ "#{version_response.implementation_name}\t#{version_response.implementation_version}\t(Sass Compiler)\t#{lang}"
78
85
  end
79
86
 
80
87
  def compile_response(message)
data/lib/sass/compiler.rb CHANGED
@@ -4,8 +4,8 @@ require_relative 'canonicalize_context'
4
4
  require_relative 'compile_result'
5
5
  require_relative 'compiler/connection'
6
6
  require_relative 'compiler/dispatcher'
7
+ require_relative 'compiler/dispatcher_manager'
7
8
  require_relative 'compiler/host'
8
- require_relative 'compiler/resilient_dispatcher'
9
9
  require_relative 'compiler/varint'
10
10
  require_relative 'embedded_protocol'
11
11
  require_relative 'exception'
@@ -27,7 +27,7 @@ module Sass
27
27
  # sass.close
28
28
  class Compiler
29
29
  def initialize
30
- @dispatcher = ResilientDispatcher.new(Dispatcher)
30
+ @dispatcher = DispatcherManager.new(Dispatcher)
31
31
  end
32
32
 
33
33
  # Compiles the Sass file at +path+ to CSS.
@@ -174,7 +174,10 @@ module Sass
174
174
  # @return [String] Information about the Sass implementation.
175
175
  # @see https://sass-lang.com/documentation/js-api/variables/info/
176
176
  def info
177
- @info ||= Host.new(@dispatcher).version_request
177
+ @info ||= <<~INFO.freeze
178
+ sass-embedded\t#{Embedded::VERSION}\t(Embedded Host)\t[Ruby]
179
+ #{Host.new(@dispatcher).version_request}
180
+ INFO
178
181
  end
179
182
 
180
183
  def close
data/lib/sass/elf.rb CHANGED
@@ -150,7 +150,7 @@ module Sass
150
150
  def initialize(buffer)
151
151
  @buffer = buffer
152
152
  @ehdr = read_ehdr
153
- @buffer.seek(@ehdr[:e_phoff], :SET)
153
+ @buffer.seek(@ehdr[:e_phoff], IO::SEEK_SET)
154
154
  @proghdrs = Array.new(@ehdr[:e_phnum]) do
155
155
  read_phdr
156
156
  end
@@ -176,7 +176,7 @@ module Sass
176
176
  phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP }
177
177
  return if phdr.nil?
178
178
 
179
- @buffer.seek(phdr[:p_offset], :SET)
179
+ @buffer.seek(phdr[:p_offset], IO::SEEK_SET)
180
180
  interpreter = @buffer.read(phdr[:p_filesz])
181
181
  raise ArgumentError unless interpreter.end_with?("\0")
182
182
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  module Embedded
5
- VERSION = '1.69.6'
5
+ VERSION = '1.69.7'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -56,7 +56,7 @@ module Sass
56
56
 
57
57
  compiler = Class.new(Compiler) do
58
58
  def initialize
59
- @dispatcher = Compiler.const_get(:ResilientDispatcher).new(Class.new(Compiler.const_get(:Dispatcher)) do
59
+ @dispatcher = Compiler.const_get(:DispatcherManager).new(Class.new(Compiler.const_get(:Dispatcher)) do
60
60
  def initialize
61
61
  super
62
62
 
@@ -50,7 +50,7 @@ module Sass
50
50
  border-bottom-style: solid;
51
51
  font-family: monospace, monospace;
52
52
  white-space: pre;
53
- content: #{Serializer.dump_quoted_string(content)};
53
+ content: #{Serializer.serialize_quoted_string(content, ascii_only: true)};
54
54
  }
55
55
  CSS
56
56
  end
@@ -44,7 +44,7 @@ module Sass
44
44
 
45
45
  private_constant :CoreExt
46
46
 
47
- Process.singleton_class.prepend(CoreExt)
47
+ Process.singleton_class.prepend(CoreExt) if Process.respond_to?(:_fork)
48
48
  end
49
49
 
50
50
  private_constant :ForkTracker
@@ -5,67 +5,35 @@ module Sass
5
5
  module Serializer
6
6
  module_function
7
7
 
8
- def dump_quoted_string(string)
9
- include_double_quote = false
10
- include_single_quote = false
11
- buffer = [34]
8
+ def serialize_quoted_string(string, ascii_only: false)
9
+ buffer = [0x22]
12
10
  string.each_codepoint do |codepoint|
13
- case codepoint
14
- when 34
15
- return dump_double_quoted_string(string) if include_single_quote
16
-
17
- include_double_quote = true
18
- buffer << 34
19
- when 39
20
- return dump_double_quoted_string(string) if include_double_quote
21
-
22
- include_single_quote = true
23
- buffer << 39
24
- when 92
25
- buffer << 92 << 92
26
- when 9
27
- buffer << 9
11
+ if codepoint.zero?
12
+ # If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD).
13
+ buffer << 0xFFFD
14
+ elsif codepoint == 0x22
15
+ # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character.
16
+ buffer << 0x5C << 0x22
17
+ elsif codepoint == 0x5C
18
+ # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character.
19
+ buffer << 0x5C << 0x5C
20
+ elsif codepoint < 0x20 || (ascii_only ? codepoint >= 0x7F : codepoint == 0x7F)
21
+ # If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F,
22
+ # then the character escaped as code point.
23
+ buffer << 0x5C
24
+ buffer.concat(codepoint.to_s(16).codepoints)
25
+ buffer << 0x20
28
26
  else
29
- if codepoint < 32 || codepoint > 126
30
- buffer << 92
31
- buffer.concat(codepoint.to_s(16).codepoints)
32
- buffer << 32
33
- else
34
- buffer << codepoint
35
- end
27
+ # Otherwise, the character itself.
28
+ buffer << codepoint
36
29
  end
37
30
  end
38
- if include_double_quote
39
- buffer[0] = 39
40
- buffer << 39
41
- else
42
- buffer << 34
43
- end
31
+ buffer << 0x22
44
32
  buffer.pack('U*')
45
33
  end
46
34
 
47
- def dump_double_quoted_string(string)
48
- buffer = [34]
49
- string.each_codepoint do |codepoint|
50
- case codepoint
51
- when 34
52
- buffer << 92 << 34
53
- when 92
54
- buffer << 92 << 92
55
- when 9
56
- buffer << 9
57
- else
58
- if codepoint < 32 || codepoint > 126
59
- buffer << 92
60
- buffer.concat(codepoint.to_s(16).codepoints)
61
- buffer << 32
62
- else
63
- buffer << codepoint
64
- end
65
- end
66
- end
67
- buffer << 34
68
- buffer.pack('U*')
35
+ def serialize_unquoted_string(string)
36
+ string.tr("\0", "\uFFFD").gsub(/\n */, ' ')
69
37
  end
70
38
  end
71
39
 
@@ -8,7 +8,7 @@ module Sass
8
8
  # map as well as the positional arguments.
9
9
  #
10
10
  # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/
11
- class ArgumentList < Value::List
11
+ class ArgumentList < List
12
12
  # @param contents [Array<Value>]
13
13
  # @param keywords [Hash<::String, Value>]
14
14
  # @param separator [::String]
@@ -53,7 +53,9 @@ module Sass
53
53
  private
54
54
 
55
55
  def initialize(name, arguments)
56
- arguments.each(&:assert_calculation_value)
56
+ arguments.each do |value|
57
+ assert_calculation_value(value)
58
+ end
57
59
 
58
60
  @name = name.freeze
59
61
  @arguments = arguments.freeze
@@ -10,9 +10,11 @@ module Sass
10
10
 
11
11
  # @param signature [::String]
12
12
  # @param callback [Proc]
13
- def initialize(signature, callback)
14
- @signature = signature
15
- @callback = callback
13
+ def initialize(signature, &callback)
14
+ raise Sass::ScriptError, 'no block given' unless signature.nil? || callback
15
+
16
+ @signature = signature.freeze
17
+ @callback = callback.freeze
16
18
  end
17
19
 
18
20
  # @return [Integer, nil]
@@ -39,14 +39,6 @@ module Sass
39
39
  self
40
40
  end
41
41
 
42
- # @return [CalculationValue]
43
- # @raise [ScriptError]
44
- def assert_calculation_value(name = nil)
45
- raise Sass::ScriptError.new("Expected #{self} to be an unquoted string.", name) if quoted?
46
-
47
- self
48
- end
49
-
50
42
  # @param sass_index [Number]
51
43
  # @return [Integer]
52
44
  def sass_index_to_string_index(sass_index, name = nil)
@@ -59,6 +51,11 @@ module Sass
59
51
 
60
52
  index.negative? ? text.length + index : index - 1
61
53
  end
54
+
55
+ # @return [String]
56
+ def to_s
57
+ @quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text)
58
+ end
62
59
  end
63
60
  end
64
61
  end
data/lib/sass/value.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'calculation_value'
4
-
5
3
  module Sass
6
4
  # The abstract base class of Sass's value types.
7
5
  #
@@ -66,12 +64,6 @@ module Sass
66
64
  raise Sass::ScriptError.new("#{self} is not a calculation", name)
67
65
  end
68
66
 
69
- # @return [CalculationValue]
70
- # @raise [ScriptError]
71
- def assert_calculation_value(name = nil)
72
- raise Sass::ScriptError.new("#{self} is not a calculation value", name)
73
- end
74
-
75
67
  # @return [Color]
76
68
  # @raise [ScriptError]
77
69
  def assert_color(name = nil)
@@ -129,6 +121,7 @@ module Sass
129
121
  end
130
122
  end
131
123
 
124
+ require_relative 'calculation_value'
132
125
  require_relative 'value/list'
133
126
  require_relative 'value/argument_list'
134
127
  require_relative 'value/boolean'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.69.6
4
+ version: 1.69.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-29 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -63,6 +63,7 @@ files:
63
63
  - lib/sass/compiler.rb
64
64
  - lib/sass/compiler/connection.rb
65
65
  - lib/sass/compiler/dispatcher.rb
66
+ - lib/sass/compiler/dispatcher_manager.rb
66
67
  - lib/sass/compiler/host.rb
67
68
  - lib/sass/compiler/host/function_registry.rb
68
69
  - lib/sass/compiler/host/importer_registry.rb
@@ -70,7 +71,6 @@ files:
70
71
  - lib/sass/compiler/host/protofier.rb
71
72
  - lib/sass/compiler/host/structifier.rb
72
73
  - lib/sass/compiler/host/value_protofier.rb
73
- - lib/sass/compiler/resilient_dispatcher.rb
74
74
  - lib/sass/compiler/varint.rb
75
75
  - lib/sass/elf.rb
76
76
  - lib/sass/embedded.rb
@@ -100,9 +100,10 @@ homepage: https://github.com/sass-contrib/sass-embedded-host-ruby
100
100
  licenses:
101
101
  - MIT
102
102
  metadata:
103
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.6
104
- source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.69.6
103
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.7
104
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.69.7
105
105
  funding_uri: https://github.com/sponsors/ntkme
106
+ rubygems_mfa_required: 'true'
106
107
  post_install_message:
107
108
  rdoc_options: []
108
109
  require_paths: