sass-embedded 1.77.5 → 1.100.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +18 -17
  3. data/README.md +1 -1
  4. data/exe/sass +2 -10
  5. data/ext/sass/Rakefile +162 -385
  6. data/ext/sass/file_utils.rb +75 -0
  7. data/ext/sass/package.json +1 -1
  8. data/ext/sass/platform.rb +44 -0
  9. data/ext/sass/sass-1.100.0.tgz +0 -0
  10. data/ext/sass/sass_config.rb +183 -0
  11. data/ext/sass/utils.rb +39 -0
  12. data/lib/sass/compiler/channel.rb +6 -4
  13. data/lib/sass/compiler/connection.rb +17 -21
  14. data/lib/sass/compiler/dispatcher.rb +27 -1
  15. data/lib/sass/compiler/host/function_registry.rb +6 -6
  16. data/lib/sass/compiler/host/importer_registry.rb +17 -11
  17. data/lib/sass/compiler/host/logger_registry.rb +17 -20
  18. data/lib/sass/compiler/host/protofier.rb +59 -73
  19. data/lib/sass/compiler/host/struct.rb +36 -0
  20. data/lib/sass/compiler/host.rb +2 -2
  21. data/lib/sass/compiler.rb +4 -3
  22. data/lib/sass/elf.rb +282 -172
  23. data/lib/sass/embedded/version.rb +1 -1
  24. data/lib/sass/embedded.rb +2 -41
  25. data/lib/sass/embedded_protocol.rb +1 -1
  26. data/{ext → lib}/sass/embedded_sass_pb.rb +3 -5
  27. data/lib/sass/exception.rb +7 -2
  28. data/lib/sass/fork_tracker.rb +36 -28
  29. data/lib/sass/gem_package_importer.rb +19 -0
  30. data/lib/sass/serializer.rb +5 -11
  31. data/lib/sass/value/argument_list.rb +0 -8
  32. data/lib/sass/value/color/channel.rb +79 -0
  33. data/lib/sass/value/color/conversions.rb +473 -0
  34. data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
  35. data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
  36. data/lib/sass/value/color/gamut_map_method.rb +45 -0
  37. data/lib/sass/value/color/interpolation_method.rb +51 -0
  38. data/lib/sass/value/color/space/a98_rgb.rb +57 -0
  39. data/lib/sass/value/color/space/display_p3.rb +72 -0
  40. data/lib/sass/value/color/space/display_p3_linear.rb +72 -0
  41. data/lib/sass/value/color/space/hsl.rb +65 -0
  42. data/lib/sass/value/color/space/hwb.rb +70 -0
  43. data/lib/sass/value/color/space/lab.rb +77 -0
  44. data/lib/sass/value/color/space/lch.rb +53 -0
  45. data/lib/sass/value/color/space/lms.rb +129 -0
  46. data/lib/sass/value/color/space/oklab.rb +66 -0
  47. data/lib/sass/value/color/space/oklch.rb +54 -0
  48. data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
  49. data/lib/sass/value/color/space/rec2020.rb +69 -0
  50. data/lib/sass/value/color/space/rgb.rb +52 -0
  51. data/lib/sass/value/color/space/srgb.rb +140 -0
  52. data/lib/sass/value/color/space/srgb_linear.rb +72 -0
  53. data/lib/sass/value/color/space/utils.rb +86 -0
  54. data/lib/sass/value/color/space/xyz_d50.rb +100 -0
  55. data/lib/sass/value/color/space/xyz_d65.rb +57 -0
  56. data/lib/sass/value/color/space.rb +201 -0
  57. data/lib/sass/value/color.rb +539 -162
  58. data/lib/sass/value/function.rb +9 -6
  59. data/lib/sass/value/fuzzy_math.rb +34 -30
  60. data/lib/sass/value/mixin.rb +5 -2
  61. data/lib/sass/value/null.rb +1 -1
  62. data/lib/sass/value/number/unit.rb +5 -4
  63. data/lib/sass/value/number.rb +15 -17
  64. data/lib/sass/value/string.rb +1 -1
  65. data/lib/sass/value.rb +1 -1
  66. metadata +42 -21
  67. data/ext/sass/expand-archive.ps1 +0 -1
  68. 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,54 +6,58 @@ 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
