sass-embedded 1.69.6 → 1.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,67 +5,30 @@ 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]
12
- string.each_codepoint do |codepoint|
13
- case codepoint
14
- when 34
15
- return dump_double_quoted_string(string) if include_single_quote
8
+ CSS_ESCAPE = {
9
+ "\0" => "\uFFFD",
10
+ '\\' => '\\\\',
11
+ '"' => '\\"',
12
+ "'" => "\\'",
13
+ **[*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"].product(
14
+ [*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil]
15
+ ).to_h do |c, x|
16
+ ["#{c}#{x}".freeze, "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze]
17
+ end
18
+ }.freeze
16
19
 
17
- include_double_quote = true
18
- buffer << 34
19
- when 39
20
- return dump_double_quoted_string(string) if include_double_quote
20
+ private_constant :CSS_ESCAPE
21
21
 
22
- include_single_quote = true
23
- buffer << 39
24
- when 92
25
- buffer << 92 << 92
26
- when 9
27
- buffer << 9
28
- 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
36
- end
37
- end
38
- if include_double_quote
39
- buffer[0] = 39
40
- buffer << 39
22
+ def serialize_quoted_string(string)
23
+ if !string.include?('"') || string.include?("'")
24
+ %("#{string.gsub(/[\0\\"]|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}")
41
25
  else
42
- buffer << 34
26
+ %('#{string.gsub(/[\0\\']|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}')
43
27
  end
44
- buffer.pack('U*')
45
28
  end
46
29
 
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*')
30
+ def serialize_unquoted_string(string)
31
+ string.tr("\0", "\uFFFD").gsub(/\n */, ' ')
69
32
  end
70
33
  end
71
34
 
@@ -8,19 +8,19 @@ 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
- # @param keywords [Hash<::String, Value>]
13
+ # @param keywords [Hash<Symbol, Value>]
14
14
  # @param separator [::String]
15
15
  def initialize(contents = [], keywords = {}, separator = ',')
16
16
  super(contents, separator:)
17
17
 
18
18
  @id = 0
19
19
  @keywords_accessed = false
20
- @keywords = keywords.transform_keys(&:to_s).freeze
20
+ @keywords = keywords.freeze
21
21
  end
22
22
 
23
- # @return [Hash<::String, Value>]
23
+ # @return [Hash<Symbol, Value>]
24
24
  def keywords
25
25
  @keywords_accessed = true
26
26
  @keywords
@@ -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]
@@ -21,9 +21,6 @@ module Sass
21
21
  @bracketed = bracketed.freeze
22
22
  end
23
23
 
24
- # @return [Array<Value>]
25
- attr_reader :contents
26
-
27
24
  # @return [::String, nil]
28
25
  attr_reader :separator
29
26
 
@@ -35,7 +32,7 @@ module Sass
35
32
  # @return [::Boolean]
36
33
  def ==(other)
37
34
  (other.is_a?(Sass::Value::List) &&
38
- other.contents == contents &&
35
+ other.to_a == to_a &&
39
36
  other.separator == separator &&
40
37
  other.bracketed? == bracketed?) ||
41
38
  (to_a.empty? && other.is_a?(Sass::Value::Map) && other.to_a.empty?)
@@ -56,7 +53,10 @@ module Sass
56
53
  @hash ||= contents.hash
57
54
  end
58
55
 
59
- alias to_a contents
56
+ # @return [Array<Value>]
57
+ def to_a
58
+ @contents
59
+ end
60
60
 
61
61
  # @return [Map, nil]
62
62
  def to_map
@@ -63,8 +63,8 @@ module Sass
63
63
  end
64
64
 
65
65
  @value = value.freeze
66
- @numerator_units = numerator_units.freeze
67
- @denominator_units = denominator_units.freeze
66
+ @numerator_units = numerator_units.each(&:freeze).freeze
67
+ @denominator_units = denominator_units.each(&:freeze).freeze
68
68
  end
69
69
 
70
70
  # @return [Numeric]
@@ -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,43 +1,43 @@
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.70.0
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-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: google-protobuf
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.25'
19
+ version: 13.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.25'
26
+ version: 13.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: google-protobuf
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 13.0.0
33
+ version: '3.25'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 13.0.0
40
+ version: '3.25'
41
41
  description: A Ruby library that will communicate with Embedded Dart Sass using the
42
42
  Embedded Sass protocol.
43
43
  email:
@@ -63,14 +63,13 @@ 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
69
70
  - lib/sass/compiler/host/logger_registry.rb
70
71
  - lib/sass/compiler/host/protofier.rb
71
72
  - lib/sass/compiler/host/structifier.rb
72
- - lib/sass/compiler/host/value_protofier.rb
73
- - lib/sass/compiler/resilient_dispatcher.rb
74
73
  - lib/sass/compiler/varint.rb
75
74
  - lib/sass/elf.rb
76
75
  - lib/sass/embedded.rb
@@ -100,9 +99,11 @@ homepage: https://github.com/sass-contrib/sass-embedded-host-ruby
100
99
  licenses:
101
100
  - MIT
102
101
  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
102
+ bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
103
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.70.0
104
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.70.0
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:
@@ -111,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
112
  requirements:
112
113
  - - ">="
113
114
  - !ruby/object:Gem::Version
114
- version: 3.1.3
115
+ version: 3.1.0
115
116
  required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  requirements:
117
118
  - - ">="
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
- rubygems_version: 3.5.3
122
+ rubygems_version: 3.5.4
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Use dart-sass with Ruby!