sassc-embedded 1.3.0 → 1.5.0
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 +49 -33
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae4ea5a6b743f50b8687316f4ff5492b91caa0e8672a7b85da21a7402e2e901d
|
4
|
+
data.tar.gz: c94a6a86fb24ee5d018feadfcc5d514fc60d3a77338fe0482f4d4451eafa4a54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42fa17dc23aa53fcfb091c5ad23d1d0e49c260dd914bab8c39ea3c15c9ae3a7e303c44e632f3088f5f4e42d1d6dd6881ec6451a3b5860adbb88e0adc12cc0d34
|
7
|
+
data.tar.gz: 35925d2e42085f78234223f56db9e406b95f6ff6541d98802ed5dc75056e4f1085a8f98efb1fe7233ce846b3c1ad8d45ec63255413a9a14191b4022b685ebeef
|
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
|
@@ -204,7 +204,7 @@ module SassC
|
|
204
204
|
class << self
|
205
205
|
def resolve_path(path, from_import)
|
206
206
|
ext = File.extname(path)
|
207
|
-
|
207
|
+
unless ext.empty?
|
208
208
|
if from_import
|
209
209
|
result = exactly_one(try_path("#{without_ext(path)}.import#{ext}"))
|
210
210
|
return result unless result.nil?
|
@@ -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 = @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.0
|
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
|
@@ -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.0
|
142
|
+
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.5.0
|
143
143
|
funding_uri: https://github.com/sponsors/ntkme
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|