sass-embedded 0.18.4 → 0.19.2
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/extconf.rb +5 -3
- data/lib/sass/embedded/async.rb +65 -0
- data/lib/sass/embedded/channel.rb +21 -22
- data/lib/sass/embedded/compiler.rb +17 -83
- data/lib/sass/embedded/dispatcher.rb +92 -0
- data/lib/sass/embedded/{compile_context → host}/function_registry.rb +6 -4
- data/lib/sass/embedded/{compile_context → host}/importer_registry.rb +6 -4
- data/lib/sass/embedded/{compile_context → host}/logger_registry.rb +4 -2
- data/lib/sass/embedded/{compile_context → host}/value_protofier.rb +4 -2
- data/lib/sass/embedded/host.rb +135 -0
- data/lib/sass/embedded/legacy.rb +8 -9
- data/lib/sass/embedded/protofier.rb +18 -32
- data/lib/sass/embedded/structifier.rb +3 -1
- data/lib/sass/embedded/varint.rb +3 -1
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +37 -39
- data/lib/sass/value/argument_list.rb +2 -2
- data/lib/sass/value/boolean.rb +5 -3
- data/lib/sass/value/color.rb +12 -5
- data/lib/sass/value/function.rb +5 -3
- data/lib/sass/value/fuzzy_math.rb +1 -1
- data/lib/sass/value/list.rb +5 -3
- data/lib/sass/value/map.rb +5 -3
- data/lib/sass/value/null.rb +5 -3
- data/lib/sass/value/number/unit.rb +1 -1
- data/lib/sass/value/number.rb +5 -3
- data/lib/sass/value/string.rb +5 -3
- data/lib/sass/value.rb +1 -1
- data/lib/sass.rb +8 -13
- metadata +11 -12
- data/lib/sass/embedded/compile_context.rb +0 -107
- data/lib/sass/embedded/observer.rb +0 -49
- data/lib/sass/embedded/protocol_error.rb +0 -7
- data/lib/sass/embedded/version_context.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 827e324d735fe63938d7ddeb8d13c31577d9eec28971561bf6eae4cca7013eeb
|
4
|
+
data.tar.gz: b8536a68113173ca68edecca565ef7f4e13aba5a647902f0dd4d1411c2127380
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c16c31eec049d62c380049e2b565fcb1d05c55205f3f5966b43b47fd058d1c0fffc959f178ed68b47465cbd0c152b355c8196912a3688ba01a2c5783a2b9719
|
7
|
+
data.tar.gz: 4d4836379db8fa44061bf92c49c2a49dcb76f0299fad42df56c8c4d59ce0babf66d8245f3c73e36b51a6f58062050e9bff8bccbfb5356a8b87b40329abcb1f41
|
data/ext/sass/extconf.rb
CHANGED
@@ -215,9 +215,11 @@ module Sass
|
|
215
215
|
def default_sass_embedded_protocol
|
216
216
|
repo = 'sass/embedded-protocol'
|
217
217
|
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
stdout, stderr, status = Open3.capture3(Compiler::PATH, '--version')
|
219
|
+
|
220
|
+
raise stderr unless status.success?
|
221
|
+
|
222
|
+
tag_name = JSON.parse(stdout)['protocolVersion']
|
221
223
|
|
222
224
|
"https://raw.githubusercontent.com/#{repo}/#{tag_name}/embedded_sass.proto"
|
223
225
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Embedded
|
5
|
+
# The {Async} class.
|
6
|
+
#
|
7
|
+
# It awaits until the promise is resolved or rejected.
|
8
|
+
class Async
|
9
|
+
module State
|
10
|
+
PENDING = 0
|
11
|
+
FULFILLED = 1
|
12
|
+
REJECTED = 2
|
13
|
+
end
|
14
|
+
|
15
|
+
private_constant :State
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@error = nil
|
19
|
+
@result = nil
|
20
|
+
@state = State::PENDING
|
21
|
+
|
22
|
+
@condition_variable = ConditionVariable.new
|
23
|
+
@mutex = Mutex.new
|
24
|
+
|
25
|
+
begin
|
26
|
+
yield if block_given?
|
27
|
+
rescue StandardError => e
|
28
|
+
reject e
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def resolve(value)
|
33
|
+
@mutex.synchronize do
|
34
|
+
return unless @state == State::PENDING
|
35
|
+
|
36
|
+
@state = State::FULFILLED
|
37
|
+
@result = value
|
38
|
+
@condition_variable.broadcast
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def reject(reason)
|
43
|
+
@mutex.synchronize do
|
44
|
+
return unless @state == State::PENDING
|
45
|
+
|
46
|
+
@state = State::REJECTED
|
47
|
+
@error = reason
|
48
|
+
@condition_variable.broadcast
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def await
|
53
|
+
@mutex.synchronize do
|
54
|
+
@condition_variable.wait(@mutex) if @state == State::PENDING
|
55
|
+
|
56
|
+
raise @error if @state == State::REJECTED
|
57
|
+
|
58
|
+
@result
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private_constant :Async
|
64
|
+
end
|
65
|
+
end
|
@@ -2,59 +2,58 @@
|
|
2
2
|
|
3
3
|
module Sass
|
4
4
|
class Embedded
|
5
|
-
# The {Channel}
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# The {Channel} class.
|
6
|
+
#
|
7
|
+
# It establishes connection between {Host} and {Dispatcher}.
|
8
8
|
class Channel
|
9
9
|
def initialize
|
10
10
|
@mutex = Mutex.new
|
11
|
-
@
|
11
|
+
@dispatcher = Dispatcher.new
|
12
12
|
end
|
13
13
|
|
14
14
|
def close
|
15
15
|
@mutex.synchronize do
|
16
|
-
@
|
16
|
+
@dispatcher.close
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def closed?
|
21
21
|
@mutex.synchronize do
|
22
|
-
@
|
22
|
+
@dispatcher.closed?
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def connect(observer)
|
27
27
|
@mutex.synchronize do
|
28
28
|
begin
|
29
|
-
id = @
|
30
|
-
rescue
|
31
|
-
@
|
32
|
-
id = @
|
29
|
+
id = @dispatcher.subscribe(observer)
|
30
|
+
rescue EOFError
|
31
|
+
@dispatcher = Dispatcher.new
|
32
|
+
id = @dispatcher.subscribe(observer)
|
33
33
|
end
|
34
|
-
|
34
|
+
Connection.new(@dispatcher, id)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# The {
|
39
|
-
class
|
38
|
+
# The {Connection} between {Host} to {Dispatcher}.
|
39
|
+
class Connection
|
40
40
|
attr_reader :id
|
41
41
|
|
42
|
-
def initialize(
|
43
|
-
@
|
44
|
-
@observer = observer
|
42
|
+
def initialize(dispatcher, id)
|
43
|
+
@dispatcher = dispatcher
|
45
44
|
@id = id
|
46
45
|
end
|
47
46
|
|
48
|
-
def
|
49
|
-
@
|
47
|
+
def disconnect
|
48
|
+
@dispatcher.unsubscribe(id)
|
50
49
|
end
|
51
50
|
|
52
|
-
def send_message(
|
53
|
-
@
|
51
|
+
def send_message(message)
|
52
|
+
@dispatcher.send_message(message)
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
|
-
private_constant :
|
56
|
+
private_constant :Connection
|
58
57
|
end
|
59
58
|
|
60
59
|
private_constant :Channel
|
@@ -1,65 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'observer'
|
4
3
|
require 'open3'
|
5
4
|
|
6
5
|
module Sass
|
7
6
|
class Embedded
|
8
|
-
# The {
|
9
|
-
#
|
10
|
-
#
|
7
|
+
# The {Compiler} class.
|
8
|
+
#
|
9
|
+
# It runs the `dart-sass-embedded` process.
|
11
10
|
class Compiler
|
12
|
-
include Observable
|
13
|
-
|
14
11
|
PATH = File.absolute_path(
|
15
12
|
"../../../ext/sass/sass_embedded/dart-sass-embedded#{Gem.win_platform? ? '.bat' : ''}", __dir__
|
16
13
|
)
|
17
14
|
|
18
|
-
PROTOCOL_ERROR_ID = 4_294_967_295
|
19
|
-
|
20
15
|
def initialize
|
21
|
-
@observerable_mutex = Mutex.new
|
22
|
-
@id = 0
|
23
16
|
@stdin_mutex = Mutex.new
|
17
|
+
@stdout_mutex = Mutex.new
|
24
18
|
@stdin, @stdout, @stderr, @wait_thread = Open3.popen3(PATH)
|
25
19
|
|
26
20
|
[@stdin, @stdout].each(&:binmode)
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_observer(*)
|
37
|
-
@observerable_mutex.synchronize do
|
38
|
-
raise ProtocolError, 'half-closed compiler' if half_closed?
|
39
|
-
|
40
|
-
super
|
41
|
-
|
42
|
-
id = @id
|
43
|
-
@id = @id.next
|
44
|
-
id
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def delete_observer(*)
|
49
|
-
@observerable_mutex.synchronize do
|
50
|
-
super
|
51
|
-
|
52
|
-
close if half_closed? && count_observers.zero?
|
22
|
+
Thread.new do
|
23
|
+
loop do
|
24
|
+
warn(@stderr.readline, uplevel: 1)
|
25
|
+
rescue IOError
|
26
|
+
break
|
27
|
+
end
|
53
28
|
end
|
54
29
|
end
|
55
30
|
|
56
|
-
def send_message(message)
|
57
|
-
write Protofier.to_proto_message message
|
58
|
-
end
|
59
|
-
|
60
31
|
def close
|
61
|
-
delete_observers
|
62
|
-
|
63
32
|
@stdin_mutex.synchronize do
|
64
33
|
@stdin.close unless @stdin.closed?
|
65
34
|
@stdout.close unless @stdout.closed?
|
@@ -75,54 +44,19 @@ module Sass
|
|
75
44
|
end
|
76
45
|
end
|
77
46
|
|
78
|
-
private
|
79
|
-
|
80
|
-
def half_closed?
|
81
|
-
@id == PROTOCOL_ERROR_ID
|
82
|
-
end
|
83
|
-
|
84
|
-
def poll
|
85
|
-
Thread.new do
|
86
|
-
loop do
|
87
|
-
yield
|
88
|
-
rescue StandardError
|
89
|
-
break
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def notify_observers(*args)
|
95
|
-
@observerable_mutex.synchronize do
|
96
|
-
changed
|
97
|
-
super(*args)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def receive_message(message)
|
102
|
-
case message
|
103
|
-
when EmbeddedProtocol::ProtocolError
|
104
|
-
notify_observers(ProtocolError.new(message.message), nil)
|
105
|
-
close
|
106
|
-
else
|
107
|
-
notify_observers(nil, message)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def read
|
112
|
-
length = Varint.read(@stdout)
|
113
|
-
@stdout.read(length)
|
114
|
-
rescue IOError => e
|
115
|
-
notify_observers(e, nil)
|
116
|
-
close
|
117
|
-
raise e
|
118
|
-
end
|
119
|
-
|
120
47
|
def write(payload)
|
121
48
|
@stdin_mutex.synchronize do
|
122
49
|
Varint.write(@stdin, payload.length)
|
123
50
|
@stdin.write(payload)
|
124
51
|
end
|
125
52
|
end
|
53
|
+
|
54
|
+
def read
|
55
|
+
@stdout_mutex.synchronize do
|
56
|
+
length = Varint.read(@stdout)
|
57
|
+
@stdout.read(length)
|
58
|
+
end
|
59
|
+
end
|
126
60
|
end
|
127
61
|
|
128
62
|
private_constant :Compiler
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Embedded
|
5
|
+
# The {Dispatcher} class.
|
6
|
+
#
|
7
|
+
# It dispatches messages between mutliple instances of {Host} and a single {Compiler}.
|
8
|
+
class Dispatcher
|
9
|
+
PROTOCOL_ERROR_ID = 4_294_967_295
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@compiler = Compiler.new
|
13
|
+
@observers = {}
|
14
|
+
@id = 0
|
15
|
+
@mutex = Mutex.new
|
16
|
+
|
17
|
+
Thread.new do
|
18
|
+
loop do
|
19
|
+
receive_message EmbeddedProtocol::OutboundMessage.decode @compiler.read
|
20
|
+
rescue IOError => e
|
21
|
+
half_close
|
22
|
+
@observers.each_value do |observer|
|
23
|
+
observer.error e
|
24
|
+
end
|
25
|
+
break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def subscribe(observer)
|
31
|
+
@mutex.synchronize do
|
32
|
+
raise EOFError if half_closed?
|
33
|
+
|
34
|
+
id = @id
|
35
|
+
@id = id.next
|
36
|
+
@observers[id] = observer
|
37
|
+
id
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def unsubscribe(id)
|
42
|
+
@observers.delete(id)
|
43
|
+
|
44
|
+
close if half_closed? && @observers.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def close
|
48
|
+
@compiler.close
|
49
|
+
end
|
50
|
+
|
51
|
+
def closed?
|
52
|
+
@compiler.closed?
|
53
|
+
end
|
54
|
+
|
55
|
+
def send_message(inbound_message)
|
56
|
+
@compiler.write(inbound_message.to_proto)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def half_close
|
62
|
+
@mutex.synchronize do
|
63
|
+
@id = PROTOCOL_ERROR_ID
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def half_closed?
|
68
|
+
@id == PROTOCOL_ERROR_ID
|
69
|
+
end
|
70
|
+
|
71
|
+
def receive_message(outbound_message)
|
72
|
+
message = outbound_message.send(outbound_message.message)
|
73
|
+
|
74
|
+
case outbound_message.message
|
75
|
+
when :error
|
76
|
+
half_close
|
77
|
+
@observers[message.id]&.send(outbound_message.message, message)
|
78
|
+
when :compile_response, :version_response
|
79
|
+
@observers[message.id].send(outbound_message.message, message)
|
80
|
+
when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request
|
81
|
+
Thread.new(@observers[message.compilation_id]) do |observer|
|
82
|
+
observer.send(outbound_message.message, message)
|
83
|
+
end
|
84
|
+
else
|
85
|
+
raise ArgumentError, "Unknown OutboundMessage.message #{message}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private_constant :Dispatcher
|
91
|
+
end
|
92
|
+
end
|
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
module Sass
|
4
4
|
class Embedded
|
5
|
-
class
|
6
|
-
# The {FunctionRegistry}
|
5
|
+
class Host
|
6
|
+
# The {FunctionRegistry} class.
|
7
|
+
#
|
8
|
+
# It stores sass custom functions and handles function calls.
|
7
9
|
class FunctionRegistry
|
8
10
|
attr_reader :global_functions
|
9
11
|
|
10
|
-
def initialize(functions,
|
12
|
+
def initialize(functions, alert_color:)
|
11
13
|
functions = functions.transform_keys(&:to_s)
|
12
14
|
|
13
15
|
@global_functions = functions.keys
|
@@ -25,7 +27,7 @@ module Sass
|
|
25
27
|
@functions_by_id = {}
|
26
28
|
@ids_by_function = {}
|
27
29
|
|
28
|
-
@highlight =
|
30
|
+
@highlight = alert_color
|
29
31
|
end
|
30
32
|
|
31
33
|
def register(function)
|
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
module Sass
|
4
4
|
class Embedded
|
5
|
-
class
|
6
|
-
# The {ImporterRegistry}
|
5
|
+
class Host
|
6
|
+
# The {ImporterRegistry} class.
|
7
|
+
#
|
8
|
+
# It stores importers and handles import requests.
|
7
9
|
class ImporterRegistry
|
8
10
|
attr_reader :importers
|
9
11
|
|
10
|
-
def initialize(importers, load_paths,
|
12
|
+
def initialize(importers, load_paths, alert_color:)
|
11
13
|
@id = 0
|
12
14
|
@importers_by_id = {}
|
13
15
|
@importers = importers
|
@@ -20,7 +22,7 @@ module Sass
|
|
20
22
|
end
|
21
23
|
)
|
22
24
|
|
23
|
-
@highlight =
|
25
|
+
@highlight = alert_color
|
24
26
|
end
|
25
27
|
|
26
28
|
def register(importer)
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
module Sass
|
4
4
|
class Embedded
|
5
|
-
class
|
6
|
-
# The {ValueProtofier}
|
5
|
+
class Host
|
6
|
+
# The {ValueProtofier} class.
|
7
|
+
#
|
8
|
+
# It converts Pure Ruby types and Protobuf Ruby types.
|
7
9
|
class ValueProtofier
|
8
10
|
def initialize(function_registry)
|
9
11
|
@function_registry = function_registry
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Embedded
|
5
|
+
# The {Host} class.
|
6
|
+
#
|
7
|
+
# It communicates with {Dispatcher} and handles the host logic.
|
8
|
+
class Host
|
9
|
+
def initialize(channel)
|
10
|
+
@channel = channel
|
11
|
+
@mutex = Mutex.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def id
|
15
|
+
@connection.id
|
16
|
+
end
|
17
|
+
|
18
|
+
def send_message(message)
|
19
|
+
@connection.send_message(message)
|
20
|
+
end
|
21
|
+
|
22
|
+
def compile_request(path:,
|
23
|
+
source:,
|
24
|
+
importer:,
|
25
|
+
load_paths:,
|
26
|
+
syntax:,
|
27
|
+
url:,
|
28
|
+
source_map:,
|
29
|
+
source_map_include_sources:,
|
30
|
+
style:,
|
31
|
+
functions:,
|
32
|
+
importers:,
|
33
|
+
alert_ascii:,
|
34
|
+
alert_color:,
|
35
|
+
logger:,
|
36
|
+
quiet_deps:,
|
37
|
+
verbose:)
|
38
|
+
await do
|
39
|
+
@function_registry = FunctionRegistry.new(functions, alert_color: alert_color)
|
40
|
+
@importer_registry = ImporterRegistry.new(importers, load_paths, alert_color: alert_color)
|
41
|
+
@logger_registry = LoggerRegistry.new(logger)
|
42
|
+
|
43
|
+
send_message EmbeddedProtocol::InboundMessage.new(
|
44
|
+
compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new(
|
45
|
+
id: id,
|
46
|
+
string: unless source.nil?
|
47
|
+
EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
|
48
|
+
source: source,
|
49
|
+
url: url&.to_s,
|
50
|
+
syntax: Protofier.to_proto_syntax(syntax),
|
51
|
+
importer: importer.nil? ? nil : @importer_registry.register(importer)
|
52
|
+
)
|
53
|
+
end,
|
54
|
+
path: path,
|
55
|
+
style: Protofier.to_proto_output_style(style),
|
56
|
+
source_map: source_map,
|
57
|
+
source_map_include_sources: source_map_include_sources,
|
58
|
+
importers: @importer_registry.importers,
|
59
|
+
global_functions: @function_registry.global_functions,
|
60
|
+
alert_ascii: alert_ascii,
|
61
|
+
alert_color: alert_color,
|
62
|
+
quiet_deps: quiet_deps,
|
63
|
+
verbose: verbose
|
64
|
+
)
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def version_request
|
70
|
+
await do
|
71
|
+
send_message EmbeddedProtocol::InboundMessage.new(
|
72
|
+
version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new(
|
73
|
+
id: id
|
74
|
+
)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def log_event(message)
|
80
|
+
@logger_registry.log(message)
|
81
|
+
end
|
82
|
+
|
83
|
+
def compile_response(message)
|
84
|
+
@async.resolve(message)
|
85
|
+
end
|
86
|
+
|
87
|
+
def version_response(message)
|
88
|
+
@async.resolve(message)
|
89
|
+
end
|
90
|
+
|
91
|
+
def canonicalize_request(message)
|
92
|
+
send_message EmbeddedProtocol::InboundMessage.new(
|
93
|
+
canonicalize_response: @importer_registry.canonicalize(message)
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
def import_request(message)
|
98
|
+
send_message EmbeddedProtocol::InboundMessage.new(
|
99
|
+
import_response: @importer_registry.import(message)
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def file_import_request(message)
|
104
|
+
send_message EmbeddedProtocol::InboundMessage.new(
|
105
|
+
file_import_response: @importer_registry.file_import(message)
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
def function_call_request(message)
|
110
|
+
send_message EmbeddedProtocol::InboundMessage.new(
|
111
|
+
function_call_response: @function_registry.function_call(message)
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
def error(message)
|
116
|
+
@async.reject(CompileError.new(message.message, nil, nil, nil))
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def await
|
122
|
+
@mutex.synchronize do
|
123
|
+
@connection = @channel.connect(self)
|
124
|
+
@async = Async.new
|
125
|
+
yield
|
126
|
+
@async.await
|
127
|
+
ensure
|
128
|
+
@connection.disconnect
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
private_constant :Host
|
134
|
+
end
|
135
|
+
end
|
data/lib/sass/embedded/legacy.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'base64'
|
4
|
-
require 'json'
|
5
|
-
require 'pathname'
|
6
|
-
require 'uri'
|
7
|
-
|
8
3
|
# The Sass module.
|
9
4
|
#
|
10
5
|
# This communicates with Embedded Dart Sass using the Embedded Sass protocol.
|
@@ -40,7 +35,6 @@ module Sass
|
|
40
35
|
# @example
|
41
36
|
# Sass.render(file: 'style.css')
|
42
37
|
# @return [Result]
|
43
|
-
# @raise [ProtocolError]
|
44
38
|
# @raise [RenderError]
|
45
39
|
def render(**kwargs)
|
46
40
|
instance.render(**kwargs)
|
@@ -71,7 +65,6 @@ module Sass
|
|
71
65
|
# See {file:README.md#options} for supported options.
|
72
66
|
#
|
73
67
|
# @return [RenderResult]
|
74
|
-
# @raise [ProtocolError]
|
75
68
|
# @raise [RenderError]
|
76
69
|
def render(data: nil,
|
77
70
|
file: nil,
|
@@ -89,10 +82,13 @@ module Sass
|
|
89
82
|
source_map_root: '',
|
90
83
|
functions: {},
|
91
84
|
importer: [])
|
92
|
-
start = now
|
93
|
-
|
94
85
|
raise ArgumentError, 'either data or file must be set' if file.nil? && data.nil?
|
95
86
|
|
87
|
+
require 'pathname'
|
88
|
+
require 'uri'
|
89
|
+
|
90
|
+
start = now
|
91
|
+
|
96
92
|
indent_type = parse_indent_type(indent_type)
|
97
93
|
indent_width = parse_indent_width(indent_width)
|
98
94
|
linefeed = parse_linefeed(linefeed)
|
@@ -219,6 +215,9 @@ module Sass
|
|
219
215
|
source_map_root:)
|
220
216
|
return if map.nil? || map.empty?
|
221
217
|
|
218
|
+
require 'base64'
|
219
|
+
require 'json'
|
220
|
+
|
222
221
|
map_data = JSON.parse(map)
|
223
222
|
|
224
223
|
map_data['sourceRoot'] = source_map_root
|