sassc-embedded 1.76.0 → 1.77.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 +134 -91
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a5084e30e04703dd21157b4dd3bf32abee7f789e939056a033bc4ddb4c2b1a2
|
4
|
+
data.tar.gz: eb1f8e6e1ce7ea90364fccbd4241fb5ccb677ae29a11ed385ec8c1bec068ae85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a1bc6dc872c8cb0ebec80c1cc4d7550b62445515a3e6eca3d510094aadc0c48ce8d213ad5b31934501150b3f771efcdc931560befb87b8c827f74a0cb80fe4e
|
7
|
+
data.tar.gz: d9012320b9955c2aea7012bd11d0874dbf3b68ff807e6b7b5f395b22e7b8e4bbc75f48c38c9618fd2da669fd093193c61c257afd0eebc1507cba5a2ab792a0a4
|
data/lib/sassc/embedded.rb
CHANGED
@@ -10,6 +10,8 @@ require_relative 'embedded/version'
|
|
10
10
|
|
11
11
|
module SassC
|
12
12
|
class Engine
|
13
|
+
remove_method(:render) if public_method_defined?(:render, false)
|
14
|
+
|
13
15
|
def render
|
14
16
|
return @template.dup if @template.empty?
|
15
17
|
|
@@ -46,11 +48,10 @@ module SassC
|
|
46
48
|
css = result.css
|
47
49
|
css += "\n" unless css.empty?
|
48
50
|
unless @source_map.nil? || omit_source_map_url?
|
49
|
-
url = URL.parse(output_url || file_url)
|
50
51
|
source_mapping_url = if source_map_embed?
|
51
52
|
"data:application/json;base64,#{[@source_map].pack('m0')}"
|
52
53
|
else
|
53
|
-
|
54
|
+
Uri.file_urls_to_relative_url(source_map_file_url, file_url)
|
54
55
|
end
|
55
56
|
css += "\n/*# sourceMappingURL=#{source_mapping_url} */"
|
56
57
|
end
|
@@ -61,29 +62,30 @@ module SassC
|
|
61
62
|
line = e.span&.start&.line
|
62
63
|
line += 1 unless line.nil?
|
63
64
|
url = e.span&.url
|
64
|
-
path = if url&.start_with?(
|
65
|
-
URL.file_urls_to_relative_path(url, URL.path_to_file_url("#{Dir.pwd}/"))
|
66
|
-
end
|
65
|
+
path = (Uri.file_urls_to_relative_path(url, Uri.path_to_file_url("#{Dir.pwd}/")) if url&.start_with?('file:'))
|
67
66
|
raise SyntaxError.new(e.full_message, filename: path, line:)
|
68
67
|
end
|
69
68
|
|
69
|
+
remove_method(:dependencies) if public_method_defined?(:dependencies, false)
|
70
|
+
|
70
71
|
def dependencies
|
71
72
|
raise NotRenderedError unless @loaded_urls
|
72
73
|
|
73
74
|
Dependency.from_filenames(@loaded_urls.filter_map do |url|
|
74
|
-
|
75
|
+
Uri.file_url_to_path(url) if url.start_with?('file:') && !url.include?('?') && url != file_url
|
75
76
|
end)
|
76
77
|
end
|
77
78
|
|
79
|
+
remove_method(:source_map) if public_method_defined?(:source_map, false)
|
80
|
+
|
78
81
|
def source_map
|
79
82
|
raise NotRenderedError unless @source_map
|
80
83
|
|
81
|
-
url =
|
84
|
+
url = Uri.parse(source_map_file_url || file_url)
|
82
85
|
data = JSON.parse(@source_map)
|
83
|
-
data['file'] = URL.file_urls_to_relative_url(output_url, url) if output_url
|
84
86
|
data['sources'].map! do |source|
|
85
|
-
if source.start_with?(
|
86
|
-
|
87
|
+
if source.start_with?('file:')
|
88
|
+
Uri.file_urls_to_relative_url(source, url)
|
87
89
|
else
|
88
90
|
source
|
89
91
|
end
|
@@ -95,35 +97,29 @@ module SassC
|
|
95
97
|
private
|
96
98
|
|
97
99
|
def file_url
|
98
|
-
@file_url ||=
|
99
|
-
end
|
100
|
-
|
101
|
-
def output_path
|
102
|
-
@output_path ||= @options.fetch(:output_path) do
|
103
|
-
"#{filename.delete_suffix(File.extname(filename))}.css" if filename
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def output_url
|
108
|
-
@output_url ||= (URL.path_to_file_url(File.absolute_path(output_path)) if output_path)
|
100
|
+
@file_url ||= Uri.path_to_file_url(File.absolute_path(filename || 'stdin'))
|
109
101
|
end
|
110
102
|
|
111
103
|
def source_map_file_url
|
112
|
-
@source_map_file_url ||=
|
104
|
+
@source_map_file_url ||= if source_map_file
|
105
|
+
Uri.path_to_file_url(File.absolute_path(source_map_file))
|
106
|
+
.gsub('%3F', '?') # https://github.com/sass-contrib/sassc-embedded-shim-ruby/pull/69
|
107
|
+
end
|
113
108
|
end
|
114
109
|
|
110
|
+
remove_method(:output_style) if private_method_defined?(:output_style, false)
|
111
|
+
|
115
112
|
def output_style
|
116
113
|
@output_style ||= begin
|
117
|
-
style = @options.fetch(:style, :sass_style_nested).to_s
|
118
|
-
style = "sass_style_#{style}" unless style.start_with?('sass_style_')
|
119
|
-
raise InvalidStyleError unless OUTPUT_STYLES.include?(style.to_sym)
|
114
|
+
style = @options.fetch(:style, :sass_style_nested).to_s.delete_prefix('sass_style_').to_sym
|
120
115
|
|
121
|
-
style = style.delete_prefix('sass_style_').to_sym
|
122
116
|
case style
|
123
|
-
when :nested, :compact
|
117
|
+
when :nested, :compact, :expanded
|
124
118
|
:expanded
|
119
|
+
when :compressed
|
120
|
+
:compressed
|
125
121
|
else
|
126
|
-
|
122
|
+
raise InvalidStyleError
|
127
123
|
end
|
128
124
|
end
|
129
125
|
end
|
@@ -134,12 +130,16 @@ module SassC
|
|
134
130
|
syntax
|
135
131
|
end
|
136
132
|
|
133
|
+
remove_method(:load_paths) if private_method_defined?(:load_paths, false)
|
134
|
+
|
137
135
|
def load_paths
|
138
136
|
@load_paths ||= (@options[:load_paths] || []) + SassC.load_paths
|
139
137
|
end
|
140
138
|
end
|
141
139
|
|
142
140
|
class FunctionsHandler
|
141
|
+
remove_method(:setup) if public_method_defined?(:setup, false)
|
142
|
+
|
143
143
|
def setup(_native_options, functions: Script::Functions)
|
144
144
|
@callbacks = {}
|
145
145
|
|
@@ -172,6 +172,8 @@ module SassC
|
|
172
172
|
|
173
173
|
private
|
174
174
|
|
175
|
+
remove_method(:arguments_from_native_list) if private_method_defined?(:arguments_from_native_list, false)
|
176
|
+
|
175
177
|
def arguments_from_native_list(native_argument_list)
|
176
178
|
native_argument_list.filter_map do |native_value|
|
177
179
|
Script::ValueConversion.from_native(native_value, @options)
|
@@ -190,6 +192,8 @@ module SassC
|
|
190
192
|
private_constant :NoopImporter
|
191
193
|
|
192
194
|
class ImportHandler
|
195
|
+
remove_method(:setup) if public_method_defined?(:setup, false)
|
196
|
+
|
193
197
|
def setup(_native_options)
|
194
198
|
if @importer
|
195
199
|
import_cache = ImportCache.new(@importer)
|
@@ -227,7 +231,7 @@ module SassC
|
|
227
231
|
|
228
232
|
private_constant :FileImporter
|
229
233
|
|
230
|
-
|
234
|
+
module FileSystemImporter
|
231
235
|
class << self
|
232
236
|
def resolve_path(path, from_import)
|
233
237
|
ext = File.extname(path)
|
@@ -304,48 +308,44 @@ module SassC
|
|
304
308
|
def initialize(importer)
|
305
309
|
@importer = importer
|
306
310
|
@importer_results = {}
|
311
|
+
@importer_result = nil
|
307
312
|
@file_url = nil
|
308
313
|
end
|
309
314
|
|
310
315
|
def canonicalize(url, context)
|
311
|
-
return
|
316
|
+
return unless context.containing_url&.start_with?('file:')
|
312
317
|
|
313
|
-
containing_url =
|
314
|
-
URL.unescape(URL.parse(context.containing_url).fragment)
|
315
|
-
else
|
316
|
-
context.containing_url
|
317
|
-
end
|
318
|
+
containing_url = context.containing_url
|
318
319
|
|
319
|
-
|
320
|
-
|
321
|
-
path = URL.unescape(url)
|
322
|
-
parent_path = URL.file_url_to_path(containing_url)
|
320
|
+
path = Uri.decode_uri_component(url)
|
321
|
+
parent_path = Uri.file_url_to_path(containing_url)
|
323
322
|
parent_dir = File.dirname(parent_path)
|
324
323
|
|
325
|
-
if containing_url
|
324
|
+
if containing_url.include?('?')
|
325
|
+
canonical_url = Uri.path_to_file_url(File.absolute_path(path, parent_dir))
|
326
|
+
unless @importer_results.key?(canonical_url)
|
327
|
+
@file_url = resolve_file_url(path, parent_dir, context.from_import)
|
328
|
+
return
|
329
|
+
end
|
330
|
+
else
|
326
331
|
imports = @importer.imports(path, parent_path)
|
327
332
|
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
328
333
|
imports = [imports] unless imports.is_a?(Array)
|
329
|
-
canonical_url = imports_to_native(imports, parent_dir, context.from_import, url,
|
330
|
-
|
331
|
-
canonical_url
|
332
|
-
else
|
334
|
+
canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, containing_url)
|
335
|
+
unless @importer_results.key?(canonical_url)
|
333
336
|
@file_url = canonical_url
|
334
|
-
|
335
|
-
end
|
336
|
-
else
|
337
|
-
canonical_url = URL.path_to_file_url(File.absolute_path(path, parent_dir))
|
338
|
-
if @importer_results.key?(canonical_url)
|
339
|
-
canonical_url
|
340
|
-
else
|
341
|
-
@file_url = resolve_file_url(path, parent_dir, context.from_import)
|
342
|
-
nil
|
337
|
+
return
|
343
338
|
end
|
344
339
|
end
|
340
|
+
|
341
|
+
@importer_result = @importer_results.delete(canonical_url)
|
342
|
+
canonical_url
|
345
343
|
end
|
346
344
|
|
347
|
-
def load(
|
348
|
-
@
|
345
|
+
def load(_canonical_url)
|
346
|
+
importer_result = @importer_result
|
347
|
+
@importer_result = nil
|
348
|
+
importer_result
|
349
349
|
end
|
350
350
|
|
351
351
|
def find_file_url(_url, context)
|
@@ -360,7 +360,7 @@ module SassC
|
|
360
360
|
|
361
361
|
def resolve_file_url(path, parent_dir, from_import)
|
362
362
|
resolved = FileSystemImporter.resolve_path(File.absolute_path(path, parent_dir), from_import)
|
363
|
-
|
363
|
+
Uri.path_to_file_url(resolved) unless resolved.nil?
|
364
364
|
end
|
365
365
|
|
366
366
|
def syntax(path)
|
@@ -376,7 +376,7 @@ module SassC
|
|
376
376
|
|
377
377
|
def import_to_native(import, parent_dir, from_import, canonicalize)
|
378
378
|
if import.source
|
379
|
-
canonical_url =
|
379
|
+
canonical_url = Uri.path_to_file_url(File.absolute_path(import.path, parent_dir))
|
380
380
|
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
381
381
|
{
|
382
382
|
contents: import.source[:contents],
|
@@ -395,13 +395,13 @@ module SassC
|
|
395
395
|
return resolve_file_url(import.path, parent_dir, from_import)
|
396
396
|
end
|
397
397
|
|
398
|
-
|
398
|
+
Uri.encode_uri_path_component(import.path)
|
399
399
|
end
|
400
400
|
|
401
401
|
def imports_to_native(imports, parent_dir, from_import, url, containing_url)
|
402
402
|
return import_to_native(imports.first, parent_dir, from_import, true) if imports.one?
|
403
403
|
|
404
|
-
canonical_url = "#{
|
404
|
+
canonical_url = "#{containing_url}?url=#{Uri.encode_uri_query_component(url)}&from_import=#{from_import}"
|
405
405
|
@importer_results[canonical_url] = {
|
406
406
|
contents: imports.flat_map do |import|
|
407
407
|
at_rule = from_import ? '@import' : '@forward'
|
@@ -419,6 +419,10 @@ module SassC
|
|
419
419
|
end
|
420
420
|
|
421
421
|
class Sass2Scss
|
422
|
+
class << self
|
423
|
+
remove_method(:convert) if public_method_defined?(:convert, false)
|
424
|
+
end
|
425
|
+
|
422
426
|
def self.convert(sass)
|
423
427
|
{
|
424
428
|
contents: sass,
|
@@ -430,6 +434,10 @@ module SassC
|
|
430
434
|
module Script
|
431
435
|
class Value
|
432
436
|
class String
|
437
|
+
class << self
|
438
|
+
remove_method(:quote) if public_method_defined?(:quote, false)
|
439
|
+
end
|
440
|
+
|
433
441
|
# Returns the quoted string representation of `contents`.
|
434
442
|
#
|
435
443
|
# @options opts :quote [String]
|
@@ -442,6 +450,8 @@ module SassC
|
|
442
450
|
opts[:sass] ? contents.gsub('#', '\#') : contents
|
443
451
|
end
|
444
452
|
|
453
|
+
remove_method(:to_s) if public_method_defined?(:to_s, false)
|
454
|
+
|
445
455
|
def to_s(opts = {})
|
446
456
|
opts = { quote: :none }.merge!(opts) if @type == :identifier
|
447
457
|
self.class.quote(@value, opts)
|
@@ -450,6 +460,10 @@ module SassC
|
|
450
460
|
end
|
451
461
|
|
452
462
|
module ValueConversion
|
463
|
+
class << self
|
464
|
+
remove_method(:from_native) if public_method_defined?(:from_native, false)
|
465
|
+
end
|
466
|
+
|
453
467
|
def self.from_native(value, options)
|
454
468
|
case value
|
455
469
|
when ::Sass::Value::Null::NULL
|
@@ -505,6 +519,10 @@ module SassC
|
|
505
519
|
end
|
506
520
|
end
|
507
521
|
|
522
|
+
class << self
|
523
|
+
remove_method(:to_native) if public_method_defined?(:to_native, false)
|
524
|
+
end
|
525
|
+
|
508
526
|
def self.to_native(value)
|
509
527
|
case value
|
510
528
|
when nil
|
@@ -565,59 +583,84 @@ module SassC
|
|
565
583
|
end
|
566
584
|
end
|
567
585
|
|
568
|
-
module
|
569
|
-
FILE = 'file:'
|
570
|
-
GLOB = 'sassc-embedded-glob:'
|
571
|
-
end
|
572
|
-
|
573
|
-
private_constant :Protocol
|
574
|
-
|
575
|
-
module URL
|
576
|
-
PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
577
|
-
|
578
|
-
private_constant :PARSER
|
579
|
-
|
586
|
+
module Uri
|
580
587
|
module_function
|
581
588
|
|
582
|
-
def
|
583
|
-
URI.
|
589
|
+
def parse(...)
|
590
|
+
::URI::RFC3986_PARSER.parse(...)
|
584
591
|
end
|
585
592
|
|
586
|
-
|
587
|
-
|
588
|
-
|
593
|
+
encode_uri_hash = {}
|
594
|
+
decode_uri_hash = {}
|
595
|
+
256.times do |i|
|
596
|
+
c = -[i].pack('C')
|
597
|
+
h = c.unpack1('H')
|
598
|
+
l = c.unpack1('h')
|
599
|
+
pdd = -"%#{h}#{l}"
|
600
|
+
pdu = -"%#{h}#{l.upcase}"
|
601
|
+
pud = -"%#{h.upcase}#{l}"
|
602
|
+
puu = -pdd.upcase
|
603
|
+
encode_uri_hash[c] = puu
|
604
|
+
decode_uri_hash[pdd] = c
|
605
|
+
decode_uri_hash[pdu] = c
|
606
|
+
decode_uri_hash[pud] = c
|
607
|
+
decode_uri_hash[puu] = c
|
608
|
+
end.freeze
|
609
|
+
encode_uri_hash.freeze
|
610
|
+
decode_uri_hash.freeze
|
611
|
+
|
612
|
+
{
|
613
|
+
uri_path_component: "!$&'()*+,;=:/@",
|
614
|
+
uri_query_component: "!$&'()*+,;=:/?@",
|
615
|
+
uri_component: nil,
|
616
|
+
uri: "!$&'()*+,;=:/?#[]@"
|
617
|
+
}
|
618
|
+
.each do |symbol, unescaped|
|
619
|
+
encode_regexp = Regexp.new("[^0-9A-Za-z#{Regexp.escape("-._~#{unescaped}")}]", Regexp::NOENCODING)
|
620
|
+
|
621
|
+
define_method(:"encode_#{symbol}") do |str|
|
622
|
+
str.b.gsub(encode_regexp, encode_uri_hash).force_encoding(str.encoding)
|
623
|
+
end
|
589
624
|
|
590
|
-
|
591
|
-
PARSER.escape(str)
|
592
|
-
end
|
625
|
+
next if symbol.match?(/_.+_/o)
|
593
626
|
|
594
|
-
|
595
|
-
|
596
|
-
|
627
|
+
decode_regexp = /%[0-9A-Fa-f]{2}/o
|
628
|
+
decode_uri_hash_with_preserve_escaped = if unescaped.nil? || unescaped.empty?
|
629
|
+
decode_uri_hash
|
630
|
+
else
|
631
|
+
decode_uri_hash.to_h do |key, value|
|
632
|
+
[key, unescaped.include?(value) ? key : value]
|
633
|
+
end.freeze
|
634
|
+
end
|
635
|
+
|
636
|
+
define_method(:"decode_#{symbol}") do |str|
|
637
|
+
str.gsub(decode_regexp, decode_uri_hash_with_preserve_escaped).force_encoding(str.encoding)
|
638
|
+
end
|
639
|
+
end
|
597
640
|
|
598
641
|
def file_urls_to_relative_url(url, from_url)
|
599
642
|
parse(url).route_from(from_url).to_s
|
600
643
|
end
|
601
644
|
|
602
645
|
def file_urls_to_relative_path(url, from_url)
|
603
|
-
|
646
|
+
decode_uri_component(file_urls_to_relative_url(url, from_url))
|
604
647
|
end
|
605
648
|
|
606
649
|
def file_url_to_path(url)
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
650
|
+
path = decode_uri_component(parse(url).path)
|
651
|
+
if path.start_with?('/')
|
652
|
+
windows_path = path[1..]
|
653
|
+
path = windows_path if File.absolute_path?(windows_path)
|
654
|
+
end
|
611
655
|
path
|
612
656
|
end
|
613
657
|
|
614
658
|
def path_to_file_url(path)
|
615
|
-
return if path.nil?
|
616
|
-
|
617
659
|
path = "/#{path}" unless path.start_with?('/')
|
618
|
-
|
660
|
+
|
661
|
+
"file://#{encode_uri_path_component(path)}"
|
619
662
|
end
|
620
663
|
end
|
621
664
|
|
622
|
-
private_constant :
|
665
|
+
private_constant :Uri
|
623
666
|
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.77.7
|
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-07-07 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.77'
|
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.77'
|
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.77.7
|
83
83
|
funding_uri: https://github.com/sponsors/ntkme
|
84
84
|
rubygems_mfa_required: 'true'
|
85
85
|
post_install_message:
|
@@ -91,14 +91,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 3.1
|
94
|
+
version: '3.1'
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.5.
|
101
|
+
rubygems_version: 3.5.11
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Use dart-sass with SassC!
|