sass-embedded 1.63.6-x86-linux-musl → 1.64.0-x86-linux-musl

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: ad82a74f03966b463e1851c3196fdff54b3cf52eb6d56b92f2e621e6067a2f9d
4
- data.tar.gz: 8c289c2b4b1cf4fd080e20440b078dd9579f0b4f58b1b142eb96af8d2c6e7323
3
+ metadata.gz: 046e2ebfb27e8bb4206544e8f7d4e406b1f174e222d7500c43099dd7925f2b73
4
+ data.tar.gz: 1b4fa97dbe7a204f7ff87fdbe7fc6028bd02ba35a906666968a0b1666fe7ee3f
5
5
  SHA512:
6
- metadata.gz: 6942d8eb2fce14e5b971ec1a8fac66811c600e7b3e9c72ab7386f12487225264a88663a62e447dd4afc1ac36ff9990f955ef9856d6c416304b9c74651b7edd6e
7
- data.tar.gz: f78678a1759b5f9721a504288c22d5fa4c8da7df86d1a74d2502514093de5ed50904e67c143fb2eb6ae3eeac63d91f6b44bf1ccd0486b0258d06ede0f423c47e
6
+ metadata.gz: 0124d703fedaf6a48074e5ec099071797394aca1917d4253c91fcfd66ca7e96a0efad7e8e9b05af325b0c0471bddcf736b8257889463e599861fde9968232241
7
+ data.tar.gz: 5680760dff94f9426358255a8532dd6b971f409c8941fd3e668c7d4fa0755bf40c66a5a6c34cabea6c3709b8c9b427f37889b37b25161ce77583783e2f532db5
Binary file
Binary file
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module CalculationValue
5
+ # A string injected into a SassCalculation using interpolation.
6
+ #
7
+ # @see https://sass-lang.com/documentation/js-api/classes/calculationinterpolation/
8
+ class CalculationInterpolation
9
+ include CalculationValue
10
+
11
+ # @param value [::String]
12
+ def initialize(value)
13
+ @value = value
14
+ end
15
+
16
+ # @return [::String]
17
+ attr_reader :value
18
+
19
+ # @return [::Boolean]
20
+ def ==(other)
21
+ other.is_a?(Sass::CalculationValue::CalculationInterpolation) &&
22
+ other.value == value
23
+ end
24
+
25
+ # @return [Integer]
26
+ def hash
27
+ @hash ||= value.hash
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module CalculationValue
5
+ # A binary operation that can appear in a SassCalculation.
6
+ #
7
+ # @see https://sass-lang.com/documentation/js-api/classes/calculationoperation/
8
+ class CalculationOperation
9
+ include CalculationValue
10
+
11
+ OPERATORS = ['+', '-', '*', '/'].freeze
12
+
13
+ private_constant :OPERATORS
14
+
15
+ # @param operator [::String]
16
+ # @param left [CalculationValue]
17
+ # @param right [CalculationValue]
18
+ def initialize(operator, left, right)
19
+ raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator)
20
+
21
+ left.assert_calculation_value
22
+ right.assert_calculation_value
23
+
24
+ @operator = operator.freeze
25
+ @left = left.freeze
26
+ @right = right.freeze
27
+ end
28
+
29
+ # @return [::String]
30
+ attr_reader :operator
31
+
32
+ # @return [CalculationValue]
33
+ attr_reader :left
34
+
35
+ # @return [CalculationValue]
36
+ attr_reader :right
37
+
38
+ # @return [::Boolean]
39
+ def ==(other)
40
+ other.is_a?(Sass::CalculationValue::CalculationOperation) &&
41
+ other.operator == operator &&
42
+ other.left == left &&
43
+ other.right == right
44
+ end
45
+
46
+ # @return [Integer]
47
+ def hash
48
+ @hash ||= [operator, left, right].hash
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ # The type of values that can be arguments to a SassCalculation.
5
+ #
6
+ # @see https://sass-lang.com/documentation/js-api/types/calculationvalue/
7
+ module CalculationValue
8
+ # @return [CalculationValue]
9
+ # @raise [ScriptError]
10
+ def assert_calculation_value(_name = nil)
11
+ self
12
+ end
13
+ end
14
+ end
15
+
16
+ require_relative 'calculation_value/calculation_interpolation'
17
+ require_relative 'calculation_value/calculation_operation'
@@ -3,7 +3,7 @@
3
3
  module Sass
