sass-embedded 1.77.5 → 1.86.3

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/exe/sass +1 -9
  3. data/ext/sass/Rakefile +407 -89
  4. data/ext/sass/embedded_sass_pb.rb +2 -4
  5. data/ext/sass/package.json +1 -1
  6. data/lib/sass/compiler/channel.rb +6 -4
  7. data/lib/sass/compiler/connection.rb +15 -20
  8. data/lib/sass/compiler/dispatcher.rb +27 -1
  9. data/lib/sass/compiler/host/function_registry.rb +6 -6
  10. data/lib/sass/compiler/host/importer_registry.rb +17 -11
  11. data/lib/sass/compiler/host/logger_registry.rb +17 -20
  12. data/lib/sass/compiler/host/protofier.rb +59 -73
  13. data/lib/sass/compiler/host/struct.rb +36 -0
  14. data/lib/sass/compiler/host.rb +2 -2
  15. data/lib/sass/compiler.rb +3 -3
  16. data/lib/sass/elf.rb +283 -170
  17. data/lib/sass/embedded/version.rb +1 -1
  18. data/lib/sass/embedded.rb +2 -41
  19. data/lib/sass/exception.rb +7 -2
  20. data/lib/sass/serializer.rb +5 -11
  21. data/lib/sass/value/argument_list.rb +0 -8
  22. data/lib/sass/value/color/channel.rb +79 -0
  23. data/lib/sass/value/color/conversions.rb +473 -0
  24. data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
  25. data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
  26. data/lib/sass/value/color/gamut_map_method.rb +45 -0
  27. data/lib/sass/value/color/interpolation_method.rb +51 -0
  28. data/lib/sass/value/color/space/a98_rgb.rb +57 -0
  29. data/lib/sass/value/color/space/display_p3.rb +57 -0
  30. data/lib/sass/value/color/space/hsl.rb +65 -0
  31. data/lib/sass/value/color/space/hwb.rb +70 -0
  32. data/lib/sass/value/color/space/lab.rb +77 -0
  33. data/lib/sass/value/color/space/lch.rb +53 -0
  34. data/lib/sass/value/color/space/lms.rb +129 -0
  35. data/lib/sass/value/color/space/oklab.rb +66 -0
  36. data/lib/sass/value/color/space/oklch.rb +54 -0
  37. data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
  38. data/lib/sass/value/color/space/rec2020.rb +69 -0
  39. data/lib/sass/value/color/space/rgb.rb +52 -0
  40. data/lib/sass/value/color/space/srgb.rb +140 -0
  41. data/lib/sass/value/color/space/srgb_linear.rb +72 -0
  42. data/lib/sass/value/color/space/utils.rb +86 -0
  43. data/lib/sass/value/color/space/xyz_d50.rb +100 -0
  44. data/lib/sass/value/color/space/xyz_d65.rb +57 -0
  45. data/lib/sass/value/color/space.rb +198 -0
  46. data/lib/sass/value/color.rb +537 -162
  47. data/lib/sass/value/function.rb +9 -6
  48. data/lib/sass/value/fuzzy_math.rb +23 -19
  49. data/lib/sass/value/mixin.rb +5 -2
  50. data/lib/sass/value/number/unit.rb +5 -4
  51. data/lib/sass/value/number.rb +8 -10
  52. data/lib/sass/value/string.rb +1 -1
  53. metadata +34 -19
  54. data/lib/sass/compiler/host/structifier.rb +0 -37
@@ -11,12 +11,13 @@ module Sass
11
11
  # @param signature [::String]
12
12
  # @param callback [Proc]
13
13
  def initialize(signature, &callback)
14
- raise Sass::ScriptError, 'no block given' unless signature.nil? || callback
15
-
16
14
  @signature = signature.freeze
17
15
  @callback = callback.freeze
18
16
  end
19
17
 
18
+ # @return [Object, nil]
19
+ protected attr_reader :compile_context
20
+
20
21
  # @return [Integer, nil]
21
22
  protected attr_reader :id
22
23
 
@@ -28,16 +29,18 @@ module Sass
28
29
 
29
30
  # @return [::Boolean]
