sass-embedded 1.69.5-aarch64-linux-android → 1.69.6-aarch64-linux-android

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2a4c5f521545557037497b3ed4b5f53fdf133ab7a02f64650bb303e9e8e1cf0
4
- data.tar.gz: a9ebca5a3b26005509156c9c63415431f5039601ada3e332532903a62329adbe
3
+ metadata.gz: ed2bd12a7e6d17bfb04b5e530ce24a621495926df2001e5df65a2c6154d99553
4
+ data.tar.gz: cdcd1b770b1e7c9b9d463f0e53960e04beefd8ea27b4303e5ace0180a778719d
5
5
  SHA512:
6
- metadata.gz: 01a1af91eb7f08c227d84bb71756dca60a77086cd8794824ad319c519f319d06e2efb9d7d035464a1c8a4a08d74987b33bbd07654314a486e1ed4fc495e63a67
7
- data.tar.gz: 41684ba75f247e581bae0371365a58718f6312c27b8b17de263c700494041c7a6d3b0c34cb63bdc6b49c9e71ac318b4370378f87df699b61c3de1e9dc7e5bf3a
6
+ metadata.gz: ad734261c8a60d4d51284588bf4d90e2ff48717470046d8bbaaa951f7f61c112d5e4c62c4c1e006bb90698173edffb0c8072ce452ece1acd7c60ba52677fa541
7
+ data.tar.gz: c370440d80b20abdb6b5886b24df675feffe16f3ae28b392a483efc51462bb55a533039b9ebcb158da5a6fb596245ddef0f778b1337b59ef4e65c45929a232bb
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Embedded Sass Host for Ruby
2
2
 