4
4
  # The result of compiling Sass to CSS. Returned by {Sass.compile} and {Sass.compile_string}.
5
5
  #
6
- # @see https://sass-lang.com/documentation/js-api/interfaces/CompileResult
6
+ # @see https://sass-lang.com/documentation/js-api/interfaces/compileresult/
7
7
  class CompileResult
8
8
  # @return [String]
9
9
  attr_reader :css
@@ -47,13 +47,11 @@ module Sass
47
47
  end
48
48
 
49
49
  success = value_protofier.to_proto(get(function_call_request).call(arguments))
50
- accessed_argument_lists = arguments
51
- .select do |argument|
52
- argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval do
53
- @keywords_accessed
54
- end
55
- end
56
- .map { |argument| argument.instance_eval { @id } }
50
+ accessed_argument_lists = arguments.filter_map do |argument|
51
+ if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed }
52
+ argument.instance_eval { @id }
53
+ end
54
+ end
57
55
 
58
56
  EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
59
57
  id: function_call_request.id,
@@ -22,11 +22,7 @@ module Sass
22
22
  )
23
23
  when Sass::Value::Number
24
24
  EmbeddedProtocol::Value.new(
25
- number: EmbeddedProtocol::Value::Number.new(
26
- value: obj.value.to_f,
27
- numerators: obj.numerator_units,
28
- denominators: obj.denominator_units
29
- )
25
+ number: Number.to_proto(obj)
30
26
  )
31
27
  when Sass::Value::Color
32
28
  if obj.instance_eval { !defined?(@hue) }
@@ -100,6 +96,10 @@ module Sass
100
96
  )
101
97
  )
102
98
  end
99
+ when Sass::Value::Calculation
100
+ EmbeddedProtocol::Value.new(
101
+ calculation: Calculation.to_proto(obj)
102
+ )
103
103
  when Sass::Value::Boolean
104
104
  EmbeddedProtocol::Value.new(
105
105
  singleton: obj.value ? :TRUE : :FALSE
@@ -123,12 +123,7 @@ module Sass
123
123
  quoted: obj.quoted
124
124
  )
125
125
  when :number
126
- Sass::Value::Number.new(
127
- obj.value, {
128
- numerator_units: obj.numerators.to_a,
129
- denominator_units: obj.denominators.to_a
130
- }
131
- )
126
+ Number.from_proto(obj)
132
127
  when :rgb_color