30
31
  def ==(other)
31
- if id.nil?
32
- other.equal?(self)
32
+ return false unless other.is_a?(Sass::Value::Function)
33
+
34
+ if defined?(@id)
35
+ other.compile_context == compile_context && other.id == id
33
36
  else
34
- other.is_a?(Sass::Value::Function) && other.id == id
37
+ other.signature == signature && other.callback == callback
35
38
  end
36
39
  end
37
40
 
38
41
  # @return [Integer]
39
42
  def hash
40
- @hash ||= id.nil? ? signature.hash : id.hash
43
+ @hash ||= defined?(@id) ? [compile_context, id].hash : [signature, callback].hash
41
44
  end
42
45
 
43
46
  # @return [Function]
@@ -6,14 +6,27 @@ module Sass
6
6
  module FuzzyMath
7
7
  PRECISION = 10
8
8
 
9
- EPSILON = 10.pow(-PRECISION - 1)
9
+ EPSILON = 10**(-PRECISION - 1)
10
10
 
11
- INVERSE_EPSILON = 1 / EPSILON
11
+ INVERSE_EPSILON = 10**(PRECISION + 1)
12
12
 
13
13
  module_function
14
14
 
15
15
  def equals(number1, number2)
16
- (number1 - number2).abs < EPSILON
16
+ return true if number1 == number2
17
+
18
+ (number1 - number2).abs <= EPSILON &&
19
+ (number1 * INVERSE_EPSILON).round ==
20
+ (number2 * INVERSE_EPSILON).round
21
+ end
22
+
23
+ def equals_nilable(number1, number2)
24
+ return true if number1 == number2
25
+ return false if number1.nil? || number2.nil?
26
+
27
+ (number1 - number2).abs <= EPSILON &&
28
+ (number1 * INVERSE_EPSILON).round ==
29
+ (number2 * INVERSE_EPSILON).round
17
30
  end
18
31
 
19
32
  def less_than(number1, number2)
@@ -34,23 +47,14 @@ module Sass
34
47
 
35
48
  def integer?(number)
36
49
  return false unless number.finite?
37
- return true if number.integer?
38
50
 
39
- equals((number - 0.5).abs % 1, 0.5)
51
+ equals(number, number.round)
40
52
  end
41
53
 
42
54
  def to_i(number)
43
55
  integer?(number) ? number.round : nil
44
56
  end
45
57
 
46
- def round(number)
47
- if number.positive?
48
- less_than(number % 1, 0.5) ? number.floor : number.ceil
49
- else
50
- less_than_or_equals(number % 1, 0.5) ? number.floor : number.ceil
51
- end
52
- end
53
-
54
58
  def between(number, min, max)
55
59
  return min if equals(number, min)
56
60
  return max if equals(number, max)
@@ -66,12 +70,12 @@ module Sass
66
70
  raise Sass::ScriptError.new("#{number} must be between #{min} and #{max}.", name)
67
71
  end
68
72
 
69
- def hash(number)
70
- if number.finite?
71
- (number * INVERSE_EPSILON).round.hash
72
- else
73
- number.hash
74
- end
73
+ def _clamp_like_css(number, lower_bound, upper_bound)
74
+ number.to_f.nan? ? lower_bound : number.clamp(lower_bound, upper_bound)
75
+ end
76
+
77
+ def _hash(number)
78
+ number&.finite? ? (number * INVERSE_EPSILON).round : number
75
79
  end
76
80
  end
77
81
 
@@ -12,17 +12,20 @@ module Sass
12
12
  private :new
13
13
  end
14
14
 
15
+ # @return [Object]
16
+ protected attr_reader :compile_context
17
+
15
18
  # @return [Integer]
16
19
  protected attr_reader :id
17
20
 
18
21
  # @return [::Boolean]
19
22
  def ==(other)
20
- other.is_a?(Sass::Value::Mixin) && other.id == id
23
+ other.is_a?(Sass::Value::Mixin) && other.compile_context == compile_context && other.id == id
21
24
  end
22
25
 
23
26
  # @return [Integer]
24
27
  def hash
