sass-embedded 1.63.3-x86_64-darwin → 1.63.4-x86_64-darwin

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: 7e75829f406d92636a36da94712e4e728142119f6fa75ce589f65876844e25e0
4
- data.tar.gz: 38717b72a4c815e30b835ae3d7bf334d30c78314b12d64778a9de5268d79c927
3
+ metadata.gz: 44521962732456ece8d4c10046a43b7e5719b2e616cbb545fb8e455d636cc749
4
+ data.tar.gz: d751bb0b2db77685248c0f1e043b8c5209ab17dd28eef67034326b34a9092b22
5
5
  SHA512:
6
- metadata.gz: 7ee68d5293eff8dfd186857bf8e609ab86c9430e6c66d0b2d23b780c2ea3314a64e16d2f0567e24a8fc2e50ad23486b47455c39a54c382ed6d2e306d14aa5380
7
- data.tar.gz: f7657bfada20fef84bd7eb67c04d9cb5437f217f7066126ad6767b35dd5c50a933f289b1c5ff483e01c3a993da3be2d269ad2cef7faef23e6904fcf42f1be89c
6
+ metadata.gz: a7c44ab021b3763a50abf79d4ebe27278f0d1253c951df6ad2d674c25d0058169afcba5743e417087d6070baea143ca483b667d7567f9f1e7d7a9cd70851d0fb
7
+ data.tar.gz: f5ab444eb79135829edcc9d40817fa8d03491a473b60b01a040d45746b8408b17392dff44ec8e5bfc9cbe8838e54dfcb21a5d20944af5b9adac89acdd1097abb
Binary file
@@ -4,10 +4,10 @@ require 'open3'
4
4
 
5
5
  module Sass
6
6
  class Embedded
7
- # The {Compiler} class.
7
+ # The stdio based {Connection} between the {Dispatcher} and the compiler.
8
8
  #
9
- # It runs the `sass --embedded` process.
10
- class Compiler
9
+ # It runs the `sass --embedded` command.
10
+ class Connection
11
11
  def initialize
12
12
  @stdin, @stdout, @stderr, @wait_thread = begin
13
13
  Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
@@ -67,6 +67,6 @@ module Sass
67
67
  end
68
68
  end
69
69
 
70
- private_constant :Compiler
70
+ private_constant :Connection
71
71
  end
72
72
  end
@@ -4,12 +4,12 @@ module Sass
4
4
  class Embedded
5
5
  # The {Dispatcher} class.
6
6
  #
7
- # It dispatches messages between mutliple instances of {Host} and a single {Compiler}.
7
+ # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler.
8
8
  class Dispatcher
9
9
  UINT_MAX = 0xffffffff
10
10
 
11
11
  def initialize
12
- @compiler = Compiler.new
12
+ @connection = Connection.new
13
13
  @observers = {}
14
14
  @id = 1
15
15
  @mutex = Mutex.new
@@ -58,22 +58,26 @@ module Sass
58
58
  end
59
59
  end
60
60
 
61
+ def connect(host)
62
+ Channel.new(self, host)
63
+ end
64
+
61
65
  def close
62
- @compiler.close
66
+ @connection.close
63
67
  end
64
68
 
65
69
  def closed?
66
- @compiler.closed?
70
+ @connection.closed?
67
71
  end
68
72
 
69
73
  def send_proto(...)
70
- @compiler.write(...)
74
+ @connection.write(...)
71
75
  end
72
76
 
73
77
  private
74
78
 
75
79
  def receive_proto
76
- id, proto = @compiler.read
80
+ id, proto = @connection.read
77
81
  case id
78
82
  when 1...UINT_MAX
79
83
  @mutex.synchronize { @observers[id] }.receive_proto(proto)
@@ -91,6 +95,26 @@ module Sass
91
95
  raise Errno::EPROTO
92
96
  end
93
97
  end
98
+
99
+ # The {Channel} between {Dispatcher} and {Host}.
100
+ class Channel
101
+ attr_reader :id
102
+
103
+ def initialize(dispatcher, host)
104
+ @dispatcher = dispatcher
105
+ @id = @dispatcher.subscribe(host)
106
+ end
107
+
108
+ def disconnect
109
+ @dispatcher.unsubscribe(id)
110
+ end
111
+
112
+ def send_proto(...)
113
+ @dispatcher.send_proto(...)
114
+ end
115
+ end
116
+
117
+ private_constant :Channel
94
118
  end
