sass-embedded 1.79.3 → 1.79.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/exe/sass +1 -9
  3. data/ext/sass/Rakefile +49 -16
  4. data/ext/sass/package.json +1 -1
  5. data/lib/sass/compiler/connection.rb +1 -9
  6. data/lib/sass/compiler/host/protofier.rb +16 -55
  7. data/lib/sass/elf.rb +4 -4
  8. data/lib/sass/embedded/version.rb +1 -1
  9. data/lib/sass/value/color/channel.rb +79 -0
  10. data/lib/sass/value/color/conversions.rb +464 -0
  11. data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
  12. data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
  13. data/lib/sass/value/color/gamut_map_method.rb +45 -0
  14. data/lib/sass/value/color/interpolation_method.rb +51 -0
  15. data/lib/sass/value/color/space/a98_rgb.rb +57 -0
  16. data/lib/sass/value/color/space/display_p3.rb +57 -0
  17. data/lib/sass/value/color/space/hsl.rb +65 -0
  18. data/lib/sass/value/color/space/hwb.rb +70 -0
  19. data/lib/sass/value/color/space/lab.rb +77 -0
  20. data/lib/sass/value/color/space/lch.rb +53 -0
  21. data/lib/sass/value/color/space/lms.rb +129 -0
  22. data/lib/sass/value/color/space/oklab.rb +66 -0
  23. data/lib/sass/value/color/space/oklch.rb +54 -0
  24. data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
  25. data/lib/sass/value/color/space/rec2020.rb +69 -0
  26. data/lib/sass/value/color/space/rgb.rb +52 -0
  27. data/lib/sass/value/color/space/srgb.rb +141 -0
  28. data/lib/sass/value/color/space/srgb_linear.rb +72 -0
  29. data/lib/sass/value/color/space/utils.rb +86 -0
  30. data/lib/sass/value/color/space/xyz_d50.rb +100 -0
  31. data/lib/sass/value/color/space/xyz_d65.rb +57 -0
  32. data/lib/sass/value/color/space.rb +198 -0
  33. data/lib/sass/value/color.rb +537 -162
  34. data/lib/sass/value/fuzzy_math.rb +30 -3
  35. data/lib/sass/value/string.rb +1 -1
  36. metadata +29 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31cfb8ec747af7e5d755f61dd9bd5d8ff9318b5c357ba5eb8b314377ae7f345f
4
- data.tar.gz: 9af64e39fecc2bdd5678412be80f8d600461edd2e3e5f5b927cb33a3ec54b02f
3
+ metadata.gz: 8db358ac19921c383272d4a02ff53e84248977328b6de28a79b5ff59712751e7
4
+ data.tar.gz: 4e7775f23fdc5ca6bfa6c9f2f662cc4604af0bb518f4ae9271508885475f6a2b
5
5
  SHA512:
6
- metadata.gz: fc936183c3a246211baa54eb1dfd4dc29662d960223f31435eefc59f2ae9067680d7f3337efbafa050f6ed4c12deba9c4badd61f5714801d142aa71cd1c8fb18
7
- data.tar.gz: e9722d935946af7fffc630689d3b4ca0bd57cf4af7917f432075327ed3e08c8b0a19db304708f8d8c40b2cfb589bd51b28f50155e3e58e5ec207528c45710307
6
+ metadata.gz: f351bf7361aad437a59aee2e0f664b5feace00cd2fc51d0b3f8b054ed2fc123dd4a65ea9c1b35924260c0254d0c2e62483f0dd0bb891c4f5e55fdd5b0c5b756a
7
+ data.tar.gz: 9f2a9ed11b03a09c0bc989101a10293add16ffb062cbd43fa6482a12b6699d7f720974c586489a4641c8e52549d846af9b70040aff500b13fe4b242ae4f8f535
data/exe/sass CHANGED
@@ -6,15 +6,7 @@ require_relative '../ext/sass/cli'
6
6
  module Sass
7
7
  # The `sass` command line interface
8
8
  module CLI
9
- begin
10
- Kernel.exec(*COMMAND, *ARGV)
11
- rescue Errno::ENOENT
12
- require_relative '../lib/sass/elf'
13
-
14
- raise if ELF::INTERPRETER.nil?
15
-
16
- Kernel.exec(ELF::INTERPRETER, *COMMAND, *ARGV)
17
- end
9
+ Kernel.exec(*COMMAND, *ARGV)
18
10
  end
19
11
 
20
12
  private_constant :CLI
data/ext/sass/Rakefile CHANGED
@@ -30,6 +30,8 @@ rescue StandardError
30
30
  end
31
31
 
32
32
  file 'cli.rb' => %w[dart-sass] do |t|
33
+ require_relative '../../lib/sass/elf'
34
+
33
35
  exe = 'dart-sass/sass'
34
36
  exe = "#{exe}#{['', '.bat', '.exe'].find { |ext| File.exist?("#{exe}#{ext}") }}"
35
37
 
@@ -40,27 +42,58 @@ file 'cli.rb' => %w[dart-sass] do |t|
40
42
  snapshot = 'dart-sass/src/sass.snapshot'