133
128
  Sass::Value::Color.new(
134
129
  red: obj.red,
@@ -181,6 +176,8 @@ module Sass
181
176
  Sass::Value::Function.new(obj.id)
182
177
  when :host_function
183
178
  raise Sass::ScriptError, 'The compiler may not send Value.host_function to host'
179
+ when :calculation
180
+ Calculation.from_proto(obj)
184
181
  when :singleton
185
182
  case obj
186
183
  when :TRUE
@@ -197,6 +194,178 @@ module Sass
197
194
  end
198
195
  end
199
196
 
197
+ # The {Number} Protofier.
198
+ module Number
199
+ module_function
200
+
201
+ def to_proto(obj)
202
+ EmbeddedProtocol::Value::Number.new(
203
+ value: obj.value.to_f,
204
+ numerators: obj.numerator_units,
205
+ denominators: obj.denominator_units
206
+ )
207
+ end
208
+
209
+ def from_proto(obj)
210
+ Sass::Value::Number.new(
211
+ obj.value, {
212
+ numerator_units: obj.numerators.to_a,
213
+ denominator_units: obj.denominators.to_a
214
+ }
215
+ )
216
+ end
217
+ end
218
+
219
+ private_constant :Number
220
+
221
+ # The {Calculation} Protofier.
222
+ module Calculation
223
+ module_function
224
+
225
+ def to_proto(obj)
226
+ EmbeddedProtocol::Value::Calculation.new(
227
+ name: obj.name,
228
+ arguments: obj.arguments.map { |argument| CalculationValue.to_proto(argument) }
229
+ )
230
+ end
231
+
232
+ def from_proto(obj)
233
+ case obj.name
234
+ when 'calc'
235
+ if obj.arguments.length != 1
236
+ raise Sass::ScriptError,
237
+ 'Value.Calculation.arguments must have exactly one argument for calc().'
238
+ end
239
+
240
+ Sass::Value::Calculation.calc(*obj.arguments.map { |argument| CalculationValue.from_proto(argument) })
241
+ when 'clamp'
242
+ if obj.arguments.length != 3
243
+ raise Sass::ScriptError,
244
+ 'Value.Calculation.arguments must have exactly 3 arguments for clamp().'
245
+ end
246
+
247
+ Sass::Value::Calculation.clamp(*obj.arguments.map { |argument| CalculationValue.from_proto(argument) })
248
+ when 'min'
249
+ if obj.arguments.empty?
250
+ raise Sass::ScriptError,
251
+ 'Value.Calculation.arguments must have at least 1 argument for min().'
252
+ end
253
+
254
+ Sass::Value::Calculation.min(obj.arguments.map { |argument| CalculationValue.from_proto(argument) })
255
+ when 'max'
256
+ if obj.arguments.empty?
257
+ raise Sass::ScriptError,
258
+ 'Value.Calculation.arguments must have at least 1 argument for max().'
259
+ end
260
+
261
+ Sass::Value::Calculation.max(obj.arguments.map { |argument| CalculationValue.from_proto(argument) })
262
+ else
263
+ raise Sass::ScriptError,
264
+ "Value.Calculation.name #{calculation.name.inspect} is not a recognized calculation type."
265
+ end
266
+ end
267
+ end
268
+
269
+ private_constant :Calculation
270
+
271
+ # The {CalculationValue} Protofier.
272
+ module CalculationValue
273
+ module_function
274
+
275
+ def to_proto(value)
276
+ case value
277
+ when Sass::Value::Number
278
+ EmbeddedProtocol::Value::Calculation::CalculationValue.new(
279
+ number: Number.to_proto(value)
280
+ )
281
+ when Sass::Value::Calculation
282
+ EmbeddedProtocol::Value::Calculation::CalculationValue.new(
283
+ calculation: Calculation.to_proto(value)
284
+ )
285
+ when Sass::Value::String
286
+ EmbeddedProtocol::Value::Calculation::CalculationValue.new(
287
+ string: value.text
288
+ )
289
+ when Sass::CalculationValue::CalculationOperation
290
+ EmbeddedProtocol::Value::Calculation::CalculationValue.new(
291
+ operation: EmbeddedProtocol::Value::Calculation::CalculationOperation.new(
292
+ operator: CalculationOperator.to_proto(value.operator),
293
+ left: to_proto(value.left),
294
+ right: to_proto(value.right)
295
+ )
296
+ )
297
+ when Sass::CalculationValue::CalculationInterpolation
298
+ EmbeddedProtocol::Value::Calculation::CalculationValue.new(
299
+ interpolation: value.value
300
+ )
301
+ else
302
+ raise Sass::ScriptError, "Unknown CalculationValue #{value}"
303
+ end
304
+ end
305
+
306
+ def from_proto(value)
307
+ oneof = value.value
308
+ obj = value.public_send(oneof)
309
+ case oneof
310
+ when :number
311
+ Number.from_proto(obj)
312
+ when :calculation
313
+ Calculation.from_proto(obj)
314
+ when :string
315
+ Sass::Value::String.new(obj, quoted: false)
316
+ when :operation
317
+ Sass::CalculationValue::CalculationOperation.new(
318
+ CalculationOperator.from_proto(obj.operator),
319
+ from_proto(obj.left),
320
+ from_proto(obj.right)
321
+ )
322
+ when :interpolation
323
+ Sass::CalculationValue::CalculationInterpolation.new(obj)
324
+ else
325
+ raise Sass::ScriptError, "Unknown CalculationValue #{value}"
326
+ end
327
+ end
328
+ end
329
+
330
+ private_constant :CalculationValue
331
+
332
+ # The {CalculationOperator} Protofier.
333
+ module CalculationOperator
334
+ module_function
335
+
336
+ def to_proto(operator)
337
+ case operator
338
+ when '+'
339
+ :PLUS
340
+ when '-'
341
+ :MINUS
342
+ when '*'
343
+ :TIMES
344
+ when '/'
345
+ :DIVIDE
346
+ else
347
+ raise Sass::ScriptError, "Unknown CalculationOperator #{separator}"
348
+ end
349
+ end
350
+
351
+ def from_proto(operator)
352
+ case operator
353
+ when :PLUS
354
+ '+'
355
+ when :MINUS
356
+ '-'
357
+ when :TIMES
358
+ '*'
359
+ when :DIVIDE
360
+ '/'
361
+ else
362
+ raise Sass::ScriptError, "Unknown CalculationOperator #{separator}"
363
+ end
364
+ end
365
+ end
366
+
367
+ private_constant :CalculationOperator
368
+
200
369
  # The {ListSeparator} Protofier.
201
370
  module ListSeparator
202
371
  module_function
@@ -86,7 +86,13 @@ module Sass
86
86
  end
87
87
 
88
88
  def error(message)
89
- @error = message
89
+ if message.is_a?(EmbeddedProtocol::ProtocolError)
90
+ return if message.id != id
91
+
92
+ @error = Errno::EPROTO.new(message.message)
93
+ else
94
+ @error = message
95
+ end
90
96
  @queue.close
91
97
  end
92
98
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.63.6'
5
+ VERSION = '1.64.0'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -95,7 +95,7 @@ module Sass
95
95
  # Compiles the Sass file at +path+ to CSS.
96
96
  # @param path [String]
97
97
  # @param load_paths [Array<String>] Paths in which to look for stylesheets loaded by rules like
98
- # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import].
98
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
99
99
  # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+
100
100
  # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to
101
101
  # browsers or other consumers. If +charset+ is +false+, these annotations are omitted.
@@ -104,7 +104,7 @@ module Sass
104
104
  # @param style [String, Symbol] The OutputStyle of the compiled CSS.
105
105
  # @param functions [Hash<String, Proc>] Additional built-in Sass functions that are available in all stylesheets.
106
106
  # @param importers [Array<Object>] Custom importers that control how Sass resolves loads from rules like
107
- # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import].
107
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
108
108
  # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error
109
109
  # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well.
110
110
  # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and
@@ -119,7 +119,7 @@ module Sass
119
119
  # deprecation warning it encounters.
120
120
  # @return [CompileResult]
121
121
  # @raise [CompileError]
122
- # @see https://sass-lang.com/documentation/js-api/modules#compile
122
+ # @see https://sass-lang.com/documentation/js-api/functions/compile/
123
123
  def compile(path,
124
124
  load_paths: [],
125
125
 
@@ -163,7 +163,7 @@ module Sass
163
163
  # @param source [String]
164
164
  # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet.
165
165
  # @param load_paths [Array<String>] Paths in which to look for stylesheets loaded by rules like
166
- # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import].
166
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
167
167
  # @param syntax [String, Symbol] The Syntax to use to parse the entrypoint stylesheet.
168
168
  # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's
169
169
  # used to resolve relative loads in the entrypoint stylesheet.
@@ -175,7 +175,7 @@ module Sass
175
175
  # @param style [String, Symbol] The OutputStyle of the compiled CSS.
176
176
  # @param functions [Hash<String, Proc>] Additional built-in Sass functions that are available in all stylesheets.
177
177
  # @param importers [Array<Object>] Custom importers that control how Sass resolves loads from rules like
178
- # {@use}[https://sass-lang.com/documentation/at-rules/use] and {@import}[https://sass-lang.com/documentation/at-rules/import].
178
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
179
179
  # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error
180
180
  # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well.
181
181
  # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and
@@ -190,7 +190,7 @@ module Sass
190
190
  # deprecation warning it encounters.
191
191
  # @return [CompileResult]
192
192
  # @raise [CompileError]
193
- # @see https://sass-lang.com/documentation/js-api/modules#compileString
193
+ # @see https://sass-lang.com/documentation/js-api/functions/compilestring/
194
194
  def compile_string(source,
195
195
  importer: nil,
196
196
  load_paths: [],
@@ -234,7 +234,7 @@ module Sass
234
234
  end
235
235
 
236
236
  # @return [String] Information about the Sass implementation.
237
- # @see https://sass-lang.com/documentation/js-api/modules#info
237
+ # @see https://sass-lang.com/documentation/js-api/variables/info/
238
238
  def info
239
239
  @info ||= Host.new(@dispatcher).version_request
240
240
  end
@@ -3,11 +3,13 @@
3
3
  module Sass
4
4
  # A namespace for built-in Loggers.
5
5
  #
6
- # @see https://sass-lang.com/documentation/js-api/modules/Logger
6
+ # @see https://sass-lang.com/documentation/js-api/modules/logger/
7
7
  module Logger
8
8
  module_function
9
9
 
10
10
  # A Logger that silently ignores all warnings and debug messages.
11
+ #
12
+ # @see https://sass-lang.com/documentation/js-api/variables/logger.silent/
11
13
  def silent
12
14
  Silent
13
15
  end
@@ -6,7 +6,7 @@ module Sass
6
6
  #
7
7
  # This is always associated with a {SourceSpan} which indicates which file it refers to.
8
8
  #
9
- # @see https://sass-lang.com/documentation/js-api/interfaces/SourceLocation
9
+ # @see https://sass-lang.com/documentation/js-api/interfaces/sourcelocation/
10
10
  class SourceLocation
11
11
  # @return [Integer]
12
12
  attr_reader :offset, :line, :column
@@ -4,7 +4,7 @@ module Sass
4
4
  module Logger
5
5
  # A span of text within a source file.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/interfaces/SourceSpan
7
+ # @see https://sass-lang.com/documentation/js-api/interfaces/sourcespan/
8
8
  class SourceSpan
9
9
  # @return [SourceLocation]
10
10
  attr_reader :start, :end
@@ -7,7 +7,7 @@ module Sass
7
7
  # An argument list comes from a rest argument. It's distinct from a normal {List} in that it may contain a keyword
8
8
  # map as well as the positional arguments.
9
9
  #
10
- # @see https://sass-lang.com/documentation/js-api/classes/SassArgumentList
10
+ # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/
11
11
  class ArgumentList < Value::List
12
12
  # @param contents [Array<Value>]
13
13
  # @param keywords [Hash<::String, Value>]
@@ -4,7 +4,7 @@ module Sass
4
4
  module Value
5
5
  # Sass's boolean type.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/classes/SassBoolean
7
+ # @see https://sass-lang.com/documentation/js-api/classes/sassboolean/
8
8
  class Boolean
9
9
  include Value
10
10
 
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ # Sass's calculation type.
6
+ #
7
+ # @see https://sass-lang.com/documentation/js-api/classes/sasscalculation/
8
+ class Calculation
9
+ include Value
10
+ include CalculationValue
11
+
12
+ def initialize(name, arguments)
13
+ @name = name.freeze
14
+ @arguments = arguments.freeze
15
+ end
16
+
17
+ # @return [::String]
18
+ attr_reader :name
19
+
20
+ # @return [Array<CalculationValue>]
21
+ attr_reader :arguments
22
+
23
+ private_class_method :new
24
+
25
+ class << self
26
+ # @param argument [CalculationValue]
27
+ # @return [Calculation]
28
+ def calc(argument)
29
+ argument.assert_calculation_value
30
+ new('calc', [argument])
31
+ end
32
+
33
+ # @param arguments [Array<CalculationValue>]
34
+ # @return [Calculation]
35
+ def min(arguments)
36
+ arguments.each(&:assert_calculation_value)
37
+ new('min', arguments)
38
+ end
39
+
40
+ # @param arguments [Array<CalculationValue>]
41
+ # @return [Calculation]
42
+ def max(arguments)
43
+ arguments.each(&:assert_calculation_value)
44
+ new('max', arguments)
45
+ end
46
+
47
+ # @param min [CalculationValue]
48
+ # @param value [CalculationValue]
49
+ # @param max [CalculationValue]
50
+ # @return [Calculation]
51
+ def clamp(min, value = nil, max = nil)
52
+ if (value.nil? && !valid_clamp_arg?(min)) ||
53
+ (max.nil? && [min, value].none? { |x| x && valid_clamp_arg?(x) })
54
+ raise Sass::ScriptError, 'Argument must be an unquoted SassString or CalculationInterpolation.'
55
+ end
56
+
57
+ arguments = [min]
58
+ arguments.push(value) unless value.nil?
59
+ arguments.push(max) unless max.nil?
60
+ arguments.each(&:assert_calculation_value)
61
+ new('clamp', arguments)
62
+ end
63
+
64
+ private
65
+
66
+ def valid_clamp_arg?(value)
67
+ value.is_a?(Sass::CalculationValue::CalculationInterpolation) ||
68
+ (value.is_a?(Sass::Value::String) && !value.quoted?)
69
+ end
70
+ end
71
+
72
+ # @return [Calculation]
73
+ def assert_calculation(_name = nil)
74
+ self
75
+ end
76
+
77
+ # @return [::Boolean]
78
+ def ==(other)
79
+ other.is_a?(Sass::Value::Calculation) &&
80
+ other.name == name &&
81
+ other.arguments == arguments
82
+ end
83
+
84
+ # @return [Integer]
85
+ def hash
86
+ @hash ||= [name, *arguments].hash
87
+ end
88
+ end
89
+ end
90
+ end
@@ -6,7 +6,7 @@ module Sass
6
6
  #
7
7
  # No matter what representation was originally used to create this color, all of its channels are accessible.
8
8
  #
9
- # @see https://sass-lang.com/documentation/js-api/classes/SassColor
9
+ # @see https://sass-lang.com/documentation/js-api/classes/sasscolor/
10
10
  class Color
11
11
  include Value
12
12
 
@@ -4,7 +4,7 @@ module Sass
4
4
  module Value
5
5
  # Sass's function type.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/classes/SassFunction
7
+ # @see https://sass-lang.com/documentation/js-api/classes/sassfunction/
8
8
  class Function
9
9
  include Value
10
10
 
@@ -4,7 +4,7 @@ module Sass
4
4
  module Value
5
5
  # Sass's list type.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/classes/SassList
7
+ # @see https://sass-lang.com/documentation/js-api/classes/sasslist/
8
8
  class List
9
9
  include Value
10
10
 
@@ -4,7 +4,7 @@ module Sass
4
4
  module Value
5
5
  # Sass's map type.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/classes/SassMap
7
+ # @see https://sass-lang.com/documentation/js-api/classes/sassmap/
8
8
  class Map
9
9
  include Value
10
10
 
@@ -4,7 +4,7 @@ module Sass
4
4
  module Value
5
5
  # Sass's null type.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/modules#sassNull
7
+ # @see https://sass-lang.com/documentation/js-api/variables/sassnull/
8
8
  class Null
9
9
  include Value
10
10
 
@@ -6,9 +6,10 @@ module Sass
6
6
  module Value
7
7
  # Sass's number type.
8
8
  #
9
- # @see https://sass-lang.com/documentation/js-api/classes/SassNumber
9
+ # @see https://sass-lang.com/documentation/js-api/classes/sassnumber/
10
10
  class Number
11
11
  include Value
12
+ include CalculationValue
12
13
 
13
14
  # @param value [Numeric]
14
15
  # @param unit [::String, Hash]
@@ -4,9 +4,10 @@ module Sass
4
4
  module Value
5
5
  # Sass's string type.
6
6
  #
7
- # @see https://sass-lang.com/documentation/js-api/classes/SassString
7
+ # @see https://sass-lang.com/documentation/js-api/classes/sassstring/
8
8
  class String
9
9
  include Value
10
+ include CalculationValue
10
11
 
11
12
  # @param text [::String]
12
13
  # @param quoted [::Boolean]
@@ -38,6 +39,14 @@ module Sass
38
39
  self
39
40
  end
40
41
 
42
+ # @return [CalculationValue]
43
+ # @raise [ScriptError]
44
+ def assert_calculation_value(_name = nil)
45
+ raise Sass::ScriptError, "Expected #{self} to be an unquoted string." if quoted?
46
+
47
+ self
48
+ end
49
+
41
50
  # @param sass_index [Number]
42
51
  # @return [Integer]
43
52
  def sass_index_to_string_index(sass_index, name = nil)
data/lib/sass/value.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'calculation_value'
3
4
  require_relative 'script_error'
4
5
 
5
6
  module Sass
6
7
  # The abstract base class of Sass's value types.
7
8
  #
8
- # @see https://sass-lang.com/documentation/js-api/classes/Value
9
+ # @see https://sass-lang.com/documentation/js-api/classes/value/
9
10
  module Value
10
11
  # @return [::String, nil]
11
12
  def separator
@@ -60,11 +61,18 @@ module Sass
60
61
  raise Sass::ScriptError.new("#{self} is not a boolean", name)
61
62
  end
62
63
 
64
+ # @return [Calculation]
63
65
  # @raise [ScriptError]
64
66
  def assert_calculation(name = nil)
65
67
  raise Sass::ScriptError.new("#{self} is not a calculation", name)
66
68
  end
67
69
 
70
+ # @return [CalculationValue]
71
+ # @raise [ScriptError]
72
+ def assert_calculation_value(name = nil)
73
+ raise Sass::ScriptError.new("#{self} is not a calculation value", name)
74
+ end
75
+
68
76
  # @return [Color]
69
77
  # @raise [ScriptError]
70
78
  def assert_color(name = nil)
@@ -119,6 +127,7 @@ end
119
127
  require_relative 'value/list'
120
128
  require_relative 'value/argument_list'
121
129
  require_relative 'value/boolean'
130
+ require_relative 'value/calculation'
122
131
  require_relative 'value/color'
123
132
  require_relative 'value/function'
124
133
  require_relative 'value/fuzzy_math'
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.63.6
4
+ version: 1.64.0
5
5
  platform: x86-linux-musl
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-21 00:00:00.000000000 Z
11
+ date: 2023-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -42,8 +42,10 @@ files:
42
42
  - ext/sass/dart-sass/src/dart
43
43
  - ext/sass/dart-sass/src/sass.snapshot
44
44
  - ext/sass/embedded_sass_pb.rb
45
- - ext/sass/win32_api.rb
46
45
  - lib/sass-embedded.rb
46
+ - lib/sass/calculation_value.rb
47
+ - lib/sass/calculation_value/calculation_interpolation.rb
48
+ - lib/sass/calculation_value/calculation_operation.rb
47
49
  - lib/sass/compile_error.rb
48
50
  - lib/sass/compile_result.rb
49
51
  - lib/sass/elf.rb
@@ -68,6 +70,7 @@ files:
68
70
  - lib/sass/value.rb
69
71
  - lib/sass/value/argument_list.rb
70
72
  - lib/sass/value/boolean.rb
73
+ - lib/sass/value/calculation.rb
71
74
  - lib/sass/value/color.rb
72
75
  - lib/sass/value/function.rb
73
76
  - lib/sass/value/fuzzy_math.rb
@@ -81,8 +84,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
81
84
  licenses:
82
85
  - MIT
83
86
  metadata:
84
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.63.6
85
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.63.6
87
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.64.0
88
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.64.0
86
89
  funding_uri: https://github.com/sponsors/ntkme
87
90
  post_install_message:
88
91
  rdoc_options: []
@@ -92,14 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
95
  requirements:
93
96
  - - ">="
94
97
  - !ruby/object:Gem::Version
95
- version: 2.7.0
98
+ version: 3.0.0
96
99
  required_rubygems_version: !ruby/object:Gem::Requirement
97
100
  requirements:
98
101
  - - ">="
99
102
  - !ruby/object:Gem::Version
100
103
  version: 3.3.22
101
104
  requirements: []
102
- rubygems_version: 3.4.14
105
+ rubygems_version: 3.4.17
103
106
  signing_key:
104
107
  specification_version: 4
105
108
  summary: Use dart-sass with Ruby!
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fiddle'
4
-
5
- # @!visibility private
6
- # @see https://learn.microsoft.com/en-us/windows/win32/api/
7
- module Win32API
8
- Kernel32 = Fiddle.dlopen('Kernel32.dll')
9
-
10
- # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
11
- module ImageFileMachineConstants
12
- IMAGE_FILE_MACHINE_I386 = 0x014c
13
- IMAGE_FILE_MACHINE_ARMNT = 0x01c4
14
- IMAGE_FILE_MACHINE_AMD64 = 0x8664
15
- IMAGE_FILE_MACHINE_ARM64 = 0xaa64
16
- end
17
-
18
- private_constant :ImageFileMachineConstants
19
-
20
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes
21
- module MachineAttributes
22
- USER_ENABLED = 0x00000001
23
- KERNEL_ENABLED = 0x00000002
24
- WOW64_CONTAINER = 0x00000004
25
- end
26
-
27
- private_constant :MachineAttributes
28
-
29
- # Specifies the ways in which an architecture of code can run on a host operating system.
30
- class MachineTypeAttributes
31
- def initialize(machine_type_attributes)
32
- @machine_type_attributes = machine_type_attributes
33
- end
34
-
35
- # The specified architecture of code can run in user mode.
36
- def user_enabled?
37
- @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED
38
- end
39
-
40
- # The specified architecture of code can run in kernel mode.
41
- def kernel_enabled?
42
- @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED
43
- end
44
-
45
- # The specified architecture of code runs on WOW64.
46
- def wow64_container?
47
- @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER
48
- end
49
- end
50
-
51
- private_constant :MachineTypeAttributes
52
-
53
- class << self
54
- def x86?
55
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled?
56
- end
57
-
58
- def arm?
59
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled?
60
- end
61
-
62
- def x64?
63
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled?
64
- end
65
-
66
- def arm64?
67
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled?
68
- end
69
-
70
- private
71
-
72
- begin
73
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes
74
- GetMachineTypeAttributes = Fiddle::Function.new(
75
- Kernel32['GetMachineTypeAttributes'],
76
- [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
77
- Fiddle::TYPE_LONG
78
- )
79
-
80
- def get_machine_type_attributes(machine)
81
- p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
82
- raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero?
83
-
84
- MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i'))
85
- end
86
- rescue Fiddle::DLError
87
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess
88
- GetCurrentProcess = Fiddle::Function.new(
89
- Kernel32['GetCurrentProcess'],
90
- [],
91
- Fiddle::TYPE_VOIDP
92
- )
93
-
94
- # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2
95
- IsWow64Process2 = Fiddle::Function.new(
96
- Kernel32['IsWow64Process2'],
97
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
98
- Fiddle::TYPE_CHAR
99
- )
100
-
101
- # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported
102
- IsWow64GuestMachineSupported = Fiddle::Function.new(
103
- Kernel32['IsWow64GuestMachineSupported'],
104
- [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
105
- Fiddle::TYPE_LONG
106
- )
107
-
108
- def get_machine_type_attributes(machine)
109
- h_process = GetCurrentProcess.call
110
- p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
111
- p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
112
- raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero?
113
-
114
- if p_native_machine.to_str.unpack1('S!') == machine
115
- return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED)
116
- end
117
-
118
- p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE)
119
- raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero?
120
-
121
- if p_machine_is_supported.to_str.unpack1('c').zero?
122
- MachineTypeAttributes.new(0)
123
- else
124
- MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER)
125
- end
126
- end
127
- end
128
- end
129
- end