sass-embedded 1.69.3-aarch64-linux-gnu → 1.69.5-aarch64-linux-gnu

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: 9ac6f22ca79d3499fa22c89b1a6fafdab3fc22c9e75a58fb58311e98307b2fee
4
- data.tar.gz: 82cb13d3e75b5b232111e151383a149eb910104480018e1875fed0d94250b1a0
3
+ metadata.gz: 556ba39ff0f5ab4bfded4090f7b645e9ad67ea07bff27ba86ca51673b6b5d3d3
4
+ data.tar.gz: f807409f66da4d9f957ee3794a216979b00f9d2ef6d518d9bd54677806369243
5
5
  SHA512:
6
- metadata.gz: c676e85b757ec5e7148434474653ed8384656d6fa14c288e9353897eb7f48255a9e4294cdb3a27fe4595090f470feb6410c6409e39e1ca2ae890954f40925996
7
- data.tar.gz: 246958ffc05554b1f4a6021b46d46996ae0167e6f08cb714a49c8c0a1c5ec13e132845f4197240b2475fbfc9384e8380ff34fa3baff3e73bb29e354406a1bbf7
6
+ metadata.gz: f4c33bedee5eff2856f4589c4b3df7cc8b12561926390806d6c4f4980878de8bc07ace1c2eb55be64ce8e15aeb66d38474f84610a1e3e1e67b77f3dba64c9f23
7
+ data.tar.gz: 995017c1efb4dab176f8618e3a427622e0a6ae3f0a7efde6878d6e0d7e2475e49b65092e4bb394af02bd90609d75f8fa8dfcd00cd7ee7a8a597cc17b12d7c4e0
Binary file
Binary file
@@ -2,14 +2,17 @@
2
2
 
3
3
  require 'open3'
4
4
 
5
+ require_relative '../../../ext/sass/cli'
6
+
5
7
  module Sass
6
8
  class Embedded
7
9
  # The stdio based {Connection} between the {Dispatcher} and the compiler.
8
10
  #
9
11
  # It runs the `sass --embedded` command.
10
12
  class Connection
11
- def initialize
12
- @stdin, @stdout, @stderr, @wait_thread = begin
13
+ def initialize(dispatcher)
14
+ @mutex = Mutex.new
15
+ @stdin, stdout, stderr, @wait_thread = begin
13
16
  Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
14
17
  rescue Errno::ENOENT
15
18
  require_relative '../elf'
@@ -18,50 +21,47 @@ module Sass
18
21
 
19
22
  Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
20
23
  end
21
-
22
24
  @stdin.binmode
23
- @stdout.binmode
24
- @stdin_mutex = Mutex.new
25
- @stdout_mutex = Mutex.new
26
25
 
27
26
  Thread.new do
27
+ stdout.binmode
28
28
  loop do
29
- warn(@stderr.readline, uplevel: 1)
29
+ length = Varint.read(stdout)
30
+ id = Varint.read(stdout)
31
+ proto = stdout.read(length - Varint.length(id))
32
+ dispatcher.receive_proto(id, proto)
33
+ rescue IOError, Errno::EBADF, Errno::EPROTO => e
34
+ dispatcher.error(e)
35
+ break
36
+ end
37
+ stdout.close
38
+ end
39
+
40
+ Thread.new do
41
+ loop do
42
+ warn(stderr.readline, uplevel: 1)
30
43
  rescue IOError, Errno::EBADF
31
44
  break
32
45
  end
46
+ stderr.close
33
47
  end
34
48
  end
35
49
 
36
50
  def close
37
- @stdin_mutex.synchronize do
38
- @stdin.close
39
- @wait_thread.join
40
- @stdout.close
41
- @stderr.close
42
- end
51
+ @stdin.close
52
+ @wait_thread.join
43
53
  end
44
54
 
45
55
  def closed?
46
- @stdin_mutex.synchronize do
47
- @stdin.closed?
48
- end
56
+ @stdin.closed? && !@wait_thread.alive?
49
57
  end
50
58
 
51
59
  def write(id, proto)
52
- @stdin_mutex.synchronize do
53
- Varint.write(@stdin, Varint.length(id) + proto.length)
54
- Varint.write(@stdin, id)
55
- @stdin.write(proto)
56
- end
57
- end
58
-
59
- def read
60
- @stdout_mutex.synchronize do
61
- length = Varint.read(@stdout)
62
- id = Varint.read(@stdout)
63
- proto = @stdout.read(length - Varint.length(id))
64
- return id, proto
60
+ buffer = []
61
+ Varint.write(buffer, Varint.length(id) + proto.length)
62
+ Varint.write(buffer, id)
63
+ @mutex.synchronize do
64
+ @stdin.write(buffer.pack('C*'), proto)
65
65
  end
