sassc-embedded 1.5.5 → 1.5.8
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 +72 -74
- 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: 47ccda859c1fd8acaffccd1945f5dc15907e5ca96086244a01fc3091003cf4d4
|
4
|
+
data.tar.gz: 7ee3c7121bf0c299771c4a9d3a6c1f5699a85565acea5392ddf3c3c9a6b3856f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f548fbe156fa13744ced7282b9a1959f35851bd24b1c3d329542e426715a7a0dbf400e7dddff9cee76b3d73af978087a0e383f0b37e7c2c61f7c64c7c096589
|
7
|
+
data.tar.gz: 8aa5ff0798d5ffbc0699543884c2c13e953d5847b59c0ea47d4573ce68e35329ff380f16fda6b3560cc012f86a35509ab272d0f5e907b8765805a5f8c0adcd55
|
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,72 +283,55 @@ 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
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
296
|
+
if url.start_with?(Protocol::IMPORT)
|
297
|
+
canonical_url = @canonical_urls.delete(url.delete_prefix(Protocol::IMPORT))
|
298
|
+
unless @importer_results.key?(canonical_url)
|
299
|
+
canonical_url = resolve_file_url(canonical_url, @parent_urls.last, from_import)
|
300
|
+
end
|
301
|
+
@parent_urls.push(canonical_url)
|
302
|
+
canonical_url
|
303
|
+
elsif url.start_with?(Protocol::FILE)
|
310
304
|
path = URL.parse(url).route_from(@parent_urls.last).to_s
|
311
|
-
|
312
|
-
return URL.path_to_file_url(resolved) unless resolved.nil?
|
313
|
-
|
314
|
-
return
|
315
|
-
end
|
305
|
+
parent_path = URL.file_url_to_path(@parent_urls.last)
|
316
306
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
307
|
+
imports = @importer.imports(path, parent_path)
|
308
|
+
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
309
|
+
imports = [imports] unless imports.is_a?(Array)
|
310
|
+
imports.each do |import|
|
311
|
+
import.path = File.absolute_path(import.path, File.dirname(parent_path))
|
312
|
+
end
|
321
313
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
314
|
+
canonical_url = "#{Protocol::IMPORT}#{next_id}"
|
315
|
+
@importer_results[canonical_url] = imports_to_native(imports)
|
316
|
+
canonical_url
|
317
|
+
elsif url.start_with?(Protocol::LOADED)
|
318
|
+
canonical_url = Protocol::LOADED
|
319
|
+
@parent_urls.pop
|
320
|
+
canonical_url
|
327
321
|
end
|
328
|
-
|
329
|
-
import_url = URL.path_to_file_url(File.absolute_path(path, File.dirname(parent_path)))
|
330
|
-
canonical_url = "#{Protocol::IMPORT}#{import_url}"
|
331
|
-
@importer_results[canonical_url] = imports_to_native(imports)
|
332
|
-
canonical_url
|
333
322
|
end
|
334
323
|
|
335
324
|
def load(canonical_url)
|
336
|
-
if
|
325
|
+
if @importer_results.key?(canonical_url)
|
337
326
|
@importer_results.delete(canonical_url)
|
338
327
|
elsif canonical_url.start_with?(Protocol::FILE)
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
contents: File.read(path),
|
346
|
-
syntax: syntax(path),
|
347
|
-
source_map_url: canonical_url
|
348
|
-
}
|
349
|
-
end
|
328
|
+
path = URL.file_url_to_path(canonical_url)
|
329
|
+
{
|
330
|
+
contents: File.read(path),
|
331
|
+
syntax: syntax(path),
|
332
|
+
source_map_url: canonical_url
|
333
|
+
}
|
350
334
|
elsif canonical_url.start_with?(Protocol::LOADED)
|
351
|
-
@parent_urls.pop
|
352
335
|
{
|
353
336
|
contents: '',
|
354
337
|
syntax: :scss
|
@@ -362,10 +345,12 @@ module SassC
|
|
362
345
|
@load_paths ||= (@importer.options[:load_paths] || []) + SassC.load_paths
|
363
346
|
end
|
364
347
|
|
365
|
-
def
|
348
|
+
def resolve_file_url(url, parent_url, from_import)
|
349
|
+
path = URL.parse(url).route_from(parent_url).to_s
|
350
|
+
parent_path = URL.file_url_to_path(parent_url)
|
366
351
|
[File.dirname(parent_path)].concat(load_paths).each do |load_path|
|
367
352
|
resolved = FileImporter.resolve_path(File.absolute_path(path, load_path), from_import)
|
368
|
-
return resolved unless resolved.nil?
|
353
|
+
return URL.path_to_file_url(resolved) unless resolved.nil?
|
369
354
|
end
|
370
355
|
nil
|
371
356
|
end
|
@@ -384,33 +369,38 @@ module SassC
|
|
384
369
|
def imports_to_native(imports)
|
385
370
|
{
|
386
371
|
contents: imports.flat_map do |import|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
@load_urls[load_id.to_s] = load_url
|
372
|
+
id = next_id
|
373
|
+
canonical_url = URL.path_to_file_url(import.path)
|
374
|
+
@canonical_urls[id] = canonical_url
|
391
375
|
if import.source
|
392
|
-
@importer_results[
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
376
|
+
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
377
|
+
{
|
378
|
+
contents: import.source[:contents],
|
379
|
+
syntax: import.source[:syntax],
|
380
|
+
source_map_url: canonical_url
|
381
|
+
}
|
382
|
+
else
|
383
|
+
{
|
384
|
+
contents: import.source,
|
385
|
+
syntax: syntax(import.path),
|
386
|
+
source_map_url: canonical_url
|
387
|
+
}
|
388
|
+
end
|
405
389
|
end
|
406
390
|
[
|
407
|
-
"@import \"#{Protocol::
|
408
|
-
"@import \"#{Protocol::LOADED}#{
|
391
|
+
"@import \"#{Protocol::IMPORT}#{id}\";",
|
392
|
+
"@import \"#{Protocol::LOADED}#{id}\";"
|
409
393
|
]
|
410
394
|
end.join("\n"),
|
411
395
|
syntax: :scss
|
412
396
|
}
|
413
397
|
end
|
398
|
+
|
399
|
+
def next_id
|
400
|
+
id = @id
|
401
|
+
@id = id.next
|
402
|
+
id.to_s
|
403
|
+
end
|
414
404
|
end
|
415
405
|
|
416
406
|
private_constant :Importer
|
@@ -542,6 +532,14 @@ module SassC
|
|
542
532
|
end
|
543
533
|
end
|
544
534
|
|
535
|
+
module Protocol
|
536
|
+
FILE = 'file:'
|
537
|
+
IMPORT = 'sassc-embedded-import:'
|
538
|
+
LOADED = 'sassc-embedded-loaded:'
|
539
|
+
end
|
540
|
+
|
541
|
+
private_constant :Protocol
|
542
|
+
|
545
543
|
module URL
|
546
544
|
PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
547
545
|
|
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.8
|
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-07 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.8
|
142
|
+
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.8
|
143
143
|
funding_uri: https://github.com/sponsors/ntkme
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|