sassc-embedded 1.74.1 → 1.75.1
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 +81 -117
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caca4b6a81b8529e57fc9c1e851f62126314738777609a8b6bacf409b498995a
|
4
|
+
data.tar.gz: 3e7ecfda63b127008aeb1e96944d9a40d7557f68d7d043bff9e7b6a6174c353e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8342c220f8f345e4f1d1ce49672cd67e4eace1024a4ea065ed16f0d6ce6868da1617b9561510393be0cb9dbee5195f22e989424b022a09e8cbb8e6141c55b5db
|
7
|
+
data.tar.gz: b9b76c117575f7c13ef736a89cc36d69eb2a1688299bf99f3d8b4f50b6554fb344a11427b56c4e8d78e1299372aaf0f36749e726b243a1efb7f4122d40070f50
|
data/lib/sassc/embedded.rb
CHANGED
@@ -13,11 +13,9 @@ module SassC
|
|
13
13
|
def render
|
14
14
|
return @template.dup if @template.empty?
|
15
15
|
|
16
|
-
importers = import_handler.setup(nil)
|
17
|
-
|
18
16
|
result = ::Sass.compile_string(
|
19
17
|
@template,
|
20
|
-
importer:
|
18
|
+
importer: (NoopImporter unless @options[:importer].nil?),
|
21
19
|
load_paths:,
|
22
20
|
syntax:,
|
23
21
|
url: file_url,
|
@@ -28,7 +26,7 @@ module SassC
|
|
28
26
|
style: output_style,
|
29
27
|
|
30
28
|
functions: functions_handler.setup(nil, functions: @functions),
|
31
|
-
importers:
|
29
|
+
importers: import_handler.setup(nil).concat(@options.fetch(:importers, [])),
|
32
30
|
|
33
31
|
alert_ascii: @options.fetch(:alert_ascii, false),
|
34
32
|
alert_color: @options.fetch(:alert_color, nil),
|
@@ -185,6 +183,16 @@ module SassC
|
|
185
183
|
end
|
186
184
|
end
|
187
185
|
|
186
|
+
module NoopImporter
|
187
|
+
module_function
|
188
|
+
|
189
|
+
def canonicalize(...); end
|
190
|
+
|
191
|
+
def load(...); end
|
192
|
+
end
|
193
|
+
|
194
|
+
private_constant :NoopImporter
|
195
|
+
|
188
196
|
class ImportHandler
|
189
197
|
def setup(_native_options)
|
190
198
|
if @importer
|
@@ -235,15 +243,6 @@ module SassC
|
|
235
243
|
return exactly_one(try_path(path))
|
236
244
|
end
|
237
245
|
|
238
|
-
unless ext.empty?
|
239
|
-
if from_import
|
240
|
-
result = exactly_one(try_path("#{without_ext(path)}.import#{ext}"))
|
241
|
-
return warn_deprecation_ext(result) unless result.nil?
|
242
|
-
end
|
243
|
-
result = exactly_one(try_path(path))
|
244
|
-
return warn_deprecation_ext(result) unless result.nil?
|
245
|
-
end
|
246
|
-
|
247
246
|
if from_import
|
248
247
|
result = exactly_one(try_path_with_ext("#{path}.import"))
|
249
248
|
return result unless result.nil?
|
@@ -300,21 +299,6 @@ module SassC
|
|
300
299
|
ext = File.extname(path)
|
301
300
|
path.delete_suffix(ext)
|
302
301
|
end
|
303
|
-
|
304
|
-
def warn_deprecation_ext(path)
|
305
|
-
basename = File.basename(path)
|
306
|
-
warn <<~WARNING
|
307
|
-
Deprecation Warning: Importing files with extensions other than `.scss`, `.sass`, `.css` from relative path or load paths without custom SassC::Importer is deprecated.
|
308
|
-
|
309
|
-
Recommandation: Rename #{basename} to #{basename}.scss
|
310
|
-
|
311
|
-
More info: https://github.com/sass-contrib/sassc-embedded-shim-ruby/pull/86
|
312
|
-
|
313
|
-
#{path}
|
314
|
-
#{' ' * (path.length - basename.length)}#{'^' * basename.length}
|
315
|
-
WARNING
|
316
|
-
path
|
317
|
-
end
|
318
302
|
end
|
319
303
|
end
|
320
304
|
|
@@ -323,83 +307,64 @@ module SassC
|
|
323
307
|
class ImportCache
|
324
308
|
def initialize(importer)
|
325
309
|
@importer = importer
|
326
|
-
@canonical_urls = {}
|
327
|
-
@id = 0
|
328
310
|
@importer_results = {}
|
311
|
+
@file_url = nil
|
329
312
|
@load_paths = (@importer.options[:load_paths] || []) + SassC.load_paths
|
330
|
-
@parent_urls = [URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin'))]
|
331
313
|
end
|
332
314
|
|
333
315
|
def canonicalize(url, context)
|
334
|
-
if
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
# https://github.com/sass/dart-sass/issues/2208
|
344
|
-
#
|
345
|
-
# if ['.sass', '.scss', '.css'].include?(File.extname(URL.file_url_to_path(canonical_url)))
|
346
|
-
# @canonical_urls[url] = canonical_url
|
347
|
-
# return nil
|
348
|
-
# end
|
349
|
-
end
|
350
|
-
@parent_urls.push(canonical_url)
|
351
|
-
canonical_url
|
352
|
-
elsif url.start_with?(Protocol::LOADED)
|
353
|
-
@parent_urls.pop
|
354
|
-
Protocol::LOADED
|
355
|
-
else
|
356
|
-
parent_url = @parent_urls.last
|
357
|
-
url = URL.join(parent_url, url)
|
358
|
-
return unless url.start_with?(Protocol::FILE)
|
316
|
+
return if context.containing_url.nil?
|
317
|
+
|
318
|
+
containing_url = if context.containing_url.start_with?(Protocol::GLOB)
|
319
|
+
URL.unescape(URL.parse(context.containing_url).fragment)
|
320
|
+
else
|
321
|
+
context.containing_url
|
322
|
+
end
|
323
|
+
|
324
|
+
return unless containing_url.start_with?(Protocol::FILE)
|
359
325
|
|
360
|
-
|
361
|
-
|
326
|
+
path = URL.unescape(url)
|
327
|
+
parent_path = URL.file_url_to_path(containing_url)
|
328
|
+
parent_dir = File.dirname(parent_path)
|
362
329
|
|
330
|
+
if containing_url == context.containing_url
|
363
331
|
imports = @importer.imports(path, parent_path)
|
364
332
|
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
365
333
|
imports = [imports] unless imports.is_a?(Array)
|
366
|
-
|
367
|
-
canonical_url
|
368
|
-
|
369
|
-
|
334
|
+
canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, context.containing_url)
|
335
|
+
if @importer_results.key?(canonical_url)
|
336
|
+
canonical_url
|
337
|
+
else
|
338
|
+
@file_url = canonical_url
|
339
|
+
nil
|
340
|
+
end
|
341
|
+
else
|
342
|
+
canonical_url = URL.path_to_file_url(File.absolute_path(path, parent_dir))
|
343
|
+
if @importer_results.key?(canonical_url)
|
344
|
+
canonical_url
|
345
|
+
else
|
346
|
+
@file_url = resolve_file_url(path, parent_dir, context.from_import)
|
347
|
+
nil
|
348
|
+
end
|
370
349
|
end
|
371
350
|
end
|
372
351
|
|
373
352
|
def load(canonical_url)
|
374
|
-
|
375
|
-
@importer_results.delete(canonical_url)
|
376
|
-
elsif canonical_url.start_with?(Protocol::FILE)
|
377
|
-
path = URL.file_url_to_path(canonical_url)
|
378
|
-
{
|
379
|
-
contents: File.read(path),
|
380
|
-
syntax: syntax(path),
|
381
|
-
source_map_url: canonical_url
|
382
|
-
}
|
383
|
-
elsif canonical_url.start_with?(Protocol::LOADED)
|
384
|
-
{
|
385
|
-
contents: '',
|
386
|
-
syntax: :scss
|
387
|
-
}
|
388
|
-
end
|
353
|
+
@importer_results.delete(canonical_url)
|
389
354
|
end
|
390
355
|
|
391
|
-
def find_file_url(
|
392
|
-
|
393
|
-
return unless canonical_url
|
356
|
+
def find_file_url(_url, context)
|
357
|
+
return if context.containing_url.nil? || @file_url.nil?
|
394
358
|
|
395
|
-
@
|
359
|
+
canonical_url = @file_url
|
360
|
+
@file_url = nil
|
396
361
|
canonical_url
|
397
362
|
end
|
398
363
|
|
399
364
|
private
|
400
365
|
|
401
|
-
def resolve_file_url(path,
|
402
|
-
[
|
366
|
+
def resolve_file_url(path, parent_dir, from_import)
|
367
|
+
[parent_dir].concat(@load_paths).each do |load_path|
|
403
368
|
resolved = FileSystemImporter.resolve_path(File.absolute_path(path, load_path), from_import)
|
404
369
|
return URL.path_to_file_url(resolved) unless resolved.nil?
|
405
370
|
end
|
@@ -417,44 +382,44 @@ module SassC
|
|
417
382
|
end
|
418
383
|
end
|
419
384
|
|
420
|
-
def
|
421
|
-
|
385
|
+
def import_to_native(import, parent_dir, from_import, canonicalize)
|
386
|
+
if import.source
|
387
|
+
canonical_url = URL.path_to_file_url(File.absolute_path(import.path, parent_dir))
|
388
|
+
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
389
|
+
{
|
390
|
+
contents: import.source[:contents],
|
391
|
+
syntax: import.source[:syntax],
|
392
|
+
source_map_url: canonical_url
|
393
|
+
}
|
394
|
+
else
|
395
|
+
{
|
396
|
+
contents: import.source,
|
397
|
+
syntax: syntax(import.path),
|
398
|
+
source_map_url: canonical_url
|
399
|
+
}
|
400
|
+
end
|
401
|
+
return canonical_url if canonicalize
|
402
|
+
elsif canonicalize
|
403
|
+
return resolve_file_url(import.path, parent_dir, from_import)
|
404
|
+
end
|
405
|
+
|
406
|
+
URL.escape(import.path)
|
407
|
+
end
|
408
|
+
|
409
|
+
def imports_to_native(imports, parent_dir, from_import, url, containing_url)
|
410
|
+
return import_to_native(imports.first, parent_dir, from_import, true) if imports.one?
|
411
|
+
|
412
|
+
canonical_url = "#{Protocol::GLOB}?#{URL.escape(url)}##{URL.escape(containing_url)}"
|
413
|
+
@importer_results[canonical_url] = {
|
422
414
|
contents: imports.flat_map do |import|
|
423
|
-
if import.source
|
424
|
-
canonical_url = URL.path_to_file_url(File.absolute_path(import.path, parent_dir))
|
425
|
-
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
426
|
-
{
|
427
|
-
contents: import.source[:contents],
|
428
|
-
syntax: import.source[:syntax],
|
429
|
-
source_map_url: canonical_url
|
430
|
-
}
|
431
|
-
else
|
432
|
-
{
|
433
|
-
contents: import.source,
|
434
|
-
syntax: syntax(import.path),
|
435
|
-
source_map_url: canonical_url
|
436
|
-
}
|
437
|
-
end
|
438
|
-
else
|
439
|
-
canonical_url = URL.escape(import.path)
|
440
|
-
end
|
441
|
-
import_url = "#{Protocol::IMPORT}#{next_id}"
|
442
|
-
loaded_url = "#{Protocol::LOADED}#{next_id}"
|
443
|
-
@canonical_urls[import_url] = canonical_url
|
444
415
|
at_rule = from_import ? '@import' : '@forward'
|
445
|
-
|
446
|
-
|
447
|
-
#{at_rule} #{Script::Value::String.quote(loaded_url)};
|
448
|
-
SCSS
|
416
|
+
url = import_to_native(import, parent_dir, from_import, false)
|
417
|
+
"#{at_rule} #{Script::Value::String.quote(url)};"
|
449
418
|
end.join("\n"),
|
450
419
|
syntax: :scss
|
451
420
|
}
|
452
|
-
end
|
453
421
|
|
454
|
-
|
455
|
-
id = @id
|
456
|
-
@id = id.next
|
457
|
-
id
|
422
|
+
canonical_url
|
458
423
|
end
|
459
424
|
end
|
460
425
|
|
@@ -610,8 +575,7 @@ module SassC
|
|
610
575
|
|
611
576
|
module Protocol
|
612
577
|
FILE = 'file:'
|
613
|
-
|
614
|
-
LOADED = 'sassc-embedded-loaded:'
|
578
|
+
GLOB = 'sassc-embedded-glob:'
|
615
579
|
end
|
616
580
|
|
617
581
|
private_constant :Protocol
|
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.
|
4
|
+
version: 1.75.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass-embedded
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.75'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.75'
|
27
27
|
description: An embedded sass shim for SassC.
|
28
28
|
email:
|
29
29
|
- i@ntk.me
|
@@ -79,7 +79,7 @@ licenses:
|
|
79
79
|
metadata:
|
80
80
|
bug_tracker_uri: https://github.com/sass-contrib/sassc-embedded-shim-ruby/issues
|
81
81
|
documentation_uri: https://rubydoc.info/gems/sassc
|
82
|
-
source_code_uri: https://github.com/sass-contrib/sassc-embedded-shim-ruby/tree/v1.
|
82
|
+
source_code_uri: https://github.com/sass-contrib/sassc-embedded-shim-ruby/tree/v1.75.1
|
83
83
|
funding_uri: https://github.com/sponsors/ntkme
|
84
84
|
rubygems_mfa_required: 'true'
|
85
85
|
post_install_message:
|