sassc-embedded 1.5.3 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sassc/embedded/version.rb +1 -1
- data/lib/sassc/embedded.rb +53 -35
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 464d4f9326ea315b791701d5ff9ca9a06201b9bbdccc920aba591ea5764f9cba
|
4
|
+
data.tar.gz: c149398af2d50cad3659f680d1f10a053e7290457340e02758fa4235a2f7ba34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b9e55b5db011df6ee7befabb77a6e74934ed7addf4bedcc8ebcf831ca38a7cdeff2b2d2f34ce7326f83cd97f52d8f19f79f1229882f8a436dd533243ad207db
|
7
|
+
data.tar.gz: 506cf7f45c08fc2e7f82e1d6675fb2d9cf9b36a66d098ae5fc43e6ea0c997b2fe4f442caa4cbdb1b442132768c32c35e83e2457da40ff2a8baff29cb9e05a60c
|
data/lib/sassc/embedded.rb
CHANGED
@@ -36,7 +36,7 @@ module SassC
|
|
36
36
|
)
|
37
37
|
|
38
38
|
@dependencies = result.loaded_urls
|
39
|
-
.filter { |url| url.start_with?(
|
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?(
|
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.
|
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?(
|
112
|
+
if source.start_with?(Protocol::FILE)
|
113
113
|
URL.parse(source).route_from(url).to_s
|
114
114
|
else
|
115
115
|
source
|
@@ -283,26 +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
292
|
@parent_urls = [URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin'))]
|
299
293
|
end
|
300
294
|
|
301
295
|
def canonicalize(url, from_import:)
|
302
|
-
return url if url.start_with?(Protocol::
|
296
|
+
return url if url.start_with?(Protocol::LOADED)
|
303
297
|
|
304
|
-
if url.start_with?(Protocol::
|
305
|
-
url = url.delete_prefix(Protocol::
|
298
|
+
if url.start_with?(Protocol::IMPORT)
|
299
|
+
url = @canonical_urls.delete(url.delete_prefix(Protocol::IMPORT))
|
306
300
|
return url if @importer_results.key?(url)
|
307
301
|
|
308
302
|
path = URL.parse(url).route_from(@parent_urls.last).to_s
|
@@ -324,8 +318,9 @@ module SassC
|
|
324
318
|
import.path = File.absolute_path(import.path, File.dirname(parent_path))
|
325
319
|
end
|
326
320
|
|
327
|
-
|
328
|
-
canonical_url = "#{Protocol::IMPORT}#{
|
321
|
+
id = next_id
|
322
|
+
canonical_url = "#{Protocol::IMPORT}#{id}"
|
323
|
+
@canonical_urls[id] = canonical_url
|
329
324
|
@importer_results[canonical_url] = imports_to_native(imports)
|
330
325
|
canonical_url
|
331
326
|
end
|
@@ -369,36 +364,51 @@ module SassC
|
|
369
364
|
end
|
370
365
|
|
371
366
|
def syntax(path)
|
372
|
-
File.extname(path)
|
367
|
+
case File.extname(path)
|
368
|
+
when '.sass'
|
369
|
+
:indented
|
370
|
+
when '.css'
|
371
|
+
:css
|
372
|
+
else
|
373
|
+
:scss
|
374
|
+
end
|
373
375
|
end
|
374
376
|
|
375
377
|
def imports_to_native(imports)
|
376
378
|
{
|
377
379
|
contents: imports.flat_map do |import|
|
378
|
-
|
380
|
+
id = next_id
|
381
|
+
canonical_url = URL.path_to_file_url(import.path)
|
382
|
+
@canonical_urls[id] = canonical_url
|
379
383
|
if import.source
|
380
|
-
@importer_results[
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
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
|
393
397
|
end
|
394
398
|
[
|
395
|
-
"@import
|
396
|
-
"@import
|
399
|
+
"@import \"#{Protocol::IMPORT}#{id}\";",
|
400
|
+
"@import \"#{Protocol::LOADED}#{id}\";"
|
397
401
|
]
|
398
402
|
end.join("\n"),
|
399
403
|
syntax: :scss
|
400
404
|
}
|
401
405
|
end
|
406
|
+
|
407
|
+
def next_id
|
408
|
+
id = @id
|
409
|
+
@id = id.next
|
410
|
+
id.to_s
|
411
|
+
end
|
402
412
|
end
|
403
413
|
|
404
414
|
private_constant :Importer
|
@@ -530,6 +540,14 @@ module SassC
|
|
530
540
|
end
|
531
541
|
end
|
532
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
|
+
|
533
551
|
module URL
|
534
552
|
PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
535
553
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sassc-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sassc
|
@@ -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.
|
142
|
-
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.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: []
|