95
119
 
96
120
  private_constant :Dispatcher
@@ -11,8 +11,8 @@ module Sass
11
11
  #
12
12
  # It communicates with {Dispatcher} and handles the host logic.
13
13
  class Host
14
- def initialize(channel)
15
- @channel = channel
14
+ def initialize(dispatcher)
15
+ @dispatcher = dispatcher
16
16
  end
17
17
 
18
18
  def compile_request(path:,
@@ -117,7 +117,7 @@ module Sass
117
117
  private
118
118
 
119
119
  def await0
120
- @connection = @channel.connect(self)
120
+ @channel = @dispatcher.connect(self)
121
121
  @queue = Queue.new
122
122
 
123
123
  yield
@@ -128,11 +128,11 @@ module Sass
128
128
 
129
129
  @result
130
130
  ensure
131
- @connection&.disconnect
131
+ @channel&.disconnect
132
132
  end
133
133
 
134
134
  def await
135
- @connection = @channel.connect(self)
135
+ @channel = @dispatcher.connect(self)
136
136
  @queue = Queue.new
137
137
 
138
138
  yield
@@ -148,21 +148,21 @@ module Sass
148
148
 
149
149
  @result
150
150
  ensure
151
- @connection&.disconnect
151
+ @channel&.disconnect
152
152
  end
153
153
 
154
154
  def id
155
- @connection.id
155
+ @channel.id
156
156
  end
157
157
 
158
158
  def send_message0(...)
159
159
  inbound_message = EmbeddedProtocol::InboundMessage.new(...)
160
- @connection.send_proto(0, inbound_message.to_proto)
160
+ @channel.send_proto(0, inbound_message.to_proto)
161
161
  end
162
162
 
163
163
  def send_message(...)
164
164
  inbound_message = EmbeddedProtocol::InboundMessage.new(...)
165
- @connection.send_proto(id, inbound_message.to_proto)
165
+ @channel.send_proto(id, inbound_message.to_proto)
166
166
  end
167
167
  end
168
168
 
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ class Embedded
5
+ # The {ResilientDispatcher} class.
6
+ #
7
+ # It recovers from failures and continues to function.
8
+ class ResilientDispatcher
9
+ def initialize
10
+ @dispatcher = Dispatcher.new
11
+ @mutex = Mutex.new
12
+ end
13
+
14
+ def close
15
+ @mutex.synchronize do
16
+ @dispatcher.close
17
+ end
18
+ end
19
+
20
+ def closed?
21
+ @mutex.synchronize do
22
+ @dispatcher.closed?
23
+ end
24
+ end
25
+
26
+ def connect(host)
27
+ @dispatcher.connect(host)
28
+ rescue Errno::EBUSY
29
+ @mutex.synchronize do
30
+ @dispatcher.connect(host)
31
+ rescue Errno::EBUSY
32
+ @dispatcher = Dispatcher.new
33
+ @dispatcher.connect(host)
34
+ end
35
+ end
36
+ end
37
+
38
+ private_constant :ResilientDispatcher
39
+ end
40
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.63.3'
5
+ VERSION = '1.63.4'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -4,11 +4,11 @@ require_relative '../../ext/sass/cli'
4
4
  require_relative '../../ext/sass/embedded_sass_pb'
5
5
  require_relative 'compile_error'
6
6
  require_relative 'compile_result'
7
- require_relative 'embedded/channel'
8
- require_relative 'embedded/compiler'
7
+ require_relative 'embedded/connection'
9
8
  require_relative 'embedded/dispatcher'
10
9
  require_relative 'embedded/host'
11
10
  require_relative 'embedded/protofier'
11
+ require_relative 'embedded/resilient_dispatcher'
12
12
  require_relative 'embedded/structifier'
13
13
  require_relative 'embedded/varint'
14
14
  require_relative 'embedded/version'
@@ -80,7 +80,7 @@ module Sass
80
80
  # rubocop:enable Layout/LineLength
81
81
 
82
82
  # The {Embedded} host for using dart-sass. Each instance creates its own
83
- # communication {Channel} with a dedicated compiler process.
83
+ # communication {Dispatcher} with a dedicated compiler process.
84
84
  #
85
85
  # @example
86
86
  # embedded = Sass::Embedded.new
@@ -89,7 +89,7 @@ module Sass
89
89
  # embedded.close
90
90
  class Embedded
91
91
  def initialize
92
- @channel = Channel.new
92
+ @dispatcher = ResilientDispatcher.new
93
93
  end
94
94
 
95
95
  # Compiles the Sass file at +path+ to CSS.
@@ -138,7 +138,7 @@ module Sass
138
138
  verbose: false)
