sass-embedded 1.100.0 → 1.101.0

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: c9528441bd2201383e83042dd654227c74e7163095e950d2412d055649386dcf
4
- data.tar.gz: 4f92b875e3c3bb56e5abf21b966a1ee4da60f9c2a0b7eb08eed7cb46feb0422a
3
+ metadata.gz: 1c1150457b872cc21b565ce1443f9a27ebd8381827cb817ba4f7c9e0cb0d4a1b
4
+ data.tar.gz: 2bac705032c8c0c1d1e17f5b94e3c0d21590a9c07d8be51fe132ee3f6c7a318e
5
5
  SHA512:
6
- metadata.gz: 5fa53e22297ad64bcb4c462e5fbc7e202bf4f8eab03d829c36bbdb9c46dd9607e9e7ce1782bd9b64dc23fb0728c448b3367ca3d8fdcf717cba85572b817e85d7
7
- data.tar.gz: 7e0f8ba6cd0852965143fecbef6fc39549edd195022a37eff1a5c6c396067bbd1892bd6500532e6e8944965fba8adfe601e7e669766ac579ea20bc6bc4c51f34
6
+ metadata.gz: 44730a3d0a601297d15e30b234497b89c0959732c60ff108165bfb664f1c53524c61d07be05451560d6d3cedc34fd3cd3ea322b9701519f9d0f88076af3ee6ac
7
+ data.tar.gz: 10f8eb4867f4669407d8f64b8f31b998d37eb9eaa2fb3cd93d7cd04c33b4c99ef8715483303b71167919c0b477e151157b9d643b1dda5cea191c6e6187672a51
data/ext/sass/Rakefile CHANGED
@@ -84,10 +84,9 @@ file File.absolute_path('node_modules/sass', ARCHDIR) do
84
84
  end
85
85
 
86
86
  task 'dart-sass' => (
87
- begin
88
- SassConfig.dart_sass
87
+ if SassConfig.dart_support?
89
88
  File.absolute_path('dart-sass/sass', ARCHDIR)
90
- rescue NotImplementedError
89
+ else
91
90
  File.absolute_path('node_modules/sass', ARCHDIR)
92
91
  end
93
92
  )
@@ -2,6 +2,8 @@
2
2
 
3
3
  # This is a FileUtils extension that defines several additional commands to be
4
4
  # added to the FileUtils utility functions.
5
+ #
6
+ # @!visibility private
5
7
  module FileUtils
6
8
  def unarchive(archive, chdir: '.')
7
9
  if Gem.win_platform?
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "dependencies": {
3
- "sass": "file:sass-1.100.0.tgz"
3
+ "sass": "file:sass-1.101.0.tgz"
4
4
  }
5
5
  }
data/ext/sass/platform.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # The {Platform} module.
4
+ #
5
+ # @!visibility private
4
6
  module Platform
5
7
  HOST_CPU = RbConfig::CONFIG['host_cpu'].downcase
6
8
 
Binary file
@@ -3,6 +3,8 @@
3
3
  require_relative 'platform'
4
4
 
5
5
  # The {SassConfig} module.
6
+ #
7
+ # @!visibility private
6
8
  module SassConfig
7
9
  module_function
8
10
 
@@ -12,6 +14,11 @@ module SassConfig
12
14
  JSON.parse(File.read(File.absolute_path('package.json', path)))
13
15
  end
14
16
 
17
+ def dart_support?
18
+ %w[darwin linux linux-android linux-musl windows].include?(Platform::OS) &&
19
+ %w[x86_64 aarch64 arm riscv64].include?(Platform::CPU)
20
+ end
21
+
15
22
  def dart_sass_version
16
23
  package_json(__dir__)['dependencies']['sass']
17
24
  # TODO: remove after https://github.com/sass/dart-sass/pull/2413
data/ext/sass/utils.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # The {Utils} module.
4
+ #
5
+ # @!visibility private
4
6
  module Utils
5
7
  module_function
6
8
 
@@ -29,24 +29,24 @@ module Sass
29
29
  end
30
30
  end
31
31
 
32
- def stream(host)
32
+ def stream(session)
33
33
  @mutex.synchronize do