25
- @hash ||= id.hash
28
+ @hash ||= [compile_context, id].hash
26
29
  end
27
30
 
28
31
  # @return [Mixin]
@@ -141,10 +141,11 @@ module Sass
141
141
  'pixel density': %w[dpi dpcm dppx]
142
142
  }.freeze
143
143
 
144
- TYPES_BY_UNIT = UNITS_BY_TYPE.invert
145
- .to_a
146
- .flat_map { |pair| pair[0].map { |key| [key, pair[1]] } }
147
- .to_h
144
+ TYPES_BY_UNIT = UNITS_BY_TYPE.each_with_object({}) do |(key, values), hash|
145
+ values.each do |value|
146
+ hash[value] = key
147
+ end
148
+ end
148
149
 
149
150
  module_function
150
151
 
@@ -25,12 +25,12 @@ module Sass
25
25
  denominator_units = []
26
26
  when ::Hash
27
27
  numerator_units = unit.fetch(:numerator_units, [])
28
- unless numerator_units.is_a?(Array)
28
+ unless numerator_units.is_a?(::Array)
29
29
  raise Sass::ScriptError, "invalid numerator_units #{numerator_units.inspect}"
30
30
  end
31
31
 
32
32
  denominator_units = unit.fetch(:denominator_units, [])
33
- unless denominator_units.is_a?(Array)
33
+ unless denominator_units.is_a?(::Array)
34
34
  raise Sass::ScriptError, "invalid denominator_units #{denominator_units.inspect}"
35
35
  end
36
36
  else
@@ -99,7 +99,7 @@ module Sass
99
99
 
100
100
  # @return [Integer]
101
101
  def hash
102
- @hash ||= FuzzyMath.hash(canonical_units_value)
102
+ @hash ||= FuzzyMath._hash(canonical_units_value).hash
103
103
  end
104
104
 
105
105
  # @return [::Boolean]
@@ -275,22 +275,20 @@ module Sass
275
275
  name: nil,
276
276
  other: nil,
277
277
  other_name: nil)
278
- if other && (other.numerator_units != new_denominator_units && other.denominator_units != new_denominator_units)
279
- raise Sass::ScriptError, "Expect #{other} to have units #{unit_string(new_numerator_units,
280
- new_denominator_units).inspect}"
278
+ unless other.nil? ||
279
+ (other.numerator_units == new_numerator_units && other.denominator_units == new_denominator_units)
280
+ raise Sass::ScriptError,
281
+ "Expected #{other} to have units #{unit_string(new_numerator_units, new_denominator_units).inspect}"
281
282
  end
282
283
 
283
284
  return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units
284
285
 
285
- return value if numerator_units == new_numerator_units && denominator_units == new_denominator_units
286
-
287
286
  other_unitless = new_numerator_units.empty? && new_denominator_units.empty?
288
-
289
287
  return value if coerce_unitless && (unitless? || other_unitless)
290
288
 
291
289
  compatibility_error = lambda {
292
290
  unless other.nil?
293
- message = +"#{self} and"
291
+ message = "#{self} and"
294
292
  message << " $#{other_name}:" unless other_name.nil?
295
293
  message << " #{other} have incompatible units"
296
294
  message << " (one has units and the other doesn't)" if unitless? || other_unitless
@@ -52,7 +52,7 @@ module Sass
52
52
  index.negative? ? text.length + index : index - 1
53
53
  end
54
54
 
55
- # @return [String]
55
+ # @return [::String]
56
56
  def to_s
57
57
  @quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text)
58
58
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.77.5
4
+ version: 1.86.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -28,22 +27,16 @@ dependencies:
28
27
  name: google-protobuf
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '3.25'
34
- - - "<"
30
+ - - "~>"
35
31
  - !ruby/object:Gem::Version
36
- version: '5.0'
32
+ version: '4.30'
37
33
  type: :runtime
38
34
  prerelease: false
39
35
  version_requirements: !ruby/object:Gem::Requirement
40
36
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '3.25'
44
- - - "<"
37
+ - - "~>"
45
38
  - !ruby/object:Gem::Version
