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