3
- [![build](https://github.com/ntkme/sass-embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ntkme/sass-embedded-host-ruby/actions/workflows/build.yml)
3
+ [![build](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml)
4
4
  [![gem](https://badge.fury.io/rb/sass-embedded.svg)](https://rubygems.org/gems/sass-embedded)
5
5
 
6
6
  This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md).
data/exe/sass CHANGED
@@ -7,13 +7,13 @@ module Sass
7
7
  # The `sass` command line interface
8
8
  class CLI
9
9
  begin
10
- exec(*COMMAND, *ARGV)
10
+ Kernel.exec(*COMMAND, *ARGV)
11
11
  rescue Errno::ENOENT
12
12
  require_relative '../lib/sass/elf'
13
13
 
14
14
  raise if ELF::INTERPRETER.nil?
15
15
 
16
- exec(ELF::INTERPRETER, *COMMAND, *ARGV)
16
+ Kernel.exec(ELF::INTERPRETER, *COMMAND, *ARGV)
17
17
  end
18
18
  end
19
19
 
@@ -1570,6 +1570,38 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1570
1570
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1571
1571
 
1572
1572
 
1573
+ --------------------------------------------------------------------------------
1574
+
1575
+ web license:
1576
+
1577
+ Copyright 2023, the Dart project authors.
1578
+
1579
+ Redistribution and use in source and binary forms, with or without
1580
+ modification, are permitted provided that the following conditions are
1581
+ met:
1582
+ * Redistributions of source code must retain the above copyright
1583
+ notice, this list of conditions and the following disclaimer.
1584
+ * Redistributions in binary form must reproduce the above
1585
+ copyright notice, this list of conditions and the following
1586
+ disclaimer in the documentation and/or other materials provided
1587
+ with the distribution.
1588
+ * Neither the name of Google LLC nor the names of its
1589
+ contributors may be used to endorse or promote products derived
1590
+ from this software without specific prior written permission.
1591
+
1592
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1593
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1594
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1595
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1596
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1597
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1598
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1599
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1600
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1601
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1602
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1603
+
1604
+
1573
1605
  --------------------------------------------------------------------------------
1574
1606
 
1575
1607
  yaml license:
Binary file
Binary file
@@ -11,7 +11,7 @@ pool = Google::Protobuf::DescriptorPool.generated_pool
11
11
 
12
12
  begin
13
13
  pool.add_serialized_file(descriptor_data)
14
- rescue TypeError => e
14
+ rescue TypeError
15
15
  # Compatibility code: will be removed in the next major version.
16
16
  require 'google/protobuf/descriptor_pb'
17
17
  parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ require_relative '../../../ext/sass/cli'
6
+
7
+ module Sass
8
+ class Compiler
9
+ # The stdio based {Connection} between the {Dispatcher} and the compiler.
10
+ #
11
+ # It runs the `sass --embedded` command.
12
+ class Connection
13
+ def initialize(dispatcher)
14
+ @mutex = Mutex.new
15
+ @stdin, @stdout, @stderr, @wait_thread = begin
16
+ Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
17
+ rescue Errno::ENOENT
18
+ require_relative '../elf'
19
+
20
+ raise if ELF::INTERPRETER.nil?
21
+
22
+ Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
23
+ end
24
+
25
+ @stdin.binmode
26
+
27
+ Thread.new do
28
+ Thread.current.name = "sass-embedded-process-stdout-poller-#{@wait_thread.pid}"
29
+
30
+ # # https://dart.dev/tools/dart-devtools
31
+ # if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe')
32
+ # Kernel.warn(@stdout.readline, uplevel: 0)
33
+ # Kernel.warn(@stdout.readline, uplevel: 0)
34
+ # end
35
+
36
+ @stdout.binmode
37
+
38
+ loop do
39
+ length = Varint.read(@stdout)
40
+ id = Varint.read(@stdout)
41
+ proto = @stdout.read(length - Varint.length(id))
42
+ dispatcher.receive_proto(id, proto)
43
+ end
44
+ rescue IOError, Errno::EBADF, Errno::EPROTO => e
45
+ dispatcher.error(e)
46
+ @mutex.synchronize do
47
+ @stdout.close
48
+ end
49
+ end
50
+
51
+ Thread.new do
52
+ Thread.current.name = "sass-embedded-process-stderr-poller-#{@wait_thread.pid}"
53
+ loop do
54
+ Kernel.warn(@stderr.readline, uplevel: 0)
55
+ end
56
+ rescue IOError, Errno::EBADF
57
+ @mutex.synchronize do
58
+ @stderr.close
59
+ end
60
+ end
61
+
62
+ @wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}"
63
+ end
64
+
65
+ def close
66
+ @mutex.synchronize do
67
+ @stdin.close
68
+ @wait_thread.join
69
+ @stdout.close
70
+ @stderr.close
71
+ end
72
+ end
73
+
74
+ def closed?
75
+ @mutex.synchronize do
76
+ @stdin.closed? && !@wait_thread.alive?
77
+ end
78
+ end
79
+
80
+ def write(id, proto)
81
+ buffer = []
82
+ Varint.write(buffer, Varint.length(id) + proto.length)
83
+ Varint.write(buffer, id)
84
+ @mutex.synchronize do
85
+ @stdin.write(buffer.pack('C*'), proto)
86
+ end
87
+ end
88
+ end
89
+
90
+ private_constant :Connection
91
+ end
92
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  # The {Dispatcher} class.
6
6
  #
7
7
  # It dispatches messages between mutliple instances of {Host} and a single {Connection} to the compiler.
@@ -11,11 +11,12 @@ module Sass
11
11
  @observers = {}
12
12
  @mutex = Mutex.new
13
13
  @connection = Connection.new(self)
14
+ ForkTracker.add(self)
14
15
  end
15
16
 
16
17
  def subscribe(observer)
17
18
  @mutex.synchronize do
18
- raise Errno::EBUSY if @id == 0xffffffff
19
+ raise Errno::EBUSY if _closed?
19
20
 
20
21
  id = @id
21
22
  @id = id.next
@@ -30,12 +31,12 @@ module Sass
30
31
 
31
32
  return unless @observers.empty?
32
33
 
33
- if @id == 0xffffffff
34
+ if _closed?
34
35
  Thread.new do
35
36
  close
36
37
  end
37
38
  else
38
- @id = 1
39
+ _idle
39
40
  end
40
41
  end
41
42
  end
@@ -45,7 +46,11 @@ module Sass
45
46
  end
46
47
 
47
48
  def close
49
+ @mutex.synchronize do
50
+ _close
51
+ end
48
52
  @connection.close
53
+ ForkTracker.delete(self)
49
54
  end
50
55
 
51
56
  def closed?
@@ -54,7 +59,7 @@ module Sass
54
59
 
55
60
  def error(error)
56
61
  observers = @mutex.synchronize do
57
- @id = 0xffffffff
62
+ _close
58
63
  @observers.values
59
64
  end
60
65
 
@@ -70,12 +75,12 @@ module Sass
70
75
  def receive_proto(id, proto)
71
76
  case id
72
77
  when 1...0xffffffff
73
- @mutex.synchronize { @observers[id] }.receive_proto(proto)
78
+ @mutex.synchronize { @observers[id] }&.receive_proto(proto)
74
79
  when 0
75
80
  outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
76
81
  oneof = outbound_message.message
77
82
  message = outbound_message.public_send(oneof)
78
- @mutex.synchronize { @observers[message.id] }.public_send(oneof, message)
83
+ @mutex.synchronize { @observers[message.id] }&.public_send(oneof, message)
79
84
  when 0xffffffff
80
85
  outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
81
86
  oneof = outbound_message.message
@@ -90,6 +95,24 @@ module Sass
90
95
  @connection.write(...)
91
96
  end
92
97
 
98
+ private
99
+
100
+ def _close
101
+ @id = 0xffffffff
102
+ end
103
+
104
+ def _closed?
105
+ @id == 0xffffffff
106
+ end
107
+
108
+ def _idle
109
+ @id = 1
110
+ end
111
+
112
+ def _idle?
113
+ @id == 1
114
+ end
115
+
93
116
  # The {Channel} between {Dispatcher} and {Host}.
94
117
  class Channel
95
118
  attr_reader :id
@@ -104,9 +127,7 @@ module Sass
104
127
  end
105
128
 
106
129
  def error(...)
107
- Thread.new do
108
- @dispatcher.error(...)
109
- end
130
+ @dispatcher.error(...)
110
131
  end
111
132
 
112
133
  def send_proto(...)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  class Host
6
6
  # The {FunctionRegistry} class.
7
7
  #
@@ -55,8 +55,8 @@ module Sass
55
55
 
56
56
  EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
57
57
  id: function_call_request.id,
58
- success: success,
59
- accessed_argument_lists: accessed_argument_lists
58
+ success:,
59
+ accessed_argument_lists:
60
60
  )
61
61
  rescue StandardError => e
62
62
  EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  class Host
6
6
  # The {ImporterRegistry} class.
7
7
  #
@@ -65,7 +65,7 @@ module Sass
65
65
 
66
66
  EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
67
67
  id: canonicalize_request.id,
68
- url: url
68
+ url:
69
69
  )
70
70
  rescue StandardError => e
71
71
  EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
@@ -100,7 +100,7 @@ module Sass
100
100
 
101
101
  EmbeddedProtocol::InboundMessage::FileImportResponse.new(
102
102
  id: file_import_request.id,
103
- file_url: file_url
103
+ file_url:
104
104
  )
105
105
  rescue StandardError => e
106
106
  EmbeddedProtocol::InboundMessage::FileImportResponse.new(
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  class Host
6
6
  # The {LoggerRegistry} class.
7
7
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  class Host
6
6
  # The {Protofier} module.
7
7
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  class Host
6
6
  # The {Structifier} module.
7
7
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  class Host
6
6
  # The {ValueProtofier} class.
7
7
  #
@@ -8,7 +8,7 @@ require_relative 'host/structifier'
8
8
  require_relative 'host/value_protofier'
9
9
 
10
10
  module Sass
11
- class Embedded
11
+ class Compiler
12
12
  # The {Host} class.
13
13
  #
14
14
  # It communicates with {Dispatcher} and handles the host logic.
@@ -35,16 +35,16 @@ module Sass
35
35
  quiet_deps:,
36
36
  verbose:)
37
37
  compile_response = await do
38
- alert_color = $stderr.tty? if alert_color.nil?
38
+ alert_color = Exception.respond_to?(:to_tty?) && Exception.to_tty? if alert_color.nil?
39
39
 
40
- @function_registry = FunctionRegistry.new(functions, alert_color: alert_color)
41
- @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color: alert_color)
40
+ @function_registry = FunctionRegistry.new(functions, alert_color:)
41
+ @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:)
42
42
  @logger_registry = LoggerRegistry.new(logger)
