autoprefixer-rails 8.6.5 → 9.6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.standard.yml +1 -0
- data/.travis.yml +7 -24
- data/CHANGELOG.md +118 -0
- data/Gemfile +10 -1
- data/README.md +27 -27
- data/Rakefile +25 -20
- data/autoprefixer-rails.gemspec +21 -17
- data/lib/autoprefixer-rails.rb +16 -13
- data/lib/autoprefixer-rails/processor.rb +71 -141
- data/lib/autoprefixer-rails/railtie.rb +6 -6
- data/lib/autoprefixer-rails/sprockets.rb +9 -9
- data/lib/autoprefixer-rails/version.rb +1 -1
- data/lib/rake/autoprefixer_tasks.rb +4 -4
- data/spec/app/Rakefile +1 -1
- data/spec/app/app/controllers/css_controller.rb +1 -1
- data/spec/app/config.ru +1 -1
- data/spec/app/config/application.rb +6 -4
- data/spec/app/config/boot.rb +2 -2
- data/spec/app/config/environment.rb +2 -2
- data/spec/app/config/initializers/secret_token.rb +1 -1
- data/spec/app/config/routes.rb +1 -1
- data/spec/autoprefixer_spec.rb +46 -37
- data/spec/processor_spec.rb +16 -5
- data/spec/rails_spec.rb +12 -22
- data/spec/railtie_spec.rb +9 -9
- data/spec/spec_helper.rb +5 -5
- data/vendor/autoprefixer.js +58064 -15703
- metadata +13 -17
- data/mini_racer.gemfile +0 -16
- data/shared.gemfile +0 -7
- data/spec/app/config/initializers/compress.rb +0 -1
- data/spec/compass/config.rb +0 -34
- data/spec/compass/sass/screen.scss +0 -3
- data/spec/compass_spec.rb +0 -21
- data/sprockets3.gemfile +0 -9
- data/sprockets4.gemfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 369fe3501dc13105f85050fb479fa2a5f913929e4d87bd1f487c4feb3fc5554a
|
4
|
+
data.tar.gz: af645ebcb8e0c1f037ab0b793897d47c2e7ffafd1c786206bec6f2782a477737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16fb0528fe567c540fb702ba9f1b34dc7d87a920f0587c7d04acb60c47055761a04e5290d7964164bedca7b71578d989892b9efa9bebf76ab09cd2bbe6365083
|
7
|
+
data.tar.gz: 22d26335e1fa479b7e7b72ca607d66b26734c05f2b6dd13b301d523f2325d532886c49d7acbf5fd60f140733ca5ef0e8fa9370dcae578925928d769c35555bdf
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tidelift: rubygems/autoprefixer-rails
|
data/.standard.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby_version: 2.3
|
data/.travis.yml
CHANGED
@@ -1,30 +1,13 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
2
|
rvm:
|
4
|
-
- "2.
|
5
|
-
- "2.
|
6
|
-
git:
|
7
|
-
depth: 5
|
3
|
+
- "2.6"
|
4
|
+
- "2.5"
|
8
5
|
cache: bundler
|
9
|
-
gemfile:
|
10
|
-
- sprockets3.gemfile
|
11
|
-
- sprockets4.gemfile
|
12
|
-
- mini_racer.gemfile
|
13
6
|
before_install:
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
# mini_racer / rubyracer or rubyrhino depending on platform:
|
18
|
-
-
|
7
|
+
- gem update --system
|
8
|
+
- nvm install node
|
9
|
+
env: "EXECJS_RUNTIME=MiniRacer"
|
19
10
|
matrix:
|
20
|
-
|
21
|
-
- rvm: "2.
|
11
|
+
include:
|
12
|
+
- rvm: "2.6"
|
22
13
|
env: "EXECJS_RUNTIME=Node"
|
23
|
-
- rvm: "2.3.5"
|
24
|
-
gemfile: mini_racer.gemfile
|
25
|
-
|
26
|
-
- rvm: "2.4.2"
|
27
|
-
gemfile: sprockets3.gemfile
|
28
|
-
|
29
|
-
- env: "EXECJS_RUNTIME=Node"
|
30
|
-
gemfile: mini_racer.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,123 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 9.6.1.1
|
4
|
+
* Update Can I Use data.
|
5
|
+
|
6
|
+
## 9.6.1
|
7
|
+
* Fix `-webkit-line-clamp` truncating multi-line text support.
|
8
|
+
|
9
|
+
## 9.6 “Nunc id vides, nunc ne vides”
|
10
|
+
* Add warning-less `overrideBrowserslist` option.
|
11
|
+
* Add `text-orientation` support.
|
12
|
+
* Add `min-resolution: 2x` alias support.
|
13
|
+
|
14
|
+
## 9.5.1.1
|
15
|
+
* Fix `register_postprocessor' for nil:NilClass` error.
|
16
|
+
* Update Can I Use data.
|
17
|
+
|
18
|
+
## 9.5.1
|
19
|
+
* Fix `backdrop-filter` for Edge (by Oleh Aloshkin).
|
20
|
+
* Fix `min-resolution` media query support in Firefox < 16.
|
21
|
+
|
22
|
+
## 9.5 “Draco dormiens nunquam titillandus”
|
23
|
+
* Add `mask-composite` support (by Semen Levenson).
|
24
|
+
|
25
|
+
## 9.4.10.2
|
26
|
+
* Fix Ruby < 2.4 support (by Jack Ford).
|
27
|
+
* Update Can I Use data.
|
28
|
+
|
29
|
+
## 9.4.10.1
|
30
|
+
* Fix non-Rails environments support (by Junya Ogura).
|
31
|
+
* Update Can I Use data.
|
32
|
+
|
33
|
+
## 9.4.10
|
34
|
+
* Add warning for named Grid rows.
|
35
|
+
|
36
|
+
## 9.4.9
|
37
|
+
* Fix `grid-template` and `@media` case (by Bogdan Dolin).
|
38
|
+
|
39
|
+
## 9.4.8
|
40
|
+
* Fix `calc()` support in Grid gap.
|
41
|
+
|
42
|
+
## 9.4.7
|
43
|
+
* Fix infinite loop on mismatched parens.
|
44
|
+
|
45
|
+
## 9.4.6
|
46
|
+
* Fix warning text (by Albert Juhé Lluveras).
|
47
|
+
|
48
|
+
## 9.4.5
|
49
|
+
* Fix `text-decoration-skip-ink` support.
|
50
|
+
|
51
|
+
## 9.4.4
|
52
|
+
* Use `direction` value for `-ms-writing-mode` (by Denys Kniazevych).
|
53
|
+
* Fix warning text (by @zzzzBov).
|
54
|
+
|
55
|
+
## 9.4.3
|
56
|
+
* Add warning to force `flex-start` instead of `start` (by Antoine du Hamel).
|
57
|
+
|
58
|
+
## 9.4.2
|
59
|
+
* Fix Grid autoplacement warning.
|
60
|
+
|
61
|
+
## 9.4.1
|
62
|
+
* Fix unnecessary Flexbox prefixes in Grid elements.
|
63
|
+
|
64
|
+
## 9.4 “Advance Australia”
|
65
|
+
* Add Grid autoplacement for `-ms-` (by Bogdan Dolin).
|
66
|
+
* Improve warnings (by Daniel Tonon).
|
67
|
+
* Remove some unnecessary warnings for Grid (by Andrey Alexandrov).
|
68
|
+
|
69
|
+
## 9.3.1
|
70
|
+
* Fix Grid prefixes with `repeat()` value (by Bogdan Dolin).
|
71
|
+
|
72
|
+
## 9.3 “Labor omnia vincit”
|
73
|
+
* Add `place-self` support (by Bogdan Dolin).
|
74
|
+
* Fix Grid row/column span inheritance bug (by Bogdan Dolin).
|
75
|
+
|
76
|
+
## 9.2.1
|
77
|
+
* Update Can I Use data.
|
78
|
+
|
79
|
+
## 9.2 “Ony est glavnaya krepost”
|
80
|
+
* Add `/* autoprefixer grid: on */` control comment (by Andrey Alexandrov).
|
81
|
+
* Add duplicate `grid-area` support (by Bogdan Dolin).
|
82
|
+
* Fix `grid-gap` support for rules with different specifity (by Bogdan Dolin).
|
83
|
+
* Disable Grid in `@supports` at-rule with non-supported Grid features.
|
84
|
+
* Improve Grid warnings (by Daniel Tonon).
|
85
|
+
|
86
|
+
## 9.1.4
|
87
|
+
* Fix `ExecJS` runtime test (by Patrice Chalin).
|
88
|
+
|
89
|
+
## 9.1.3
|
90
|
+
* Sort properties in `rake autoprefixer` alphabetically.
|
91
|
+
* Fix old Firefox gradient prefix.
|
92
|
+
|
93
|
+
## 9.1.2
|
94
|
+
* Fix `autoprefixer --info` in new Node.js.
|
95
|
+
* Fix ExecJS runtime warning.
|
96
|
+
|
97
|
+
## 9.1.1
|
98
|
+
* Retain `grid-gap` through `@media` (by Bogdan Dolin).
|
99
|
+
* Fix `grid-template` and `@media` (by Bogdan Dolin).
|
100
|
+
* Fix Grid areas searching error (by Bogdan Dolin).
|
101
|
+
* Fix `span X` Grid prefix (by Bogdan Dolin).
|
102
|
+
* Fix `log2` error.
|
103
|
+
|
104
|
+
## 9.1 “Equality before the law”
|
105
|
+
* Add `background-clip: text` support.
|
106
|
+
* Fix adding Grid span for IE (by Bogdan).
|
107
|
+
|
108
|
+
## 9.0.2
|
109
|
+
* Show warning on Grid area names conflict (by Bogdan).
|
110
|
+
* Fix ExecJS warning (by Jan Kmet).
|
111
|
+
|
112
|
+
## 9.0.1
|
113
|
+
* Fix nested at-rules in Grid prefixes (by Ivan Malov).
|
114
|
+
|
115
|
+
## 9.0 “A Mari Usque Ad Mare”
|
116
|
+
* Remove Node.js 9 and Node.js 4 support.
|
117
|
+
* Remove RubyRacer and Sprockets 3 support.
|
118
|
+
* Use PostCSS 7.0.
|
119
|
+
* Use Browserslist 4.0.
|
120
|
+
|
3
121
|
## 8.6.5
|
4
122
|
* Do not show Grid warnings if IE was not selected.
|
5
123
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -28,8 +28,17 @@ Autoprefixer Rails doesn’t support these Autoprefixer features:
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
Windows users should install [
|
32
|
-
|
31
|
+
Windows users should install [Node.js]. Autoprefixer Rails doesn’t work with
|
32
|
+
old JScript in Windows.
|
33
|
+
|
34
|
+
Autoprefixer Rails uses [ExecJS] that will use the best available JavaScript
|
35
|
+
runtime. Currently this gem is tested to work with Node.js version 6 and up and
|
36
|
+
with [mini_racer], but will not work with [therubyracer].
|
37
|
+
|
38
|
+
[Node.js]: http://nodejs.org/
|
39
|
+
[ExecJS]: https://github.com/rails/execjs
|
40
|
+
[mini_racer]: https://github.com/discourse/mini_racer
|
41
|
+
[therubyracer]: https://github.com/cowboyd/therubyracer
|
33
42
|
|
34
43
|
### Ruby on Rails
|
35
44
|
|
@@ -78,26 +87,15 @@ support to add vendor prefixes automatically using the Asset Pipeline:
|
|
78
87
|
}
|
79
88
|
```
|
80
89
|
|
81
|
-
If you need to specify browsers for your Rails project, you can save them
|
82
|
-
|
83
|
-
|
84
|
-
or any of its ancestor directories
|
85
|
-
|
86
|
-
```
|
87
|
-
> 1%
|
88
|
-
last 2 versions
|
89
|
-
IE > 8 # comment
|
90
|
-
```
|
90
|
+
If you need to specify browsers for your Rails project, you can save them
|
91
|
+
to `.browserslistrc` and place it under `app/assets/stylesheets/`
|
92
|
+
or any of its ancestor directories
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
- "> 1%"
|
98
|
-
- "last 2 versions"
|
99
|
-
- "IE > 8"
|
100
|
-
```
|
94
|
+
```
|
95
|
+
> 1%
|
96
|
+
last 2 versions
|
97
|
+
IE > 8 # comment
|
98
|
+
```
|
101
99
|
|
102
100
|
See [Browserslist docs] for config format. But `> 5% in US` query is not
|
103
101
|
supported in Rails, because of ExecJS limitations. You should migrate to webpack
|
@@ -145,12 +143,6 @@ require "autoprefixer-rails"
|
|
145
143
|
prefixed = AutoprefixerRails.process(css, from: 'main.css').css
|
146
144
|
```
|
147
145
|
|
148
|
-
You can specify browsers with the `browsers` option:
|
149
|
-
|
150
|
-
```ruby
|
151
|
-
AutoprefixerRails.process(css, from: 'a.css', browsers: ['> 1%', 'ie 10']).css
|
152
|
-
```
|
153
|
-
|
154
146
|
### Compass
|
155
147
|
|
156
148
|
You should consider using Gulp instead of Compass binary,
|
@@ -235,3 +227,11 @@ to JS style, so you can use `map: { sources_content: false }`
|
|
235
227
|
instead of camelcase `sourcesContent`.
|
236
228
|
|
237
229
|
[PostCSS docs]: https://github.com/postcss/postcss#source-map-1
|
230
|
+
|
231
|
+
|
232
|
+
## Security Contact
|
233
|
+
|
234
|
+
To report a security vulnerability, please use the [Tidelift security contact].
|
235
|
+
Tidelift will coordinate the fix and disclosure.
|
236
|
+
|
237
|
+
[Tidelift security contact]: https://tidelift.com/security
|
data/Rakefile
CHANGED
@@ -1,31 +1,36 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
1
|
+
require "rubygems"
|
3
2
|
|
4
|
-
require
|
3
|
+
require "bundler/setup"
|
5
4
|
Bundler::GemHelper.install_tasks
|
6
5
|
|
7
|
-
require
|
6
|
+
require "standard/rake"
|
7
|
+
|
8
|
+
require "rspec/core/rake_task"
|
8
9
|
RSpec::Core::RakeTask.new
|
9
|
-
task :
|
10
|
+
task default: [:spec, "standard:fix"]
|
10
11
|
|
11
12
|
task :clobber_package do
|
12
|
-
|
13
|
+
begin
|
14
|
+
rm_r "pkg"
|
15
|
+
rescue
|
16
|
+
nil
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
|
-
desc
|
16
|
-
task :
|
20
|
+
desc "Delete all generated files"
|
21
|
+
task clobber: [:clobber_package]
|
17
22
|
|
18
|
-
desc
|
23
|
+
desc "Test all Gemfiles from spec/*.gemfile"
|
19
24
|
task :test_all do
|
20
|
-
require
|
21
|
-
require
|
22
|
-
cmd =
|
23
|
-
statuses = Dir.glob(
|
25
|
+
require "pty"
|
26
|
+
require "shellwords"
|
27
|
+
cmd = "bundle update && bundle exec rake --trace"
|
28
|
+
statuses = Dir.glob("./sprockets*.gemfile").map { |gemfile|
|
24
29
|
Bundler.with_clean_env do
|
25
|
-
env = {
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
env = {"BUNDLE_GEMFILE" => gemfile}
|
31
|
+
warn "Testing #{File.basename(gemfile)}:"
|
32
|
+
warn " export BUNDLE_GEMFILE=#{gemfile}"
|
33
|
+
warn " #{cmd}"
|
29
34
|
PTY.spawn(env, cmd) do |r, _w, pid|
|
30
35
|
begin
|
31
36
|
r.each_line { |l| puts l }
|
@@ -37,12 +42,12 @@ task :test_all do
|
|
37
42
|
end
|
38
43
|
[$? && $?.exitstatus == 0, gemfile]
|
39
44
|
end
|
40
|
-
|
45
|
+
}
|
41
46
|
failed = statuses.reject(&:first).map(&:last)
|
42
47
|
if failed.empty?
|
43
|
-
|
48
|
+
warn "✓ Tests pass with all #{statuses.size} gemfiles"
|
44
49
|
else
|
45
|
-
|
50
|
+
warn "❌ FAILING #{failed * "\n"}"
|
46
51
|
exit 1
|
47
52
|
end
|
48
53
|
end
|
data/autoprefixer-rails.gemspec
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../lib/autoprefixer-rails/version", __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
|
-
s.name =
|
5
|
+
s.name = "autoprefixer-rails"
|
6
6
|
s.version = AutoprefixerRails::VERSION.dup
|
7
|
-
s.date = Time.now.strftime(
|
8
|
-
s.summary =
|
9
|
-
|
7
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
8
|
+
s.summary = "Parse CSS and add vendor prefixes to CSS rules using" \
|
9
|
+
"values from the Can I Use website."
|
10
10
|
|
11
11
|
s.files = `git ls-files`.split("\n")
|
12
12
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
13
|
-
s.extra_rdoc_files = [
|
14
|
-
s.require_path =
|
15
|
-
s.required_ruby_version =
|
13
|
+
s.extra_rdoc_files = ["README.md", "LICENSE", "CHANGELOG.md"]
|
14
|
+
s.require_path = "lib"
|
15
|
+
s.required_ruby_version = ">= 2.0"
|
16
16
|
|
17
|
-
s.author =
|
18
|
-
s.email =
|
19
|
-
s.homepage =
|
20
|
-
s.license =
|
17
|
+
s.author = "Andrey Sitnik"
|
18
|
+
s.email = "andrey@sitnik.ru"
|
19
|
+
s.homepage = "https://github.com/ai/autoprefixer-rails"
|
20
|
+
s.license = "MIT"
|
21
21
|
|
22
|
-
s.add_dependency
|
22
|
+
s.add_dependency "execjs", ">= 0"
|
23
23
|
|
24
|
-
s.add_development_dependency
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
s.add_development_dependency "rails"
|
26
|
+
s.add_development_dependency "rspec-rails"
|
27
|
+
s.add_development_dependency "standard"
|
28
|
+
|
29
|
+
s.metadata["changelog_uri"] = "https://github.com/ai/autoprefixer-rails/blob/master/CHANGELOG.md"
|
30
|
+
s.metadata["source_code_uri"] = "https://github.com/ai/autoprefixer-rails"
|
31
|
+
s.metadata["bug_tracker_uri"] = "https://github.com/ai/autoprefixer-rails/issues"
|
28
32
|
end
|
data/lib/autoprefixer-rails.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
# Ruby integration with Autoprefixer JS library, which parse CSS and adds
|
2
2
|
# only actual prefixed
|
3
3
|
module AutoprefixerRails
|
4
|
-
autoload :Sprockets,
|
4
|
+
autoload :Sprockets, "autoprefixer-rails/sprockets"
|
5
5
|
|
6
6
|
# Add prefixes to `css`. See `Processor#process` for options.
|
7
|
-
def self.process(css, opts = {
|
8
|
-
params = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
params[:
|
7
|
+
def self.process(css, opts = {})
|
8
|
+
params = {}
|
9
|
+
if opts.key?(:overrideBrowserslist)
|
10
|
+
params[:overrideBrowserslist] = opts.delete(:overrideBrowserslist)
|
11
|
+
end
|
12
|
+
params[:browsers] = opts.delete(:browsers) if opts.key?(:browsers)
|
13
|
+
params[:cascade] = opts.delete(:cascade) if opts.key?(:cascade)
|
14
|
+
params[:remove] = opts.delete(:remove) if opts.key?(:remove)
|
15
|
+
params[:env] = opts.delete(:env) if opts.key?(:env)
|
13
16
|
processor(params).process(css, opts)
|
14
17
|
end
|
15
18
|
|
16
19
|
# Add Autoprefixer for Sprockets environment in `assets`.
|
17
20
|
# You can specify `browsers` actual in your project.
|
18
|
-
def self.install(assets, params = {
|
21
|
+
def self.install(assets, params = {})
|
19
22
|
Sprockets.register_processor(processor(params))
|
20
23
|
Sprockets.install(assets)
|
21
24
|
end
|
@@ -26,13 +29,13 @@ module AutoprefixerRails
|
|
26
29
|
end
|
27
30
|
|
28
31
|
# Cache processor instances
|
29
|
-
def self.processor(params = {
|
32
|
+
def self.processor(params = {})
|
30
33
|
Processor.new(params)
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
34
|
-
require_relative
|
35
|
-
require_relative
|
36
|
-
require_relative
|
37
|
+
require_relative "autoprefixer-rails/result"
|
38
|
+
require_relative "autoprefixer-rails/version"
|
39
|
+
require_relative "autoprefixer-rails/processor"
|
37
40
|
|
38
|
-
require_relative
|
41
|
+
require_relative "autoprefixer-rails/railtie" if defined?(Rails)
|
@@ -1,15 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "pathname"
|
2
|
+
require "execjs"
|
3
|
+
require "json"
|
4
4
|
|
5
5
|
IS_SECTION = /^\s*\[(.+)\]\s*$/
|
6
6
|
|
7
7
|
module AutoprefixerRails
|
8
8
|
# Ruby to JS wrapper for Autoprefixer processor instance
|
9
9
|
class Processor
|
10
|
-
|
11
|
-
|
12
|
-
@params = params || { }
|
10
|
+
def initialize(params = {})
|
11
|
+
@params = params || {}
|
13
12
|
end
|
14
13
|
|
15
14
|
# Process `css` and return result.
|
@@ -18,85 +17,79 @@ module AutoprefixerRails
|
|
18
17
|
# * `from` with input CSS file name. Will be used in error messages.
|
19
18
|
# * `to` with output CSS file name.
|
20
19
|
# * `map` with true to generate new source map or with previous map.
|
21
|
-
def process(css, opts = {
|
20
|
+
def process(css, opts = {})
|
22
21
|
opts = convert_options(opts)
|
23
22
|
|
24
23
|
apply_wrapper =
|
25
|
-
"(function(opts, pluginOpts) {"
|
26
|
-
"return eval(process.apply(this, opts, pluginOpts));"
|
24
|
+
"(function(opts, pluginOpts) {" \
|
25
|
+
"return eval(process.apply(this, opts, pluginOpts));" \
|
27
26
|
"})"
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
from:
|
32
|
-
to:
|
33
|
-
map:
|
28
|
+
plugin_opts = params_with_browsers(opts[:from]).merge(opts)
|
29
|
+
process_opts = {
|
30
|
+
from: plugin_opts.delete(:from),
|
31
|
+
to: plugin_opts.delete(:to),
|
32
|
+
map: plugin_opts.delete(:map),
|
34
33
|
}
|
35
34
|
|
36
35
|
begin
|
37
|
-
result = runtime.call(apply_wrapper, [css,
|
36
|
+
result = runtime.call(apply_wrapper, [css, process_opts, plugin_opts])
|
38
37
|
rescue ExecJS::ProgramError => e
|
39
|
-
contry_error =
|
40
|
-
|
41
|
-
|
38
|
+
contry_error = "BrowserslistError: " \
|
39
|
+
"Country statistics is not supported " \
|
40
|
+
"in client-side build of Browserslist"
|
42
41
|
if e.message == contry_error
|
43
|
-
raise
|
44
|
-
|
42
|
+
raise "Country statistics is not supported in AutoprefixerRails. " \
|
43
|
+
"Use Autoprefixer with webpack or other Node.js builder."
|
45
44
|
else
|
46
45
|
raise e
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
Result.new(result[
|
49
|
+
Result.new(result["css"], result["map"], result["warnings"])
|
51
50
|
end
|
52
51
|
|
53
52
|
# Return, which browsers and prefixes will be used
|
54
53
|
def info
|
55
|
-
runtime.eval("autoprefixer(#{
|
54
|
+
runtime.eval("autoprefixer(#{js_params}).info()")
|
56
55
|
end
|
57
56
|
|
58
57
|
# Parse Browserslist config
|
59
58
|
def parse_config(config)
|
60
|
-
sections = {
|
61
|
-
current =
|
62
|
-
config.gsub(/#[^\n]*/,
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
sections = {"defaults" => []}
|
60
|
+
current = "defaults"
|
61
|
+
config.gsub(/#[^\n]*/, "")
|
62
|
+
.split(/\n/)
|
63
|
+
.map(&:strip)
|
64
|
+
.reject(&:empty?)
|
65
|
+
.each do |line|
|
66
|
+
if IS_SECTION =~ line
|
67
|
+
current = line.match(IS_SECTION)[1].strip
|
68
|
+
sections[current] ||= []
|
69
|
+
else
|
70
|
+
sections[current] << line
|
71
|
+
end
|
72
|
+
end
|
74
73
|
sections
|
75
74
|
end
|
76
75
|
|
77
76
|
private
|
78
77
|
|
79
78
|
def params_with_browsers(from = nil)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
from = '.'
|
85
|
-
end
|
79
|
+
from ||= if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
|
80
|
+
Rails.root.join("app/assets/stylesheets").to_s
|
81
|
+
else
|
82
|
+
"."
|
86
83
|
end
|
87
84
|
|
88
85
|
params = @params
|
89
|
-
if
|
86
|
+
if !params.key?(:browsers) && !params.key?(:overrideBrowserslist) && from
|
90
87
|
file = find_config(from)
|
91
88
|
if file
|
92
|
-
env = params[:env].to_s ||
|
89
|
+
env = params[:env].to_s || "development"
|
93
90
|
config = parse_config(file)
|
94
91
|
params = params.dup
|
95
|
-
|
96
|
-
params[:browsers] = config[env]
|
97
|
-
else
|
98
|
-
params[:browsers] = config['defaults']
|
99
|
-
end
|
92
|
+
params[:overrideBrowserslist] = (config[env] || config["defaults"])
|
100
93
|
end
|
101
94
|
end
|
102
95
|
|
@@ -105,18 +98,18 @@ module AutoprefixerRails
|
|
105
98
|
|
106
99
|
# Convert params to JS string and add browsers from Browserslist config
|
107
100
|
def js_params
|
108
|
-
|
109
|
-
params_with_browsers.map { |k, v| "#{k}: #{v.inspect}"}.join(
|
110
|
-
|
101
|
+
"{ " +
|
102
|
+
params_with_browsers.map { |k, v| "#{k}: #{v.inspect}"}.join(", ") +
|
103
|
+
" }"
|
111
104
|
end
|
112
105
|
|
113
106
|
# Convert ruby_options to jsOptions
|
114
107
|
def convert_options(opts)
|
115
|
-
converted = {
|
108
|
+
converted = {}
|
116
109
|
|
117
110
|
opts.each_pair do |name, value|
|
118
|
-
if
|
119
|
-
name = name.to_s.gsub(/_\w/) { |i| i.
|
111
|
+
if /_/ =~ name
|
112
|
+
name = name.to_s.gsub(/_\w/) { |i| i.delete("_").upcase }.to_sym
|
120
113
|
end
|
121
114
|
value = convert_options(value) if value.is_a? Hash
|
122
115
|
converted[name] = value
|
@@ -130,11 +123,11 @@ module AutoprefixerRails
|
|
130
123
|
path = Pathname(file).expand_path
|
131
124
|
|
132
125
|
while path.parent != path
|
133
|
-
config1 = path.join(
|
134
|
-
return config1.read if config1.exist?
|
126
|
+
config1 = path.join("browserslist")
|
127
|
+
return config1.read if config1.exist? && !config1.directory?
|
135
128
|
|
136
|
-
config2 = path.join(
|
137
|
-
return config2.read if config2.exist?
|
129
|
+
config2 = path.join(".browserslistrc")
|
130
|
+
return config2.read if config2.exist? && !config1.directory?
|
138
131
|
|
139
132
|
path = path.parent
|
140
133
|
end
|
@@ -145,9 +138,23 @@ module AutoprefixerRails
|
|
145
138
|
# Lazy load for JS library
|
146
139
|
def runtime
|
147
140
|
@runtime ||= begin
|
148
|
-
if ExecJS.eval(
|
149
|
-
|
150
|
-
|
141
|
+
if ExecJS.eval("typeof Uint8Array") != "function"
|
142
|
+
if ExecJS.runtime.name.start_with?("therubyracer")
|
143
|
+
raise "ExecJS::RubyRacerRuntime is not supported. " \
|
144
|
+
"Please replace therubyracer with mini_racer " \
|
145
|
+
"in your Gemfile or use Node.js as ExecJS runtime."
|
146
|
+
else
|
147
|
+
raise "#{ExecJS.runtime.name} runtime does’t support ES6. " \
|
148
|
+
"Please update or replace your current ExecJS runtime."
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
if ExecJS.runtime == ExecJS::Runtimes::Node
|
153
|
+
version = ExecJS.runtime.eval("process.version")
|
154
|
+
first = version.match(/^v(\d+)/)[1].to_i
|
155
|
+
if first < 6
|
156
|
+
raise "Autoprefixer doesn’t support Node #{version}. Update it."
|
157
|
+
end
|
151
158
|
end
|
152
159
|
|
153
160
|
ExecJS.compile(build_js)
|
@@ -159,90 +166,13 @@ module AutoprefixerRails
|
|
159
166
|
@@js ||= begin
|
160
167
|
root = Pathname(File.dirname(__FILE__))
|
161
168
|
path = root.join("../../vendor/autoprefixer.js")
|
162
|
-
path.read
|
169
|
+
path.read
|
163
170
|
end
|
164
171
|
end
|
165
172
|
|
166
|
-
def polyfills
|
167
|
-
<<-JS
|
168
|
-
if (typeof Uint8Array === "undefined")
|
169
|
-
global.Uint8Array = Array;
|
170
|
-
if (typeof ArrayBuffer === "undefined")
|
171
|
-
global.ArrayBuffer = Array;
|
172
|
-
if (typeof Set === "undefined") {
|
173
|
-
global.Set = function (values) { this.values = values }
|
174
|
-
global.Set.prototype = {
|
175
|
-
has: function (i) { return this.values.indexOf(i) !== -1 }
|
176
|
-
}
|
177
|
-
}
|
178
|
-
if (typeof Map === "undefined") {
|
179
|
-
global.Map = function () { this.data = { } }
|
180
|
-
global.Map.prototype = {
|
181
|
-
set: function (k, v) { this.data[k] = v },
|
182
|
-
get: function (k) { return this.data[k] },
|
183
|
-
has: function (k) {
|
184
|
-
return Object.keys(this.data).indexOf(k) !== -1
|
185
|
-
},
|
186
|
-
}
|
187
|
-
}
|
188
|
-
Math.log2 = Math.log2 ||
|
189
|
-
function(x) { return Math.log(x) * Math.LOG2E; };
|
190
|
-
Math.sign = Math.sign ||
|
191
|
-
function(x) {
|
192
|
-
x = +x;
|
193
|
-
if (x === 0 || isNaN(x)) return Number(x);
|
194
|
-
return x > 0 ? 1 : -1;
|
195
|
-
};
|
196
|
-
Array.prototype.fill = Array.prototype.fill ||
|
197
|
-
function(value) {
|
198
|
-
var O = Object(this);
|
199
|
-
var len = O.length >>> 0;
|
200
|
-
var start = arguments[1];
|
201
|
-
var relativeStart = start >> 0;
|
202
|
-
var k = relativeStart < 0 ?
|
203
|
-
Math.max(len + relativeStart, 0) :
|
204
|
-
Math.min(relativeStart, len);
|
205
|
-
var end = arguments[2];
|
206
|
-
var relativeEnd = end === undefined ?
|
207
|
-
len : end >> 0;
|
208
|
-
var final = relativeEnd < 0 ?
|
209
|
-
Math.max(len + relativeEnd, 0) :
|
210
|
-
Math.min(relativeEnd, len);
|
211
|
-
while (k < final) {
|
212
|
-
O[k] = value;
|
213
|
-
k++;
|
214
|
-
}
|
215
|
-
return O;
|
216
|
-
};
|
217
|
-
if (!Object.assign) {
|
218
|
-
Object.assign = function(target, firstSource) {
|
219
|
-
var to = Object(target);
|
220
|
-
for (var i = 1; i < arguments.length; i++) {
|
221
|
-
var nextSource = arguments[i];
|
222
|
-
if (nextSource === undefined || nextSource === null) continue;
|
223
|
-
var keysArray = Object.keys(Object(nextSource));
|
224
|
-
for (var n = 0, len = keysArray.length; n < len; n++) {
|
225
|
-
var nextKey = keysArray[n];
|
226
|
-
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
227
|
-
if (desc !== undefined && desc.enumerable) {
|
228
|
-
to[nextKey] = nextSource[nextKey];
|
229
|
-
}
|
230
|
-
}
|
231
|
-
}
|
232
|
-
return to;
|
233
|
-
}
|
234
|
-
}
|
235
|
-
if (!Array.isView) {
|
236
|
-
Array.isView = function () {
|
237
|
-
return false
|
238
|
-
}
|
239
|
-
}
|
240
|
-
JS
|
241
|
-
end
|
242
|
-
|
243
173
|
# Return processor JS with some extra methods
|
244
174
|
def build_js
|
245
|
-
|
175
|
+
"var global = this;" + read_js + process_proxy
|
246
176
|
end
|
247
177
|
|
248
178
|
# Return JS code for process method proxy
|