41
43
 
42
44
  command = if File.exist?(runtime) && File.exist?(snapshot)
43
- "
44
- File.absolute_path('#{runtime}', __dir__).freeze,
45
- File.absolute_path('#{snapshot}', __dir__).freeze
46
- "
45
+ [runtime, snapshot]
47
46
  else
48
- "
49
- File.absolute_path('#{exe}', __dir__).freeze
50
- "
47
+ [exe]
51
48
  end
52
49
 
53
- File.write(t.name, <<~CLI_RB)
54
- # frozen_string_literal: true
50
+ interpreter = File.open(command[0], 'rb') do |file|
51
+ Sass.const_get(:ELF).new(file).interpreter
52
+ rescue ArgumentError
53
+ nil
54
+ end
55
55
 
56
- module Sass
57
- module CLI
58
- COMMAND = [#{command}].freeze
59
- end
56
+ command_source = command.map do |argument|
57
+ "File.absolute_path('#{argument}', __dir__).freeze"
58
+ end.join(',
59
+ ')
60
60
 
61
- private_constant :CLI
62
- end
63
- CLI_RB
61
+ if interpreter.nil?
62
+ File.write(t.name, <<~CLI_RB)
63
+ # frozen_string_literal: true
64
+
65
+ module Sass
66
+ module CLI
67
+ COMMAND = [
68
+ #{command_source}
69
+ ].freeze
70
+ end
71
+
72
+ private_constant :CLI
73
+ end
74
+ CLI_RB
75
+ else
76
+ File.write(t.name, <<~CLI_RB)
77
+ # frozen_string_literal: true
78
+
79
+ require_relative '../../lib/sass/elf'
80
+
81
+ module Sass
82
+ module CLI
83
+ INTERPRETER = '#{interpreter}'
84
+
85
+ COMMAND = [
86
+ *(ELF::INTERPRETER unless ELF::INTERPRETER.nil? ||
87
+ ELF::INTERPRETER == INTERPRETER ||
88
+ !ELF::INTERPRETER.end_with?(INTERPRETER)),
89
+ #{command_source}
90
+ ].freeze
91
+ end
92
+
93
+ private_constant :CLI
94
+ end
95
+ CLI_RB
96
+ end
64
97
  end
65
98
 
66
99
  file 'embedded_sass.proto' => %w[cli.rb] do |t|
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "dependencies": {
3
- "sass": "1.79.3"
3
+ "sass": "1.79.4"
4
4
  }
5
5
  }
@@ -12,15 +12,7 @@ module Sass
12
12
  class Connection
13
13
  def initialize
14
14
  @mutex = Mutex.new
15
- @stdin, @stdout, @stderr, @wait_thread = begin
16
- Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
17
- rescue Errno::ENOENT
18
- require_relative '../elf'
19
-
20
- raise if ELF::INTERPRETER.nil?
21
-
22
- Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
23
- end
15
+ @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
24
16
 
25
17
  @stdin.binmode
26
18
 
@@ -25,37 +25,15 @@ module Sass
25
25
  number: Number.to_proto(obj)
26
26
  )
27
27
  when Sass::Value::Color