34
34
  raise IOError, 'closed compiler' if @dispatcher.nil?
35
35
 
36
- Stream.new(@dispatcher, host)
36
+ Stream.new(@dispatcher, session)
37
37
  rescue Errno::EBUSY
38
38
  @dispatcher = Dispatcher.new(*@args, **@kwargs, &@block)
39
- Stream.new(@dispatcher, host)
39
+ Stream.new(@dispatcher, session)
40
40
  end
41
41
  end
42
42
 
43
- # The {Stream} between {Dispatcher} and {Host}.
43
+ # The {Stream} between {Dispatcher} and {Session}.
44
44
  class Stream
45
45
  attr_reader :id
46
46
 
47
- def initialize(dispatcher, host)
47
+ def initialize(dispatcher, session)
48
48
  @dispatcher = dispatcher
49
- @id = @dispatcher.subscribe(host)
49
+ @id = @dispatcher.subscribe(session)
50
50
  end
51
51
 
52
52
  def close
@@ -4,7 +4,7 @@ module Sass
4
4
  class Compiler
5
5
  # The {Dispatcher} class.
6
6
  #
7
- # It dispatches messages between multiple instances of {Host} and a single {Connection} to the compiler.
7
+ # It dispatches messages between multiple instances of {Session} and a single {Connection} to the compiler.
8
8
  class Dispatcher
9
9
  def initialize(idle_timeout: 0)
10
10
  @id = 1
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Sass
4
4
  class Compiler
5
- class Host
5
+ class Session
6
6
  # The {FunctionRegistry} class.
7
7
  #
8
8
  # It stores sass custom functions and handles function calls.
9
9
  class FunctionRegistry
10
10
  attr_reader :compile_context, :global_functions
11
11
 
12
- def initialize(functions, alert_color:)
12
+ def initialize(functions, session:)
13
13
  @compile_context = Object.new
14
14
  @global_functions = functions.keys.map!(&:to_s)
15
15
  @functions_by_name = functions.transform_keys do |signature|
@@ -26,7 +26,7 @@ module Sass
26
26
  @functions_by_id = {}.compare_by_identity
27
27
  @ids_by_function = {}.compare_by_identity
28
28
 
29
- @highlight = alert_color
29
+ @session = session
30
30
  end
31
31
 
32
32
  def register(function)
@@ -68,9 +68,14 @@ module Sass
68
68
  accessed_argument_lists:
69
69
  )
70
70
  rescue StandardError => e
71
+ @session.backtrace = e.backtrace
71
72
  EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
72
73
  id: function_call_request.id,
73
- error: e.full_message(highlight: @highlight, order: :top)
74
+ error: if e.respond_to?(:detailed_message)
75
+ e.detailed_message(highlight: false)
76
+ else # TODO: remove once ruby 3.1 support is dropped
77
+ "#{e.message} (#{e.class.name})"
78
+ end
74
79
  )
75
80
  end
76
81
 
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Sass
4
4
  class Compiler
5
- class Host
5
+ class Session
6
6
  # The {ImporterRegistry} class.
7
7
  #
8
8
  # It stores importers and handles import requests.
9
9
  class ImporterRegistry
10
10
  attr_reader :importers
11
11
 
12
- def initialize(importers, load_paths, alert_color:)
12
+ def initialize(importers, load_paths, session:)
13
13
  @id = 0
14
14
  @importers_by_id = {}.compare_by_identity
15
15
  @importers = importers
@@ -22,7 +22,7 @@ module Sass
22
22
  end
23
23
  )
24
24
 
25
- @highlight = alert_color
25
+ @session = session
26
26
  end
27
27
 
28
28
  IMPORTER_ATTRS = %i[non_canonical_scheme].freeze
@@ -79,9 +79,14 @@ module Sass
79
79
  containing_url_unused: canonicalize_context.instance_variable_get(:@containing_url_unused)
80
80
  )
81
81
  rescue StandardError => e
82
+ @session.backtrace = e.backtrace
82
83
  EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
83
84
  id: canonicalize_request.id,
84
- error: e.full_message(highlight: @highlight, order: :top)
85
+ error: if e.respond_to?(:detailed_message)
86
+ e.detailed_message(highlight: false)
87
+ else # TODO: remove once ruby 3.1 support is dropped
88
+ "#{e.message} (#{e.class.name})"
89
+ end
85
90
  )
