sass-embedded 0.10.0 → 0.13.1

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: e3c01d861dce5149bb56f25e6cb89e54d21a26bc4e50486298f860b2386198b7
4
- data.tar.gz: 36f04488a3118b833f6210766e590a617fe7204dabb31b0908023b32a008ed21
3
+ metadata.gz: 6c8f92f0e6135b60c156ef3e8db7c7db99e5c2bc6eb3d0a8d557000851297c8e
4
+ data.tar.gz: 751defdb3ff0b131e31ce532bc879137df34ee59f949497fdad0bad03df4ee95
5
5
  SHA512:
6
- metadata.gz: c7c15d96579e3dc1843c3dfc66709c9a3ae48bcbb7458f0defcc91c313cffb53dc43b01d114c35b13b8a7b8cfae516440037730283d52e5ea506fffa70a9bcac
7
- data.tar.gz: ae089947ade94c0550e9a066860e89e1c774572ddc1ab7c5b42327f4a9f3fe6db41c4422ce96a9454d63b44ae8675091239278ebd8d6f524438c0f680a3e5e26
6
+ metadata.gz: 85b2081c739e06f454d3d47d15c2c8cf2321b38f9853ef7a18713761029c2adc0bbc40d38d43c9ebc44b4bec13b986ae1915c29e4fab5dd6f62eb68624f37246
7
+ data.tar.gz: 2efe026a515f212d6025635b9e12bacc8532102a1441582daee31931a59a9268aedb8430a35aefb1c94e102100c216b0151f10bcc74b501a458c7ff2606855aa
@@ -20,6 +20,7 @@ module Sass
20
20
  url:,
21
21
 
22
22
  source_map:,
23
+ source_map_include_sources:,
23
24
  style:,
24
25
 
25
26
  functions:,
@@ -39,6 +40,7 @@ module Sass
39
40
  @url = url
40
41
 
41
42
  @source_map = source_map
43
+ @source_map_include_sources = source_map_include_sources
42
44
  @style = style
43
45
 
44
46
  @global_functions = functions.keys.map(&:to_s)
@@ -50,7 +52,11 @@ module Sass
50
52
 
51
53
  @alert_ascii = alert_ascii
52
54
  @alert_color = alert_color
53
- @logger = logger
55
+
56
+ %i[debug warn].each do |sym|
57
+ instance_variable_set("@#{sym}".to_sym, get_method(logger, sym))
58
+ end
59
+
54
60
  @quiet_deps = quiet_deps
55
61
  @verbose = verbose
56
62
 
@@ -109,24 +115,26 @@ module Sass
109
115
  def log(event)
110
116
  case event.type
111
117
  when :DEBUG
112
- if @logger.respond_to? :debug
113
- @logger.debug(event.message, span: Logger::SourceSpan.from_proto(event.span))
114
- else
118
+ if @debug.nil?
115
119
  Kernel.warn(event.formatted)
120
+ else
121
+ @debug.call(event.message, span: Logger::SourceSpan.from_proto(event.span))
116
122
  end
117
123
  when :DEPRECATION_WARNING
118
- if @logger.respond_to? :warn
119
- @logger.warn(event.message, deprecation: true, span: Logger::SourceSpan.from_proto(event.span),
120
- stack: event.stack_trace)
121
- else
124
+ if @warn.nil?
122
125
  Kernel.warn(event.formatted)
126
+ else
127
+ @warn.call(event.message, deprecation: true,
128
+ span: Logger::SourceSpan.from_proto(event.span),
129
+ stack: event.stack_trace)
123
130
  end
124
131
  when :WARNING
125
- if @logger.respond_to? :warn
126
- @logger.warn(event.message, deprecation: false, span: Logger::SourceSpan.from_proto(event.span),
127
- stack: event.stack_trace)
128
- else
132
+ if @warn.nil?
129
133
  Kernel.warn(event.formatted)
134
+ else
135
+ @warn.call(event.message, deprecation: false,
136
+ span: Logger::SourceSpan.from_proto(event.span),
137
+ stack: event.stack_trace)
130
138
  end
131
139
  end
132
140
  end
@@ -145,6 +153,7 @@ module Sass
145
153
  path: @path,