- def equals(number1, number2)
16
- (number1 - number2).abs < EPSILON
15
+ def equals?(number1, number2)
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
- def less_than(number1, number2)
20
- number1 < number2 && !equals(number1, number2)
32
+ def less_than?(number1, number2)
33
+ number1 < number2 && !equals?(number1, number2)
21
34
  end
22
35
 
23
- def less_than_or_equals(number1, number2)
24
- number1 < number2 || equals(number1, number2)
36
+ def less_than_or_equals?(number1, number2)
37
+ number1 < number2 || equals?(number1, number2)
25
38
  end
26
39
 
27
- def greater_than(number1, number2)
28
- number1 > number2 && !equals(number1, number2)
40
+ def greater_than?(number1, number2)
41
+ number1 > number2 && !equals?(number1, number2)
29
42
  end
30
43
 
31
- def greater_than_or_equals(number1, number2)
32
- number1 > number2 || equals(number1, number2)
44
+ def greater_than_or_equals?(number1, number2)
45
+ number1 > number2 || equals?(number1, number2)
33
46
  end
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
- return min if equals(number, min)
56
- return max if equals(number, max)
59
+ return min if equals?(number, min)
60
+ return max if equals?(number, max)
57
61
  return number if number > min && number < max
58
62
 
59
63
  nil
@@ -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]
@@ -31,7 +31,7 @@ module Sass
31
31
  end
32
32
 
33
33
  # @return [::Boolean]
34
- def to_bool
34
+ def to_bool # rubocop:disable Naming/PredicateMethod
35
35
  false
36
36
  end
37
37
 
@@ -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
@@ -80,26 +80,26 @@ module Sass
80
80
  return false if numerator_units.length != other.numerator_units.length ||
81
81
  denominator_units.length != other.denominator_units.length
82
82
 
83
- return FuzzyMath.equals(value, other.value) if unitless?
83
+ return FuzzyMath.equals?(value, other.value) if unitless?
84
84
 
85
85
  if Unit.canonicalize_units(numerator_units) != Unit.canonicalize_units(other.numerator_units) &&
86
86
  Unit.canonicalize_units(denominator_units) != Unit.canonicalize_units(other.denominator_units)
87
87
  return false
88
88
  end
89
89
 
90
- FuzzyMath.equals(
91
- (value *
90
+ FuzzyMath.equals?(
91
+ value *
92
92
  Unit.canonical_multiplier(numerator_units) /
93
- Unit.canonical_multiplier(denominator_units)),
94
- (other.value *
93
+ Unit.canonical_multiplier(denominator_units),
94
+ other.value *
95
95
  Unit.canonical_multiplier(other.numerator_units) /
96
- Unit.canonical_multiplier(other.denominator_units))
96
+ Unit.canonical_multiplier(other.denominator_units)
97
97
  )
98
98
  end
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
@@ -308,7 +306,7 @@ module Sass
308
306
 
309
307
  unit_length = new_numerator_units.length + new_denominator_units.length
310
308
  units = unit_string(new_numerator_units, new_denominator_units)
311
- Sass::ScriptError.new("Expected #{self} to have unit#{unit_length > 1 ? 's' : ''} #{units}", name)
309
+ Sass::ScriptError.new("Expected #{self} to have unit#{'s' if unit_length > 1} #{units}", name)
312
310
  }
313
311
 
314
312
  result = value
@@ -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
data/lib/sass/value.rb CHANGED
@@ -38,7 +38,7 @@ module Sass
38
38
  end
39
39
 
40
40
  # @return [::Boolean]
41
- def to_bool
41
+ def to_bool # rubocop:disable Naming/PredicateMethod
42
42
  true
43
43
  end
44
44
 
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.100.0
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.31'
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.31'
47
40
  description: A Ruby library that will communicate with Embedded Dart Sass using the
48
41
  Embedded Sass protocol.
49
42
  email:
@@ -58,9 +51,12 @@ files:
58
51
  - README.md
59
52
  - exe/sass
60
53
  - ext/sass/Rakefile
61
- - ext/sass/embedded_sass_pb.rb
62
- - ext/sass/expand-archive.ps1
54
+ - ext/sass/file_utils.rb
63
55
  - ext/sass/package.json
