sass-embedded 1.107.0-aarch64-mswin64
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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +48 -0
- data/exe/sass +13 -0
- data/lib/sass/calculation_value/calculation_operation.rb +49 -0
- data/lib/sass/calculation_value.rb +22 -0
- data/lib/sass/canonicalize_context.rb +25 -0
- data/lib/sass/cli.rb +12 -0
- data/lib/sass/compile_result.rb +24 -0
- data/lib/sass/compiler/channel.rb +70 -0
- data/lib/sass/compiler/connection.rb +109 -0
- data/lib/sass/compiler/dispatcher.rb +142 -0
- data/lib/sass/compiler/session/function_registry.rb +88 -0
- data/lib/sass/compiler/session/importer_registry.rb +190 -0
- data/lib/sass/compiler/session/logger_registry.rb +99 -0
- data/lib/sass/compiler/session/path.rb +23 -0
- data/lib/sass/compiler/session/protofier.rb +384 -0
- data/lib/sass/compiler/session/stack_trace.rb +46 -0
- data/lib/sass/compiler/session.rb +242 -0
- data/lib/sass/compiler/varint.rb +39 -0
- data/lib/sass/compiler.rb +214 -0
- data/lib/sass/dart-sass/sass.bat +7 -0
- data/lib/sass/dart-sass/src/LICENSE +1659 -0
- data/lib/sass/dart-sass/src/dart.exe +0 -0
- data/lib/sass/dart-sass/src/sass.snapshot +0 -0
- data/lib/sass/elf.rb +386 -0
- data/lib/sass/embedded/version.rb +7 -0
- data/lib/sass/embedded.rb +67 -0
- data/lib/sass/embedded_protocol.rb +10 -0
- data/lib/sass/embedded_sass_pb.rb +62 -0
- data/lib/sass/exception.rb +73 -0
- data/lib/sass/fork_tracker.rb +56 -0
- data/lib/sass/gem_package_importer.rb +28 -0
- data/lib/sass/logger/silent.rb +28 -0
- data/lib/sass/logger/source_location.rb +22 -0
- data/lib/sass/logger/source_span.rb +28 -0
- data/lib/sass/node_package_importer.rb +17 -0
- data/lib/sass/serializer.rb +30 -0
- data/lib/sass/uri.rb +56 -0
- data/lib/sass/value/argument_list.rb +29 -0
- data/lib/sass/value/boolean.rb +59 -0
- data/lib/sass/value/calculation.rb +90 -0
- data/lib/sass/value/color/channel.rb +79 -0
- data/lib/sass/value/color/conversions.rb +473 -0
- data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
- data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
- data/lib/sass/value/color/gamut_map_method.rb +45 -0
- data/lib/sass/value/color/interpolation_method.rb +51 -0
- data/lib/sass/value/color/space/a98_rgb.rb +57 -0
- data/lib/sass/value/color/space/display_p3.rb +72 -0
- data/lib/sass/value/color/space/display_p3_linear.rb +72 -0
- data/lib/sass/value/color/space/hsl.rb +65 -0
- data/lib/sass/value/color/space/hwb.rb +94 -0
- data/lib/sass/value/color/space/lab.rb +85 -0
- data/lib/sass/value/color/space/lch.rb +53 -0
- data/lib/sass/value/color/space/lms.rb +146 -0
- data/lib/sass/value/color/space/oklab.rb +71 -0
- data/lib/sass/value/color/space/oklch.rb +54 -0
- data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
- data/lib/sass/value/color/space/rec2020.rb +57 -0
- data/lib/sass/value/color/space/rgb.rb +52 -0
- data/lib/sass/value/color/space/srgb.rb +145 -0
- data/lib/sass/value/color/space/srgb_linear.rb +72 -0
- data/lib/sass/value/color/space/utils.rb +89 -0
- data/lib/sass/value/color/space/xyz_d50.rb +113 -0
- data/lib/sass/value/color/space/xyz_d65.rb +57 -0
- data/lib/sass/value/color/space.rb +218 -0
- data/lib/sass/value/color.rb +631 -0
- data/lib/sass/value/function.rb +66 -0
- data/lib/sass/value/fuzzy_math.rb +84 -0
- data/lib/sass/value/list.rb +89 -0
- data/lib/sass/value/map.rb +77 -0
- data/lib/sass/value/mixin.rb +47 -0
- data/lib/sass/value/module.rb +47 -0
- data/lib/sass/value/null.rb +58 -0
- data/lib/sass/value/number/unit.rb +187 -0
- data/lib/sass/value/number.rb +364 -0
- data/lib/sass/value/string.rb +78 -0
- data/lib/sass/value.rb +174 -0
- data/lib/sass-embedded.rb +4 -0
- metadata +140 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
# The built-in RubyGems package importer. This loads pkg: URLs from gems.
|
|
5
|
+
#
|
|
6
|
+
# @example
|
|
7
|
+
# require 'bundler/inline'
|
|
8
|
+
#
|
|
9
|
+
# gemfile do
|
|
10
|
+
# source 'https://rubygems.org'
|
|
11
|
+
# gem 'bootstrap', require: false
|
|
12
|
+
# gem 'sass-embedded'
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# puts Sass.compile_string('@use "pkg:bootstrap/assets/stylesheets/bootstrap";', importers: [Sass::GemPackageImporter.new]).css
|
|
16
|
+
class GemPackageImporter
|
|
17
|
+
# @!visibility private
|
|
18
|
+
def find_file_url(url, _canonicalize_context)
|
|
19
|
+
return unless url.start_with?('pkg:')
|
|
20
|
+
|
|
21
|
+
library, _, path = url[4..].partition('/')
|
|
22
|
+
gem_dir = Gem::Dependency.new(Uri.decode_uri_component(library)).to_spec.gem_dir
|
|
23
|
+
"#{Uri.path_to_file_uri(gem_dir)}/#{path}"
|
|
24
|
+
rescue Gem::MissingSpecError
|
|
25
|
+
nil
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
# A namespace for built-in Loggers.
|
|
5
|
+
#
|
|
6
|
+
# @see https://sass-lang.com/documentation/js-api/modules/logger/
|
|
7
|
+
module Logger
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
# A Logger that silently ignores all warnings and debug messages.
|
|
11
|
+
#
|
|
12
|
+
# @see https://sass-lang.com/documentation/js-api/variables/logger.silent/
|
|
13
|
+
def silent
|
|
14
|
+
Silent
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# A Logger that silently ignores all warnings and debug messages.
|
|
18
|
+
module Silent
|
|
19
|
+
module_function
|
|
20
|
+
|
|
21
|
+
def warn(message, options); end
|
|
22
|
+
|
|
23
|
+
def debug(message, options); end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private_constant :Silent
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
module Logger
|
|
5
|
+
# A specific location within a source file.
|
|
6
|
+
#
|
|
7
|
+
# This is always associated with a {SourceSpan} which indicates which file it refers to.
|
|
8
|
+
#
|
|
9
|
+
# @see https://sass-lang.com/documentation/js-api/interfaces/sourcelocation/
|
|
10
|
+
class SourceLocation
|
|
11
|
+
# @return [Integer]
|
|
12
|
+
attr_reader :offset, :line, :column
|
|
13
|
+
|
|
14
|
+
# @!visibility private
|
|
15
|
+
def initialize(source_location)
|
|
16
|
+
@offset = source_location.offset
|
|
17
|
+
@line = source_location.line
|
|
18
|
+
@column = source_location.column
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
module Logger
|
|
5
|
+
# A span of text within a source file.
|
|
6
|
+
#
|
|
7
|
+
# @see https://sass-lang.com/documentation/js-api/interfaces/sourcespan/
|
|
8
|
+
class SourceSpan
|
|
9
|
+
# @return [SourceLocation]
|
|
10
|
+
attr_reader :start, :end
|
|
11
|
+
|
|
12
|
+
# @return [String]
|
|
13
|
+
attr_reader :text
|
|
14
|
+
|
|
15
|
+
# @return [String, nil]
|
|
16
|
+
attr_reader :url, :context
|
|
17
|
+
|
|
18
|
+
# @!visibility private
|
|
19
|
+
def initialize(source_span)
|
|
20
|
+
@start = source_span.start.nil? ? nil : Logger::SourceLocation.new(source_span.start)
|
|
21
|
+
@end = source_span.end.nil? ? nil : Logger::SourceLocation.new(source_span.end)
|
|
22
|
+
@text = source_span.text
|
|
23
|
+
@url = source_span.url == '' ? nil : source_span.url
|
|
24
|
+
@context = source_span.context == '' ? nil : source_span.context
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
# The built-in Node.js package importer. This loads pkg: URLs from node_modules
|
|
5
|
+
# according to the standard Node.js resolution algorithm.
|
|
6
|
+
#
|
|
7
|
+
# @see https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/
|
|
8
|
+
class NodePackageImporter
|
|
9
|
+
# @param entry_point_directory [String] The directory where the {NodePackageImporter} should start when resolving
|
|
10
|
+
# `pkg:` URLs in sources other than files on disk.
|
|
11
|
+
def initialize(entry_point_directory)
|
|
12
|
+
raise ArgumentError, 'entry_point_directory must be set' if entry_point_directory.nil?
|
|
13
|
+
|
|
14
|
+
@entry_point_directory = File.absolute_path(entry_point_directory)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
# The {Serializer} module.
|
|
5
|
+
module Serializer
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
CSS_ESCAPE = [*"\x01".."\x08", *"\x0A".."\x1F", "\x7F"]
|
|
9
|
+
.product([*'0'..'9', *'a'..'f', *'A'..'F', "\t", ' ', nil])
|
|
10
|
+
.each_with_object({ "\0" => "\uFFFD", '\\' => '\\\\', '"' => '\\"', "'" => "\\'" }) do |(c, x), h|
|
|
11
|
+
h["#{c}#{x}".freeze] = "\\#{c.ord.to_s(16)}#{" #{x}" if x}".freeze
|
|
12
|
+
end.freeze
|
|
13
|
+
|
|
14
|
+
private_constant :CSS_ESCAPE
|
|
15
|
+
|
|
16
|
+
def serialize_quoted_string(string)
|
|
17
|
+
if !string.include?('"') || string.include?("'")
|
|
18
|
+
%("#{string.gsub(/[\0\\"]|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}")
|
|
19
|
+
else
|
|
20
|
+
%('#{string.gsub(/[\0\\']|[\x01-\x08\x0A-\x1F\x7F][\h\t ]?/, CSS_ESCAPE)}')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def serialize_unquoted_string(string)
|
|
25
|
+
string.tr("\0", "\uFFFD").gsub(/\n */, ' ')
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private_constant :Serializer
|
|
30
|
+
end
|
data/lib/sass/uri.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Sass
|
|
6
|
+
# The {Uri} class.
|
|
7
|
+
#
|
|
8
|
+
# It follows RFC3986 to match the behavior of Uri class from Dart.
|
|
9
|
+
#
|
|
10
|
+
# @see https://www.rfc-editor.org/info/rfc3986/
|
|
11
|
+
module Uri
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
def decode_uri_component(str)
|
|
15
|
+
str.b.gsub(/%\h\h/, ::URI::TBLDECWWWCOMP_).force_encoding(str.encoding)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def encode_uri_component(str)
|
|
19
|
+
str.b.gsub(/[^0-9A-Za-z\-._~]/n, ::URI::TBLENCURICOMP_).force_encoding(str.encoding)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def encode_uri_path_component(str)
|
|
23
|
+
str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/]}n, ::URI::TBLENCURICOMP_).force_encoding(str.encoding)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def encode_uri_query_component(str)
|
|
27
|
+
str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/?]}n, ::URI::TBLENCURICOMP_).force_encoding(str.encoding)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def file_uri_to_path(uri)
|
|
31
|
+
path = decode_uri_component(::URI::RFC3986_PARSER.parse(uri).path)
|
|
32
|
+
if path.start_with?('/')
|
|
33
|
+
windows_path = path[1..]
|
|
34
|
+
path = windows_path if File.absolute_path?(windows_path)
|
|
35
|
+
end
|
|
36
|
+
path
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def path_to_file_uri(path)
|
|
40
|
+
path = "/#{path}" unless path.start_with?('/')
|
|
41
|
+
"file://#{encode_uri_path_component(path)}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def pwd
|
|
45
|
+
pwd = Dir.pwd
|
|
46
|
+
pwd += '/' unless pwd.end_with?('/')
|
|
47
|
+
path_to_file_uri(pwd)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def relative(to, from)
|
|
51
|
+
::URI::RFC3986_PARSER.parse(to).route_from(from).to_s
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private_constant :Uri
|
|
56
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
module Value
|
|
5
|
+
# Sass's argument list type.
|
|
6
|
+
#
|
|
7
|
+
# An argument list comes from a rest argument. It's distinct from a normal {List} in that it may contain a keyword
|
|
8
|
+
# map as well as the positional arguments.
|
|
9
|
+
#
|
|
10
|
+
# @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/
|
|
11
|
+
class ArgumentList < List
|
|
12
|
+
# @param contents [Array<Value>]
|
|
13
|
+
# @param keywords [Hash<Symbol, Value>]
|
|
14
|
+
# @param separator [::String]
|
|
15
|
+
def initialize(contents = [], keywords = {}, separator = ',')
|
|
16
|
+
super(contents, separator:)
|
|
17
|
+
|
|
18
|
+
@keywords_accessed = false
|
|
19
|
+
@keywords = keywords.freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [Hash<Symbol, Value>]
|
|
23
|
+
def keywords
|
|
24
|
+
@keywords_accessed = true
|
|
25
|
+
@keywords
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
module Value
|
|
5
|
+
# Sass's boolean type.
|
|
6
|
+
#
|
|
7
|
+
# @see https://sass-lang.com/documentation/js-api/classes/sassboolean/
|
|
8
|
+
class Boolean
|
|
9
|
+
include Value
|
|
10
|
+
|
|
11
|
+
# @param value [::Boolean]
|
|
12
|
+
def initialize(value)
|
|
13
|
+
@value = value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @return [::Boolean]
|
|
17
|
+
attr_reader :value
|
|
18
|
+
|
|
19
|
+
# @return [Boolean]
|
|
20
|
+
def !
|
|
21
|
+
value ? Boolean::FALSE : Boolean::TRUE
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @return [::Boolean]
|
|
25
|
+
def ==(other)
|
|
26
|
+
other.is_a?(Sass::Value::Boolean) && other.value == value
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @return [Integer]
|
|
30
|
+
def hash
|
|
31
|
+
@hash ||= value.hash
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @return [::String]
|
|
35
|
+
def to_s
|
|
36
|
+
value.to_s
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
alias inspect to_s
|
|
40
|
+
|
|
41
|
+
alias to_bool value
|
|
42
|
+
|
|
43
|
+
# @return [Boolean]
|
|
44
|
+
def assert_boolean(_name = nil)
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Sass's true value.
|
|
49
|
+
TRUE = Boolean.new(true)
|
|
50
|
+
|
|
51
|
+
# Sass's false value.
|
|
52
|
+
FALSE = Boolean.new(false)
|
|
53
|
+
|
|
54
|
+
def self.new(value)
|
|
55
|
+
value ? Boolean::TRUE : Boolean::FALSE
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -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
|
+
class << self
|
|
13
|
+
private :new
|
|
14
|
+
|
|
15
|
+
# @param argument [CalculationValue]
|
|
16
|
+
# @return [Calculation]
|
|
17
|
+
def calc(argument)
|
|
18
|
+
new('calc', [argument])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @param arguments [Array<CalculationValue>]
|
|
22
|
+
# @return [Calculation]
|
|
23
|
+
def min(arguments)
|
|
24
|
+
new('min', arguments)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @param arguments [Array<CalculationValue>]
|
|
28
|
+
# @return [Calculation]
|
|
29
|
+
def max(arguments)
|
|
30
|
+
new('max', arguments)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @param min [CalculationValue]
|
|
34
|
+
# @param value [CalculationValue]
|
|
35
|
+
# @param max [CalculationValue]
|
|
36
|
+
# @return [Calculation]
|
|
37
|
+
def clamp(min, value = nil, max = nil)
|
|
38
|
+
if (value.nil? && !valid_clamp_arg?(min)) ||
|
|
39
|
+
(max.nil? && [min, value].none? { |x| x && valid_clamp_arg?(x) })
|
|
40
|
+
raise Sass::ScriptError, 'Argument must be an unquoted SassString.'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
new('clamp', [min, value, max].compact)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def valid_clamp_arg?(value)
|
|
49
|
+
value.is_a?(Sass::Value::String) && !value.quoted?
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def initialize(name, arguments)
|
|
56
|
+
arguments.each do |value|
|
|
57
|
+
assert_calculation_value(value)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
@name = name.freeze
|
|
61
|
+
@arguments = arguments.freeze
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
public
|
|
65
|
+
|
|
66
|
+
# @return [::String]
|
|
67
|
+
attr_reader :name
|
|
68
|
+
|
|
69
|
+
# @return [Array<CalculationValue>]
|
|
70
|
+
attr_reader :arguments
|
|
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
|
|
@@ -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
|