139
139
  raise ArgumentError, 'path must be set' if path.nil?
140
140
 
141
- Host.new(@channel).compile_request(
141
+ Host.new(@dispatcher).compile_request(
142
142
  path: path,
143
143
  source: nil,
144
144
  importer: nil,
@@ -212,7 +212,7 @@ module Sass
212
212
  verbose: false)
213
213
  raise ArgumentError, 'source must be set' if source.nil?
214
214
 
215
- Host.new(@channel).compile_request(
215
+ Host.new(@dispatcher).compile_request(
216
216
  path: nil,
217
217
  source: source,
218
218
  importer: importer,
@@ -236,15 +236,15 @@ module Sass
236
236
  # @return [String] Information about the Sass implementation.
237
237
  # @see https://sass-lang.com/documentation/js-api/modules#info
238
238
  def info
239
- @info ||= Host.new(@channel).version_request
239
+ @info ||= Host.new(@dispatcher).version_request
240
240
  end
241
241
 
242
242
  def close
243
- @channel.close
243
+ @dispatcher.close
244
244
  end
245
245
 
246
246
  def closed?
247
- @channel.closed?
247
+ @dispatcher.closed?
248
248
  end
249
249
  end
250
250
 
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.63.3
4
+ version: 1.63.4
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-09 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -47,8 +47,7 @@ files:
47
47
  - lib/sass/compile_result.rb
48
48
  - lib/sass/elf.rb
49
49
  - lib/sass/embedded.rb
50
- - lib/sass/embedded/channel.rb
51
- - lib/sass/embedded/compiler.rb
50
+ - lib/sass/embedded/connection.rb
52
51
  - lib/sass/embedded/dispatcher.rb
53
52
  - lib/sass/embedded/host.rb
54
53
  - lib/sass/embedded/host/function_registry.rb
@@ -56,6 +55,7 @@ files:
56
55
  - lib/sass/embedded/host/logger_registry.rb
57
56
  - lib/sass/embedded/host/value_protofier.rb
58
57
  - lib/sass/embedded/protofier.rb
58
+ - lib/sass/embedded/resilient_dispatcher.rb
59
59
  - lib/sass/embedded/structifier.rb
60
60
  - lib/sass/embedded/varint.rb
61
61
  - lib/sass/embedded/version.rb
@@ -79,8 +79,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
79
79
  licenses:
80
80
  - MIT
81
81
  metadata:
82
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.63.3
83
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.63.3
82
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.63.4
83
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.63.4
84
84
  funding_uri: https://github.com/sponsors/ntkme
85
85
  post_install_message:
86
86
  rdoc_options: []
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.4.13
100
+ rubygems_version: 3.4.14
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Use dart-sass with Ruby!
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- # The {Channel} class.
6
- #
7
- # It establishes connection between {Host} and {Dispatcher}.
8
- class Channel
9
- def initialize
10
- @dispatcher = Dispatcher.new
11
- @mutex = Mutex.new
12
- end
13
-
14
- def close
15
- @mutex.synchronize do
16
- @dispatcher.close
17
- end
18
- end
19
-
20
- def closed?
21
- @mutex.synchronize do
22
- @dispatcher.closed?
23
- end
24
- end
25
-
26
- def connect(observer)
27
- @mutex.synchronize do
28
- begin
29
- id = @dispatcher.subscribe(observer)
30
- rescue Errno::EBUSY
31
- @dispatcher = Dispatcher.new
32
- id = @dispatcher.subscribe(observer)
33
- end
34
- Connection.new(@dispatcher, id)
35
- end
36
- end
37
-
38
- # The {Connection} between {Host} to {Dispatcher}.
39
- class Connection
40
- attr_reader :id
41
-
42
- def initialize(dispatcher, id)
43
- @dispatcher = dispatcher
44
- @id = id
45
- end
46
-
47
- def disconnect
48
- @dispatcher.unsubscribe(id)
49
- end
50
-
51
- def send_proto(...)
52
- @dispatcher.send_proto(...)
53
- end
54
- end
55
-
56
- private_constant :Connection
57
- end
58
-
59
- private_constant :Channel
60
- end
61
- end