46
- version: '5.0'
39
+ version: '4.30'
47
40
  description: A Ruby library that will communicate with Embedded Dart Sass using the
48
41
  Embedded Sass protocol.
49
42
  email:
@@ -75,7 +68,7 @@ files:
75
68
  - lib/sass/compiler/host/importer_registry.rb
76
69
  - lib/sass/compiler/host/logger_registry.rb
77
70
  - lib/sass/compiler/host/protofier.rb
78
- - lib/sass/compiler/host/structifier.rb
71
+ - lib/sass/compiler/host/struct.rb
79
72
  - lib/sass/compiler/varint.rb
80
73
  - lib/sass/elf.rb
81
74
  - lib/sass/embedded.rb
@@ -93,6 +86,30 @@ files:
93
86
  - lib/sass/value/boolean.rb
94
87
  - lib/sass/value/calculation.rb
95
88
  - lib/sass/value/color.rb
89
+ - lib/sass/value/color/channel.rb
90
+ - lib/sass/value/color/conversions.rb
91
+ - lib/sass/value/color/gamut_map_method.rb
92
+ - lib/sass/value/color/gamut_map_method/clip.rb
93
+ - lib/sass/value/color/gamut_map_method/local_minde.rb
94
+ - lib/sass/value/color/interpolation_method.rb
95
+ - lib/sass/value/color/space.rb
96
+ - lib/sass/value/color/space/a98_rgb.rb
97
+ - lib/sass/value/color/space/display_p3.rb
98
+ - lib/sass/value/color/space/hsl.rb
99
+ - lib/sass/value/color/space/hwb.rb
100
+ - lib/sass/value/color/space/lab.rb
101
+ - lib/sass/value/color/space/lch.rb
102
+ - lib/sass/value/color/space/lms.rb
103
+ - lib/sass/value/color/space/oklab.rb
104
+ - lib/sass/value/color/space/oklch.rb
105
+ - lib/sass/value/color/space/prophoto_rgb.rb
106
+ - lib/sass/value/color/space/rec2020.rb
107
+ - lib/sass/value/color/space/rgb.rb
108
+ - lib/sass/value/color/space/srgb.rb
109
+ - lib/sass/value/color/space/srgb_linear.rb
110
+ - lib/sass/value/color/space/utils.rb
111
+ - lib/sass/value/color/space/xyz_d50.rb
112
+ - lib/sass/value/color/space/xyz_d65.rb
96
113
  - lib/sass/value/function.rb
97
114
  - lib/sass/value/fuzzy_math.rb
98
115
  - lib/sass/value/list.rb
@@ -107,11 +124,10 @@ licenses:
107
124
  - MIT
108
125
  metadata:
109
126
  bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
110
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.77.5
111
- source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.77.5
127
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.86.3
128
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.86.3
112
129
  funding_uri: https://github.com/sponsors/ntkme
113
130
  rubygems_mfa_required: 'true'
114
- post_install_message:
115
131
  rdoc_options: []
116
132
  require_paths:
117
133
  - lib
@@ -126,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
142
  - !ruby/object:Gem::Version
127
143
  version: '0'
128
144
  requirements: []
129
- rubygems_version: 3.5.11
130
- signing_key:
145
+ rubygems_version: 3.6.7
131
146
  specification_version: 4
132
147
  summary: Use dart-sass with Ruby!
133
148
  test_files: []
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Compiler
5
- class Host
6
- # The {Structifier} module.
7
- #
8
- # It converts {::Hash} to {Struct}-like objects.
9
- module Structifier
10
- module_function
11
-
12
- def to_struct(obj, *symbols)
13
- return obj unless obj.is_a?(Hash)
14
-
15
- struct = Object.new
16
- symbols.each do |key|
17
- next unless obj.key?(key)
18
-
19
- value = obj[key]
20
- if value.respond_to?(:call)
21
- struct.define_singleton_method key do |*args, **kwargs|
22
- value.call(*args, **kwargs)
23
- end
24
- else
25
- struct.define_singleton_method key do
26
- value
27
- end
28
- end
29
- end
30
- struct
31
- end
32
- end
33
-
34
- private_constant :Structifier
35
- end
36
- end
37
- end