sass-embedded 1.99.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.
@@ -3,7 +3,7 @@
3
3
  module Sass
4
4
  # @see https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md
5
5
  module EmbeddedProtocol
6
- require_relative 'embedded_sass_pb'
6
+ require 'sass/embedded_sass_pb'
7
7
  end
8
8
 
9
9
  private_constant :EmbeddedProtocol
@@ -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.99.0
4
+ version: 1.101.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
@@ -51,8 +51,12 @@ files:
51
51
  - README.md
52
52
  - exe/sass
53
53
  - ext/sass/Rakefile
54
+ - ext/sass/file_utils.rb
54
55
  - ext/sass/package.json
55
- - ext/sass/sass-1.99.0.tgz
56
+ - ext/sass/platform.rb
57
+ - ext/sass/sass-1.101.0.tgz
58
+ - ext/sass/sass_config.rb
59
+ - ext/sass/utils.rb
56
60
  - lib/sass-embedded.rb
57
61
  - lib/sass/calculation_value.rb
58
62
  - lib/sass/calculation_value/calculation_operation.rb
@@ -62,12 +66,14 @@ files:
62
66
  - lib/sass/compiler/channel.rb
63
67
  - lib/sass/compiler/connection.rb
64
68
  - lib/sass/compiler/dispatcher.rb
65
- - lib/sass/compiler/host.rb
66
- - lib/sass/compiler/host/function_registry.rb
67
- - lib/sass/compiler/host/importer_registry.rb
68
- - lib/sass/compiler/host/logger_registry.rb
69
- - lib/sass/compiler/host/protofier.rb
70
- - 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
71
77
  - lib/sass/compiler/varint.rb
72
78
  - lib/sass/elf.rb
73
79
  - lib/sass/embedded.rb
@@ -82,6 +88,7 @@ files:
82
88
  - lib/sass/logger/source_span.rb
83
89
  - lib/sass/node_package_importer.rb
84
90
  - lib/sass/serializer.rb
91
+ - lib/sass/uri.rb
85
92
  - lib/sass/value.rb
86
93
  - lib/sass/value/argument_list.rb
87
94
  - lib/sass/value/boolean.rb
@@ -126,8 +133,8 @@ licenses:
126
133
  - MIT
127
134
  metadata:
128
135
  bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
129
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.99.0
130
- source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.99.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
131
138
  funding_uri: https://github.com/sponsors/ntkme
132
139
  rubygems_mfa_required: 'true'
133
140
  rdoc_options: []
@@ -144,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
151
  - !ruby/object:Gem::Version
145
152
  version: '0'
146
153
  requirements: []
147
- rubygems_version: 4.0.9
154
+ rubygems_version: 4.0.14
148
155
  specification_version: 4
149
156
  summary: Use dart-sass with Ruby!
150
157
  test_files: []
Binary file