66
66
  end
67
67
  end
@@ -6,33 +6,16 @@ module Sass
6
6
  #
7
7
  # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler.
8
8
  class Dispatcher
9
- UINT_MAX = 0xffffffff
10
-
11
9
  def initialize
12
- @connection = Connection.new
13
- @observers = {}
14
10
  @id = 1
11
+ @observers = {}
15
12
  @mutex = Mutex.new
16
-
17
- Thread.new do
18
- loop do
19
- receive_proto
20
- rescue IOError, Errno::EBADF, Errno::EPROTO => e
21
- values = @mutex.synchronize do
22
- @id = UINT_MAX
23
- @observers.values
24
- end
25
- values.each do |observer|
26
- observer.error(e)
27
- end
28
- break
29
- end
30
- end
13
+ @connection = Connection.new(self)
31
14
  end
32
15
 
33
16
  def subscribe(observer)
34
17
  @mutex.synchronize do
35
- raise Errno::EBUSY if @id == UINT_MAX
18
+ raise Errno::EBUSY if @id == 0xffffffff
36
19
 
37
20
  id = @id
38
21
  @id = id.next
@@ -47,7 +30,7 @@ module Sass
47
30
 
48
31
  return unless @observers.empty?
49
32
 
50
- if @id == UINT_MAX
33
+ if @id == 0xffffffff
51
34
  Thread.new do
52
35
  close
53
36
  end
@@ -69,29 +52,31 @@ module Sass
69
52
  @connection.closed?
70
53
  end
71
54
 
72
- def error
73
- @mutex.synchronize do
74
- @id = UINT_MAX
55
+ def error(error)
56
+ observers = @mutex.synchronize do
57
+ @id = 0xffffffff
58
+ @observers.values
75
59
  end
76
- end
77
60
 
78
- def send_proto(...)
79
- @connection.write(...)
61
+ if observers.empty?
62
+ close
63
+ else
64
+ observers.each do |observer|
65
+ observer.error(error)
66
+ end
67
+ end
80
68
  end
81
69
 
82
- private
83
-
84
- def receive_proto
85
- id, proto = @connection.read
70
+ def receive_proto(id, proto)
86
71
  case id
87
- when 1...UINT_MAX
72
+ when 1...0xffffffff
88
73
  @mutex.synchronize { @observers[id] }.receive_proto(proto)
89
74
  when 0
90
75
  outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
91
76
  oneof = outbound_message.message
92
77
  message = outbound_message.public_send(oneof)
93
78
  @mutex.synchronize { @observers[message.id] }.public_send(oneof, message)
94
- when UINT_MAX
79
+ when 0xffffffff
95
80
  outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
96
81
  oneof = outbound_message.message
97
82
  message = outbound_message.public_send(oneof)
@@ -101,6 +86,10 @@ module Sass
101
86
  end
102
87
  end
103
88
 
89
+ def send_proto(...)
90
+ @connection.write(...)
91
+ end
92
+
104
93
  # The {Channel} between {Dispatcher} and {Host}.
105
94
  class Channel
106
95
  attr_reader :id
@@ -114,6 +103,12 @@ module Sass
114
103
  @dispatcher.unsubscribe(id)
115
104
  end
116
105
 
106
+ def error(...)
107
+ Thread.new do
108
+ @dispatcher.error(...)
109
+ end
110
+ end
111
+
117
112
  def send_proto(...)
118
113
  @dispatcher.send_proto(...)
119
114
  end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ class Embedded