56
+ - ext/sass/platform.rb
57
+ - ext/sass/sass-1.100.0.tgz
58
+ - ext/sass/sass_config.rb
59
+ - ext/sass/utils.rb
64
60
  - lib/sass-embedded.rb
65
61
  - lib/sass/calculation_value.rb
66
62
  - lib/sass/calculation_value/calculation_operation.rb
@@ -75,14 +71,16 @@ files:
75
71
  - lib/sass/compiler/host/importer_registry.rb
76
72
  - lib/sass/compiler/host/logger_registry.rb
77
73
  - lib/sass/compiler/host/protofier.rb
78
- - lib/sass/compiler/host/structifier.rb
74
+ - lib/sass/compiler/host/struct.rb
79
75
  - lib/sass/compiler/varint.rb
80
76
  - lib/sass/elf.rb
81
77
  - lib/sass/embedded.rb
82
78
  - lib/sass/embedded/version.rb
83
79
  - lib/sass/embedded_protocol.rb
80
+ - lib/sass/embedded_sass_pb.rb
84
81
  - lib/sass/exception.rb
85
82
  - lib/sass/fork_tracker.rb
83
+ - lib/sass/gem_package_importer.rb
86
84
  - lib/sass/logger/silent.rb
87
85
  - lib/sass/logger/source_location.rb
88
86
  - lib/sass/logger/source_span.rb
@@ -93,6 +91,31 @@ files:
93
91
  - lib/sass/value/boolean.rb
94
92
  - lib/sass/value/calculation.rb
95
93
  - lib/sass/value/color.rb
94
+ - lib/sass/value/color/channel.rb
95
+ - lib/sass/value/color/conversions.rb
96
+ - lib/sass/value/color/gamut_map_method.rb
97
+ - lib/sass/value/color/gamut_map_method/clip.rb
98
+ - lib/sass/value/color/gamut_map_method/local_minde.rb
99
+ - lib/sass/value/color/interpolation_method.rb
100
+ - lib/sass/value/color/space.rb
101
+ - lib/sass/value/color/space/a98_rgb.rb
102
+ - lib/sass/value/color/space/display_p3.rb
103
+ - lib/sass/value/color/space/display_p3_linear.rb
104
+ - lib/sass/value/color/space/hsl.rb
105
+ - lib/sass/value/color/space/hwb.rb
106
+ - lib/sass/value/color/space/lab.rb
107
+ - lib/sass/value/color/space/lch.rb
108
+ - lib/sass/value/color/space/lms.rb
109
+ - lib/sass/value/color/space/oklab.rb
110
+ - lib/sass/value/color/space/oklch.rb
111
+ - lib/sass/value/color/space/prophoto_rgb.rb
112
+ - lib/sass/value/color/space/rec2020.rb
113
+ - lib/sass/value/color/space/rgb.rb
114
+ - lib/sass/value/color/space/srgb.rb
115
+ - lib/sass/value/color/space/srgb_linear.rb
116
+ - lib/sass/value/color/space/utils.rb
117
+ - lib/sass/value/color/space/xyz_d50.rb
118
+ - lib/sass/value/color/space/xyz_d65.rb
96
119
  - lib/sass/value/function.rb
97
120
  - lib/sass/value/fuzzy_math.rb
98
121
  - lib/sass/value/list.rb
@@ -107,11 +130,10 @@ licenses:
107
130
  - MIT
108
131
  metadata:
109
132
  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
133
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.100.0
134
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.100.0
112
135
  funding_uri: https://github.com/sponsors/ntkme
113
136
  rubygems_mfa_required: 'true'
114
- post_install_message:
115
137
  rdoc_options: []
116
138
  require_paths:
117
139
  - lib
@@ -126,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
148
  - !ruby/object:Gem::Version
127
149
  version: '0'
128
150
  requirements: []
129
- rubygems_version: 3.5.11
130
- signing_key:
151
+ rubygems_version: 4.0.12
131
152
  specification_version: 4
132
153
  summary: Use dart-sass with Ruby!
133
154
  test_files: []
@@ -1 +0,0 @@
1
- Expand-Archive @args
@@ -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