sass-embedded 1.2.2 → 1.2.5
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/lib/sass/embedded/compiler.rb +1 -1
- data/lib/sass/embedded/dispatcher.rb +22 -22
- data/lib/sass/embedded/host.rb +8 -11
- data/lib/sass/embedded/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dffd620ac06d052e6e95e09031ad514c89fba2412d782dd1f546db088936056
|
4
|
+
data.tar.gz: b370d90e94189504b07f35256ea2dc5891f879236d11e99fc443cf6becbd8e4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ec4d5b99e9cdcfcbfef8bce95625f81860dafbad7cdd86f8077a14786a28b6ec969caccb5de2a2cc88e592757af2b74f61d68d212575382b7060ac33a90626
|
7
|
+
data.tar.gz: 4f43882a8d3eea5788297a604cca8742d13a66061cebd5ab791e68922f5acb25c26e138b33a5fc6de552f8dc6e7b0563f617c1321399e493b07a274abb527efe
|
@@ -6,20 +6,24 @@ module Sass
|
|
6
6
|
#
|
7
7
|
# It dispatches messages between mutliple instances of {Host} and a single {Compiler}.
|
8
8
|
class Dispatcher
|
9
|
-
PROTOCOL_ERROR_ID =
|
9
|
+
PROTOCOL_ERROR_ID = 0xffffffff
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@compiler = Compiler.new
|
13
13
|
@observers = {}
|
14
|
-
|
14
|
+
# TODO: Revert to `@id = 0` when upstream bug is fixed
|
15
|
+
# https://github.com/sass/dart-sass-embedded/pull/80
|
16
|
+
@id = 0xfffffffe
|
15
17
|
@mutex = Mutex.new
|
16
18
|
|
17
19
|
Thread.new do
|
18
20
|
loop do
|
19
21
|
receive_message EmbeddedProtocol::OutboundMessage.decode @compiler.read
|
20
|
-
rescue IOError,
|
21
|
-
|
22
|
-
|
22
|
+
rescue IOError, Errno::EBADF => e
|
23
|
+
@mutex.synchronize do
|
24
|
+
@id = PROTOCOL_ERROR_ID
|
25
|
+
@observers.values
|
26
|
+
end.each do |observer|
|
23
27
|
observer.error e
|
24
28
|
end
|
25
29
|
break
|
@@ -29,7 +33,7 @@ module Sass
|
|
29
33
|
|
30
34
|
def subscribe(observer)
|
31
35
|
@mutex.synchronize do
|
32
|
-
raise EOFError if
|
36
|
+
raise EOFError if @id == PROTOCOL_ERROR_ID
|
33
37
|
|
34
38
|
id = @id
|
35
39
|
@id = id.next
|
@@ -39,9 +43,11 @@ module Sass
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def unsubscribe(id)
|
42
|
-
@
|
46
|
+
@mutex.synchronize do
|
47
|
+
@observers.delete(id)
|
43
48
|
|
44
|
-
|
49
|
+
close if @id == PROTOCOL_ERROR_ID && @observers.empty?
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
47
53
|
def close
|
@@ -58,27 +64,21 @@ module Sass
|
|
58
64
|
|
59
65
|
private
|
60
66
|
|
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
67
|
def receive_message(outbound_message)
|
72
68
|
oneof = outbound_message.message
|
73
69
|
message = outbound_message.public_send(oneof)
|
74
70
|
case oneof
|
75
71
|
when :error
|
76
|
-
|
77
|
-
|
72
|
+
@mutex.synchronize do
|
73
|
+
@id = PROTOCOL_ERROR_ID
|
74
|
+
message.id == PROTOCOL_ERROR_ID ? @observers.values : [@observers[message.id]]
|
75
|
+
end.each do |observer|
|
76
|
+
observer.public_send(oneof, message)
|
77
|
+
end
|
78
78
|
when :compile_response, :version_response
|
79
|
-
@observers[message.id].public_send(oneof, message)
|
79
|
+
@mutex.synchronize { @observers[message.id] }.public_send(oneof, message)
|
80
80
|
when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request
|
81
|
-
Thread.new(@observers[message.compilation_id]) do |observer|
|
81
|
+
Thread.new(@mutex.synchronize { @observers[message.compilation_id] }) do |observer|
|
82
82
|
observer.public_send(oneof, message)
|
83
83
|
end
|
84
84
|
else
|
data/lib/sass/embedded/host.rb
CHANGED
@@ -13,7 +13,6 @@ module Sass
|
|
13
13
|
class Host
|
14
14
|
def initialize(channel)
|
15
15
|
@channel = channel
|
16
|
-
@mutex = Mutex.new
|
17
16
|
end
|
18
17
|
|
19
18
|
def id
|
@@ -126,16 +125,14 @@ module Sass
|
|
126
125
|
private
|
127
126
|
|
128
127
|
def await
|
129
|
-
@
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
@connection.disconnect
|
138
|
-
end
|
128
|
+
raise EOFError if defined? @async
|
129
|
+
|
130
|
+
@connection = @channel.connect(self)
|
131
|
+
@async = Async.new
|
132
|
+
yield
|
133
|
+
@async.await
|
134
|
+
ensure
|
135
|
+
@connection.disconnect
|
139
136
|
end
|
140
137
|
end
|
141
138
|
|
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.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -159,8 +159,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
161
|
metadata:
|
162
|
-
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.2.
|
163
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.2.
|
162
|
+
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.2.5
|
163
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.2.5
|
164
164
|
funding_uri: https://github.com/sponsors/ntkme
|
165
165
|
post_install_message:
|
166
166
|
rdoc_options: []
|