146
154
  style: to_proto_output_style(@style),
147
155
  source_map: @source_map,
156
+ source_map_include_sources: @source_map_include_sources,
148
157
  importers: to_proto_importers(@importers, @load_paths),
149
158
  global_functions: @global_functions,
150
159
  alert_ascii: @alert_ascii,
@@ -153,7 +162,9 @@ module Sass
153
162
  end
154
163
 
155
164
  def canonicalize_response(canonicalize_request)
156
- url = importer_with_id(canonicalize_request.importer_id).canonicalize canonicalize_request.url
165
+ importer = importer_with_id(canonicalize_request.importer_id)
166
+ url = get_method(importer, :canonicalize).call canonicalize_request.url,
167
+ from_import: canonicalize_request.from_import
157
168
 
158
169
  EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
159
170
  id: canonicalize_request.id,
@@ -167,14 +178,15 @@ module Sass
167
178
  end
168
179
 
169
180
  def import_response(import_request)
170
- importer_result = importer_with_id(import_request.importer_id).load import_request.url
181
+ importer = importer_with_id(import_request.importer_id)
182
+ importer_result = get_method(importer, :load).call import_request.url
171
183
 
172
184
  EmbeddedProtocol::InboundMessage::ImportResponse.new(
173
185
  id: import_request.id,
174
186
  success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
175
- contents: importer_result.contents,
176
- syntax: to_proto_syntax(importer_result.syntax),
177
- source_map_url: importer_result.source_map_url
187
+ contents: get_attr(importer_result, :contents),
188
+ syntax: to_proto_syntax(get_attr(importer_result, :syntax)),
189
+ source_map_url: get_attr(importer_result, :source_map_url)
178
190
  )
179
191
  )
180
192
  rescue StandardError => e
@@ -186,8 +198,10 @@ module Sass
186
198
 
187
199
  def file_import_response(file_import_request)
188
200
  file_importer = importer_with_id(file_import_request.importer_id)
189
- file_url = file_importer.find_file_url file_import_request.url,
190
- from_import: file_import_request.from_import
201
+ file_url = get_method(file_importer, :find_file_url).call file_import_request.url,
202
+ from_import: file_import_request.from_import
203
+
204
+ raise "file_url must be a file: URL, was \"#{file_url}\"" if !file_url.nil? && !file_url.start_with?('file:')
191
205
 
192
206
  EmbeddedProtocol::InboundMessage::FileImportResponse.new(
193
207
  id: file_import_request.id,
@@ -235,16 +249,19 @@ module Sass
235
249
  when :compressed
236
250
  EmbeddedProtocol::OutputStyle::COMPRESSED
237
251
  else
238
- raise ArgumentError, 'output_style must be one of :expanded, :compressed'
252
+ raise ArgumentError, 'style must be one of :expanded, :compressed'
239
253
  end
240
254
  end
241
255
 
242
256
  def to_proto_importer(importer, id)
243
- if importer.respond_to?(:canonicalize) && importer.respond_to?(:load)
257
+ is_importer = get_method(importer, :canonicalize) && get_method(importer, :load)
258
+ is_file_importer = get_method(importer, :find_file_url)
259
+
260
+ if is_importer && !is_file_importer
244
261
  EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
245
262
  importer_id: id
246
263
  )
247
- elsif importer.respond_to?(:find_file_url)
264
+ elsif is_file_importer && !is_importer
248
265
  EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
249
266
  file_importer_id: id
250
267
  )
@@ -274,6 +291,32 @@ module Sass
274
291
  @importers[id]
275
292
  end
276
293
  end
294
+
295
+ def get_method(obj, sym)
296
+ sym = sym.to_sym
297
+ if obj.respond_to? sym
298
+ obj.method(sym)
299
+ elsif obj.respond_to? :[]
300
+ if obj[sym].respond_to? :call
301
+ obj[sym]
302
+ elsif obj[sym.to_s].respond_to? :call
303
+ obj[sym.to_s]
304
+ end
305
+ end
306
+ end
307
+
308
+ def get_attr(obj, sym)
309
+ sym = sym.to_sym
310
+ if obj.respond_to? sym
311
+ obj.method(sym).call
312
+ elsif obj.respond_to? :[]
313
+ if obj[sym]
314
+ obj[sym]
315
+ elsif obj[sym.to_s]
316
+ obj[sym.to_s]
317
+ end
318
+ end
319
+ end
277
320
  end