28
- if obj.instance_eval { !defined?(@hue) }
29
- EmbeddedProtocol::Value.new(
30
- color: EmbeddedProtocol::Value::Color.new(
31
- channel1: obj.red,
32
- channel2: obj.green,
33
- channel3: obj.blue,
34
- alpha: obj.alpha.to_f,
35
- space: 'rgb'
36
- )
37
- )
38
- elsif obj.instance_eval { !defined?(@saturation) }
39
- EmbeddedProtocol::Value.new(
40
- color: EmbeddedProtocol::Value::Color.new(
41
- channel1: obj.hue.to_f,
42
- channel2: obj.whiteness.to_f,
43
- channel3: obj.blackness.to_f,
44
- alpha: obj.alpha.to_f,
45
- space: 'hwb'
46
- )
47
- )
48
- else
49
- EmbeddedProtocol::Value.new(
50
- color: EmbeddedProtocol::Value::Color.new(
51
- channel1: obj.hue.to_f,
52
- channel2: obj.saturation.to_f,
53
- channel3: obj.lightness.to_f,
54
- alpha: obj.alpha.to_f,
55
- space: 'hsl'
56
- )
28
+ EmbeddedProtocol::Value.new(
29
+ color: EmbeddedProtocol::Value::Color.new(
30
+ channel1: obj.send(:channel0_or_nil),
31
+ channel2: obj.send(:channel1_or_nil),
32
+ channel3: obj.send(:channel2_or_nil),
33
+ alpha: obj.send(:alpha_or_nil),
34
+ space: obj.space
57
35
  )
58
- end
36
+ )
59
37
  when Sass::Value::ArgumentList
60
38
  EmbeddedProtocol::Value.new(
61
39
  argument_list: EmbeddedProtocol::Value::ArgumentList.new(
@@ -134,31 +112,14 @@ module Sass
134
112
  when :number
135
113
  Number.from_proto(obj)
136
114
  when :color
137
- case obj.space
138
- when 'rgb'
139
- Sass::Value::Color.new(
140
- red: obj.channel1,
141
- green: obj.channel2,
142
- blue: obj.channel3,
143
- alpha: obj.alpha
144
- )
145
- when 'hsl'
146
- Sass::Value::Color.new(
147
- hue: obj.channel1,
148
- saturation: obj.channel2,
149
- lightness: obj.channel3,
150
- alpha: obj.alpha
151
- )
152
- when 'hwb'
153
- Sass::Value::Color.new(
154
- hue: obj.channel1,
155
- whiteness: obj.channel2,
156
- blackness: obj.channel3,
157
- alpha: obj.alpha
158
- )
159
- else
160
- raise NotImplementedError, 'CSS Color Level 4 will be supported in a future release'
161
- end
115
+ Sass::Value::Color.send(
116
+ :for_space,
117
+ obj.space,
118
+ obj.channel1,
119
+ obj.channel2,
120
+ obj.channel3,
121
+ obj.alpha
122
+ )
162
123
  when :argument_list
163
124
  Sass::Value::ArgumentList.new(
164
125
  obj.contents.map do |element|
data/lib/sass/elf.rb CHANGED
@@ -147,7 +147,7 @@ module Sass
147
147
  elf_ehdr = :Elf64_Ehdr
148
148
  elf_phdr = :Elf64_Phdr
149
149
  else
150
- raise ArgumentError
150
+ raise EncodingError
151
151
  end
152
152
 
153
153
  case @ehdr[:e_ident][EI_DATA]
@@ -156,7 +156,7 @@ module Sass
156
156
  when ELFDATA2MSB
157
157
  little_endian = false
158
158
  else
159
- raise ArgumentError
159
+ raise EncodingError
160
160
  end
161
161
 
162
162
  @ehdr.merge!(read(elf_ehdr, little_endian))
@@ -189,7 +189,7 @@ module Sass
189
189
 
190
190
  @buffer.seek(phdr[:p_offset], IO::SEEK_SET)
191
191
  interpreter = @buffer.read(phdr[:p_filesz])
192
- raise ArgumentError unless interpreter.end_with?("\0")
192
+ raise EncodingError unless interpreter.end_with?("\0")
193
193
 
194
194
  interpreter.chomp!("\0")
195
195
  end
@@ -215,7 +215,7 @@ module Sass
215
215
  end
216
216
  end
217
217
  end
218
- end
218
+ end.freeze
219
219
  end
220
220
 
221
221
  private_constant :ELF
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  module Embedded
5
- VERSION = '1.79.3'
5
+ VERSION = '1.79.4'
6
6
  end
7
7
  end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/channel.dart
7
+ class ColorChannel
8
+ # @return [::String]
9
+ attr_reader :name
10
+
11
+ # @return [::Boolean]
12
+ def polar_angle?
13
+ @polar_angle
14
+ end
15
+
16
+ # @return [::String, nil]
17
+ attr_reader :associated_unit
18
+
19
+ # @param name [::String]
20
+ # @param polar_angle [::Boolean]
21
+ # @param associated_unit [::String]
22
+ def initialize(name, polar_angle:, associated_unit: nil)
23
+ @name = name
24
+ @polar_angle = polar_angle
25
+ @associated_unit = associated_unit
26
+ end
27
+
28
+ # @return [::Boolean]
29
+ def analogous?(other)
30
+ case [name, other.name]
31
+ in ['red' | 'x', 'red' | 'x'] |
32
+ ['green' | 'y', 'green' | 'y'] |
33
+ ['blue' | 'z', 'blue' | 'z'] |
34
+ ['chroma' | 'saturation', 'chroma' | 'saturation'] |
35
+ ['lightness', 'lightness'] |
36
+ ['hue', 'hue']
37
+ true
38
+ else
39
+ false
40
+ end
41
+ end
42
+ end
43
+
44
+ private_constant :ColorChannel
45
+
46
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/channel.dart
47
+ class LinearChannel < ColorChannel
48
+ # @return [Numeric]
49
+ attr_reader :min, :max
50
+
51
+ # @return [::Boolean]
52
+ attr_reader :requires_percent, :lower_clamped, :upper_clamped
53
+
54
+ # @param name [::String]
55
+ # @param min [Numeric]
56
+ # @param max [Numeric]
57
+ # @param requires_percent [::Boolean]
58
+ # @param lower_clamped [::Boolean]
59
+ # @param upper_clamped [::Boolean]
60
+ # @param conventionally_percent [::Boolean]
61
+ def initialize(name, min, max, requires_percent: false, lower_clamped: false, upper_clamped: false,
62
+ conventionally_percent: nil)
63
+ super(name,
64
+ polar_angle: false,
65
+ associated_unit: if conventionally_percent.nil? ? (min.zero? && max == 100) : conventionally_percent
66
+ '%'
67
+ end)
68
+ @min = min
69
+ @max = max
70
+ @requires_percent = requires_percent
71
+ @lower_clamped = lower_clamped
72
+ @upper_clamped = upper_clamped
73
+ end
74
+ end
75
+
76
+ private_constant :LinearChannel
77
+ end
78
+ end
79
+ end