sass-embedded 0.19.0 → 0.19.3

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: 573a157ee6e0c3fa51cefec5c011649717718133d934e031a339d32a84838a13
4
- data.tar.gz: ef27dd3177b8f58f3dd19180340686901597e9ac05efa77e2f9cc12b7784dbbb
3
+ metadata.gz: 5bd880f5e8c75f6b6a49d2359b96df7f11b49cad5273f81d08a46eeac5c105f1
4
+ data.tar.gz: ac523992c522ae01aac03727690d35c67f00d1d24d3d73d36400917b29968616
5
5
  SHA512:
6
- metadata.gz: 538de1728de2da841ce66648d669acec38a4a3c3f15357e5d33e1d5dac773f246b43f29d244ec39076fc3d18504f6935374f9a5277baac7a1c400548b44aef5b
7
- data.tar.gz: 26db551dd98592327a0c7e4fc9ee39c5917b1aff92431bfc7cdac6eea3c79899439c976512c7bed393493f564fd00e0ccafe735fe8cd8a514827d7a42b689d58
6
+ metadata.gz: 586635d023e843dbcc27e48669b5421f9e1488d90770f062a55e02328cec114753c5e8c94ba8b2afcb1d8ddace38eff746ffb3357bfdf27efd999d9c33edc388
7
+ data.tar.gz: 3aca765800907870df8a5fe377ab7211be5293f244c7b140ed6ca6de7f0588589b4f76e8e8258fc1da8b8e8d136126de6f873579ae91136c5c60178d2951e416
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
- tag_name = IO.popen([Compiler::PATH, '--version']) do |file|
219
- JSON.parse(file.read)['protocolVersion']
220
- end
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
@@ -33,7 +33,7 @@ module Sass
33
33
 
34
34
  id = @id
35
35
  @id = id.next
36
- @observers.store(id, observer)
36
+ @observers[id] = observer
37
37
  id
38
38
  end
39
39
  end
@@ -76,9 +76,11 @@ module Sass
76
76
  half_close
77
77
  @observers[message.id]&.send(outbound_message.message, message)
78
78
  when :compile_response, :version_response
79
- @observers[message.id]&.send(outbound_message.message, message)
79
+ @observers[message.id].send(outbound_message.message, message)
80
80
  when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request
81
- @observers[message.compilation_id]&.send(outbound_message.message, message)
81
+ Thread.new(@observers[message.compilation_id]) do |observer|
82
+ observer.send(outbound_message.message, message)
83
+ end
82
84
  else
83
85
  raise ArgumentError, "Unknown OutboundMessage.message #{message}"
84
86
  end
@@ -35,7 +35,7 @@ module Sass
35
35
  logger:,
36
36
  quiet_deps:,
37
37
  verbose:)
38
- async do
38
+ await do
39
39
  @function_registry = FunctionRegistry.new(functions, alert_color: alert_color)
40
40
  @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color: alert_color)
41
41
  @logger_registry = LoggerRegistry.new(logger)
@@ -67,7 +67,7 @@ module Sass
67
67
  end
68
68
 
69
69
  def version_request
70
- async do
70
+ await do
71
71
  send_message EmbeddedProtocol::InboundMessage.new(
72
72
  version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new(
73
73
  id: id
@@ -118,7 +118,7 @@ module Sass
118
118
 
119
119
  private
120
120
 
121
- def async
121
+ def await
122
122
  @mutex.synchronize do
123
123
  @connection = @channel.connect(self)
124
124
  @async = Async.new
@@ -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.
@@ -87,10 +82,13 @@ module Sass
87
82
  source_map_root: '',
88
83
  functions: {},
89
84
  importer: [])
90
- start = now
91
-
92
85
  raise ArgumentError, 'either data or file must be set' if file.nil? && data.nil?
93
86
 
87
+ require 'pathname'
88
+ require 'uri'
89
+
90
+ start = now
91
+
94
92
  indent_type = parse_indent_type(indent_type)
95
93
  indent_width = parse_indent_width(indent_width)
96
94
  linefeed = parse_linefeed(linefeed)
@@ -217,6 +215,9 @@ module Sass
217
215
  source_map_root:)
218
216
  return if map.nil? || map.empty?
219
217
 
218
+ require 'base64'
219
+ require 'json'
220
+
220
221
  map_data = JSON.parse(map)
221
222
 
222
223
  map_data['sourceRoot'] = source_map_root
@@ -371,30 +372,33 @@ module Sass
371
372
  # @deprecated
372
373
  # The {Url} module.
373
374
  module Url
374
- # The {::URI::Parser} that is in consistent with RFC 2396 (URI Generic Syntax) and dart:core library.
375
- URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
376
-
377
375
  FILE_SCHEME = 'file://'
378
376
 
379
- private_constant :URI_PARSER, :FILE_SCHEME
377
+ private_constant :FILE_SCHEME
380
378
 
381
379
  module_function
382
380
 
383
381
  def path_to_file_url(path)
384
382
  if File.absolute_path? path
385
- URI_PARSER.escape "#{FILE_SCHEME}#{Gem.win_platform? ? '/' : ''}#{path}"
383
+ uri_parser.escape "#{FILE_SCHEME}#{Gem.win_platform? ? '/' : ''}#{path}"
386
384
  else
387
- URI_PARSER.escape path
385
+ uri_parser.escape path
388
386
  end
389
387
  end
390
388
 
391
389
  def file_url_to_path(url)
392
390
  if url.start_with? FILE_SCHEME
393
- URI_PARSER.unescape url[(FILE_SCHEME.length + (Gem.win_platform? ? 1 : 0))..]
391
+ uri_parser.unescape url[(FILE_SCHEME.length + (Gem.win_platform? ? 1 : 0))..]
394
392
  else
395
- URI_PARSER.unescape url
393
+ uri_parser.unescape url
396
394
  end
397
395
  end
396
+
397
+ private
398
+
399
+ def uri_parser
400
+ @uri_parser ||= URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
401
+ end
398
402
  end
399
403
 
400
404
  private_constant :LegacyImporter
@@ -9,20 +9,24 @@ module Sass
9
9
  module_function
10
10
 
11
11
  def from_proto_compile_response(compile_response)
12
- if compile_response.result == :failure
12
+ result = compile_response.send(compile_response.result)
13
+ case compile_response.result
14
+ when :failure
13
15
  raise CompileError.new(
14
- compile_response.failure.message,
15
- compile_response.failure.formatted,
16
- compile_response.failure.stack_trace,
17
- from_proto_source_span(compile_response.failure.span)
16
+ result.message,
17
+ result.formatted,
18
+ result.stack_trace,
19
+ from_proto_source_span(result.span)
18
20
  )
21
+ when :success
22
+ CompileResult.new(
23
+ result.css,
24
+ result.source_map,
25
+ result.loaded_urls
26
+ )
27
+ else
28
+ raise ArgumentError, "Unknown CompileResponse.result #{result}"
19
29
  end
20
-
21
- CompileResult.new(
22
- compile_response.success.css,
23
- compile_response.success.source_map,
24
- compile_response.success.loaded_urls
25
- )
26
30
  end
27
31
 
28
32
  def from_proto_source_span(source_span)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '0.19.0'
5
+ VERSION = '0.19.3'
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: 0.19.0
4
+ version: 0.19.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -163,8 +163,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
163
163
  licenses:
164
164
  - MIT
165
165
  metadata:
166
- documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.19.0
167
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.19.0
166
+ documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.19.3
167
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.19.3
168
168
  funding_uri: https://github.com/sponsors/ntkme
169
169
  post_install_message:
170
170
  rdoc_options: []