5
+ class Host
6
+ # The {Protofier} module.
7
+ #
8
+ # It converts Pure Ruby types and Protobuf Ruby types.
9
+ module Protofier
10
+ module_function
11
+
12
+ def from_proto_canonicalize_context(canonicalize_request)
13
+ CanonicalizeContext.new(
14
+ canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url,
15
+ canonicalize_request.from_import
16
+ )
17
+ end
18
+
19
+ def from_proto_compile_response(compile_response)
20
+ oneof = compile_response.result
21
+ result = compile_response.public_send(oneof)
22
+ case oneof
23
+ when :failure
24
+ raise CompileError.new(
25
+ result.message,
26
+ result.formatted == '' ? nil : result.formatted,
27
+ result.stack_trace == '' ? nil : result.stack_trace,
28
+ from_proto_source_span(result.span),
29
+ compile_response.loaded_urls
30
+ )
31
+ when :success
32
+ CompileResult.new(
33
+ result.css,
34
+ result.source_map == '' ? nil : result.source_map,
35
+ compile_response.loaded_urls
36
+ )
37
+ else
38
+ raise ArgumentError, "Unknown CompileResponse.result #{result}"
39
+ end
40
+ end
41
+
42
+ def from_proto_source_span(source_span)
43
+ return if source_span.nil?
44
+
45
+ Logger::SourceSpan.new(from_proto_source_location(source_span.start),
46
+ from_proto_source_location(source_span.end),
47
+ source_span.text,
48
+ source_span.url == '' ? nil : source_span.url,
49
+ source_span.context == '' ? nil : source_span.context)
50
+ end
51
+
52
+ def from_proto_source_location(source_location)
53
+ return if source_location.nil?
54
+
55
+ Logger::SourceLocation.new(source_location.offset,
56
+ source_location.line,
57
+ source_location.column)
58
+ end
59
+
60
+ def to_proto_syntax(syntax)
61
+ case syntax&.to_sym
62
+ when :scss
63
+ EmbeddedProtocol::Syntax::SCSS
64
+ when :indented
65
+ EmbeddedProtocol::Syntax::INDENTED
66
+ when :css
67
+ EmbeddedProtocol::Syntax::CSS
68
+ else
69
+ raise ArgumentError, 'syntax must be one of :scss, :indented, :css'
70
+ end
71
+ end
72
+
73
+ def to_proto_output_style(style)
74
+ case style&.to_sym
75
+ when :expanded
76
+ EmbeddedProtocol::OutputStyle::EXPANDED
77
+ when :compressed
78
+ EmbeddedProtocol::OutputStyle::COMPRESSED
79
+ else
80
+ raise ArgumentError, 'style must be one of :expanded, :compressed'
81
+ end
82
+ end
83
+ end
84
+
85
+ private_constant :Protofier
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ class Embedded
5
+ class Host
6
+ # The {Structifier} module.
7
+ #
8
+ # It converts {::Hash} to {Struct}-like objects.
9
+ module Structifier
10
+ module_function
11
+
12
+ def to_struct(obj, *symbols)
13
+ return obj unless obj.is_a?(Hash)
14
+
15
+ struct = Object.new
16
+ symbols.each do |key|
17
+ next unless obj.key?(key)
18
+
19
+ value = obj[key]
20
+ if value.respond_to?(:call)
21
+ struct.define_singleton_method key do |*args, **kwargs|
22
+ value.call(*args, **kwargs)
23
+ end
24
+ else
25
+ struct.define_singleton_method key do
26
+ value
27
+ end
28
+ end
29
+ end
30
+ struct
31
+ end
32
+ end
33
+
34
+ private_constant :Structifier
35
+ end
36
+ end
37
+ end
@@ -3,6 +3,8 @@
3
3
  require_relative 'host/function_registry'
4
4
  require_relative 'host/importer_registry'
5
5
  require_relative 'host/logger_registry'
6
+ require_relative 'host/protofier'
7
+ require_relative 'host/structifier'
6
8
  require_relative 'host/value_protofier'
7
9
 
8
10
  module Sass
@@ -88,8 +90,8 @@ module Sass
88
90
  def error(message)
89
91
  case message
90
92
  when EmbeddedProtocol::ProtocolError
91
- @dispatcher.error
92
93
  @error = Errno::EPROTO.new(message.message)
94
+ @channel.error(@error)
93
95
  else
94
96
  @error ||= message
95
97
  end
@@ -33,10 +33,6 @@ module Sass
33
33
  @dispatcher.connect(...)
34
34
  end
35
35
  end
36
-
37
- def error(...)
38
- @dispatcher.error(...)
39
- end
40
36
  end
41
37
 
42
38
  private_constant :ResilientDispatcher
@@ -26,13 +26,11 @@ module Sass
26
26
  end
27
27
 
28
28
  def write(writeable, value)
29
- bytes = []
30
29
  until value < 0x80
31
- bytes << ((value & 0x7f) | 0x80)
30
+ writeable << ((value & 0x7f) | 0x80)
32
31
  value >>= 7
33
32
  end
34
- bytes << value
35
- writeable.write bytes.pack('C*')
33
+ writeable << value
36
34
  end
37
35
  end
