sassc-embedded 1.0.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -2
- data/lib/sassc/embedded/version.rb +1 -1
- data/lib/sassc/embedded.rb +71 -77
- 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: 4e2addfbb017852dd21ee5479229563bdefe9cc16e09bc24f869be9a373de0e5
|
4
|
+
data.tar.gz: 3440bfd0846119ea58c412e87898d2e195764e81fd443bf29b61eff452702d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9072fe76ae2e6574cc15428e7d270883d8914d3d7c55ab63caa100750755095d3f0b06cf461db20190feb5c82012b5559b8a9fa50dab99e582a423edb0567264
|
7
|
+
data.tar.gz: 1dfe21ca7f48a5e1a8d1a5391cf62ea35dc3ff6bf5eb69673ae20daa549453a2e74d7c7371a744a59ec636f4608281797492bb3f307780e836a33e5c7a48debe
|
data/README.md
CHANGED
@@ -10,6 +10,21 @@ This library polyfills [`sassc`](https://github.com/sass/sassc-ruby) with the [`
|
|
10
10
|
|
11
11
|
## Install
|
12
12
|
|
13
|
+
Add these lines to your application's Gemfile:
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
gem 'sassc', github: 'sass/sassc-ruby', ref: 'refs/pull/233/head'
|
17
|
+
gem 'sassc-embedded'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
``` sh
|
23
|
+
bundle
|
24
|
+
```
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
13
28
|
``` sh
|
14
29
|
gem install sassc-embedded
|
15
30
|
```
|
@@ -29,8 +44,13 @@ See [rubydoc.info/gems/sassc](https://rubydoc.info/gems/sassc) for full API docu
|
|
29
44
|
## Behavioral Differences from SassC Ruby
|
30
45
|
|
31
46
|
1. Option `:style => :nested` behaves as `:expanded`.
|
47
|
+
|
32
48
|
2. Option `:style => :compact` behaves as `:compressed`.
|
49
|
+
|
33
50
|
3. Option `:precision` is ignored.
|
51
|
+
|
34
52
|
4. Option `:line_comments` is ignored.
|
35
|
-
|
36
|
-
|
53
|
+
|
54
|
+
5. In `Importer#imports(path, parent_path)`, argument `path` is set to absolute path, and argument `parent_path` is set to value of option `:filename`.
|
55
|
+
|
56
|
+
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
@@ -39,7 +39,7 @@ module SassC
|
|
39
39
|
@dependencies = result.loaded_urls
|
40
40
|
.filter { |url| url.start_with?('file:') && url != file_url }
|
41
41
|
.map { |url| Util.file_url_to_path(url) }
|
42
|
-
@source_map
|
42
|
+
@source_map = post_process_source_map(result.source_map)
|
43
43
|
|
44
44
|
return post_process_css(result.css) unless quiet?
|
45
45
|
rescue ::Sass::CompileError => e
|
@@ -98,11 +98,7 @@ module SassC
|
|
98
98
|
|
99
99
|
source_map_dir = File.dirname(source_map_file || '')
|
100
100
|
|
101
|
-
if output_path
|
102
|
-
data['file'] = Util::URI_PARSER.escape(
|
103
|
-
relative_path(source_map_dir, output_path)
|
104
|
-
)
|
105
|
-
end
|
101
|
+
data['file'] = Util::URI_PARSER.escape(relative_path(source_map_dir, output_path)) if output_path
|
106
102
|
|
107
103
|
data['sources'].map! do |source|
|
108
104
|
if source.start_with? 'file:'
|
@@ -112,7 +108,7 @@ module SassC
|
|
112
108
|
end
|
113
109
|
end
|
114
110
|
|
115
|
-
|
111
|
+
JSON.generate(data)
|
116
112
|
end
|
117
113
|
|
118
114
|
def post_process_css(css)
|
@@ -121,13 +117,11 @@ module SassC
|
|
121
117
|
url = if source_map_embed?
|
122
118
|
"data:application/json;base64,#{Base64.strict_encode64(@source_map)}"
|
123
119
|
else
|
124
|
-
Util::URI_PARSER.escape(
|
125
|
-
relative_path(File.dirname(output_path || ''), source_map_file)
|
126
|
-
)
|
120
|
+
Util::URI_PARSER.escape(relative_path(File.dirname(output_path || ''), source_map_file))
|
127
121
|
end
|
128
122
|
css += "\n/*# sourceMappingURL=#{url} */"
|
129
123
|
end
|
130
|
-
|
124
|
+
css
|
131
125
|
end
|
132
126
|
|
133
127
|
def relative_path(from, to)
|
@@ -170,7 +164,7 @@ module SassC
|
|
170
164
|
|
171
165
|
def arguments_from_native_list(native_argument_list)
|
172
166
|
native_argument_list.map do |embedded_value|
|
173
|
-
Script::ValueConversion.from_native embedded_value
|
167
|
+
Script::ValueConversion.from_native embedded_value, @options
|
174
168
|
end
|
175
169
|
end
|
176
170
|
|
@@ -229,7 +223,7 @@ module SassC
|
|
229
223
|
return canonical_url
|
230
224
|
end
|
231
225
|
|
232
|
-
canonical_url = "
|
226
|
+
canonical_url = "sassc-embedded:#{canonical_url}"
|
233
227
|
|
234
228
|
imports = @importer.imports path, @importer.options[:filename]
|
235
229
|
unless imports.is_a? Array
|
@@ -238,25 +232,25 @@ module SassC
|
|
238
232
|
imports = [imports]
|
239
233
|
end
|
240
234
|
|
235
|
+
dirname = File.dirname(@importer.options.fetch(:filename, 'stdin'))
|
241
236
|
contents = imports.map do |import|
|
242
|
-
|
243
|
-
import_url = Util.path_to_file_url(import_path)
|
237
|
+
import_url = Util.path_to_file_url(File.absolute_path(import.path, dirname))
|
244
238
|
@importer_results[import_url] = if import.source
|
245
239
|
{
|
246
240
|
contents: import.source,
|
247
241
|
syntax: case import.path
|
248
|
-
when /\.scss$/i
|
249
|
-
:scss
|
250
242
|
when /\.sass$/i
|
251
243
|
:indented
|
252
244
|
when /\.css$/i
|
253
245
|
:css
|
254
246
|
else
|
255
|
-
|
247
|
+
:scss
|
256
248
|
end,
|
257
249
|
source_map_url: if import.source_map_path
|
258
250
|
Util.path_to_file_url(
|
259
|
-
File.absolute_path(
|
251
|
+
File.absolute_path(
|
252
|
+
import.source_map_path, dirname
|
253
|
+
)
|
260
254
|
)
|
261
255
|
end
|
262
256
|
}
|
@@ -282,6 +276,61 @@ module SassC
|
|
282
276
|
|
283
277
|
module Script
|
284
278
|
module ValueConversion
|
279
|
+
def self.from_native(value, options)
|
280
|
+
case value
|
281
|
+
when ::Sass::Value::Null::NULL
|
282
|
+
nil
|
283
|
+
when ::Sass::Value::Boolean
|
284
|
+
::SassC::Script::Value::Bool.new(value.to_bool)
|
285
|
+
when ::Sass::Value::Color
|
286
|
+
if value.instance_eval { defined? @hue }
|
287
|
+
::SassC::Script::Value::Color.new(
|
288
|
+
hue: value.hue,
|
289
|
+
saturation: value.saturation,
|
290
|
+
lightness: value.lightness,
|
291
|
+
alpha: value.alpha
|
292
|
+
)
|
293
|
+
else
|
294
|
+
::SassC::Script::Value::Color.new(
|
295
|
+
red: value.red,
|
296
|
+
green: value.green,
|
297
|
+
blue: value.blue,
|
298
|
+
alpha: value.alpha
|
299
|
+
)
|
300
|
+
end
|
301
|
+
when ::Sass::Value::List
|
302
|
+
::SassC::Script::Value::List.new(
|
303
|
+
value.to_a.map { |element| from_native(element, options) },
|
304
|
+
separator: case value.separator
|
305
|
+
when ','
|
306
|
+
:comma
|
307
|
+
when ' '
|
308
|
+
:space
|
309
|
+
else
|
310
|
+
raise UnsupportedValue, "Sass list separator #{value.separator} unsupported"
|
311
|
+
end,
|
312
|
+
bracketed: value.bracketed?
|
313
|
+
)
|
314
|
+
when ::Sass::Value::Map
|
315
|
+
::SassC::Script::Value::Map.new(
|
316
|
+
value.contents.to_a.to_h { |k, v| [from_native(k, options), from_native(v, options)] }
|
317
|
+
)
|
318
|
+
when ::Sass::Value::Number
|
319
|
+
::SassC::Script::Value::Number.new(
|
320
|
+
value.value,
|
321
|
+
value.numerator_units,
|
322
|
+
value.denominator_units
|
323
|
+
)
|
324
|
+
when ::Sass::Value::String
|
325
|
+
::SassC::Script::Value::String.new(
|
326
|
+
value.text,
|
327
|
+
value.quoted? ? :string : :identifier
|
328
|
+
)
|
329
|
+
else
|
330
|
+
raise UnsupportedValue, "Sass argument of type #{value.class.name.split('::').last} unsupported"
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
285
334
|
def self.to_native(value)
|
286
335
|
case value
|
287
336
|
when nil
|
@@ -304,7 +353,7 @@ module SassC
|
|
304
353
|
alpha: value.alpha
|
305
354
|
)
|
306
355
|
else
|
307
|
-
raise
|
356
|
+
raise UnsupportedValue, "Sass color mode #{value.instance_eval { @mode }} unsupported"
|
308
357
|
end
|
309
358
|
when ::SassC::Script::Value::List
|
310
359
|
::Sass::Value::List.new(
|
@@ -315,7 +364,7 @@ module SassC
|
|
315
364
|
when :space
|
316
365
|
' '
|
317
366
|
else
|
318
|
-
raise
|
367
|
+
raise UnsupportedValue, "Sass list separator #{value.separator} unsupported"
|
319
368
|
end,
|
320
369
|
bracketed: value.bracketed
|
321
370
|
)
|
@@ -336,62 +385,7 @@ module SassC
|
|
336
385
|
quoted: value.type != :identifier
|
337
386
|
)
|
338
387
|
else
|
339
|
-
raise
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
def self.from_native(value)
|
344
|
-
case value
|
345
|
-
when ::Sass::Value::Null::NULL
|
346
|
-
nil
|
347
|
-
when ::Sass::Value::Boolean
|
348
|
-
::SassC::Script::Value::Bool.new(value.to_bool)
|
349
|
-
when ::Sass::Value::Color
|
350
|
-
if value.instance_eval { defined? @hue }
|
351
|
-
::SassC::Script::Value::Color.new(
|
352
|
-
hue: value.hue,
|
353
|
-
saturation: value.saturation,
|
354
|
-
lightness: value.lightness,
|
355
|
-
alpha: value.alpha
|
356
|
-
)
|
357
|
-
else
|
358
|
-
::SassC::Script::Value::Color.new(
|
359
|
-
red: value.red,
|
360
|
-
green: value.green,
|
361
|
-
blue: value.blue,
|
362
|
-
alpha: value.alpha
|
363
|
-
)
|
364
|
-
end
|
365
|
-
when ::Sass::Value::List
|
366
|
-
::SassC::Script::Value::List.new(
|
367
|
-
value.to_a.map { |element| from_native(element) },
|
368
|
-
separator: case value.separator
|
369
|
-
when ','
|
370
|
-
:comma
|
371
|
-
when ' '
|
372
|
-
:space
|
373
|
-
else
|
374
|
-
raise ArgumentError
|
375
|
-
end,
|
376
|
-
bracketed: value.bracketed?
|
377
|
-
)
|
378
|
-
when ::Sass::Value::Map
|
379
|
-
::SassC::Script::Value::Map.new(
|
380
|
-
value.contents.to_a.to_h { |k, v| [from_native(k), from_native(v)] }
|
381
|
-
)
|
382
|
-
when ::Sass::Value::Number
|
383
|
-
::SassC::Script::Value::Number.new(
|
384
|
-
value.value,
|
385
|
-
value.numerator_units,
|
386
|
-
value.denominator_units
|
387
|
-
)
|
388
|
-
when ::Sass::Value::String
|
389
|
-
::SassC::Script::Value::String.new(
|
390
|
-
value.text,
|
391
|
-
value.quoted? ? :string : :identifier
|
392
|
-
)
|
393
|
-
else
|
394
|
-
raise ArgumentError
|
388
|
+
raise UnsupportedValue, "Sass return type #{value.class.name.split('::').last} unsupported"
|
395
389
|
end
|
396
390
|
end
|
397
391
|
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.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-22 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.0.
|
142
|
-
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.0.
|
141
|
+
documentation_uri: https://rubydoc.info/gems/sassc-embedded/1.0.4
|
142
|
+
source_code_uri: https://github.com/ntkme/sassc-embedded-polyfill-ruby/tree/v1.0.4
|
143
143
|
funding_uri: https://github.com/sponsors/ntkme
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|