sass-embedded 1.62.1-x86-linux-android → 1.63.1-x86-linux-android

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,17 +6,17 @@ module Sass
6
6
  class Embedded
7
7
  # The {Compiler} class.
8
8
  #
9
- # It runs the `dart-sass-embedded` process.
9
+ # It runs the `sass --embedded` process.
10
10
  class Compiler
11
11
  def initialize
12
12
  @stdin, @stdout, @stderr, @wait_thread = begin
13
- Open3.popen3(*COMMAND, chdir: __dir__)
13
+ Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
14
14
  rescue Errno::ENOENT
15
- require_relative 'elf'
15
+ require_relative '../elf'
16
16
 
17
17
  raise if ELF::INTERPRETER.nil?
18
18
 
19
- Open3.popen3(ELF::INTERPRETER, *COMMAND, chdir: __dir__)
19
+ Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
20
20
  end
21
21
 
22
22
  @stdin.binmode
@@ -49,17 +49,20 @@ module Sass
49
49
  end
50
50
  end
51
51
 
52
- def write(payload)
52
+ def write(id, proto)
53
53
  @stdin_mutex.synchronize do
54
- Varint.write(@stdin, payload.length)
55
- @stdin.write(payload)
54
+ Varint.write(@stdin, Varint.length(id) + proto.length)
55
+ Varint.write(@stdin, id)
56
+ @stdin.write(proto)
56
57
  end
57
58
  end
58
59
 
59
60
  def read
60
61
  @stdout_mutex.synchronize do
61
62
  length = Varint.read(@stdout)
62
- @stdout.read(length)
63
+ id = Varint.read(@stdout)
64
+ proto = @stdout.read(length - Varint.length(id))
65
+ return id, proto
63
66
  end
64
67
  end
65
68
  end
@@ -6,23 +6,23 @@ 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 = 0xffffffff
9
+ UINT_MAX = 0xffffffff
10
10
 
11
11
  def initialize
12
12
  @compiler = Compiler.new
13
13
  @observers = {}
14
- @id = 0
14
+ @id = 1
15
15
  @mutex = Mutex.new
16
16
 
17
17
  Thread.new do
18
18
  loop do
19
- receive_message
20
- rescue IOError, Errno::EBADF => e
19
+ receive_proto
20
+ rescue IOError, Errno::EBADF, Errno::EPROTO => e
21
21
  @mutex.synchronize do
22
- @id = PROTOCOL_ERROR_ID
22
+ @id = UINT_MAX
23
23
  @observers.values
24
24
  end.each do |observer|
25
- observer.error e
25
+ observer.error(e)
26
26
  end
27
27
  break
28
28
  end
@@ -31,7 +31,7 @@ module Sass
31
31
 
32
32
  def subscribe(observer)
33
33
  @mutex.synchronize do
34
- raise EOFError if @id == PROTOCOL_ERROR_ID
34
+ raise Errno::EBUSY if @id == UINT_MAX
35
35
 
36
36
  id = @id
37
37
  @id = id.next
@@ -46,10 +46,10 @@ module Sass
46
46
 
47
47
  return unless @observers.empty?
48
48
 
49
- if @id == PROTOCOL_ERROR_ID
49
+ if @id == UINT_MAX
50
50
  close
51
51
  else
52
- @id = 0
52
+ @id = 1
53
53
  end
54
54
  end
55
55
  end
@@ -62,33 +62,29 @@ module Sass
62
62
  @compiler.closed?
63
63
  end
64
64
 
65
- def send_message(...)
66
- inbound_message = EmbeddedProtocol::InboundMessage.new(...)
67
- @compiler.write(inbound_message.to_proto)
65
+ def send_proto(...)
66
+ @compiler.write(...)
68
67
  end
69
68
 
70
69
  private
71
70
 
72
- def receive_message
73
- outbound_message = EmbeddedProtocol::OutboundMessage.decode(@compiler.read)
74
- oneof = outbound_message.message
75
- message = outbound_message.public_send(oneof)
76
- case oneof
77
- when :error
78
- @mutex.synchronize do
79
- @id = PROTOCOL_ERROR_ID
80
- message.id == PROTOCOL_ERROR_ID ? @observers.values : [@observers[message.id]]
81
- end.each do |observer|
82
- observer.public_send(oneof, message)
83
- end
84
- when :compile_response, :version_response
71
+ def receive_proto
72
+ id, proto = @compiler.read
73
+ case id
74
+ when 1...UINT_MAX
75
+ @mutex.synchronize { @observers[id] }.receive_proto(proto)
76
+ when 0
77
+ outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
78
+ oneof = outbound_message.message
79
+ message = outbound_message.public_send(oneof)
85
80
  @mutex.synchronize { @observers[message.id] }.public_send(oneof, message)
