sassc-embedded 1.3.1 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/lib/sassc/embedded/version.rb +1 -1
- data/lib/sassc/embedded.rb +48 -32
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 506575e793d5ee699691de8907a88ceebfd7beb59bdab24dbb2cf635c2ffb404
|
4
|
+
data.tar.gz: af6c43358f10c090d012aa78e0e5137f556b372f10bcfe44588e23cc2a831bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7519d7e819f13d826b28f432010ab427bb5edeb1a3a047731f82363b982265ea2533ded7fb7598d5f9d6232ec20c07b143331ef1ae54a7c7f2e51f3134888216
|
7
|
+
data.tar.gz: 7118fc14334409be70766a79be3e9adb3f3a41ef451b3779762d90ee8409d795277e4a04ac3e71ed27464e870c3d52216d981e84bbba936f680eaaa3ca5a8618
|
data/README.md
CHANGED
@@ -7,6 +7,12 @@ Use `sass-embedded` with SassC Ruby!
|
|
7
7
|
|
8
8
|
This library polyfills [`sassc`](https://github.com/sass/sassc-ruby) with the [`sass-embedded`](https://github.com/ntkme/sass-embedded-host-ruby) implementation.
|
9
9
|
|
10
|
+
It has been tested with:
|
11
|
+
|
12
|
+
- [`sassc`](https://github.com/sass/sassc-ruby)
|
13
|
+
- [`sassc-rails`](https://github.com/sass/sassc-rails)
|
14
|
+
- [`sprockets`](https://github.com/rails/sprockets)
|
15
|
+
- [`sprockets-rails`](https://github.com/rails/sprockets-rails)
|
10
16
|
|
11
17
|
## Install
|
12
18
|
|
@@ -43,12 +49,10 @@ See [rubydoc.info/gems/sassc](https://rubydoc.info/gems/sassc) for full API docu
|
|
43
49
|
|
44
50
|
## Behavioral Differences from SassC Ruby
|
45
51
|
|
46
|
-
1. Option `:style => :nested`
|
47
|
-
|
48
|
-
2. Option `:style => :compact` behaves as `:compressed`.
|
52
|
+
1. Option `:style => :nested` and `:style => :compact` behave as `:style => :expanded`.
|
49
53
|
|
50
|
-
|
54
|
+
2. Option `:precision` is ignored.
|
51
55
|
|
52
|
-
|
56
|
+
3. Option `:line_comments` is ignored.
|
53
57
|
|
54
58
|
See [the dart-sass documentation](https://github.com/sass/dart-sass#behavioral-differences-from-ruby-sass) for other differences.
|
data/lib/sassc/embedded.rb
CHANGED
@@ -5,7 +5,6 @@ require 'sass-embedded'
|
|
5
5
|
|
6
6
|
require 'base64'
|
7
7
|
require 'json'
|
8
|
-
require 'pathname'
|
9
8
|
require 'uri'
|
10
9
|
|
11
10
|
require_relative 'embedded/version'
|
@@ -46,8 +45,9 @@ module SassC
|
|
46
45
|
line = e.span&.start&.line
|
47
46
|
line += 1 unless line.nil?
|
48
47
|
url = e.span&.url
|
49
|
-
path = url&.start_with?('file:')
|
50
|
-
|
48
|
+
path = if url&.start_with?('file:')
|
49
|
+
URL.parse(url).route_from(URL.path_to_file_url("#{File.absolute_path('')}/"))
|
50
|
+
end
|
51
51
|
raise SyntaxError.new(e.message, filename: path, line: line)
|
52
52
|
end
|
53
53
|
|
@@ -64,6 +64,14 @@ module SassC
|
|
64
64
|
)
|
65
65
|
end
|
66
66
|
|
67
|
+
def output_url
|
68
|
+
@output_url ||= (URL.path_to_file_url(File.absolute_path(output_path)) if output_path)
|
69
|
+
end
|
70
|
+
|
71
|
+
def source_map_file_url
|
72
|
+
@source_map_file_url ||= (URL.path_to_file_url(File.absolute_path(source_map_file)) if source_map_file)
|
73
|
+
end
|
74
|
+
|
67
75
|
def output_style
|
68
76
|
@output_style ||= begin
|
69
77
|
style = @options.fetch(:style, :sass_style_nested).to_s
|
@@ -72,10 +80,8 @@ module SassC
|
|
72
80
|
|
73
81
|
style = style.delete_prefix('sass_style_').to_sym
|
74
82
|
case style
|
75
|
-
when :nested
|
83
|
+
when :nested, :compact
|
76
84
|
:expanded
|
77
|
-
when :compact
|
78
|
-
:compressed
|
79
85
|
else
|
80
86
|
style
|
81
87
|
end
|
@@ -99,15 +105,12 @@ module SassC
|
|
99
105
|
def post_process_source_map(source_map)
|
100
106
|
return unless source_map
|
101
107
|
|
108
|
+
url = URL.parse(source_map_file_url || file_url)
|
102
109
|
data = JSON.parse(source_map)
|
103
|
-
|
104
|
-
source_map_dir = File.dirname(source_map_file || '')
|
105
|
-
|
106
|
-
data['file'] = URL.escape(relative_path(source_map_dir, output_path)) if output_path
|
107
|
-
|
110
|
+
data['file'] = URL.parse(output_url).route_from(url).to_s if output_url
|
108
111
|
data['sources'].map! do |source|
|
109
112
|
if source.start_with?('file:')
|
110
|
-
|
113
|
+
URL.parse(source).route_from(url).to_s
|
111
114
|
else
|
112
115
|
source
|
113
116
|
end
|
@@ -119,19 +122,16 @@ module SassC
|
|
119
122
|
def post_process_css(css)
|
120
123
|
css += "\n" unless css.empty?
|
121
124
|
unless @source_map.nil? || omit_source_map_url?
|
122
|
-
url =
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
url = URL.parse(output_url || file_url)
|
126
|
+
source_mapping_url = if source_map_embed?
|
127
|
+
"data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
|
128
|
+
else
|
129
|
+
URL.parse(source_map_file_url).route_from(url).to_s
|
130
|
+
end
|
131
|
+
css += "\n/*# sourceMappingURL=#{source_mapping_url} */"
|
128
132
|
end
|
129
133
|
css
|
130
134
|
end
|
131
|
-
|
132
|
-
def relative_path(from, to)
|
133
|
-
Pathname.new(File.absolute_path(to)).relative_path_from(Pathname.new(File.absolute_path(from))).to_s
|
134
|
-
end
|
135
135
|
end
|
136
136
|
|
137
137
|
class FunctionsHandler
|
@@ -286,8 +286,7 @@ module SassC
|
|
286
286
|
def initialize(importer)
|
287
287
|
@importer = importer
|
288
288
|
@importer_results = {}
|
289
|
-
@
|
290
|
-
@parent_urls = [URL.parse(URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin')))]
|
289
|
+
@parent_urls = [URL.path_to_file_url(File.absolute_path(@importer.options[:filename] || 'stdin'))]
|
291
290
|
end
|
292
291
|
|
293
292
|
def canonicalize(url, from_import:)
|
@@ -305,7 +304,7 @@ module SassC
|
|
305
304
|
return unless url.start_with?(Protocol::FILE)
|
306
305
|
|
307
306
|
path = URL.parse(url).route_from(@parent_urls.last).to_s
|
308
|
-
parent_path = URL.file_url_to_path(@parent_urls.last
|
307
|
+
parent_path = URL.file_url_to_path(@parent_urls.last)
|
309
308
|
|
310
309
|
imports = @importer.imports(path, parent_path)
|
311
310
|
imports = [SassC::Importer::Import.new(path)] if imports.nil?
|
@@ -324,7 +323,7 @@ module SassC
|
|
324
323
|
if canonical_url.start_with?(Protocol::IMPORT)
|
325
324
|
@importer_results.delete(canonical_url)
|
326
325
|
elsif canonical_url.start_with?(Protocol::FILE)
|
327
|
-
@parent_urls.push(
|
326
|
+
@parent_urls.push(canonical_url)
|
328
327
|
if @importer_results.key?(canonical_url)
|
329
328
|
@importer_results.delete(canonical_url)
|
330
329
|
else
|
@@ -339,7 +338,7 @@ module SassC
|
|
339
338
|
@parent_urls.pop
|
340
339
|
{
|
341
340
|
contents: '',
|
342
|
-
syntax:
|
341
|
+
syntax: :scss
|
343
342
|
}
|
344
343
|
end
|
345
344
|
end
|
@@ -374,11 +373,19 @@ module SassC
|
|
374
373
|
contents: imports.flat_map do |import|
|
375
374
|
file_url = URL.path_to_file_url(import.path)
|
376
375
|
if import.source
|
377
|
-
@importer_results[file_url] =
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
376
|
+
@importer_results[file_url] = if import.source.is_a?(Hash)
|
377
|
+
{
|
378
|
+
contents: import.source[:contents],
|
379
|
+
syntax: import.source[:syntax],
|
380
|
+
source_map_url: file_url
|
381
|
+
}
|
382
|
+
else
|
383
|
+
{
|
384
|
+
contents: import.source,
|
385
|
+
syntax: syntax(import.path),
|
386
|
+
source_map_url: file_url
|
387
|
+
}
|
388
|
+
end
|
382
389
|
end
|
383
390
|
[
|
384
391
|
"@import #{"#{Protocol::LOAD}#{file_url}".inspect};",
|
@@ -393,6 +400,15 @@ module SassC
|
|
393
400
|
private_constant :Importer
|
394
401
|
end
|
395
402
|
|
403
|
+
class Sass2Scss
|
404
|
+
def self.convert(sass)
|
405
|
+
{
|
406
|
+
contents: sass,
|
407
|
+
syntax: :indented
|
408
|
+
}
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
396
412
|
module Script
|
397
413
|
module ValueConversion
|
398
414
|
def self.from_native(value, options)
|
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.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sassc
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,8 +138,8 @@ homepage: https://github.com/ntkme/sassc-embedded-polyfill-ruby
|
|
138
138
|
licenses:
|
139
139
|
- MIT
|
140
140
|
metadata:
|
141
|
-
documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.
|
142
|
-
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.
|
141
|
+
documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.5.1
|
142
|
+
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.1
|
143
143
|
funding_uri: https://github.com/sponsors/ntkme
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|