sassc-embedded 1.70.1 → 1.74.0
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 +113 -49
- 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: f2035f16da9c3d02bf4fce8ac06465db89afbee4b1ece61dfd3213b4fec4a150
|
4
|
+
data.tar.gz: 1ec55533d5a8949ed2ab53266b52abf963a2be427d228605e0c7147974490856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f0d03db8a9d0848c96c21bcc340ee8fc15993f7b56697649fee823bb4e6a398a992b6245c4b6d274a12cf846c6aa8ee59bf56cc19c1b11081d251ae4509e05e
|
7
|
+
data.tar.gz: 40760cf8ab3aa85a459b83f2b41e5513b96fea52fc000fa435dd4f4115526914e3665388305962fdd91da1c454a326f64acb27bd47fd6ddd566a6e428bfb1b9f
|
data/lib/sassc/embedded.rb
CHANGED
@@ -13,11 +13,11 @@ module SassC
|
|
13
13
|
def render
|
14
14
|
return @template.dup if @template.empty?
|
15
15
|
|
16
|
-
|
16
|
+
importers = import_handler.setup(nil)
|
17
17
|
|
18
18
|
result = ::Sass.compile_string(
|
19
19
|
@template,
|
20
|
-
importer:
|
20
|
+
importer: importers.first,
|
21
21
|
load_paths:,
|
22
22
|
syntax:,
|
23
23
|
url: file_url,
|
@@ -28,12 +28,15 @@ module SassC
|
|
28
28
|
style: output_style,
|
29
29
|
|
30
30
|
functions: functions_handler.setup(nil, functions: @functions),
|
31
|
-
importers:
|
31
|
+
importers: importers.concat(@options.fetch(:importers, [])),
|
32
32
|
|
33
33
|
alert_ascii: @options.fetch(:alert_ascii, false),
|
34
34
|
alert_color: @options.fetch(:alert_color, nil),
|
35
|
+
fatal_deprecations: @options.fetch(:fatal_deprecations, []),
|
36
|
+
future_deprecations: @options.fetch(:future_deprecations, []),
|
35
37
|
logger: @options.fetch(:logger, nil),
|
36
38
|
quiet_deps: @options.fetch(:quiet_deps, false),
|
39
|
+
silence_deprecations: @options.fetch(:silence_deprecations, []),
|
37
40
|
verbose: @options.fetch(:verbose, false)
|
38
41
|
)
|
39
42
|
|
@@ -184,10 +187,43 @@ module SassC
|
|
184
187
|
|
185
188
|
class ImportHandler
|
186
189
|
def setup(_native_options)
|
187
|
-
|
190
|
+
if @importer
|
191
|
+
import_cache = ImportCache.new(@importer)
|
192
|
+
[Importer.new(import_cache), FileImporter.new(import_cache)]
|
193
|
+
else
|
194
|
+
[]
|
195
|
+
end
|
188
196
|
end
|
189
197
|
|
198
|
+
class Importer
|
199
|
+
def initialize(import_cache)
|
200
|
+
@import_cache = import_cache
|
201
|
+
end
|
202
|
+
|
203
|
+
def canonicalize(...)
|
204
|
+
@import_cache.canonicalize(...)
|
205
|
+
end
|
206
|
+
|
207
|
+
def load(...)
|
208
|
+
@import_cache.load(...)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
private_constant :Importer
|
213
|
+
|
190
214
|
class FileImporter
|
215
|
+
def initialize(import_cache)
|
216
|
+
@import_cache = import_cache
|
217
|
+
end
|
218
|
+
|
219
|
+
def find_file_url(...)
|
220
|
+
@import_cache.find_file_url(...)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
private_constant :FileImporter
|
225
|
+
|
226
|
+
class FileSystemImporter
|
191
227
|
class << self
|
192
228
|
def resolve_path(path, from_import)
|
193
229
|
ext = File.extname(path)
|
@@ -202,10 +238,10 @@ module SassC
|
|
202
238
|
unless ext.empty?
|
203
239
|
if from_import
|
204
240
|
result = exactly_one(try_path("#{without_ext(path)}.import#{ext}"))
|
205
|
-
return result unless result.nil?
|
241
|
+
return warn_deprecation_ext(result) unless result.nil?
|
206
242
|
end
|
207
243
|
result = exactly_one(try_path(path))
|
208
|
-
return result unless result.nil?
|
244
|
+
return warn_deprecation_ext(result) unless result.nil?
|
209
245
|
end
|
210
246
|
|
211
247
|
if from_import
|
@@ -235,7 +271,7 @@ module SassC
|
|
235
271
|
end
|
236
272
|
|
237
273
|
def try_path_as_dir(path, from_import)
|
238
|
-
return unless dir_exist?
|
274
|
+
return unless dir_exist?(path)
|
239
275
|
|
240
276
|
if from_import
|
241
277
|
result = exactly_one(try_path_with_ext(File.join(path, 'index.import')))
|
@@ -247,7 +283,7 @@ module SassC
|
|
247
283
|
|
248
284
|
def exactly_one(paths)
|
249
285
|
return if paths.empty?
|
250
|
-
return paths.first if paths.
|
286
|
+
return paths.first if paths.one?
|
251
287
|
|
252
288
|
raise "It's not clear which file to import. Found:\n#{paths.map { |path| " #{path}" }.join("\n")}"
|
253
289
|
end
|
@@ -264,46 +300,71 @@ module SassC
|
|
264
300
|
ext = File.extname(path)
|
265
301
|
path.delete_suffix(ext)
|
266
302
|
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
|
267
318
|
end
|
268
319
|
end
|
269
320
|
|
270
|
-
private_constant :
|
321
|
+
private_constant :FileSystemImporter
|
271
322
|
|
272
|
-
class
|
323
|
+
class ImportCache
|
273
324
|
def initialize(importer)
|
274
325
|
@importer = importer
|
275
|
-
|
276
326
|
@canonical_urls = {}
|
277
|
-
@id = 0
|
278
327
|
@importer_results = {}
|
328
|
+
@load_paths = (@importer.options[:load_paths] || []) + SassC.load_paths
|
279
329
|
@parent_urls = [URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin'))]
|
280
330
|
end
|
281
331
|
|
282
332
|
def canonicalize(url, context)
|
283
333
|
if url.start_with?(Protocol::IMPORT)
|
284
|
-
canonical_url = @canonical_urls.delete(url
|
334
|
+
canonical_url = @canonical_urls.delete(url)
|
285
335
|
unless @importer_results.key?(canonical_url)
|
286
|
-
|
336
|
+
path = URL.unescape(canonical_url)
|
337
|
+
parent_path = URL.file_url_to_path(@parent_urls.last)
|
338
|
+
canonical_url = resolve_file_url(path, parent_path, context.from_import)
|
339
|
+
return unless canonical_url
|
340
|
+
|
341
|
+
# Temporarily disable FileImporter optimization
|
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
|
287
348
|
end
|
288
349
|
@parent_urls.push(canonical_url)
|
289
350
|
canonical_url
|
290
|
-
elsif url.start_with?(Protocol::
|
291
|
-
|
292
|
-
|
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)
|
358
|
+
|
359
|
+
path = URL.file_urls_to_relative_path(url, parent_url)
|
360
|
+
parent_path = URL.file_url_to_path(parent_url)
|
293
361
|
|
294
362
|
imports = @importer.imports(path, parent_path)
|
295
363
|
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
296
364
|
imports = [imports] unless imports.is_a?(Array)
|
297
|
-
imports.each do |import|
|
298
|
-
import.path = File.absolute_path(import.path, File.dirname(parent_path))
|
299
|
-
end
|
300
365
|
|
301
|
-
canonical_url = "#{Protocol::IMPORT}#{
|
302
|
-
@importer_results[canonical_url] = imports_to_native(imports, context.from_import)
|
303
|
-
canonical_url
|
304
|
-
elsif url.start_with?(Protocol::LOADED)
|
305
|
-
canonical_url = Protocol::LOADED
|
306
|
-
@parent_urls.pop
|
366
|
+
canonical_url = "#{Protocol::IMPORT}#{url}"
|
367
|
+
@importer_results[canonical_url] = imports_to_native(imports, File.dirname(parent_path), context.from_import)
|
307
368
|
canonical_url
|
308
369
|
end
|
309
370
|
end
|
@@ -326,17 +387,19 @@ module SassC
|
|
326
387
|
end
|
327
388
|
end
|
328
389
|
|
329
|
-
|
390
|
+
def find_file_url(url, _context)
|
391
|
+
canonical_url = @canonical_urls.delete(url)
|
392
|
+
return unless canonical_url
|
330
393
|
|
331
|
-
|
332
|
-
|
394
|
+
@parent_urls.push(canonical_url)
|
395
|
+
canonical_url
|
333
396
|
end
|
334
397
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
[File.dirname(parent_path)].concat(load_paths).each do |load_path|
|
339
|
-
resolved =
|
398
|
+
private
|
399
|
+
|
400
|
+
def resolve_file_url(path, parent_path, from_import)
|
401
|
+
[File.dirname(parent_path)].concat(@load_paths).each do |load_path|
|
402
|
+
resolved = FileSystemImporter.resolve_path(File.absolute_path(path, load_path), from_import)
|
340
403
|
return URL.path_to_file_url(resolved) unless resolved.nil?
|
341
404
|
end
|
342
405
|
nil
|
@@ -353,13 +416,11 @@ module SassC
|
|
353
416
|
end
|
354
417
|
end
|
355
418
|
|
356
|
-
def imports_to_native(imports, from_import)
|
419
|
+
def imports_to_native(imports, parent_dir, from_import)
|
357
420
|
{
|
358
421
|
contents: imports.flat_map do |import|
|
359
|
-
id = next_id
|
360
|
-
canonical_url = URL.path_to_file_url(import.path)
|
361
|
-
@canonical_urls[id] = canonical_url
|
362
422
|
if import.source
|
423
|
+
canonical_url = URL.path_to_file_url(File.absolute_path(import.path, parent_dir))
|
363
424
|
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
364
425
|
{
|
365
426
|
contents: import.source[:contents],
|
@@ -373,25 +434,24 @@ module SassC
|
|
373
434
|
source_map_url: canonical_url
|
374
435
|
}
|
375
436
|
end
|
437
|
+
else
|
438
|
+
canonical_url = URL.escape(import.path)
|
376
439
|
end
|
440
|
+
import_url = "#{Protocol::IMPORT}#{canonical_url}"
|
441
|
+
loaded_url = "#{Protocol::LOADED}#{canonical_url}"
|
442
|
+
@canonical_urls[import_url] = canonical_url
|
377
443
|
at_rule = from_import ? '@import' : '@forward'
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
444
|
+
<<~SCSS
|
445
|
+
#{at_rule} #{Script::Value::String.quote(import_url)};
|
446
|
+
#{at_rule} #{Script::Value::String.quote(loaded_url)};
|
447
|
+
SCSS
|
382
448
|
end.join("\n"),
|
383
449
|
syntax: :scss
|
384
450
|
}
|
385
451
|
end
|
386
|
-
|
387
|
-
def next_id
|
388
|
-
id = @id
|
389
|
-
@id = id.next
|
390
|
-
id.to_s
|
391
|
-
end
|
392
452
|
end
|
393
453
|
|
394
|
-
private_constant :
|
454
|
+
private_constant :ImportCache
|
395
455
|
end
|
396
456
|
|
397
457
|
class Sass2Scss
|
@@ -556,6 +616,10 @@ module SassC
|
|
556
616
|
|
557
617
|
module_function
|
558
618
|
|
619
|
+
def join(...)
|
620
|
+
URI.join(...).to_s
|
621
|
+
end
|
622
|
+
|
559
623
|
def parse(str)
|
560
624
|
PARSER.parse(str)
|
561
625
|
end
|
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.74.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-04 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.74'
|
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.74'
|
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.74.0
|
83
83
|
funding_uri: https://github.com/sponsors/ntkme
|
84
84
|
rubygems_mfa_required: 'true'
|
85
85
|
post_install_message:
|