86
- when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request
87
- Thread.new(@mutex.synchronize { @observers[message.compilation_id] }) do |observer|
88
- observer.public_send(oneof, message)
89
- end
81
+ when UINT_MAX
82
+ outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
83
+ oneof = outbound_message.message
84
+ message = outbound_message.public_send(oneof)
85
+ raise Errno::EPROTO, message.message
90
86
  else
91
- raise ArgumentError, "Unknown OutboundMessage.message #{message}"
87
+ raise Errno::EPROTO
92
88
  end
93
89
  end
94
90
  end
@@ -7,41 +7,44 @@ module Sass
7
7
  #
8
8
  # It stores logger and handles log events.
9
9
  class LoggerRegistry
10
- attr_reader :logger
11
-
12
10
  def initialize(logger)
13
- @logger = Structifier.to_struct(logger, :debug, :warn)
14
- end
11
+ logger = Structifier.to_struct(logger, :debug, :warn)
15
12
 
16
- def log(event)
17
- case event.type
18
- when :DEBUG
19
- if logger.respond_to? :debug
13
+ if logger.respond_to?(:debug)
14
+ define_singleton_method(:debug) do |event|
20
15
  logger.debug(event.message,
21
16
  span: Protofier.from_proto_source_span(event.span))
22
- else
23
- warn(event.formatted)
24
17
  end
25
- when :DEPRECATION_WARNING
26
- if logger.respond_to? :warn
27
- logger.warn(event.message,
28
- deprecation: true,
29
- span: Protofier.from_proto_source_span(event.span),
30
- stack: event.stack_trace)
31
- else
32
- warn(event.formatted)
33
- end
34
- when :WARNING
35
- if logger.respond_to? :warn
18
+ end
19
+
20
+ if logger.respond_to?(:warn) # rubocop:disable Style/GuardClause
21
+ define_singleton_method(:warn) do |event|
36
22
  logger.warn(event.message,
37
- deprecation: false,
23
+ deprecation: event.type == :DEPRECATION_WARNING,
38
24
  span: Protofier.from_proto_source_span(event.span),
39
25
  stack: event.stack_trace)
40
- else
41
- warn(event.formatted)
42
26
  end
43
27
  end
44
28
  end
29
+
30
+ def log(event)
31
+ case event.type
32
+ when :DEBUG
33
+ debug(event)
34
+ when :DEPRECATION_WARNING, :WARNING
35
+ warn(event)
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def debug(event)
42
+ Kernel.warn(event.formatted)
43
+ end
44
+
45
+ def warn(event)
46
+ Kernel.warn(event.formatted)
47
+ end
45
48
  end
46
49
 
47
50
  private_constant :LoggerRegistry
@@ -40,7 +40,6 @@ module Sass
40
40
  @logger_registry = LoggerRegistry.new(logger)
41
41
 
