sassc-embedded 1.76.0 → 1.77.1
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 +64 -64
- 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: a4b63d6cb7265fce189ee1c9dd5a5e6c06a2ae5d0d0ccf2fe88bf9ea15a0b4f2
|
4
|
+
data.tar.gz: 9742024209ffbcd80ec482028500370fb12343af829e814b3e4daf9d15e3a7f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d332ab05fee496aa0bcd14aad0d623a4309ef9244cf30125f191fc5542bc79c7cf2effe8e0ec2069a59384c621467097977b70c030e465c798f5b46860159ecb
|
7
|
+
data.tar.gz: e14c9ffb2dc052809527cc30619fa28224457523780237fd44004f953de09e867fb0ea2b1933a23cece2cb6cb3c8cb8ce2264096848c8cb86acd8876d55cec7a
|
data/lib/sassc/embedded.rb
CHANGED
@@ -46,11 +46,11 @@ module SassC
|
|
46
46
|
css = result.css
|
47
47
|
css += "\n" unless css.empty?
|
48
48
|
unless @source_map.nil? || omit_source_map_url?
|
49
|
-
url =
|
49
|
+
url = Uri.parse(output_url || file_url)
|
50
50
|
source_mapping_url = if source_map_embed?
|
51
51
|
"data:application/json;base64,#{[@source_map].pack('m0')}"
|
52
52
|
else
|
53
|
-
|
53
|
+
Uri.file_urls_to_relative_url(source_map_file_url, url)
|
54
54
|
end
|
55
55
|
css += "\n/*# sourceMappingURL=#{source_mapping_url} */"
|
56
56
|
end
|
@@ -61,9 +61,7 @@ module SassC
|
|
61
61
|
line = e.span&.start&.line
|
62
62
|
line += 1 unless line.nil?
|
63
63
|
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
|
64
|
+
path = (Uri.file_urls_to_relative_path(url, Uri.path_to_file_url("#{Dir.pwd}/")) if url&.start_with?('file:'))
|
67
65
|
raise SyntaxError.new(e.full_message, filename: path, line:)
|
68
66
|
end
|
69
67
|
|
@@ -71,19 +69,19 @@ module SassC
|
|
71
69
|
raise NotRenderedError unless @loaded_urls
|
72
70
|
|
73
71
|
Dependency.from_filenames(@loaded_urls.filter_map do |url|
|
74
|
-
|
72
|
+
Uri.file_url_to_path(url) if url.start_with?('file:') && !url.include?('?') && url != file_url
|
75
73
|
end)
|
76
74
|
end
|
77
75
|
|
78
76
|
def source_map
|
79
77
|
raise NotRenderedError unless @source_map
|
80
78
|
|
81
|
-
url =
|
79
|
+
url = Uri.parse(source_map_file_url || file_url)
|
82
80
|
data = JSON.parse(@source_map)
|
83
|
-
data['file'] =
|
81
|
+
data['file'] = Uri.file_urls_to_relative_url(output_url, url) if output_url
|
84
82
|
data['sources'].map! do |source|
|
85
|
-
if source.start_with?(
|
86
|
-
|
83
|
+
if source.start_with?('file:')
|
84
|
+
Uri.file_urls_to_relative_url(source, url)
|
87
85
|
else
|
88
86
|
source
|
89
87
|
end
|
@@ -95,7 +93,7 @@ module SassC
|
|
95
93
|
private
|
96
94
|
|
97
95
|
def file_url
|
98
|
-
@file_url ||=
|
96
|
+
@file_url ||= Uri.path_to_file_url(File.absolute_path(filename || 'stdin'))
|
99
97
|
end
|
100
98
|
|
101
99
|
def output_path
|
@@ -105,11 +103,18 @@ module SassC
|
|
105
103
|
end
|
106
104
|
|
107
105
|
def output_url
|
108
|
-
@output_url ||= (
|
106
|
+
@output_url ||= (Uri.path_to_file_url(File.absolute_path(output_path)) if output_path)
|
109
107
|
end
|
110
108
|
|
111
109
|
def source_map_file_url
|
112
|
-
@source_map_file_url ||=
|
110
|
+
@source_map_file_url ||= if source_map_file
|
111
|
+
# https://github.com/sass-contrib/sassc-embedded-shim-ruby/pull/69
|
112
|
+
# SassC does not encode path as uri for sourceMappingURL, which is technically wrong.
|
113
|
+
# However, this behavior has been abused to append query string to sourceMappingURL.
|
114
|
+
components = source_map_file.split('?', 2)
|
115
|
+
components[0] = Uri.path_to_file_url(File.absolute_path(components[0]))
|
116
|
+
components.join('?')
|
117
|
+
end
|
113
118
|
end
|
114
119
|
|
115
120
|
def output_style
|
@@ -308,37 +313,31 @@ module SassC
|
|
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
|
326
|
-
|
327
|
-
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
328
|
-
imports = [imports] unless imports.is_a?(Array)
|
329
|
-
canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, context.containing_url)
|
324
|
+
if containing_url.include?('?')
|
325
|
+
canonical_url = Uri.path_to_file_url(File.absolute_path(path, parent_dir))
|
330
326
|
if @importer_results.key?(canonical_url)
|
331
327
|
canonical_url
|
332
328
|
else
|
333
|
-
@file_url =
|
329
|
+
@file_url = resolve_file_url(path, parent_dir, context.from_import)
|
334
330
|
nil
|
335
331
|
end
|
336
332
|
else
|
337
|
-
|
333
|
+
imports = @importer.imports(path, parent_path)
|
334
|
+
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
335
|
+
imports = [imports] unless imports.is_a?(Array)
|
336
|
+
canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, containing_url)
|
338
337
|
if @importer_results.key?(canonical_url)
|
339
338
|
canonical_url
|
340
339
|
else
|
341
|
-
@file_url =
|
340
|
+
@file_url = canonical_url
|
342
341
|
nil
|
343
342
|
end
|
344
343
|
end
|
@@ -360,7 +359,7 @@ module SassC
|
|
360
359
|
|
361
360
|
def resolve_file_url(path, parent_dir, from_import)
|
362
361
|
resolved = FileSystemImporter.resolve_path(File.absolute_path(path, parent_dir), from_import)
|
363
|
-
|
362
|
+
Uri.path_to_file_url(resolved) unless resolved.nil?
|
364
363
|
end
|
365
364
|
|
366
365
|
def syntax(path)
|
@@ -376,7 +375,7 @@ module SassC
|
|
376
375
|
|
377
376
|
def import_to_native(import, parent_dir, from_import, canonicalize)
|
378
377
|
if import.source
|
379
|
-
canonical_url =
|
378
|
+
canonical_url = Uri.path_to_file_url(File.absolute_path(import.path, parent_dir))
|
380
379
|
@importer_results[canonical_url] = if import.source.is_a?(Hash)
|
381
380
|
{
|
382
381
|
contents: import.source[:contents],
|
@@ -395,13 +394,13 @@ module SassC
|
|
395
394
|
return resolve_file_url(import.path, parent_dir, from_import)
|
396
395
|
end
|
397
396
|
|
398
|
-
|
397
|
+
Uri.encode_uri_path_component(import.path)
|
399
398
|
end
|
400
399
|
|
401
400
|
def imports_to_native(imports, parent_dir, from_import, url, containing_url)
|
402
401
|
return import_to_native(imports.first, parent_dir, from_import, true) if imports.one?
|
403
402
|
|
404
|
-
canonical_url = "#{
|
403
|
+
canonical_url = "#{containing_url}?url=#{Uri.encode_uri_query_component(url)}&from_import=#{from_import}"
|
405
404
|
@importer_results[canonical_url] = {
|
406
405
|
contents: imports.flat_map do |import|
|
407
406
|
at_rule = from_import ? '@import' : '@forward'
|
@@ -565,34 +564,35 @@ module SassC
|
|
565
564
|
end
|
566
565
|
end
|
567
566
|
|
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
|
-
|
567
|
+
module Uri
|
580
568
|
module_function
|
581
569
|
|
582
|
-
def
|
583
|
-
URI.
|
570
|
+
def parse(...)
|
571
|
+
::URI.parse(...)
|
584
572
|
end
|
585
573
|
|
586
|
-
def
|
587
|
-
|
574
|
+
def encode_uri_path_component(str)
|
575
|
+
str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/]}n) do |match|
|
576
|
+
format('%%%02X', match.unpack1('C'))
|
577
|
+
end.force_encoding(str.encoding)
|
588
578
|
end
|
589
579
|
|
590
|
-
def
|
591
|
-
|
580
|
+
def encode_uri_query_component(str)
|
581
|
+
str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/?]}n) do |match|
|
582
|
+
format('%%%02X', match.unpack1('C'))
|
583
|
+
end.force_encoding(str.encoding)
|
592
584
|
end
|
593
585
|
|
594
|
-
def
|
595
|
-
|
586
|
+
def encode_uri_component(str)
|
587
|
+
str.b.gsub(/[^0-9A-Za-z\-._~]/n) do |match|
|
588
|
+
format('%%%02X', match.unpack1('C'))
|
589
|
+
end.force_encoding(str.encoding)
|
590
|
+
end
|
591
|
+
|
592
|
+
def decode_uri_component(str)
|
593
|
+
str.gsub(/%[0-9A-Fa-f]{2}/) do |match|
|
594
|
+
[match[1, 2]].pack('H2')
|
595
|
+
end
|
596
596
|
end
|
597
597
|
|
598
598
|
def file_urls_to_relative_url(url, from_url)
|
@@ -600,24 +600,24 @@ module SassC
|
|
600
600
|
end
|
601
601
|
|
602
602
|
def file_urls_to_relative_path(url, from_url)
|
603
|
-
|
603
|
+
decode_uri_component(file_urls_to_relative_url(url, from_url))
|
604
604
|
end
|
605
605
|
|
606
606
|
def file_url_to_path(url)
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
607
|
+
path = decode_uri_component(parse(url).path)
|
608
|
+
if path.start_with?('/')
|
609
|
+
windows_path = path[1..]
|
610
|
+
path = windows_path if File.absolute_path?(windows_path)
|
611
|
+
end
|
611
612
|
path
|
612
613
|
end
|
613
614
|
|
614
615
|
def path_to_file_url(path)
|
615
|
-
return if path.nil?
|
616
|
-
|
617
616
|
path = "/#{path}" unless path.start_with?('/')
|
618
|
-
|
617
|
+
|
618
|
+
"file://#{encode_uri_path_component(path)}"
|
619
619
|
end
|
620
620
|
end
|
621
621
|
|
622
|
-
private_constant :
|
622
|
+
private_constant :Uri
|
623
623
|
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.1
|
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-06-29 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.1
|
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!
|