sassc-embedded 1.74.0 → 1.75.0
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 +82 -111
- 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: 0de8391b1121b4101cf613ea4f7d7f854e4e96211cc0d5463ae0b419523aa85f
|
4
|
+
data.tar.gz: '06514688a9cd96979626c33a1ff7314ec6a0846d917f83b3e22404f5f1b67ec2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3474d7c63a4fd2d1f9f9b1c1c8fc808620fa6080801c0d50a7e9448ea33083f1c1aaf341eeb919af9ffc5d20fa21d7c5f3ba1b2100b9316c7abb796eec4775
|
7
|
+
data.tar.gz: 7a7cdb33102bc838a17ef302d814abb60dfe59d5f855c50f800b1f91ad6bc3b49937194d26d62fa0fcb5cc6964b4b5d72e22bc25bd73c37e381fe7851017a6ba
|
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,82 +307,64 @@ module SassC
|
|
323
307
|
class ImportCache
|
324
308
|
def initialize(importer)
|
325
309
|
@importer = importer
|
326
|
-
@canonical_urls = {}
|
327
310
|
@importer_results = {}
|
311
|
+
@file_url = nil
|
328
312
|
@load_paths = (@importer.options[:load_paths] || []) + SassC.load_paths
|
329
|
-
@parent_urls = [URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin'))]
|
330
313
|
end
|
331
314
|
|
332
315
|
def canonicalize(url, context)
|
333
|
-
if
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
# https://github.com/sass/dart-sass/issues/2208
|
343
|
-
#
|
344
|
-
# if ['.sass', '.scss', '.css'].include?(File.extname(URL.file_url_to_path(canonical_url)))
|
345
|
-
# @canonical_urls[url] = canonical_url
|
346
|
-
# return nil
|
347
|
-
# end
|
348
|
-
end
|
349
|
-
@parent_urls.push(canonical_url)
|
350
|
-
canonical_url
|
351
|
-
elsif url.start_with?(Protocol::LOADED)
|
352
|
-
@parent_urls.pop
|
353
|
-
Protocol::LOADED
|
354
|
-
else
|
355
|
-
parent_url = @parent_urls.last
|
356
|
-
url = URL.join(parent_url, url)
|
357
|
-
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)
|
358
325
|
|
359
|
-
|
360
|
-
|
326
|
+
path = URL.unescape(url)
|
327
|
+
parent_path = URL.file_url_to_path(containing_url)
|
328
|
+
parent_dir = File.dirname(parent_path)
|
361
329
|
|
330
|
+
if containing_url == context.containing_url
|
362
331
|
imports = @importer.imports(path, parent_path)
|
363
332
|
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
364
333
|
imports = [imports] unless imports.is_a?(Array)
|
365
|
-
|
366
|
-
canonical_url
|
367
|
-
|
368
|
-
|
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
|
369
349
|
end
|
370
350
|
end
|
371
351
|
|
372
352
|
def load(canonical_url)
|
373
|
-
|
374
|
-
@importer_results.delete(canonical_url)
|
375
|
-
elsif canonical_url.start_with?(Protocol::FILE)
|
376
|
-
path = URL.file_url_to_path(canonical_url)
|
377
|
-
{
|
378
|
-
contents: File.read(path),
|
379
|
-
syntax: syntax(path),
|
380
|
-
source_map_url: canonical_url
|
381
|
-
}
|
382
|
-
elsif canonical_url.start_with?(Protocol::LOADED)
|
383
|
-
{
|
384
|
-
contents: '',
|
385
|
-
syntax: :scss
|
386
|
-
}
|
387
|
-
end
|
353
|
+
@importer_results.delete(canonical_url)
|
388
354
|
end
|
389
355
|
|
390
|
-
def find_file_url(
|
391
|
-
|
392
|
-
return unless canonical_url
|
356
|
+
def find_file_url(_url, _context)
|
357
|
+
return if @file_url.nil?
|
393
358
|
|
394
|
-
@
|
359
|
+
canonical_url = @file_url
|
360
|
+
@file_url = nil
|
395
361
|
canonical_url
|
396
362
|
end
|
397
363
|
|
398
364
|
private
|
399
365
|
|
400
|
-
def resolve_file_url(path,
|
401
|
-
[
|
366
|
+
def resolve_file_url(path, parent_dir, from_import)
|
367
|
+
[parent_dir].concat(@load_paths).each do |load_path|
|
402
368
|
resolved = FileSystemImporter.resolve_path(File.absolute_path(path, load_path), from_import)
|
403
369
|
return URL.path_to_file_url(resolved) unless resolved.nil?
|
404
370
|
end
|
@@ -416,38 +382,44 @@ module SassC
|
|
416
382
|
end
|
417
383
|
end
|
418
384
|
|
419
|
-
def
|
420
|
-
|
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] = {
|
421
414
|
contents: imports.flat_map do |import|
|
422
|
-
if import.source
|
423
|
-
canonical_url = URL.path_to_file_url(File.absolute_path(import.path, parent_dir))
|
424
|
-
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
425
|
-
{
|
426
|
-
contents: import.source[:contents],
|
427
|
-
syntax: import.source[:syntax],
|
428
|
-
source_map_url: canonical_url
|
429
|
-
}
|
430
|
-
else
|
431
|
-
{
|
432
|
-
contents: import.source,
|
433
|
-
syntax: syntax(import.path),
|
434
|
-
source_map_url: canonical_url
|
435
|
-
}
|
436
|
-
end
|
437
|
-
else
|
438
|
-
canonical_url = URL.escape(import.path)
|
439
|
-
end
|
440
|
-
import_url = "#{Protocol::IMPORT}#{canonical_url}"
|
441
|
-
loaded_url = "#{Protocol::LOADED}#{canonical_url}"
|
442
|
-
@canonical_urls[import_url] = canonical_url
|
443
415
|
at_rule = from_import ? '@import' : '@forward'
|
444
|
-
|
445
|
-
|
446
|
-
#{at_rule} #{Script::Value::String.quote(loaded_url)};
|
447
|
-
SCSS
|
416
|
+
url = import_to_native(import, parent_dir, from_import, false)
|
417
|
+
"#{at_rule} #{Script::Value::String.quote(url)};"
|
448
418
|
end.join("\n"),
|
449
419
|
syntax: :scss
|
450
420
|
}
|
421
|
+
|
422
|
+
canonical_url
|
451
423
|
end
|
452
424
|
end
|
453
425
|
|
@@ -603,8 +575,7 @@ module SassC
|
|
603
575
|
|
604
576
|
module Protocol
|
605
577
|
FILE = 'file:'
|
606
|
-
|
607
|
-
LOADED = 'sassc-embedded-loaded:'
|
578
|
+
GLOB = 'sassc-embedded-glob:'
|
608
579
|
end
|
609
580
|
|
610
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.0
|
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-12 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.0
|
83
83
|
funding_uri: https://github.com/sponsors/ntkme
|
84
84
|
rubygems_mfa_required: 'true'
|
85
85
|
post_install_message:
|