86
91
  end
87
92
 
@@ -103,9 +108,14 @@ module Sass
103
108
  )
104
109
  )
105
110
  rescue StandardError => e
111
+ @session.backtrace = e.backtrace
106
112
  EmbeddedProtocol::InboundMessage::ImportResponse.new(
107
113
  id: import_request.id,
108
- error: e.full_message(highlight: @highlight, order: :top)
114
+ error: if e.respond_to?(:detailed_message)
115
+ e.detailed_message(highlight: false)
116
+ else # TODO: remove once ruby 3.1 support is dropped
117
+ "#{e.message} (#{e.class.name})"
118
+ end
109
119
  )
110
120
  end
111
121
 
@@ -121,9 +131,14 @@ module Sass
121
131
  containing_url_unused: canonicalize_context.instance_variable_get(:@containing_url_unused)
122
132
  )
123
133
  rescue StandardError => e
134
+ @session.backtrace = e.backtrace
124
135
  EmbeddedProtocol::InboundMessage::FileImportResponse.new(
125
136
  id: file_import_request.id,
126
- error: e.full_message(highlight: @highlight, order: :top)
137
+ error: if e.respond_to?(:detailed_message)
138
+ e.detailed_message(highlight: false)
139
+ else # TODO: remove once ruby 3.1 support is dropped
140
+ "#{e.message} (#{e.class.name})"
141
+ end
127
142
  )
128
143
  end
129
144
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Sass
4
4
  class Compiler
5
- class Host
5
+ class Session
6
6
  # The {LoggerRegistry} class.
7
7
  #
8
8
  # It stores logger and handles log events.
@@ -24,13 +24,13 @@ module Sass
24
24
  if @logger_respond_to_debug
25
25
  @logger.debug(event.message, DebugContext.new(event))
26
26
  else
27
- Kernel.warn(event.formatted)
27
+ Kernel.warn(Path.pretty_formatted!(+event.formatted, event.span.url))
28
28
  end
29
29
  when :DEPRECATION_WARNING, :WARNING
30
30
  if @logger_respond_to_warn
31
31
  @logger.warn(event.message, WarnContext.new(event))
32
32
  else
33
- Kernel.warn(event.formatted)
33
+ Kernel.warn(StackTrace.pretty_formatted!(+event.formatted, event.stack_trace))
34
34
  end
35
35
  else
36
36
  raise ArgumentError, "Unknown LogEvent.type #{event.type}"
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ class Compiler
5
+ class Session
6
+ # @see https://pub.dev/documentation/path/latest/path/
7
+ module Path
8
+ module_function
9
+
10
+ # @see https://pub.dev/documentation/path/latest/path/Context/prettyUri.html
11
+ def pretty_uri(uri)
12
+ return uri unless uri&.start_with?('file:')
13
+
14
+ absolute_path = Uri.file_uri_to_path(uri)
15
+ relative_path = Uri.decode_uri_component(Uri.relative(uri, Uri.pwd))
16
+ relative_path.count('/') > absolute_path.count('/') ? absolute_path : relative_path
17
+ end
18
+
19
+ def pretty_formatted!(formatted, uri)
20
+ index = formatted.index(uri)
21
+ return formatted unless index
22
+
23
+ replacement = pretty_uri(uri)
24
+ return formatted if uri == replacement
25
+
26
+ formatted[index, uri.length] = replacement
27
+ formatted
28
+ end
29
+ end
30
+
31
+ private_constant :Path
32
+ end
33
+ end
34
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Sass
4
4
  class Compiler
5
- class Host
5
+ class Session
6
6
  # The {Protofier} class.
7
7
  #