42
42
  send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new(
43
- id: id,
44
43
  string: unless source.nil?
45
44
  EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
46
45
  source: source,
@@ -67,8 +66,8 @@ module Sass
67
66
  end
68
67
 
69
68
  def version_request
70
- version_response = await do
71
- send_message(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new(
69
+ version_response = await0 do
70
+ send_message0(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new(
72
71
  id: id
73
72
  ))
74
73
  end
@@ -76,16 +75,23 @@ module Sass
76
75
  "sass-embedded\t#{version_response.implementation_version}"
77
76
  end
78
77
 
79
- def log_event(message)
80
- @logger_registry.log(message)
81
- end
82
-
83
78
  def compile_response(message)
84
- resolve(message)
79
+ @result = message
80
+ @queue.close
85
81
  end
86
82
 
87
83
  def version_response(message)
88
- resolve(message)
84
+ @result = message
85
+ @queue.close
86
+ end
87
+
88
+ def error(message)
89
+ @error = message
90
+ @queue.close
91
+ end
92
+
93
+ def log_event(message)
94
+ @logger_registry.log(message)
89
95
  end
90
96
 
91
97
  def canonicalize_request(message)
@@ -104,35 +110,59 @@ module Sass
104
110
  send_message(function_call_response: @function_registry.function_call(message))
105
111
  end
106
112
 
107
- def error(message)
108
- reject(CompileError.new(message.message, nil, nil, nil))
113
+ def receive_proto(proto)
114
+ @queue.push(proto)
109
115
  end
110
116
 
111
117
  private
112
118
 
113
- def await
119
+ def await0
114
120
  @connection = @channel.connect(self)
115
- @async = Async.new
121
+ @queue = Queue.new
122
+
116
123
  yield
117
- @async.await
124
+
125
+ @queue.pop
126
+
127
+ raise @error if @error
128
+
129
+ @result
118
130
  ensure
119
131
  @connection&.disconnect
120
132
  end
121
133
 
122
- def resolve(value)
123
- @async.resolve(value)
124
- end
134
+ def await
135
+ @connection = @channel.connect(self)
136
+ @queue = Queue.new
137
+
138
+ yield
125
139
 
126
- def reject(reason)
127
- @async.reject(reason)
140
+ while (proto = @queue.pop)
141
+ outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
142
+ oneof = outbound_message.message
143
+ message = outbound_message.public_send(oneof)
144
+ public_send(oneof, message)
145
+ end
146
+
147
+ raise @error if @error
148
+
149
+ @result
150
+ ensure
151
+ @connection&.disconnect
128
152
  end
129
153
 
130
154
  def id
131
155
  @connection.id
132
156
  end
133
157
 
158
+ def send_message0(...)
159
+ inbound_message = EmbeddedProtocol::InboundMessage.new(...)
160
+ @connection.send_proto(0, inbound_message.to_proto)
161
+ end
162
+
134
163
  def send_message(...)
135
- @connection.send_message(...)
164
+ inbound_message = EmbeddedProtocol::InboundMessage.new(...)
165
+ @connection.send_proto(id, inbound_message.to_proto)
136
166
  end
137
167
  end
138
168
 
@@ -15,15 +15,16 @@ module Sass
15
15
  when :failure
16
16
  raise CompileError.new(
17
17
  result.message,
18
- result.formatted,
19
- result.stack_trace,
20
- from_proto_source_span(result.span)
18
+ result.formatted == '' ? nil : result.formatted,
19
+ result.stack_trace == '' ? nil : result.stack_trace,
20
+ from_proto_source_span(result.span),
21
+ compile_response.loaded_urls
21
22
  )
22
23
  when :success
23
24
  CompileResult.new(
24
25
  result.css,
25
- result.source_map,
26
- result.loaded_urls
26
+ result.source_map == '' ? nil : result.source_map,
27
+ compile_response.loaded_urls
27
28
  )
28
29
  else
29
30
  raise ArgumentError, "Unknown CompileResponse.result #{result}"
@@ -36,8 +37,8 @@ module Sass
36
37
  Logger::SourceSpan.new(from_proto_source_location(source_span.start),
37
38
  from_proto_source_location(source_span.end),
38
39
  source_span.text,
39
- source_span.url,
40
- source_span.context)
40
+ source_span.url == '' ? nil : source_span.url,
41
+ source_span.context == '' ? nil : source_span.context)
41
42
  end
42
43
 
43
44
  def from_proto_source_location(source_location)
@@ -8,6 +8,12 @@ module Sass
8
8
  module Varint
9
9
  module_function
10
10
 
11
+ def length(value)
12
+ return 1 if value < 128
13
+
14
+ (value.bit_length + 6) / 7
15
+ end
16
+
11
17
  def read(readable)
12
18
  value = bits = 0
13
19
  loop do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.62.1'
5
+ VERSION = '1.63.1'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../ext/sass/embedded'
3
+ 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/async'
8
7
  require_relative 'embedded/channel'
9
8
  require_relative 'embedded/compiler'
10
9
  require_relative 'embedded/dispatcher'
@@ -80,8 +79,8 @@ module Sass
80
79
  end
81
80
  # rubocop:enable Layout/LineLength
82
81
 
83
- # The {Embedded} host for using dart-sass-embedded. Each instance creates
84
- # its own communication {Channel} with a dedicated compiler process.
82
+ # The {Embedded} host for using dart-sass. Each instance creates its own
83
+ # communication {Channel} with a dedicated compiler process.
85
84
  #
86
85
  # @example
87
86
  # embedded = Sass::Embedded.new
@@ -19,8 +19,8 @@ module Sass
19
19
  @start = start
20
20
  @end = end_
21
21
  @text = text
22
- @url = url == '' ? nil : url
23
- @context = context == '' ? nil : context
22
+ @url = url
23
+ @context = context
24
24
  end
25
25
  end
26
26
  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.62.1
4
+ version: 1.63.1
5
5
  platform: x86-linux-android
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-26 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -16,123 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.21'
19
+ version: '3.23'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.21'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 10.0.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 10.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.12.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.12.0
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 1.50.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 1.50.0
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.17.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.17.1
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.6.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.6.0
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 2.20.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 2.20.0
26
+ version: '3.23'
111
27
  description: A Ruby library that will communicate with Embedded Dart Sass using the
112
28
  Embedded Sass protocol.
113
29
  email:
114
30
  - i@ntk.me
115
- executables: []
31
+ executables:
32
+ - sass
116
33
  extensions: []
117
34
  extra_rdoc_files: []
118
35
  files:
119
36
  - LICENSE
120
37
  - README.md
121
- - ext/sass/embedded.rb
38
+ - exe/sass
39
+ - ext/sass/cli.rb
40
+ - ext/sass/dart-sass/sass
41
+ - ext/sass/dart-sass/src/LICENSE
42
+ - ext/sass/dart-sass/src/dart
43
+ - ext/sass/dart-sass/src/sass.snapshot
122
44
  - ext/sass/embedded_sass_pb.rb
123
- - ext/sass/sass_embedded/dart-sass-embedded
124
- - ext/sass/sass_embedded/src/LICENSE
125
- - ext/sass/sass_embedded/src/dart
126
- - ext/sass/sass_embedded/src/dart-sass-embedded.snapshot
127
45
  - lib/sass-embedded.rb
128
46
  - lib/sass/compile_error.rb
129
47
  - lib/sass/compile_result.rb
48
+ - lib/sass/elf.rb
130
49
  - lib/sass/embedded.rb
131
- - lib/sass/embedded/async.rb
132
50
  - lib/sass/embedded/channel.rb
133
51
  - lib/sass/embedded/compiler.rb
134
52
  - lib/sass/embedded/dispatcher.rb
135
- - lib/sass/embedded/elf.rb
136
53
  - lib/sass/embedded/host.rb
137
54
  - lib/sass/embedded/host/function_registry.rb
138
55
  - lib/sass/embedded/host/importer_registry.rb
@@ -162,8 +79,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
162
79
  licenses:
163
80
  - MIT
164
81
  metadata:
165
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.62.1
166
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.62.1
82
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.63.1
83
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.63.1
167
84
  funding_uri: https://github.com/sponsors/ntkme
168
85
  post_install_message:
169
86
  rdoc_options: []
@@ -180,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
97
  - !ruby/object:Gem::Version
181
98
  version: 3.3.22
182
99
  requirements: []
183
- rubygems_version: 3.4.12
100
+ rubygems_version: 3.4.13
184
101
  signing_key:
185
102
  specification_version: 4
186
103
  summary: Use dart-sass with Ruby!
data/ext/sass/embedded.rb DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- class Compiler
6
- COMMAND = [
7
- File.absolute_path('sass_embedded/src/dart', __dir__),
8
- File.absolute_path('sass_embedded/src/dart-sass-embedded.snapshot', __dir__)
9
- ].freeze
10
- end
11
- end
12
- end
@@ -1,58 +0,0 @@
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
- @result = nil
19
- @state = State::PENDING
20
-
21
- @condition_variable = ConditionVariable.new
22
- @mutex = Mutex.new
23
- end
24
-
25
- def resolve(value)
26
- @mutex.synchronize do
27
- return unless @state == State::PENDING
28
-
29
- @result = value
30
- @state = State::FULFILLED
31
- @condition_variable.broadcast
32
- end
33
- end
34
-
35
- def reject(reason)
36
- @mutex.synchronize do
37
- return unless @state == State::PENDING
38
-
39
- @result = reason
40
- @state = State::REJECTED
41
- @condition_variable.broadcast
42
- end
43
- end
44
-
45
- def await
46
- @mutex.synchronize do
47
- @condition_variable.wait(@mutex) if @state == State::PENDING
48
-
49
- raise @result if @state == State::REJECTED
50
-
51
- @result
52
- end
53
- end
54
- end
55
-
56
- private_constant :Async
57
- end
58
- end