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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ece7b47b80c138eaa6fc421f0d583576f88ff8c1400da32257286ee91b15caf9
4
- data.tar.gz: 677da00dc0a4257d5dfe2b5c8b61e3d208001b6dc1da0e517330f6277d507d88
3
+ metadata.gz: 7dffd620ac06d052e6e95e09031ad514c89fba2412d782dd1f546db088936056
4
+ data.tar.gz: b370d90e94189504b07f35256ea2dc5891f879236d11e99fc443cf6becbd8e4a
5
5
  SHA512:
6
- metadata.gz: 4cd965978023da3f88dec165ad20d478b097819c403b28d2640731b42c5afaf6ad8272f19ae84a6b1a491e88b7ced579568ccb2e53d87acb675d761f1605e90f
7
- data.tar.gz: 8fb45773f5549e264416397055ac7ebd13cdaf7826920eea2b9e15e3a81268d742ab17883b3c37bc7304d50db72cfe57acd79980f920fc0769d53443e681d364
6
+ metadata.gz: d5ec4d5b99e9cdcfcbfef8bce95625f81860dafbad7cdd86f8077a14786a28b6ec969caccb5de2a2cc88e592757af2b74f61d68d212575382b7060ac33a90626
7
+ data.tar.gz: 4f43882a8d3eea5788297a604cca8742d13a66061cebd5ab791e68922f5acb25c26e138b33a5fc6de552f8dc6e7b0563f617c1321399e493b07a274abb527efe
@@ -18,7 +18,7 @@ module Sass
18
18
  Thread.new do
19
19
  loop do
20
20
  warn(@stderr.readline, uplevel: 1)
21
- rescue IOError, SystemCallError
21
+ rescue IOError, Errno::EBADF
22
22
  break
23
23
  end
24
24
  end
@@ -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 = 4_294_967_295
9
+ PROTOCOL_ERROR_ID = 0xffffffff
10
10
 
11
11
  def initialize
12
12
  @compiler = Compiler.new
13
13
  @observers = {}
14
- @id = 0
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, SystemCallError => e
21
- half_close
22
- @observers.each_value do |observer|
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 half_closed?
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
- @observers.delete(id)
46
+ @mutex.synchronize do
47
+ @observers.delete(id)
43
48
 
44
- close if half_closed? && @observers.empty?
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
- half_close
77
- @observers[message.id]&.public_send(oneof, message)
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
@@ -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
- @mutex.synchronize do
130
- raise EOFError if defined? @async
131
-
132
- @connection = @channel.connect(self)
133
- @async = Async.new
134
- yield
135
- @async.await
136
- ensure
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.2.2'
5
+ VERSION = '1.2.5'
6
6
  end
7
7
  end
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.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-22 00:00:00.000000000 Z
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.2
163
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.2.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: []