sassc-embedded 1.5.5 → 1.5.6

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: 695381cf5ae96903ffaf015c6e406eab12c38312008ee5dce88e2f1658d6da35
4
- data.tar.gz: c5c981214af6123d9c17ff3dc4b6099bc78864419df9c29848ce146ebbfeca2d
3
+ metadata.gz: 464d4f9326ea315b791701d5ff9ca9a06201b9bbdccc920aba591ea5764f9cba
4
+ data.tar.gz: c149398af2d50cad3659f680d1f10a053e7290457340e02758fa4235a2f7ba34
5
5
  SHA512:
6
- metadata.gz: 9a346cd91ea29ae9618460eee15592b1316948637bae1054a343521f9a0194b290c972d37481fd91b068d47bf83d38a033efb2f9e20f3713fcbc7ad339110cbb
7
- data.tar.gz: 36d53934e2f475d3c62a42a5f7530c32668d42d4ba3a09a84eed6177bb9256d4dc7383adf64d80b6863590bffbfc676c6cec6b792b24523cbce7b516d887ff5d
6
+ metadata.gz: 7b9e55b5db011df6ee7befabb77a6e74934ed7addf4bedcc8ebcf831ca38a7cdeff2b2d2f34ce7326f83cd97f52d8f19f79f1229882f8a436dd533243ad207db
7
+ data.tar.gz: 506cf7f45c08fc2e7f82e1d6675fb2d9cf9b36a66d098ae5fc43e6ea0c997b2fe4f442caa4cbdb1b442132768c32c35e83e2457da40ff2a8baff29cb9e05a60c
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Embedded
5
- VERSION = '1.5.5'
5
+ VERSION = '1.5.6'
6
6
  end
7
7
  end
@@ -36,7 +36,7 @@ module SassC
36
36
  )
37
37
 
38
38
  @dependencies = result.loaded_urls
39
- .filter { |url| url.start_with?('file:') && url != file_url }
39
+ .filter { |url| url.start_with?(Protocol::FILE) && url != file_url }
40
40
  .map { |url| URL.file_url_to_path(url) }
41
41
  @source_map = post_process_source_map(result.source_map)
42
42
 
@@ -45,10 +45,10 @@ module SassC
45
45
  line = e.span&.start&.line
46
46
  line += 1 unless line.nil?
47
47
  url = e.span&.url
48
- path = if url&.start_with?('file:')
48
+ path = if url&.start_with?(Protocol::FILE)
49
49
  URL.parse(url).route_from(URL.path_to_file_url("#{File.absolute_path('')}/"))
50
50
  end
51
- raise SyntaxError.new(e.message, filename: path, line: line)
51
+ raise SyntaxError.new(e.full_message, filename: path, line: line)
52
52
  end
53
53
 
54
54
  private
@@ -109,7 +109,7 @@ module SassC
109
109
  data = JSON.parse(source_map)
110
110
  data['file'] = URL.parse(output_url).route_from(url).to_s if output_url
111
111
  data['sources'].map! do |source|
112
- if source.start_with?('file:')
112
+ if source.start_with?(Protocol::FILE)
113
113
  URL.parse(source).route_from(url).to_s
114
114
  else
115
115
  source
@@ -283,28 +283,20 @@ module SassC
283
283
  private_constant :FileImporter
284
284
 
285
285
  class Importer
286
- module Protocol
287
- FILE = 'file:'
288
- IMPORT = 'sassc-embedded-import:'
289
- LOAD = 'sassc-embedded-load:'
290
- LOADED = 'sassc-embedded-loaded:'
291
- end
292
-
293
- private_constant :Protocol
294
-
295
286
  def initialize(importer)
296
287
  @importer = importer
288
+
289
+ @canonical_urls = {}
290
+ @id = 0
297
291
  @importer_results = {}