8
8
  # It converts Pure Ruby types and Protobuf Ruby types.
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ class Compiler
5
+ class Session
6
+ # @see https://pub.dev/documentation/stack_trace/latest/stack_trace/
7
+ module StackTrace
8
+ module_function
9
+
10
+ # @see https://pub.dev/documentation/stack_trace/latest/stack_trace/Trace/toString.html
11
+ def pretty_formatted!(formatted, stack_trace)
12
+ longest = 0
13
+
14
+ frames = stack_trace.lines("\n", chomp: true).map do |frame|
15
+ location, member = frame.split(/ +/, 2)
16
+ uri, line_column = location.split(' ', 2)
17
+
18
+ uri = Path.pretty_uri(uri)
19
+ location = line_column.nil? ? uri : "#{uri} #{line_column}"
20
+
21
+ longest = location.length if location.length > longest
22
+ [frame, location, member]
23
+ end
24
+
25
+ offset = formatted.length
26
+
27
+ frames.reverse_each do |frame, location, member|
28
+ index = formatted.rindex(frame, offset)
29
+ next unless index
30
+
31
+ offset = index
32
+
33
+ replacement = "#{location.ljust(longest)} #{member}"
34
+ next if frame == replacement
35
+
36
+ formatted[index, frame.length] = replacement
37
+ end
38
+
39
+ formatted
40
+ end
41
+ end
42
+
43
+ private_constant :StackTrace
44
+ end
45
+ end
46
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Sass
4
4
  class Compiler
5
- class Host
5
+ class Session
6
6
  # The {Struct} class.
7
7
  #
8
8
  # It creates {::Struct}-like objects from {::Hash}.
@@ -1,19 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'host/function_registry'
4
- require_relative 'host/importer_registry'
5
- require_relative 'host/logger_registry'
6
- require_relative 'host/protofier'
7
- require_relative 'host/struct'
3
+ require_relative 'session/function_registry'
4
+ require_relative 'session/importer_registry'
5
+ require_relative 'session/logger_registry'
6
+ require_relative 'session/path'
7
+ require_relative 'session/protofier'
8
+ require_relative 'session/stack_trace'
9
+ require_relative 'session/struct'
8
10
 
9
11
  module Sass
10
12
  class Compiler
11
- # The {Host} class.
13
+ # The {Session} class.
12
14
  #
13
15
  # It communicates with {Dispatcher} and handles the host logic.
14
- class Host
16
+ class Session
17
+ attr_writer :backtrace
18
+
15
19
  def initialize(channel)
16
20
  @channel = channel
21
+ @backtrace = nil
17
22
  end
18
23
 
19
24
  def compile_request(path:,
@@ -38,8 +43,8 @@ module Sass
38
43
  verbose:)
39
44
  alert_color = Exception.to_tty? if alert_color.nil?
40
45
 
41
- @function_registry = FunctionRegistry.new(functions, alert_color:)
42
- @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color:)
46
+ @function_registry = FunctionRegistry.new(functions, session: self)
47
+ @importer_registry = ImporterRegistry.new(importers, load_paths, session: self)
43
48
  @logger_registry = LoggerRegistry.new(logger)
44
49
 
