sass-embedded 1.63.5 → 1.64.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.
- checksums.yaml +4 -4
- data/ext/sass/Rakefile +113 -51
- data/ext/sass/package.json +1 -1
- data/ext/sass/win32_api.rb +105 -101
- data/lib/sass/calculation_value/calculation_interpolation.rb +31 -0
- data/lib/sass/calculation_value/calculation_operation.rb +52 -0
- data/lib/sass/calculation_value.rb +17 -0
- data/lib/sass/compile_result.rb +1 -1
- data/lib/sass/embedded/host/function_registry.rb +5 -7
- data/lib/sass/embedded/host/value_protofier.rb +180 -11
- data/lib/sass/embedded/host.rb +7 -1
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +7 -7
- data/lib/sass/logger/silent.rb +3 -1
- data/lib/sass/logger/source_location.rb +1 -1
- data/lib/sass/logger/source_span.rb +1 -1
- data/lib/sass/value/argument_list.rb +1 -1
- data/lib/sass/value/boolean.rb +1 -1
- data/lib/sass/value/calculation.rb +90 -0
- data/lib/sass/value/color.rb +1 -1
- data/lib/sass/value/function.rb +1 -1
- data/lib/sass/value/list.rb +1 -1
- data/lib/sass/value/map.rb +1 -1
- data/lib/sass/value/null.rb +1 -1
- data/lib/sass/value/number.rb +2 -1
- data/lib/sass/value/string.rb +10 -1
- data/lib/sass/value.rb +10 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ab7f4ccdb57babfe8dc2af27348ef74956b60b6051389839211004aee50b4a
|
4
|
+
data.tar.gz: f423e6703e1beeaaf12d87c2085f2f918812ac6eed6639b939108128abf5b0b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df45e1d1804557bd66f0062f4c46f015f74f9ade4349bf0094c61557d32ae2f0b26aea707e449e722d629b41e866ffa0a67fba24d15a1ce5cfc5119ecd7f9261
|
7
|
+
data.tar.gz: 5eec5885c830ad9d5d2e68ce637c3754c22186da39aa8c12353e38d38ed80748cacbe4b6cf3f2a566950e65fbcff8f8c3852de41657c2a9c8b305c75ec2062ec
|
data/ext/sass/Rakefile
CHANGED
@@ -8,17 +8,23 @@ task install: %w[cli.rb] do
|
|
8
8
|
Rake::Task['embedded_sass_pb.rb'].invoke unless File.exist?('embedded_sass_pb.rb')
|
9
9
|
end
|
10
10
|
|
11
|
-
CLEAN.include %w[protoc.exe *.proto *.tar.gz *.zip]
|
11
|
+
CLEAN.include %w[protoc.exe ruby *.proto *.tar.gz *.zip]
|
12
12
|
|
13
13
|
CLOBBER.include %w[dart-sass cli.rb embedded_sass_pb.rb]
|
14
14
|
|
15
15
|
file 'protoc.exe' do |t|
|
16
|
-
fetch(ENV.fetch('PROTOC_BIN') {
|
16
|
+
fetch(ENV.fetch('PROTOC_BIN') { SassConfig.default_protoc }, t.name)
|
17
17
|
chmod 'a+x', t.name
|
18
18
|
end
|
19
19
|
|
20
20
|
file 'dart-sass' do |t|
|
21
|
-
|
21
|
+
raise if ENV.key?('DART_SASS')
|
22
|
+
|
23
|
+
gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir|
|
24
|
+
cp_r File.absolute_path("ext/sass/#{t.name}", dir), t.name
|
25
|
+
end
|
26
|
+
rescue StandardError
|
27
|
+
archive = fetch(ENV.fetch('DART_SASS') { SassConfig.default_dart_sass })
|
22
28
|
unarchive archive
|
23
29
|
rm archive
|
24
30
|
end
|
@@ -58,7 +64,7 @@ file 'cli.rb' => %w[dart-sass] do |t|
|
|
58
64
|
end
|
59
65
|
|
60
66
|
file 'embedded_sass.proto' => %w[cli.rb] do |t|
|
61
|
-
fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') {
|
67
|
+
fetch(ENV.fetch('EMBEDDED_SASS_PROTOCOL') { SassConfig.default_embedded_sass_protocol }, t.name)
|
62
68
|
end
|
63
69
|
|
64
70
|
rule '_pb.rb' => %w[.proto protoc.exe] do |t|
|
@@ -174,10 +180,48 @@ module FileUtils
|
|
174
180
|
|
175
181
|
dest_path
|
176
182
|
end
|
183
|
+
|
184
|
+
def gem_install(name, version, platform)
|
185
|
+
install_dir = File.absolute_path('ruby', __dir__)
|
186
|
+
|
187
|
+
if Rake::FileUtilsExt.verbose_flag
|
188
|
+
Rake.rake_output_message [
|
189
|
+
'gem', 'install',
|
190
|
+
'--force',
|
191
|
+
'--install-dir', install_dir,
|
192
|
+
'--no-document', '--ignore-dependencies',
|
193
|
+
'--platform', platform,
|
194
|
+
'--version', version,
|
195
|
+
'sass-embedded'
|
196
|
+
].join(' ')
|
197
|
+
end
|
198
|
+
|
199
|
+
dependency = Gem::Dependency.new(name, version)
|
200
|
+
|
201
|
+
specs_and_sources, _errors = Gem::SpecFetcher.fetcher.spec_for_dependency(dependency, false)
|
202
|
+
|
203
|
+
spec, source = specs_and_sources.find do |s, _|
|
204
|
+
s.platform == platform
|
205
|
+
end
|
206
|
+
|
207
|
+
raise if spec.nil? || source.nil?
|
208
|
+
|
209
|
+
if Rake::FileUtilsExt.nowrite_flag
|
210
|
+
installer = Gem::Installer.for_spec(spec, { force: true, install_dir: install_dir })
|
211
|
+
else
|
212
|
+
path = source.download(spec, install_dir)
|
213
|
+
installer = Gem::Installer.at(path, { force: true, install_dir: install_dir })
|
214
|
+
installer.install
|
215
|
+
end
|
216
|
+
|
217
|
+
yield installer.dir
|
218
|
+
ensure
|
219
|
+
rm_rf install_dir
|
220
|
+
end
|
177
221
|
end
|
178
222
|
|
179
|
-
# The {
|
180
|
-
module
|
223
|
+
# The {SassConfig} module.
|
224
|
+
module SassConfig
|
181
225
|
module Platform
|
182
226
|
OS = case RbConfig::CONFIG['host_os'].downcase
|
183
227
|
when /darwin/
|
@@ -204,8 +248,7 @@ module Configuration
|
|
204
248
|
when /arm64|aarch64/
|
205
249
|
'aarch64'
|
206
250
|
when /arm/
|
207
|
-
|
208
|
-
OS == 'darwin' ? 'aarch64' : 'arm'
|
251
|
+
'arm'
|
209
252
|
when /ppc64le|powerpc64le/
|
210
253
|
'powerpc64le'
|
211
254
|
when /s390x/
|
@@ -214,21 +257,39 @@ module Configuration
|
|
214
257
|
RbConfig::CONFIG['host_cpu']
|
215
258
|
end
|
216
259
|
|
217
|
-
ARCH = "#{CPU}-#{OS}"
|
260
|
+
ARCH = "#{CPU}-#{OS}".freeze
|
261
|
+
|
262
|
+
EMULATION = if ARCH == 'aarch64-windows'
|
263
|
+
begin
|
264
|
+
require_relative 'win32_api'
|
265
|
+
|
266
|
+
if Win32API.x64?
|
267
|
+
'x86_64'
|
268
|
+
elsif Win32API.x86?
|
269
|
+
'i386'
|
270
|
+
end
|
271
|
+
rescue LoadError
|
272
|
+
'i386'
|
273
|
+
end
|
274
|
+
end
|
218
275
|
end
|
219
276
|
|
220
277
|
private_constant :Platform
|
221
278
|
|
222
279
|
module_function
|
223
280
|
|
224
|
-
def
|
281
|
+
def dart_sass_version
|
225
282
|
require 'json'
|
226
283
|
|
227
|
-
repo = 'https://github.com/sass/dart-sass'
|
228
|
-
|
229
284
|
spec = JSON.parse(File.read(File.absolute_path('package.json', __dir__)))
|
230
285
|
|
231
|
-
|
286
|
+
spec['dependencies']['sass']
|
287
|
+
end
|
288
|
+
|
289
|
+
def default_dart_sass
|
290
|
+
repo = 'https://github.com/sass/dart-sass'
|
291
|
+
|
292
|
+
tag_name = dart_sass_version
|
232
293
|
|
233
294
|
message = "dart-sass for #{Platform::ARCH} not available at #{repo}/releases/tag/#{tag_name}"
|
234
295
|
|
@@ -249,30 +310,13 @@ module Configuration
|
|
249
310
|
raise NotImplementedError, message
|
250
311
|
end
|
251
312
|
|
252
|
-
cpu = case Platform::CPU
|
313
|
+
cpu = case Platform::EMULATION || Platform::CPU
|
253
314
|
when 'i386'
|
254
315
|
'ia32'
|
255
316
|
when 'x86_64'
|
256
317
|
'x64'
|
257
318
|
when 'aarch64'
|
258
|
-
|
259
|
-
begin
|
260
|
-
require_relative 'win32_api'
|
261
|
-
|
262
|
-
if Win32API.x64?
|
263
|
-
'x64'
|
264
|
-
elsif Win32API.x86?
|
265
|
-
'ia32'
|
266
|
-
else
|
267
|
-
raise NotImplementedError, message
|
268
|
-
end
|
269
|
-
rescue LoadError
|
270
|
-
# TODO: remove begin/rescue once jruby/jffi support windows aarch64
|
271
|
-
'ia32'
|
272
|
-
end
|
273
|
-
else
|
274
|
-
'arm64'
|
275
|
-
end
|
319
|
+
'arm64'
|
276
320
|
when 'arm'
|
277
321
|
'arm'
|
278
322
|
else
|
@@ -306,30 +350,13 @@ module Configuration
|
|
306
350
|
raise NotImplementedError, message
|
307
351
|
end
|
308
352
|
|
309
|
-
cpu = case Platform::CPU
|
353
|
+
cpu = case Platform::EMULATION || Platform::CPU
|
310
354
|
when 'i386'
|
311
355
|
'x86_32'
|
312
356
|
when 'x86_64'
|
313
357
|
'x86_64'
|
314
358
|
when 'aarch64'
|
315
|
-
|
316
|
-
begin
|
317
|
-
require_relative 'win32_api'
|
318
|
-
|
319
|
-
if Win32API.x64?
|
320
|
-
'x86_64'
|
321
|
-
elsif Win32API.x86?
|
322
|
-
'x86_32'
|
323
|
-
else
|
324
|
-
raise NotImplementedError, message
|
325
|
-
end
|
326
|
-
rescue LoadError
|
327
|
-
# TODO: remove begin/rescue once jruby/jffi support windows aarch64
|
328
|
-
'x86_32'
|
329
|
-
end
|
330
|
-
else
|
331
|
-
'aarch_64'
|
332
|
-
end
|
359
|
+
'aarch_64'
|
333
360
|
when 'powerpc64le'
|
334
361
|
'ppcle_64'
|
335
362
|
when 's390x'
|
@@ -374,4 +401,39 @@ module Configuration
|
|
374
401
|
|
375
402
|
"https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto"
|
376
403
|
end
|
404
|
+
|
405
|
+
def development?
|
406
|
+
File.exist?('../../Gemfile')
|
407
|
+
end
|
408
|
+
|
409
|
+
def gem_version
|
410
|
+
require_relative '../../lib/sass/embedded/version'
|
411
|
+
|
412
|
+
development? ? dart_sass_version : Sass::Embedded::VERSION
|
413
|
+
end
|
414
|
+
|
415
|
+
def gem_platform
|
416
|
+
platform = Gem::Platform.new("#{RbConfig::CONFIG['host_cpu']}-#{RbConfig::CONFIG['host_os']}")
|
417
|
+
case Platform::OS
|
418
|
+
when 'darwin'
|
419
|
+
Gem::Platform.new([platform.cpu, platform.os])
|
420
|
+
when 'linux'
|
421
|
+
if platform.version&.start_with?('gnu')
|
422
|
+
platform
|
423
|
+
else
|
424
|
+
Gem::Platform.new([platform.cpu, platform.os, "gnu#{platform.version}"])
|
425
|
+
end
|
426
|
+
when 'windows'
|
427
|
+
case Platform::EMULATION || Platform::CPU
|
428
|
+
when 'x86_64'
|
429
|
+
Gem::Platform.new('x64-mingw32')
|
430
|
+
when 'i386'
|
431
|
+
Gem::Platform.new('x86-mingw32')
|
432
|
+
else
|
433
|
+
Gem::Platform.new([platform.cpu, 'mingw32'])
|
434
|
+
end
|
435
|
+
else
|
436
|
+
platform
|
437
|
+
end
|
438
|
+
end
|
377
439
|
end
|
data/ext/sass/package.json
CHANGED
data/ext/sass/win32_api.rb
CHANGED
@@ -3,127 +3,131 @@
|
|
3
3
|
require 'fiddle'
|
4
4
|
|
5
5
|
# @!visibility private
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
6
|
+
module SassConfig
|
7
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/api/
|
8
|
+
module Win32API
|
9
|
+
Kernel32 = Fiddle.dlopen('Kernel32.dll')
|
10
|
+
|
11
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
|
12
|
+
module ImageFileMachineConstants
|
13
|
+
IMAGE_FILE_MACHINE_I386 = 0x014c
|
14
|
+
IMAGE_FILE_MACHINE_ARMNT = 0x01c4
|
15
|
+
IMAGE_FILE_MACHINE_AMD64 = 0x8664
|
16
|
+
IMAGE_FILE_MACHINE_ARM64 = 0xaa64
|
33
17
|
end
|
34
18
|
|
35
|
-
|
36
|
-
def user_enabled?
|
37
|
-
@machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED
|
38
|
-
end
|
19
|
+
private_constant :ImageFileMachineConstants
|
39
20
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
21
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes
|
22
|
+
module MachineAttributes
|
23
|
+
USER_ENABLED = 0x00000001
|
24
|
+
KERNEL_ENABLED = 0x00000002
|
25
|
+
WOW64_CONTAINER = 0x00000004
|
43
26
|
end
|
44
27
|
|
45
|
-
|
46
|
-
def wow64_container?
|
47
|
-
@machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER
|
48
|
-
end
|
49
|
-
end
|
28
|
+
private_constant :MachineAttributes
|
50
29
|
|
51
|
-
|
30
|
+
# Specifies the ways in which an architecture of code can run on a host operating system.
|
31
|
+
class MachineTypeAttributes
|
32
|
+
def initialize(machine_type_attributes)
|
33
|
+
@machine_type_attributes = machine_type_attributes
|
34
|
+
end
|
52
35
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
36
|
+
# The specified architecture of code can run in user mode.
|
37
|
+
def user_enabled?
|
38
|
+
@machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED
|
39
|
+
end
|
57
40
|
|
58
|
-
|
59
|
-
|
60
|
-
|
41
|
+
# The specified architecture of code can run in kernel mode.
|
42
|
+
def kernel_enabled?
|
43
|
+
@machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED
|
44
|
+
end
|
61
45
|
|
62
|
-
|
63
|
-
|
46
|
+
# The specified architecture of code runs on WOW64.
|
47
|
+
def wow64_container?
|
48
|
+
@machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER
|
49
|
+
end
|
64
50
|
end
|
65
51
|
|
66
|
-
|
67
|
-
get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled?
|
68
|
-
end
|
52
|
+
private_constant :MachineTypeAttributes
|
69
53
|
|
70
|
-
|
54
|
+
class << self
|
55
|
+
def x86?
|
56
|
+
get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled?
|
57
|
+
end
|
71
58
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
Kernel32['GetMachineTypeAttributes'],
|
76
|
-
[-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
|
77
|
-
Fiddle::TYPE_LONG
|
78
|
-
)
|
59
|
+
def arm?
|
60
|
+
get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled?
|
61
|
+
end
|
79
62
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
63
|
+
def x64?
|
64
|
+
get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled?
|
65
|
+
end
|
83
66
|
|
84
|
-
|
67
|
+
def arm64?
|
68
|
+
get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled?
|
85
69
|
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
70
|
|
118
|
-
|
119
|
-
|
71
|
+
private
|
72
|
+
|
73
|
+
begin
|
74
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes
|
75
|
+
GetMachineTypeAttributes = Fiddle::Function.new(
|
76
|
+
Kernel32['GetMachineTypeAttributes'],
|
77
|
+
[-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
|
78
|
+
Fiddle::TYPE_LONG
|
79
|
+
)
|
120
80
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
81
|
+
def get_machine_type_attributes(machine)
|
82
|
+
p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
|
83
|
+
raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero?
|
84
|
+
|
85
|
+
MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i'))
|
86
|
+
end
|
87
|
+
rescue Fiddle::DLError
|
88
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess
|
89
|
+
GetCurrentProcess = Fiddle::Function.new(
|
90
|
+
Kernel32['GetCurrentProcess'],
|
91
|
+
[],
|
92
|
+
Fiddle::TYPE_VOIDP
|
93
|
+
)
|
94
|
+
|
95
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2
|
96
|
+
IsWow64Process2 = Fiddle::Function.new(
|
97
|
+
Kernel32['IsWow64Process2'],
|
98
|
+
[Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
|
99
|
+
Fiddle::TYPE_CHAR
|
100
|
+
)
|
101
|
+
|
102
|
+
# @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported
|
103
|
+
IsWow64GuestMachineSupported = Fiddle::Function.new(
|
104
|
+
Kernel32['IsWow64GuestMachineSupported'],
|
105
|
+
[-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
|
106
|
+
Fiddle::TYPE_LONG
|
107
|
+
)
|
108
|
+
|
109
|
+
def get_machine_type_attributes(machine)
|
110
|
+
h_process = GetCurrentProcess.call
|
111
|
+
p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
|
112
|
+
p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
|
113
|
+
raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero?
|
114
|
+
|
115
|
+
if p_native_machine.to_str.unpack1('S!') == machine
|
116
|
+
return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED)
|
117
|
+
end
|
118
|
+
|
119
|
+
p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE)
|
120
|
+
raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero?
|
121
|
+
|
122
|
+
if p_machine_is_supported.to_str.unpack1('c').zero?
|
123
|
+
MachineTypeAttributes.new(0)
|
124
|
+
else
|
125
|
+
MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER)
|
126
|
+
end
|
125
127
|
end
|
126
128
|
end
|
127
129
|
end
|
128
130
|
end
|
131
|
+
|
132
|
+
private_constant :Win32API
|
129
133
|
end
|
@@ -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'
|
data/lib/sass/compile_result.rb
CHANGED
@@ -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/
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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:
|
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
|
-
|
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
|
data/lib/sass/embedded/host.rb
CHANGED
@@ -86,7 +86,13 @@ module Sass
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def error(message)
|
89
|
-
|
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
|
|
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/
|
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/
|
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/
|
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
|
data/lib/sass/logger/silent.rb
CHANGED
@@ -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/
|
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/
|
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/
|
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/
|
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>]
|
data/lib/sass/value/boolean.rb
CHANGED
@@ -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
|
data/lib/sass/value/color.rb
CHANGED
@@ -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/
|
9
|
+
# @see https://sass-lang.com/documentation/js-api/classes/sasscolor/
|
10
10
|
class Color
|
11
11
|
include Value
|
12
12
|
|
data/lib/sass/value/function.rb
CHANGED
data/lib/sass/value/list.rb
CHANGED
data/lib/sass/value/map.rb
CHANGED
data/lib/sass/value/null.rb
CHANGED
data/lib/sass/value/number.rb
CHANGED
@@ -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/
|
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]
|
data/lib/sass/value/string.rb
CHANGED
@@ -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/
|
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/
|
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.
|
4
|
+
version: 1.64.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -57,6 +57,9 @@ files:
|
|
57
57
|
- ext/sass/package.json
|
58
58
|
- ext/sass/win32_api.rb
|
59
59
|
- lib/sass-embedded.rb
|
60
|
+
- lib/sass/calculation_value.rb
|
61
|
+
- lib/sass/calculation_value/calculation_interpolation.rb
|
62
|
+
- lib/sass/calculation_value/calculation_operation.rb
|
60
63
|
- lib/sass/compile_error.rb
|
61
64
|
- lib/sass/compile_result.rb
|
62
65
|
- lib/sass/elf.rb
|
@@ -81,6 +84,7 @@ files:
|
|
81
84
|
- lib/sass/value.rb
|
82
85
|
- lib/sass/value/argument_list.rb
|
83
86
|
- lib/sass/value/boolean.rb
|
87
|
+
- lib/sass/value/calculation.rb
|
84
88
|
- lib/sass/value/color.rb
|
85
89
|
- lib/sass/value/function.rb
|
86
90
|
- lib/sass/value/fuzzy_math.rb
|
@@ -94,8 +98,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
94
98
|
licenses:
|
95
99
|
- MIT
|
96
100
|
metadata:
|
97
|
-
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.
|
98
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.
|
101
|
+
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.64.0
|
102
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.64.0
|
99
103
|
funding_uri: https://github.com/sponsors/ntkme
|
100
104
|
post_install_message:
|
101
105
|
rdoc_options: []
|
@@ -105,14 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
109
|
requirements:
|
106
110
|
- - ">="
|
107
111
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
112
|
+
version: 3.0.0
|
109
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
114
|
requirements:
|
111
115
|
- - ">="
|
112
116
|
- !ruby/object:Gem::Version
|
113
117
|
version: '0'
|
114
118
|
requirements: []
|
115
|
-
rubygems_version: 3.4.
|
119
|
+
rubygems_version: 3.4.17
|
116
120
|
signing_key:
|
117
121
|
specification_version: 4
|
118
122
|
summary: Use dart-sass with Ruby!
|