43
43
 
44
44
  send_message(compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new(
45
45
  string: unless source.nil?
46
46
  EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
47
- source: source,
47
+ source:,
48
48
  url: url&.to_s,
49
49
  syntax: Protofier.to_proto_syntax(syntax),
50
50
  importer: (@importer_registry.register(importer) unless importer.nil?)
@@ -52,15 +52,15 @@ module Sass
52
52
  end,
53
53
  path: (File.absolute_path(path) unless path.nil?),
54
54
  style: Protofier.to_proto_output_style(style),
55
- charset: charset,
56
- source_map: source_map,
57
- source_map_include_sources: source_map_include_sources,
55
+ charset:,
56
+ source_map:,
57
+ source_map_include_sources:,
58
58
  importers: @importer_registry.importers,
59
59
  global_functions: @function_registry.global_functions,
60
- alert_ascii: alert_ascii,
61
- alert_color: alert_color,
62
- quiet_deps: quiet_deps,
63
- verbose: verbose
60
+ alert_ascii:,
61
+ alert_color:,
62
+ quiet_deps:,
63
+ verbose:
64
64
  ))
65
65
  end
66
66
 
@@ -70,7 +70,7 @@ module Sass
70
70
  def version_request
71
71
  version_response = await0 do
72
72
  send_message0(version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new(
73
- id: id
73
+ id:
74
74
  ))