298
- @load_id = 0
299
- @load_urls = {}
300
292
  @parent_urls = [URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin'))]
301
293
  end
302
294
 
303
295
  def canonicalize(url, from_import:)
304
- return url if url.start_with?(Protocol::IMPORT, Protocol::LOADED)
296
+ return url if url.start_with?(Protocol::LOADED)
305
297
 
306
- if url.start_with?(Protocol::LOAD)
307
- url = @load_urls.delete(url.delete_prefix(Protocol::LOAD))
298
+ if url.start_with?(Protocol::IMPORT)
299
+ url = @canonical_urls.delete(url.delete_prefix(Protocol::IMPORT))
308
300
  return url if @importer_results.key?(url)
309
301
 
310
302
  path = URL.parse(url).route_from(@parent_urls.last).to_s
@@ -326,8 +318,9 @@ module SassC
326
318
  import.path = File.absolute_path(import.path, File.dirname(parent_path))
327
319
  end
328
320
 
329
- import_url = URL.path_to_file_url(File.absolute_path(path, File.dirname(parent_path)))
330
- canonical_url = "#{Protocol::IMPORT}#{import_url}"
321
+ id = next_id
322
+ canonical_url = "#{Protocol::IMPORT}#{id}"
323
+ @canonical_urls[id] = canonical_url
331
324
  @importer_results[canonical_url] = imports_to_native(imports)
332
325
  canonical_url
333
326
  end
@@ -384,33 +377,38 @@ module SassC
384
377
  def imports_to_native(imports)
385
378
  {
386
379
  contents: imports.flat_map do |import|
387
- load_id = @load_id
388
- @load_id = load_id.next
389
- load_url = URL.path_to_file_url(import.path)
390
- @load_urls[load_id.to_s] = load_url
380
+ id = next_id
381
+ canonical_url = URL.path_to_file_url(import.path)
382
+ @canonical_urls[id] = canonical_url
391
383
  if import.source
392
- @importer_results[load_url] = if import.source.is_a?(Hash)
393
- {
394
- contents: import.source[:contents],
395
- syntax: import.source[:syntax],
396
- source_map_url: load_url
397
- }
398
- else
399
- {
400
- contents: import.source,
401
- syntax: syntax(import.path),
402
- source_map_url: load_url
403
- }
404
- end
384
+ @importer_results[canonical_url] = if import.source.is_a?(Hash)
385
+ {
386
+ contents: import.source[:contents],
387
+ syntax: import.source[:syntax],
388
+ source_map_url: canonical_url
389
+ }
390
+ else
391
+ {
392
+ contents: import.source,
393
+ syntax: syntax(import.path),
394
+ source_map_url: canonical_url
395
+ }
396
+ end
405
397
  end
406
398
  [
407
- "@import \"#{Protocol::LOAD}#{load_id}\";",
408
- "@import \"#{Protocol::LOADED}#{load_id}\";"
399
+ "@import \"#{Protocol::IMPORT}#{id}\";",
400
+ "@import \"#{Protocol::LOADED}#{id}\";"
409
401
  ]
410
402
  end.join("\n"),
411
403
  syntax: :scss
412
404
  }
413
405
  end
406
+
407
+ def next_id
408
+ id = @id
409
+ @id = id.next
410
+ id.to_s
411
+ end
414
412
  end
415
413
 
416
414
  private_constant :Importer
@@ -542,6 +540,14 @@ module SassC
542
540
  end
543
541
  end
544
542
 
543
+ module Protocol
544
+ FILE = 'file:'
545
+ IMPORT = 'sassc-embedded-import:'
546
+ LOADED = 'sassc-embedded-loaded:'
547
+ end
548
+
549
+ private_constant :Protocol
550
+
545
551
  module URL
546
552
  PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
547
553
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassc-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
@@ -138,8 +138,8 @@ homepage: https://github.com/ntkme/sassc-embedded-polyfill-ruby
138
138
  licenses:
139
139
  - MIT
140
140
  metadata:
141
- documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.5.5
142
- source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.5
141
+ documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.5.6
142
+ source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.6
143
143
  funding_uri: https://github.com/sponsors/ntkme
144
144
  post_install_message:
145
145
  rdoc_options: []