sass-embedded 1.69.4 → 1.69.6
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/README.md +1 -1
- data/exe/sass +2 -2
- data/ext/sass/Rakefile +5 -21
- data/ext/sass/embedded_sass_pb.rb +1 -1
- data/ext/sass/package.json +1 -1
- data/lib/sass/compiler/connection.rb +92 -0
- data/lib/sass/{embedded → compiler}/dispatcher.rb +31 -10
- data/lib/sass/{embedded → compiler}/host/function_registry.rb +3 -3
- data/lib/sass/{embedded → compiler}/host/importer_registry.rb +3 -3
- data/lib/sass/{embedded → compiler}/host/logger_registry.rb +1 -1
- data/lib/sass/{embedded → compiler}/host/protofier.rb +1 -1
- data/lib/sass/{embedded → compiler}/host/structifier.rb +3 -3
- data/lib/sass/{embedded → compiler}/host/value_protofier.rb +1 -1
- data/lib/sass/{embedded → compiler}/host.rb +15 -13
- data/lib/sass/{embedded → compiler}/resilient_dispatcher.rb +5 -4
- data/lib/sass/{embedded → compiler}/varint.rb +1 -1
- data/lib/sass/compiler.rb +188 -0
- data/lib/sass/embedded/version.rb +2 -2
- data/lib/sass/embedded.rb +65 -205
- data/lib/sass/exception.rb +65 -0
- data/lib/sass/fork_tracker.rb +51 -0
- data/lib/sass/serializer.rb +73 -0
- data/lib/sass/value/argument_list.rb +1 -1
- data/lib/sass/value/color.rb +6 -6
- data/lib/sass/value/function.rb +1 -1
- data/lib/sass/value/map.rb +1 -1
- data/lib/sass/value/number.rb +11 -11
- data/lib/sass/value.rb +0 -1
- metadata +24 -23
- data/ext/sass/win32_api.rb +0 -133
- data/lib/sass/compile_error.rb +0 -31
- data/lib/sass/embedded/connection.rb +0 -68
- data/lib/sass/script_error.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f5aca7429ea164cf789851aadd9cf704c044e32a47283ad5a6f0ad39e535f7c
|
4
|
+
data.tar.gz: 8f0b68119c27970e5013d147e12ee9fecebc7e28b169e1d6be5cb170cc17d901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f95ca5d66e45a2f8928465824de7fb9c5830c84fcab7b00a2c0fb520e9c0cd8cb1c2112c24b08f0f978e0e4c9d88206fcab209a97e3875a948fb034da4ac006
|
7
|
+
data.tar.gz: dd63a5e0eec736eef021087120a5d03a8b60c17189380d466c7467fc989859a173c57480d4490dfb6d8fc82e61dd08bcc7703adf098a846f81e79f7742fec11b
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Embedded Sass Host for Ruby
|
2
2
|
|
3
|
-
[](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml)
|
4
4
|
[](https://rubygems.org/gems/sass-embedded)
|
5
5
|
|
6
6
|
This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md).
|
data/exe/sass
CHANGED
@@ -7,13 +7,13 @@ module Sass
|
|
7
7
|
# The `sass` command line interface
|
8
8
|
class CLI
|
9
9
|
begin
|
10
|
-
exec(*COMMAND, *ARGV)
|
10
|
+
Kernel.exec(*COMMAND, *ARGV)
|
11
11
|
rescue Errno::ENOENT
|
12
12
|
require_relative '../lib/sass/elf'
|
13
13
|
|
14
14
|
raise if ELF::INTERPRETER.nil?
|
15
15
|
|
16
|
-
exec(ELF::INTERPRETER, *COMMAND, *ARGV)
|
16
|
+
Kernel.exec(ELF::INTERPRETER, *COMMAND, *ARGV)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
data/ext/sass/Rakefile
CHANGED
@@ -164,7 +164,7 @@ module FileUtils
|
|
164
164
|
cp source_path, dest_path
|
165
165
|
else
|
166
166
|
fetcher = Gem::RemoteFetcher.fetcher
|
167
|
-
symbol = "fetch_#{scheme}"
|
167
|
+
symbol = :"fetch_#{scheme}"
|
168
168
|
raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol)
|
169
169
|
|
170
170
|
if Rake::FileUtilsExt.verbose_flag
|
@@ -207,10 +207,10 @@ module FileUtils
|
|
207
207
|
raise if spec.nil? || source.nil?
|
208
208
|
|
209
209
|
if Rake::FileUtilsExt.nowrite_flag
|
210
|
-
installer = Gem::Installer.for_spec(spec, { force: true, install_dir:
|
210
|
+
installer = Gem::Installer.for_spec(spec, { force: true, install_dir: })
|
211
211
|
else
|
212
212
|
path = source.download(spec, install_dir)
|
213
|
-
installer = Gem::Installer.at(path, { force: true, install_dir:
|
213
|
+
installer = Gem::Installer.at(path, { force: true, install_dir: })
|
214
214
|
installer.install
|
215
215
|
end
|
216
216
|
|
@@ -251,27 +251,13 @@ module SassConfig
|
|
251
251
|
'arm'
|
252
252
|
when /ppc64le|powerpc64le/
|
253
253
|
'powerpc64le'
|
254
|
-
when /s390x/
|
255
|
-
's390x'
|
256
254
|
else
|
257
255
|
RbConfig::CONFIG['host_cpu']
|
258
256
|
end
|
259
257
|
|
260
258
|
ARCH = "#{CPU}-#{OS}".freeze
|
261
259
|
|
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
|
260
|
+
EMULATION = ('x86_64' if ARCH == 'aarch64-windows')
|
275
261
|
end
|
276
262
|
|
277
263
|
private_constant :Platform
|
@@ -299,11 +285,9 @@ module SassConfig
|
|
299
285
|
when 'linux'
|
300
286
|
'linux'
|
301
287
|
when 'linux-android'
|
302
|
-
repo = 'https://github.com/dart-android/dart-sass'
|
303
288
|
'android'
|
304
289
|
when 'linux-musl'
|
305
|
-
|
306
|
-
'linux'
|
290
|
+
'linux-musl'
|
307
291
|
when 'windows'
|
308
292
|
'windows'
|
309
293
|
else
|
@@ -11,7 +11,7 @@ pool = Google::Protobuf::DescriptorPool.generated_pool
|
|
11
11
|
|
12
12
|
begin
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
14
|
-
rescue TypeError
|
14
|
+
rescue TypeError
|
15
15
|
# Compatibility code: will be removed in the next major version.
|
16
16
|
require 'google/protobuf/descriptor_pb'
|
17
17
|
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
data/ext/sass/package.json
CHANGED
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
require_relative '../../../ext/sass/cli'
|
6
|
+
|
7
|
+
module Sass
|
8
|
+
class Compiler
|
9
|
+
# The stdio based {Connection} between the {Dispatcher} and the compiler.
|
10
|
+
#
|
11
|
+
# It runs the `sass --embedded` command.
|
12
|
+
class Connection
|
13
|
+
def initialize(dispatcher)
|
14
|
+
@mutex = Mutex.new
|
15
|
+
@stdin, @stdout, @stderr, @wait_thread = begin
|
16
|
+
Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
require_relative '../elf'
|
19
|
+
|
20
|
+
raise if ELF::INTERPRETER.nil?
|
21
|
+
|
22
|
+
Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
|
23
|
+
end
|
24
|
+
|
25
|
+
@stdin.binmode
|
26
|
+
|
27
|
+
Thread.new do
|
28
|
+
Thread.current.name = "sass-embedded-process-stdout-poller-#{@wait_thread.pid}"
|
29
|
+
|
30
|
+
# # https://dart.dev/tools/dart-devtools
|
31
|
+
# if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe')
|
32
|
+
# Kernel.warn(@stdout.readline, uplevel: 0)
|
33
|
+
# Kernel.warn(@stdout.readline, uplevel: 0)
|
34
|
+
# end
|
35
|
+
|
36
|
+
@stdout.binmode
|
37
|
+
|
38
|
+
loop do
|
39
|
+
length = Varint.read(@stdout)
|
40
|
+
id = Varint.read(@stdout)
|
41
|
+
proto = @stdout.read(length - Varint.length(id))
|
42
|
+
dispatcher.receive_proto(id, proto)
|
43
|
+
end
|
44
|
+
rescue IOError, Errno::EBADF, Errno::EPROTO => e
|
45
|
+
dispatcher.error(e)
|
46
|
+
@mutex.synchronize do
|
47
|
+
@stdout.close
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Thread.new do
|
52
|
+
Thread.current.name = "sass-embedded-process-stderr-poller-#{@wait_thread.pid}"
|
53
|
+
loop do
|
54
|
+
Kernel.warn(@stderr.readline, uplevel: 0)
|
55
|
+
end
|
56
|
+
rescue IOError, Errno::EBADF
|
57
|
+
@mutex.synchronize do
|
58
|
+
@stderr.close
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
@wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def close
|
66
|
+
@mutex.synchronize do
|
67
|
+
@stdin.close
|
68
|
+
@wait_thread.join
|
69
|
+
@stdout.close
|
70
|
+
@stderr.close
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def closed?
|
75
|
+
@mutex.synchronize do
|
76
|
+
@stdin.closed? && !@wait_thread.alive?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def write(id, proto)
|
81
|
+
buffer = []
|
82
|
+
Varint.write(buffer, Varint.length(id) + proto.length)
|
83
|
+
Varint.write(buffer, id)
|
84
|
+
@mutex.synchronize do
|
85
|
+
@stdin.write(buffer.pack('C*'), proto)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private_constant :Connection
|
91
|
+
end
|
92
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
class
|
4
|
+
class Compiler
|
5
5
|
# The {Dispatcher} class.
|
6
6
|
#
|
7
7
|
# It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler.
|
@@ -11,11 +11,12 @@ module Sass
|
|
11
11
|
@observers = {}
|
12
12
|
@mutex = Mutex.new
|
13
13
|
@connection = Connection.new(self)
|
14
|
+
ForkTracker.add(self)
|
14
15
|
end
|
15
16
|
|
16
17
|
def subscribe(observer)
|
17
18
|
@mutex.synchronize do
|
18
|
-
raise Errno::EBUSY if
|
19
|
+
raise Errno::EBUSY if _closed?
|
19
20
|
|
20
21
|
id = @id
|
21
22
|
@id = id.next
|
@@ -30,12 +31,12 @@ module Sass
|
|
30
31
|
|
31
32
|
return unless @observers.empty?
|
32
33
|
|
33
|
-
if
|
34
|
+
if _closed?
|
34
35
|
Thread.new do
|
35
36
|
close
|
36
37
|
end
|
37
38
|
else
|
38
|
-
|
39
|
+
_idle
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -45,7 +46,11 @@ module Sass
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def close
|
49
|
+
@mutex.synchronize do
|
50
|
+
_close
|
51
|
+
end
|
48
52
|
@connection.close
|
53
|
+
ForkTracker.delete(self)
|
49
54
|
end
|
50
55
|
|
51
56
|
def closed?
|
@@ -54,7 +59,7 @@ module Sass
|
|
54
59
|
|
55
60
|
def error(error)
|
56
61
|
observers = @mutex.synchronize do
|
57
|
-
|
62
|
+
_close
|
58
63
|
@observers.values
|
59
64
|
end
|
60
65
|
|
@@ -70,12 +75,12 @@ module Sass
|
|
70
75
|
def receive_proto(id, proto)
|
71
76
|
case id
|
72
77
|
when 1...0xffffffff
|
73
|
-
@mutex.synchronize { @observers[id] }
|
78
|
+
@mutex.synchronize { @observers[id] }&.receive_proto(proto)
|
74
79
|
when 0
|
75
80
|
outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
76
81
|
oneof = outbound_message.message
|
77
82
|
message = outbound_message.public_send(oneof)
|
78
|
-
@mutex.synchronize { @observers[message.id] }
|
83
|
+
@mutex.synchronize { @observers[message.id] }&.public_send(oneof, message)
|
79
84
|
when 0xffffffff
|
80
85
|
outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
81
86
|
oneof = outbound_message.message
|
@@ -90,6 +95,24 @@ module Sass
|
|
90
95
|
@connection.write(...)
|
91
96
|
end
|
92
97
|
|
98
|
+
private
|
99
|
+
|
100
|
+
def _close
|
101
|
+
@id = 0xffffffff
|
102
|
+
end
|
103
|
+
|
104
|
+
def _closed?
|
105
|
+
@id == 0xffffffff
|
106
|
+
end
|
107
|
+
|
108
|
+
def _idle
|
109
|
+
@id = 1
|
110
|
+
end
|
111
|
+
|
112
|
+
def _idle?
|
113
|
+
@id == 1
|
114
|
+
end
|
115
|
+
|
93
116
|
# The {Channel} between {Dispatcher} and {Host}.
|
94
117
|
class Channel
|
95
118
|
attr_reader :id
|
@@ -104,9 +127,7 @@ module Sass
|
|
104
127
|
end
|
105
128
|
|
106
129
|
def error(...)
|
107
|
-
|
108
|
-
@dispatcher.error(...)
|
109
|
-
end
|
130
|
+
@dispatcher.error(...)
|
110
131
|
end
|
111
132
|
|
112
133
|
def send_proto(...)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
class
|
4
|
+
class Compiler
|
5
5
|
class Host
|
6
6
|
# The {FunctionRegistry} class.
|
7
7
|
#
|
@@ -55,8 +55,8 @@ module Sass
|
|
55
55
|
|
56
56
|
EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
|
57
57
|
id: function_call_request.id,
|
58
|
-
success
|
59
|
-
accessed_argument_lists:
|
58
|
+
success:,
|
59
|
+
accessed_argument_lists:
|
60
60
|
)
|
61
61
|
rescue StandardError => e
|
62
62
|
EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
class
|
4
|
+
class Compiler
|
5
5
|
class Host
|
6
6
|
# The {ImporterRegistry} class.
|
7
7
|
#
|
@@ -65,7 +65,7 @@ module Sass
|
|
65
65
|
|
66
66
|
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
67
67
|
id: canonicalize_request.id,
|
68
|
-
url:
|
68
|
+
url:
|
69
69
|
)
|
70
70
|
rescue StandardError => e
|
71
71
|
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
@@ -100,7 +100,7 @@ module Sass
|
|
100
100
|
|
101
101
|
EmbeddedProtocol::InboundMessage::FileImportResponse.new(
|
102
102
|
id: file_import_request.id,
|
103
|
-
file_url:
|
103
|
+
file_url:
|
104
104
|
)
|
105
105
|
rescue StandardError => e
|
106
106
|
EmbeddedProtocol::InboundMessage::FileImportResponse.new(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
class
|
4
|
+
class Compiler
|
5
5
|
class Host
|
6
6
|
# The {Structifier} module.
|
7
7
|
#
|
@@ -10,14 +10,14 @@ module Sass
|
|
10
10
|
module_function
|
11
11
|
|
12
12
|
def to_struct(obj, *symbols)
|
13
|
-
return obj unless obj.is_a?
|
13
|
+
return obj unless obj.is_a?(Hash)
|
14
14
|
|
15
15
|
struct = Object.new
|
16
16
|
symbols.each do |key|
|
17
17
|
next unless obj.key?(key)
|
18
18
|
|
19
19
|
value = obj[key]
|
20
|
-
if value.respond_to?
|
20
|
+
if value.respond_to?(:call)
|
21
21
|
struct.define_singleton_method key do |*args, **kwargs|
|
22
22
|
value.call(*args, **kwargs)
|
23
23
|
end
|
@@ -8,7 +8,7 @@ require_relative 'host/structifier'
|
|
8
8
|
require_relative 'host/value_protofier'
|
9
9
|
|
10
10
|
module Sass
|
11
|
-
class
|
11
|
+
class Compiler
|
12
12
|
# The {Host} class.
|
13
13
|
#
|
14
14
|
# It communicates with {Dispatcher} and handles the host logic.
|
@@ -35,16 +35,16 @@ module Sass
|
|
35
35
|
quiet_deps:,
|
36
36
|
verbose:)
|
37
37
|
compile_response = await do
|
38
|
-
alert_color =
|
38
|
+
alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil?
|
39
39
|
|
40
|
-
@function_registry = FunctionRegistry.new(functions, alert_color:
|
41
|
-
@importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:
|
40
|
+
@function_registry = FunctionRegistry.new(functions, alert_color:)
|
41
|
+
@importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:)
|
42
42
|
@logger_registry = LoggerRegistry.new(logger)
|
43
43
|
|
44
44
|
send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new(
|
45
45
|
string: unless source.nil?
|
46
46
|
EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
|
47
|
-
source
|
47
|
+
source:,
|
48
48
|
url: url&.to_s,
|
49
49
|
syntax: Protofier.to_proto_syntax(syntax),
|
50
50
|
importer: (@importer_registry.register(importer) unless importer.nil?)
|
@@ -52,15 +52,15 @@ module Sass
|
|
52
52
|
end,
|
53
53
|
path: (File.absolute_path(path) unless path.nil?),
|
54
54
|
style: Protofier.to_proto_output_style(style),
|
55
|
-
charset
|
56
|
-
source_map
|
57
|
-
source_map_include_sources
|
55
|
+
charset:,
|
56
|
+
source_map:,
|
57
|
+
source_map_include_sources:,
|
58
58
|
importers: @importer_registry.importers,
|
59
59
|
global_functions: @function_registry.global_functions,
|
60
|
-
alert_ascii
|
61
|
-
alert_color
|
62
|
-
quiet_deps
|
63
|
-
verbose:
|
60
|
+
alert_ascii:,
|
61
|
+
alert_color:,
|
62
|
+
quiet_deps:,
|
63
|
+
verbose:
|
64
64
|
))
|
65
65
|
end
|
66
66
|
|
@@ -70,7 +70,7 @@ module Sass
|
|
70
70
|
def version_request
|
71
71
|
version_response = await0 do
|
72
72
|
send_message0(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new(
|
73
|
-
id:
|
73
|
+
id:
|
74
74
|
))
|
75
75
|
end
|
76
76
|
|
@@ -100,6 +100,8 @@ module Sass
|
|
100
100
|
|
101
101
|
def log_event(message)
|
102
102
|
@logger_registry.log(message)
|
103
|
+
rescue StandardError => e
|
104
|
+
@channel.error(e)
|
103
105
|
end
|
104
106
|
|
105
107
|
def canonicalize_request(message)
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
class
|
4
|
+
class Compiler
|
5
5
|
# The {ResilientDispatcher} class.
|
6
6
|
#
|
7
7
|
# It recovers from failures and continues to function.
|
8
8
|
class ResilientDispatcher
|
9
|
-
def initialize
|
10
|
-
@
|
9
|
+
def initialize(dispatcher_class)
|
10
|
+
@dispatcher_class = dispatcher_class
|
11
|
+
@dispatcher = @dispatcher_class.new
|
11
12
|
@mutex = Mutex.new
|
12
13
|
end
|
13
14
|
|
@@ -29,7 +30,7 @@ module Sass
|
|
29
30
|
@mutex.synchronize do
|
30
31
|
@dispatcher.connect(...)
|
31
32
|
rescue Errno::EBUSY
|
32
|
-
@dispatcher =
|
33
|
+
@dispatcher = @dispatcher_class.new
|
33
34
|
@dispatcher.connect(...)
|
34
35
|
end
|
35
36
|
end
|