38
36
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.69.3'
5
+ VERSION = '1.69.5'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -1,15 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../ext/sass/cli'
4
3
  require_relative 'canonicalize_context'
5
4
  require_relative 'compile_error'
6
5
  require_relative 'compile_result'
7
6
  require_relative 'embedded/connection'
8
7
  require_relative 'embedded/dispatcher'
9
8
  require_relative 'embedded/host'
10
- require_relative 'embedded/protofier'
11
9
  require_relative 'embedded/resilient_dispatcher'
12
- require_relative 'embedded/structifier'
13
10
  require_relative 'embedded/varint'
14
11
  require_relative 'embedded/version'
15
12
  require_relative 'embedded_protocol'
@@ -73,9 +70,8 @@ module Sass
73
70
  at_exit do
74
71
  @instance.close
75
72
  end
73
+ @instance
76
74
  end
77
-
78
- @instance
79
75
  end
80
76
  end
81
77
  # rubocop:enable Layout/LineLength
@@ -50,42 +50,42 @@ module Sass
50
50
 
51
51
  # @return [Integer]
52
52
  def red
53
- hsl_to_rgb unless defined? @red
53
+ hsl_to_rgb unless defined?(@red)
54
54
 
55
55
  @red
56
56
  end
57
57
 
58
58
  # @return [Integer]
59
59
  def green
60
- hsl_to_rgb unless defined? @green
60
+ hsl_to_rgb unless defined?(@green)
61
61
 
62
62
  @green
63
63
  end
64
64
 
65
65
  # @return [Integer]
66
66
  def blue
67
- hsl_to_rgb unless defined? @blue
67
+ hsl_to_rgb unless defined?(@blue)
68
68
 
69
69
  @blue
70
70
  end
71
71
 
72
72
  # @return [Numeric]
73
73
  def hue
74
- rgb_to_hsl unless defined? @hue
74
+ rgb_to_hsl unless defined?(@hue)
75
75
 
76
76
  @hue
77
77
  end
78
78
 
79
79
  # @return [Numeric]
80
80
  def saturation
81
- rgb_to_hsl unless defined? @saturation
81
+ rgb_to_hsl unless defined?(@saturation)
82
82
 
83
83
  @saturation
84
84
  end
85
85
 
86
86
  # @return [Numeric]
87
87
  def lightness
88
- rgb_to_hsl unless defined? @lightness
88
+ rgb_to_hsl unless defined?(@lightness)
89
89
 
90
90
  @lightness
91
91
  end
@@ -29,7 +29,7 @@ module Sass
29
29
  # @return [::Boolean]
30
30
  def ==(other)
31
31
  if id.nil?
32
- other.equal? self
32
+ other.equal?(self)
33
33
  else
34
34
  other.is_a?(Sass::Value::Function) && other.id == id
35
35
  end
@@ -30,7 +30,7 @@ module Sass
30
30
  # @param index [Numeric, Value]
31
31
  # @return [List<(Value, Value)>, Value]
32
32
  def at(index)
33
- if index.is_a? Numeric
33
+ if index.is_a?(Numeric)
34
34
  index = index.floor
35
35
  index = to_a_length + index if index.negative?
36
36
  return nil if index.negative? || index >= to_a_length
@@ -25,12 +25,12 @@ module Sass
25
25
  denominator_units = []
26
26
  when ::Hash
27
27
  numerator_units = unit.fetch(:numerator_units, [])
28
- unless numerator_units.is_a? Array
28
+ unless numerator_units.is_a?(Array)
29
29
  raise Sass::ScriptError, "invalid numerator_units #{numerator_units.inspect}"
30
30
  end
31
31
 
32
32
  denominator_units = unit.fetch(:denominator_units, [])
33
- unless denominator_units.is_a? Array
33
+ unless denominator_units.is_a?(Array)
34
34
  raise Sass::ScriptError, "invalid denominator_units #{denominator_units.inspect}"
35
35
  end
36
36
  else
@@ -75,7 +75,7 @@ module Sass
75
75
 
76
76
  # @return [::Boolean]
77
77
  def ==(other)
78
- return false unless other.is_a? Sass::Value::Number
78
+ return false unless other.is_a?(Sass::Value::Number)
79
79
 
80
80
  return false if numerator_units.length != other.numerator_units.length ||
81
81
  denominator_units.length != other.denominator_units.length
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.69.3
4
+ version: 1.69.5
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-12 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -56,10 +56,10 @@ files:
56
56
  - lib/sass/embedded/host/function_registry.rb
57
57
  - lib/sass/embedded/host/importer_registry.rb