75
75
  end
76
76
 
@@ -100,6 +100,8 @@ module Sass
100
100
 
101
101
  def log_event(message)
102
102
  @logger_registry.log(message)
103
+ rescue StandardError => e
104
+ @channel.error(e)
103
105
  end
104
106
 
105
107
  def canonicalize_request(message)
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  # The {ResilientDispatcher} class.
6
6
  #
7
7
  # It recovers from failures and continues to function.
8
8
  class ResilientDispatcher
9
- def initialize
10
- @dispatcher = Dispatcher.new
9
+ def initialize(dispatcher_class)
10
+ @dispatcher_class = dispatcher_class
11
+ @dispatcher = @dispatcher_class.new
11
12
  @mutex = Mutex.new
12
13
  end
13
14
 
@@ -29,7 +30,7 @@ module Sass
29
30
  @mutex.synchronize do
30
31
  @dispatcher.connect(...)
31
32
  rescue Errno::EBUSY
32
- @dispatcher = Dispatcher.new
33
+ @dispatcher = @dispatcher_class.new
33
34
  @dispatcher.connect(...)
34
35
  end
35
36
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
- class Embedded
4
+ class Compiler
5
5
  # The {Varint} module.
6
6
  #
7
7
  # It reads and writes varints.
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'canonicalize_context'
4
+ require_relative 'compile_result'
5
+ require_relative 'compiler/connection'
6
+ require_relative 'compiler/dispatcher'
7
+ require_relative 'compiler/host'
8
+ require_relative 'compiler/resilient_dispatcher'
9
+ require_relative 'compiler/varint'
10
+ require_relative 'embedded_protocol'
11
+ require_relative 'exception'
12
+ require_relative 'fork_tracker'
13
+ require_relative 'logger/silent'
14
+ require_relative 'logger/source_location'
15
+ require_relative 'logger/source_span'
16
+ require_relative 'serializer'
17
+ require_relative 'value'
18
+
19
+ module Sass
20
+ # The {Compiler} for using dart-sass. Each instance creates its own
21
+ # communication {Dispatcher} with a dedicated compiler process.
22
+ #
23
+ # @example
24
+ # sass = Sass::Compiler.new
25
+ # result = sass.compile_string('h1 { font-size: 40px; }')
26
+ # result = sass.compile('style.scss')
27
+ # sass.close
28
+ class Compiler
29
+ def initialize
30
+ @dispatcher = ResilientDispatcher.new(Dispatcher)
31
+ end
32
+
33
+ # Compiles the Sass file at +path+ to CSS.
34
+ # @param path [String]
35
+ # @param load_paths [Array<String>] Paths in which to look for stylesheets loaded by rules like
36
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
37
+ # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+
38
+ # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to
39
+ # browsers or other consumers. If +charset+ is +false+, these annotations are omitted.
40
+ # @param source_map [Boolean] Whether or not Sass should generate a source map.
41
+ # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map.
42
+ # @param style [String, Symbol] The OutputStyle of the compiled CSS.
43
+ # @param functions [Hash<String, Proc>] Additional built-in Sass functions that are available in all stylesheets.
44
+ # @param importers [Array<Object>] Custom importers that control how Sass resolves loads from rules like
45
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
46
+ # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error
47
+ # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well.
48
+ # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and
49
+ # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or
50
+ # not to use colors depending on whether the user is using an interactive terminal.
51
+ # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass.
52
+ # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by
53
+ # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+.
54
+ # Stylesheets that are imported relative to the entrypoint are not considered dependencies.
55
+ # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per
56
+ # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every
57
+ # deprecation warning it encounters.
58
+ # @return [CompileResult]
59
+ # @raise [ArgumentError, CompileError]
60
+ # @see https://sass-lang.com/documentation/js-api/functions/compile/
61
+ def compile(path,
62
+ load_paths: [],
63
+
64
+ charset: true,
65
+ source_map: false,
66
+ source_map_include_sources: false,
67
+ style: :expanded,
68
+
69
+ functions: {},
70
+ importers: [],
71
+
72
+ alert_ascii: false,
73
+ alert_color: nil,
74
+ logger: nil,
75
+ quiet_deps: false,
76
+ verbose: false)
77
+ raise ArgumentError, 'path must be set' if path.nil?
78
+
79
+ Host.new(@dispatcher).compile_request(
80
+ path:,
81
+ source: nil,
82
+ importer: nil,
83
+ load_paths:,
84
+ syntax: nil,
85
+ url: nil,
86
+ charset:,
87
+ source_map:,
88
+ source_map_include_sources:,
89
+ style:,
90
+ functions:,
91
+ importers:,
92
+ alert_color:,
93
+ alert_ascii:,
94
+ logger:,
95
+ quiet_deps:,
96
+ verbose:
97
+ )
98
+ end
99
+
100
+ # Compiles a stylesheet whose contents is +source+ to CSS.
101
+ # @param source [String]
102
+ # @param importer [Object] The importer to use to handle loads that are relative to the entrypoint stylesheet.
103
+ # @param load_paths [Array<String>] Paths in which to look for stylesheets loaded by rules like
104
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
105
+ # @param syntax [String, Symbol] The Syntax to use to parse the entrypoint stylesheet.
106
+ # @param url [String] The canonical URL of the entrypoint stylesheet. If this is passed along with +importer+, it's
107
+ # used to resolve relative loads in the entrypoint stylesheet.
108
+ # @param charset [Boolean] By default, if the CSS document contains non-ASCII characters, Sass adds a +@charset+
109
+ # declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to
110
+ # browsers or other consumers. If +charset+ is +false+, these annotations are omitted.
111
+ # @param source_map [Boolean] Whether or not Sass should generate a source map.
112
+ # @param source_map_include_sources [Boolean] Whether Sass should include the sources in the generated source map.
113
+ # @param style [String, Symbol] The OutputStyle of the compiled CSS.
114
+ # @param functions [Hash<String, Proc>] Additional built-in Sass functions that are available in all stylesheets.
115
+ # @param importers [Array<Object>] Custom importers that control how Sass resolves loads from rules like
116
+ # {@use}[https://sass-lang.com/documentation/at-rules/use/] and {@import}[https://sass-lang.com/documentation/at-rules/import/].
117
+ # @param alert_ascii [Boolean] If this is +true+, the compiler will exclusively use ASCII characters in its error
118
+ # and warning messages. Otherwise, it may use non-ASCII Unicode characters as well.
119
+ # @param alert_color [Boolean] If this is +true+, the compiler will use ANSI color escape codes in its error and
120
+ # warning messages. If it's +false+, it won't use these. If it's +nil+, the compiler will determine whether or
121
+ # not to use colors depending on whether the user is using an interactive terminal.
122
+ # @param logger [Object] An object to use to handle warnings and/or debug messages from Sass.
123
+ # @param quiet_deps [Boolean] If this option is set to +true+, Sass won’t print warnings that are caused by
124
+ # dependencies. A “dependency” is defined as any file that’s loaded through +load_paths+ or +importer+.
125
+ # Stylesheets that are imported relative to the entrypoint are not considered dependencies.
126
+ # @param verbose [Boolean] By default, Dart Sass will print only five instances of the same deprecation warning per
127
+ # compilation to avoid deluging users in console noise. If you set verbose to +true+, it will instead print every
128
+ # deprecation warning it encounters.
129
+ # @return [CompileResult]
130
+ # @raise [ArgumentError, CompileError]
131
+ # @see https://sass-lang.com/documentation/js-api/functions/compilestring/
132
+ def compile_string(source,
133
+ importer: nil,
134
+ load_paths: [],
135
+ syntax: :scss,
136
+ url: nil,
137
+
138
+ charset: true,
139
+ source_map: false,
140
+ source_map_include_sources: false,
141
+ style: :expanded,
142
+
143
+ functions: {},
144
+ importers: [],
145
+
146
+ alert_ascii: false,
147
+ alert_color: nil,
148
+ logger: nil,
149
+ quiet_deps: false,
150
+ verbose: false)
151
+ raise ArgumentError, 'source must be set' if source.nil?
152
+
153
+ Host.new(@dispatcher).compile_request(
154
+ path: nil,
155
+ source:,
156
+ importer:,
157
+ load_paths:,
158
+ syntax:,
159
+ url:,
160
+ charset:,
161
+ source_map:,
162
+ source_map_include_sources:,
163
+ style:,
164
+ functions:,
165
+ importers:,
166
+ alert_color:,
167
+ alert_ascii:,
168
+ logger:,
169
+ quiet_deps:,
170
+ verbose:
171
+ )
172
+ end
173
+
174
+ # @return [String] Information about the Sass implementation.
175
+ # @see https://sass-lang.com/documentation/js-api/variables/info/
176
+ def info
177
+ @info ||= Host.new(@dispatcher).version_request
178
+ end
179
+
180
+ def close
181
+ @dispatcher.close
182
+ end
183
+
184
+ def closed?
185
+ @dispatcher.closed?
186
+ end
187
+ end
188
+ end