45
50
  compile_request = EmbeddedProtocol::InboundMessage::CompileRequest.new(
@@ -83,13 +88,15 @@ module Sass
83
88
  result = compile_response.public_send(oneof)
84
89
  case oneof
85
90
  when :failure
86
- raise CompileError.new(
91
+ compile_error = CompileError.new(
87
92
  result.message,
88
- result.formatted == '' ? nil : result.formatted,
93
+ result.formatted == '' ? nil : StackTrace.pretty_formatted!(+result.formatted, result.stack_trace),
89
94
  result.stack_trace == '' ? nil : result.stack_trace,
90
95
  result.span.nil? ? nil : Logger::SourceSpan.new(result.span),
91
96
  compile_response.loaded_urls.to_a
92
97
  )
98
+ compile_error.set_backtrace(@backtrace) unless @backtrace.nil?
99
+ raise compile_error
93
100
  when :success
94
101
  CompileResult.new(
95
102
  result.css,
@@ -221,6 +228,6 @@ module Sass
221
228
  end
222
229
  end
223
230
 
224
- private_constant :Host
231
+ private_constant :Session
225
232
  end
226
233
  end
data/lib/sass/compiler.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'compile_result'
5
5
  require_relative 'compiler/channel'
6
6
  require_relative 'compiler/connection'
7
7
  require_relative 'compiler/dispatcher'
8
- require_relative 'compiler/host'
8
+ require_relative 'compiler/session'
9
9
  require_relative 'compiler/varint'
10
10
  require_relative 'embedded/version'
11
11
  require_relative 'embedded_protocol'
@@ -17,6 +17,7 @@ require_relative 'logger/source_location'
17
17
  require_relative 'logger/source_span'
18
18
  require_relative 'node_package_importer'
19
19
  require_relative 'serializer'
20
+ require_relative 'uri'
20
21
  require_relative 'value'
21
22
 
22
23
  module Sass
@@ -86,7 +87,7 @@ module Sass
86
87
  verbose: false)
87
88
  raise ArgumentError, 'path must be set' if path.nil?
88
89
 
89
- Host.new(@channel).compile_request(
90
+ Session.new(@channel).compile_request(
90
91
  path:,
91
92
  source: nil,
92
93
  importer: nil,
@@ -169,7 +170,7 @@ module Sass
169
170
  verbose: false)
170
171
  raise ArgumentError, 'source must be set' if source.nil?
171
172
 
172
- Host.new(@channel).compile_request(
173
+ Session.new(@channel).compile_request(
173
174
  path: nil,
174
175
  source:,
175
176
  importer:,
@@ -198,7 +199,7 @@ module Sass
198
199
  def info
199
200
  @info ||= [
200
201
  ['sass-embedded', Embedded::VERSION, '(Embedded Host)', '[Ruby]'].join("\t"),
201
- Host.new(@channel).version_request.join("\t")
202
+ Session.new(@channel).version_request.join("\t")
202
203
  ].join("\n").freeze
203
204
  end
204
205
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  module Embedded
5
- VERSION = '1.100.0'
5
+ VERSION = '1.101.0'
6
6
  end
7
7
  end
@@ -12,25 +12,77 @@ module Sass
12
12
  # @return [Array<String>]
13
13
  attr_reader :loaded_urls
14
14
 
15
- # @!visibility private
16
- def initialize(message, full_message, sass_stack, span, loaded_urls)
17
- super(message)
15
+ if Exception.public_method_defined?(:detailed_message, false)
16
+ # @!visibility private
17
+ def initialize(message, detailed_message, sass_stack, span, loaded_urls)
18
+ super(message)
18
19
 
19
- @full_message = full_message
20
- @sass_stack = sass_stack
21
- @span = span
22
- @loaded_urls = loaded_urls
23
- end
20
+ @detailed_message = detailed_message
21
+ @sass_stack = sass_stack
22
+ @span = span
23
+ @loaded_urls = loaded_urls
24
+ end
24
25
 
25
- # @return [String]
26
- def full_message(highlight: nil, order: nil, **)
27
- return super if @full_message.nil?
28
-
29
- highlight = Exception.to_tty? if highlight.nil?
30
- if highlight
31
- @full_message.dup
32
- else
33
- @full_message.gsub(/\e\[[0-9;]*m/, '')
26
+ # @!visibility private
27
+ def detailed_message(highlight: nil, **)
28
+ return super if @detailed_message.nil?
29
+
30
+ highlight = Exception.to_tty? if highlight.nil?
31
+
32
+ detailed_message = @detailed_message.sub(message, super)
33
+ detailed_message.gsub!(/\e\[[0-9;]*m/, '') unless highlight
34
+ detailed_message
35
+ end
36
+ else # TODO: remove once ruby 3.1 support is dropped
37
+ # @!visibility private
38
+ def initialize(message, detailed_message, sass_stack, span, loaded_urls)
39
+ super(detailed_message.nil? ? message : detailed_message)
40
+
41
+ @message = message
42
+ @detailed_message = detailed_message
43
+ @sass_stack = sass_stack
44
+ @span = span
45
+ @loaded_urls = loaded_urls
46
+ end
47
+
48
+ # @!visibility private
49
+ def message
50
+ return @message if @detailed_message.nil? || @full_message.nil?
51
+
52
+ @detailed_message
53
+ end
54
+
55
+ # @!visibility private
56
+ def detailed_message(highlight: nil, **)
57
+ highlight = Exception.to_tty? if highlight.nil?
58
+
59
+ super_ = if highlight
60
+ lines = message.split("\n")
61
+ lines[0] += " (\e[1;4m#{self.class.name}\e[m\e[1m)" unless lines.empty?
62
+ lines.map { |line| "\e[1m#{line}\e[m" }.join("\n")
63
+ else
64
+ lines = message.split("\n", 2)
65
+ lines[0] += " (#{self.class.name})" unless lines.empty?
66
+ lines.join("\n")
67
+ end
68
+
69
+ return super_ if @detailed_message.nil?
70
+
71
+ detailed_message = @detailed_message.sub(message, super_)
72
+ detailed_message.gsub!(/\e\[[0-9;]*m/, '') unless highlight
73
+ detailed_message
74
+ end
75
+
76
+ # @!visibility private
77
+ def full_message(highlight: nil, order: :top, **)
78
+ highlight = Exception.to_tty? if highlight.nil?
79
+
80
+ @full_message = true
81
+ full_message = super.force_encoding(message.encoding)
82
+ full_message.gsub!(/\e\[[0-9;]*m/, '') unless highlight
83
+ full_message
84
+ ensure
85
+ @full_message = nil
34
86
  end
35
87
  end
36
88
 
@@ -2,16 +2,25 @@
2
2
 
3
3
  module Sass
4
4
  # The built-in RubyGems package importer. This loads pkg: URLs from gems.
5
+ #
6
+ # @example
7
+ # require 'bundler/inline'
8
+ #
9
+ # gemfile do
10
+ # source 'https://rubygems.org'
11
+ # gem 'bootstrap', require: false
12
+ # gem 'sass-embedded'
13
+ # end
14
+ #
15
+ # puts Sass.compile_string('@use "pkg:bootstrap/assets/stylesheets/bootstrap";', importers: [Sass::GemPackageImporter.new]).css
5
16
  class GemPackageImporter
6
17
  # @!visibility private
7
18
  def find_file_url(url, _canonicalize_context)
8
19
  return unless url.start_with?('pkg:')
9
20
 
10
- library, _, path = url[4..].partition(/[#?]/).first.partition('/')
11
- gem_dir = Gem::Dependency.new(library).to_spec.gem_dir
12
- gem_dir = "/#{gem_dir}" unless gem_dir.start_with?('/')
13
-
14
- "file://#{gem_dir.gsub(/[#%?\\]/, { '#' => '%23', '%' => '%25', '?' => '%3F', '\\' => '%5C' })}/#{path}"
21
+ library, _, path = url[4..].partition('/')
22
+ gem_dir = Gem::Dependency.new(Uri.decode_uri_component(library)).to_spec.gem_dir
23
+ "#{Uri.path_to_file_uri(gem_dir)}/#{path}"
15
24
  rescue Gem::MissingSpecError
16
25
  nil
17
26
  end
data/lib/sass/uri.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module Sass
6
+ # The {Uri} class.
7
+ #
8
+ # It follows RFC3986 to match the behavior of Uri class from Dart.
9
+ #
10
+ # @see https://www.rfc-editor.org/info/rfc3986/
11
+ module Uri
12
+ module_function
13
+
14
+ def decode_uri_component(str)
15
+ str.b.gsub(/%\h\h/, ::URI::TBLDECWWWCOMP_).force_encoding(str.encoding)
16
+ end
17
+
18
+ def encode_uri_component(str)
19
+ str.b.gsub(/[^0-9A-Za-z\-._~]/n, ::URI::TBLENCURICOMP_).force_encoding(str.encoding)
20
+ end
21
+
22
+ def encode_uri_path_component(str)
23
+ str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/]}n, ::URI::TBLENCURICOMP_).force_encoding(str.encoding)
24
+ end
25
+
26
+ def encode_uri_query_component(str)
27
+ str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/?]}n, ::URI::TBLENCURICOMP_).force_encoding(str.encoding)
28
+ end
29
+
30
+ def file_uri_to_path(uri)
31
+ path = decode_uri_component(::URI::RFC3986_PARSER.parse(uri).path)
32
+ if path.start_with?('/')
33
+ windows_path = path[1..]
34
+ path = windows_path if File.absolute_path?(windows_path)
35
+ end
36
+ path
37
+ end
38
+
39
+ def path_to_file_uri(path)
40
+ path = "/#{path}" unless path.start_with?('/')
41
+ "file://#{encode_uri_path_component(path)}"
42
+ end
43
+
44
+ def pwd
45
+ pwd = Dir.pwd
46
+ pwd += '/' unless pwd.end_with?('/')
47
+ path_to_file_uri(pwd)
48
+ end
49
+
50
+ def relative(to, from)
51
+ ::URI::RFC3986_PARSER.parse(to).route_from(from).to_s
52
+ end
53
+ end
54
+
55
+ private_constant :Uri
56
+ end
@@ -33,7 +33,7 @@ module Sass
33
33
 
34
34
  # The algorithm for converting a single `srgb` or `display-p3` channel to
35
35
  # linear-light form.
36
- # @param [Numeric]
36
+ # @param channel [Numeric]
37
37
  # @return [Numeric]
38
38
  def srgb_and_display_p3_to_linear(channel)
39
39
  abs = channel.abs
@@ -42,7 +42,7 @@ module Sass
42
42
 
43
43
  # The algorithm for converting a single `srgb` or `display-p3` channel to
44
44
  # gamma-corrected form.
45
- # @param [Numeric]
45
+ # @param channel [Numeric]
46
46
  # @return [Numeric]
47
47
  def srgb_and_display_p3_from_linear(channel)
48
48
  abs = channel.abs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.100.0
4
+ version: 1.101.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
@@ -54,7 +54,7 @@ files:
54
54
  - ext/sass/file_utils.rb
55
55
  - ext/sass/package.json
56
56
  - ext/sass/platform.rb
57
- - ext/sass/sass-1.100.0.tgz
57
+ - ext/sass/sass-1.101.0.tgz
58
58
  - ext/sass/sass_config.rb
59
59
  - ext/sass/utils.rb
60
60
  - lib/sass-embedded.rb
@@ -66,12 +66,14 @@ files:
66
66
  - lib/sass/compiler/channel.rb
67
67
  - lib/sass/compiler/connection.rb
68
68
  - lib/sass/compiler/dispatcher.rb
69
- - lib/sass/compiler/host.rb
70
- - lib/sass/compiler/host/function_registry.rb
71
- - lib/sass/compiler/host/importer_registry.rb
72
- - lib/sass/compiler/host/logger_registry.rb
73
- - lib/sass/compiler/host/protofier.rb
74
- - lib/sass/compiler/host/struct.rb
69
+ - lib/sass/compiler/session.rb
70
+ - lib/sass/compiler/session/function_registry.rb
71
+ - lib/sass/compiler/session/importer_registry.rb
72
+ - lib/sass/compiler/session/logger_registry.rb
73
+ - lib/sass/compiler/session/path.rb
74
+ - lib/sass/compiler/session/protofier.rb
75
+ - lib/sass/compiler/session/stack_trace.rb
76
+ - lib/sass/compiler/session/struct.rb
75
77
  - lib/sass/compiler/varint.rb
76
78
  - lib/sass/elf.rb
77
79
  - lib/sass/embedded.rb
@@ -86,6 +88,7 @@ files:
86
88
  - lib/sass/logger/source_span.rb
87
89
  - lib/sass/node_package_importer.rb
88
90
  - lib/sass/serializer.rb
91
+ - lib/sass/uri.rb
89
92
  - lib/sass/value.rb
90
93
  - lib/sass/value/argument_list.rb
91
94
  - lib/sass/value/boolean.rb
@@ -130,8 +133,8 @@ licenses:
130
133
  - MIT
131
134
  metadata:
132
135
  bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
133
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.100.0
134
- source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.100.0
136
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.101.0
137
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.101.0
135
138
  funding_uri: https://github.com/sponsors/ntkme
136
139
  rubygems_mfa_required: 'true'
137
140
  rdoc_options: []
@@ -148,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
151
  - !ruby/object:Gem::Version
149
152
  version: '0'
150
153
  requirements: []
151
- rubygems_version: 4.0.12
154
+ rubygems_version: 4.0.14
152
155
  specification_version: 4
153
156
  summary: Use dart-sass with Ruby!
154
157
  test_files: []
Binary file