58
58
  - lib/sass/embedded/host/logger_registry.rb
59
+ - lib/sass/embedded/host/protofier.rb
60
+ - lib/sass/embedded/host/structifier.rb
59
61
  - lib/sass/embedded/host/value_protofier.rb
60
- - lib/sass/embedded/protofier.rb
61
62
  - lib/sass/embedded/resilient_dispatcher.rb
62
- - lib/sass/embedded/structifier.rb
63
63
  - lib/sass/embedded/varint.rb
64
64
  - lib/sass/embedded/version.rb
65
65
  - lib/sass/embedded_protocol.rb
@@ -85,8 +85,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
85
85
  licenses:
86
86
  - MIT
87
87
  metadata:
88
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.3
89
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.69.3
88
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.5
89
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.69.5
90
90
  funding_uri: https://github.com/sponsors/ntkme
91
91
  post_install_message:
92
92
  rdoc_options: []
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: 3.3.22
105
105
  requirements: []
106
- rubygems_version: 3.4.20
106
+ rubygems_version: 3.4.21
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Use dart-sass with Ruby!
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- # The {Protofier} module.
6
- #
7
- # It converts Pure Ruby types and Protobuf Ruby types.
8
- module Protofier
9
- module_function
10
-
11
- def from_proto_canonicalize_context(canonicalize_request)
12
- CanonicalizeContext.new(
13
- canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url,
14
- canonicalize_request.from_import
15
- )
16
- end
17
-
18
- def from_proto_compile_response(compile_response)
19
- oneof = compile_response.result
20
- result = compile_response.public_send(oneof)
21
- case oneof
22
- when :failure
23
- raise CompileError.new(
24
- result.message,
25
- result.formatted == '' ? nil : result.formatted,
26
- result.stack_trace == '' ? nil : result.stack_trace,
27
- from_proto_source_span(result.span),
28
- compile_response.loaded_urls
29
- )
30
- when :success
31
- CompileResult.new(
32
- result.css,
33
- result.source_map == '' ? nil : result.source_map,
34
- compile_response.loaded_urls
35
- )
36
- else
37
- raise ArgumentError, "Unknown CompileResponse.result #{result}"
38
- end
39
- end
40
-
41
- def from_proto_source_span(source_span)
42
- return if source_span.nil?
43
-
44
- Logger::SourceSpan.new(from_proto_source_location(source_span.start),
45
- from_proto_source_location(source_span.end),
46
- source_span.text,
47
- source_span.url == '' ? nil : source_span.url,
48
- source_span.context == '' ? nil : source_span.context)
49
- end
50
-
51
- def from_proto_source_location(source_location)
52
- return if source_location.nil?
53
-
54
- Logger::SourceLocation.new(source_location.offset,
55
- source_location.line,
56
- source_location.column)
57
- end
58
-
59
- def to_proto_syntax(syntax)
60
- case syntax&.to_sym
61
- when :scss
62
- EmbeddedProtocol::Syntax::SCSS
63
- when :indented
64
- EmbeddedProtocol::Syntax::INDENTED
65
- when :css
66
- EmbeddedProtocol::Syntax::CSS
67
- else
68
- raise ArgumentError, 'syntax must be one of :scss, :indented, :css'
69
- end
70
- end
71
-
72
- def to_proto_output_style(style)
73
- case style&.to_sym
74
- when :expanded
75
- EmbeddedProtocol::OutputStyle::EXPANDED
76
- when :compressed
77
- EmbeddedProtocol::OutputStyle::COMPRESSED
78
- else
79
- raise ArgumentError, 'style must be one of :expanded, :compressed'
80
- end
81
- end
82
- end
83
-
84
- private_constant :Protofier
85
- end
86
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- # The {Structifier} module.
6
- #
7
- # It converts {::Hash} to {Struct}-like objects.
8
- module Structifier
9
- module_function
10
-
11
- def to_struct(obj, *symbols)
12
- return obj unless obj.is_a? Hash
13
-
14
- struct = Object.new
15
- symbols.each do |key|
16
- next unless obj.key?(key)
17
-
18
- value = obj[key]
19
- if value.respond_to? :call
20
- struct.define_singleton_method key do |*args, **kwargs|
21
- value.call(*args, **kwargs)
22
- end
23
- else
24
- struct.define_singleton_method key do
25
- value
26
- end
27
- end
28
- end
29
- struct
30
- end
31
- end
32
-
33
- private_constant :Structifier
34
- end
35
- end