278
321
  end
279
322
  end
@@ -3,7 +3,7 @@
3
3
  module Sass
4
4
  class Embedded
5
5
  class Compiler
6
- REQUIREMENTS = '~> 1.0.0-beta.16'
6
+ REQUIREMENTS = '~> 1.49.7'
7
7
  end
8
8
  end
9
9
  end
@@ -66,6 +66,7 @@ module Sass
66
66
  syntax: indented_syntax ? :indented : :scss,
67
67
  url: (Url.path_to_file_url(File.absolute_path(file)) unless file.nil?),
68
68
  source_map: source_map_option,
69
+ source_map_include_sources: source_map_contents,
69
70
  style: output_style,
70
71
  functions: functions,
71
72
  importers: importer.map do |legacy_importer|
@@ -74,6 +75,7 @@ module Sass
74
75
  else
75
76
  compile(file, load_paths: load_paths,
76
77
  source_map: source_map_option,
78
+ source_map_include_sources: source_map_contents,
77
79
  style: output_style,
78
80
  functions: functions,
79
81
  importers: importer.map do |legacy_importer|
@@ -98,11 +100,9 @@ module Sass
98
100
  end
99
101
 
100
102
  map, source_map = post_process_map(map: compile_result.source_map,
101
- data: data,
102
103
  file: file,
103
104
  out_file: out_file,
104
105
  source_map: source_map,
105
- source_map_contents: source_map_contents,
106
106
  source_map_root: source_map_root)
107
107
 
108
108
  css = post_process_css(css: compile_result.css,
@@ -172,11 +172,9 @@ module Sass
172
172
 
173
173
  # @deprecated
174
174
  def post_process_map(map:,
175
- data:,
176
175
  file:,
177
176
  out_file:,
178
177
  source_map:,
179
- source_map_contents:,
180
178
  source_map_root:)
181
179
  return if map.nil? || map.empty?
182
180
 
@@ -201,26 +199,11 @@ module Sass
201
199
  map_data['file'] = 'stdin.css'
202
200
  end
203
201
 
204
- map_data['sourcesContent'] = [] if source_map_contents
205
-
206
- file = File.absolute_path(file) unless file.nil?
207
-
208
202
  map_data['sources'].map! do |source|
209
203
  if source.start_with? 'file://'
210
204
  path = Url.file_url_to_path(source)
211
- content = if path == file && !data.nil?
212
- data
213
- else
214
- begin
215
- File.read(path)
216
- rescue StandardError
217
- nil
218
- end
219
- end
220
- map_data['sourcesContent'].push(content) if source_map_contents
221
205
  relative_path(source_map_dir, path)
222
206
  else
223
- map_data['sourcesContent'].push(nil) if source_map_contents
224
207
  source
225
208
  end
226
209
  end
@@ -317,8 +300,9 @@ module Sass
317
300
  @importer_results = {}
318
301
  end
319
302
 
320
- def canonicalize(url)
321
- canonical_url = Url.path_to_file_url(File.absolute_path(url, (@file.nil? ? 'stdin' : @file)))
303
+ def canonicalize(url, **_kwargs)
304
+ path = Url.file_url_to_path(url)
305
+ canonical_url = Url.path_to_file_url(File.absolute_path(path, (@file.nil? ? 'stdin' : @file)))
322
306
 
323
307
  result = @importer.call canonical_url, @file
324
308
 
@@ -6,19 +6,29 @@ module Sass
6
6
  class Embedded
7
7
  # The {Url} module.
8
8
  module Url
9
- # The {::URI::Parser} that is in consistent with Dart Uri.
9
+ # The {::URI::Parser} that is in consistent with RFC 2396 (URI Generic Syntax) and dart:core library.
10
10
  URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
11
11
 
12
- private_constant :URI_PARSER
12
+ FILE_SCHEME = 'file://'
13
+
14
+ private_constant :URI_PARSER, :FILE_SCHEME
13
15
 
14
16
  module_function
15
17
 
16
18
  def path_to_file_url(path)
17
- "file://#{Platform::OS == 'windows' ? File::SEPARATOR : ''}#{URI_PARSER.escape(path)}"
19
+ if File.absolute_path? path
20
+ URI_PARSER.escape "#{FILE_SCHEME}#{Platform::OS == 'windows' ? File::SEPARATOR : ''}#{path}"
21
+ else
22
+ URI_PARSER.escape path
23
+ end
18
24
  end
19
25
 
20
- def file_url_to_path(file_uri)
21
- URI_PARSER.unescape(file_uri[(Platform::OS == 'windows' ? 8 : 7)..])
26
+ def file_url_to_path(url)
27
+ if url.start_with? FILE_SCHEME
28
+ URI_PARSER.unescape url[(FILE_SCHEME.length + (Platform::OS == 'windows' ? 1 : 0))..]
29
+ else
30
+ URI_PARSER.unescape url
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '0.10.0'
5
+ VERSION = '0.13.1'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -34,6 +34,7 @@ module Sass
34
34
  load_paths: [],
35
35
 
36
36
  source_map: false,
37
+ source_map_include_sources: false,
37
38
  style: :expanded,
38
39
 
39
40
  functions: {},
@@ -55,6 +56,7 @@ module Sass
55
56
  syntax: nil,
56
57
  url: nil,
57
58
  source_map: source_map,
59
+ source_map_include_sources: source_map_include_sources,
58
60
  style: style,
59
61
  functions: functions,
60
62
  importers: importers,
@@ -81,6 +83,7 @@ module Sass
81
83
  url: nil,
82
84
 
83
85
  source_map: false,
86
+ source_map_include_sources: false,
84
87
  style: :expanded,
85
88
 
86
89
  functions: {},
@@ -101,6 +104,7 @@ module Sass
101
104
  syntax: syntax,
102
105
  url: url,
103
106
  source_map: source_map,
107
+ source_map_include_sources: source_map_include_sources,
104
108
  style: style,
105
109
  functions: functions,
106
110
  importers: importers,
data/lib/sass/logger.rb CHANGED
@@ -3,18 +3,22 @@
3
3
  module Sass
4
4
  # The {Logger} module.
5
5
  module Logger
6
- # The instance of a slient {Logger}.
7
- def self.slient
8
- @slient ||= Slient.new
6
+ module_function
7
+
8
+ # The instance of a silent {Logger}.
9
+ def silent
10
+ Silent
9
11
  end
10
12
 
11
- # The slient {Logger}.
12
- class Slient
13
+ # The silent {Logger}.
14
+ module Silent
15
+ module_function
16
+
13
17
  def warn(message, deprecation: false, span: nil, stack: nil); end
14
18
 
15
19
  def debug(message, span: nil); end
16
20
  end
17
21
 
18
- private_constant :Slient
22
+ private_constant :Silent
19
23
  end
20
24
  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.10.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-15 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -66,20 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 13.0.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.10.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.10.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 1.24.0
89
+ version: 1.25.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 1.24.0
96
+ version: 1.25.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubocop-minitest
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: 0.6.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.8.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.8.0
125
153
  description: A Ruby library that will communicate with Embedded Dart Sass using the
126
154
  Embedded Sass protocol.
127
155
  email:
@@ -164,8 +192,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
164
192
  licenses:
165
193
  - MIT
166
194
  metadata:
167
- documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.10.0
168
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.10.0
195
+ documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.13.1
196
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.13.1
169
197
  funding_uri: https://github.com/sponsors/ntkme
170
198
  post_install_message:
171
199
  rdoc_options: []
@@ -175,14 +203,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
203
  requirements:
176
204
  - - ">="
177
205
  - !ruby/object:Gem::Version
178
- version: 2.6.0
206
+ version: 2.7.0
179
207
  required_rubygems_version: !ruby/object:Gem::Requirement
180
208
  requirements:
181
209
  - - ">="
182
210
  - !ruby/object:Gem::Version
183
211
  version: '0'
184
212
  requirements: []
185
- rubygems_version: 3.2.32
213
+ rubygems_version: 3.3.3
186
214
  signing_key:
187
215
  specification_version: 4
188
216
  summary: Use dart-sass with Ruby!