autoprefixer-rails 9.8.5 → 10.4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +95 -0
  3. data/README.md +9 -8
  4. data/lib/autoprefixer-rails/processor.rb +43 -72
  5. data/lib/autoprefixer-rails/railtie.rb +15 -10
  6. data/lib/autoprefixer-rails/result.rb +2 -0
  7. data/lib/autoprefixer-rails/sprockets.rb +7 -5
  8. data/lib/autoprefixer-rails/version.rb +4 -2
  9. data/lib/autoprefixer-rails.rb +3 -3
  10. data/lib/rake/autoprefixer_tasks.rb +2 -0
  11. data/vendor/autoprefixer.js +72678 -65743
  12. metadata +40 -38
  13. data/Rakefile +0 -53
  14. data/autoprefixer-rails.gemspec +0 -33
  15. data/spec/app/.browserslistrc +0 -4
  16. data/spec/app/.gitignore +0 -2
  17. data/spec/app/Rakefile +0 -2
  18. data/spec/app/app/assets/config/manifest.js +0 -0
  19. data/spec/app/app/assets/stylesheets/evaluate.css.erb +0 -1
  20. data/spec/app/app/assets/stylesheets/loaded.sass +0 -2
  21. data/spec/app/app/assets/stylesheets/sass.sass +0 -1
  22. data/spec/app/app/assets/stylesheets/test.css +0 -3
  23. data/spec/app/app/assets/stylesheets/wrong.css +0 -2
  24. data/spec/app/app/controllers/application_controller.rb +0 -2
  25. data/spec/app/app/controllers/css_controller.rb +0 -6
  26. data/spec/app/config/application.rb +0 -16
  27. data/spec/app/config/autoprefixer.yml +0 -2
  28. data/spec/app/config/boot.rb +0 -2
  29. data/spec/app/config/environment.rb +0 -3
  30. data/spec/app/config/environments/test.rb +0 -9
  31. data/spec/app/config/initializers/secret_token.rb +0 -1
  32. data/spec/app/config/routes.rb +0 -3
  33. data/spec/app/config.ru +0 -2
  34. data/spec/autoprefixer_spec.rb +0 -121
  35. data/spec/processor_spec.rb +0 -25
  36. data/spec/rails_spec.rb +0 -40
  37. data/spec/railtie_spec.rb +0 -29
  38. data/spec/spec_helper.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5182124a6fefc07d412d82b244a521dd3094a1d7bc1bcd481156ea53d19082a
4
- data.tar.gz: 8efdba7a1317cd31cb68fd67ef782fa32e8ced7b208ac806f6d7af9c0e0bb3b2
3
+ metadata.gz: 57c218760a92a4c4449c643e59d5c9b99d187c228aaa68c563d03c468fc2a055
4
+ data.tar.gz: fa282be312c5ad55816deb7475a3d2f3357266a806ac96a624f125f2f0d0fc4b
5
5
  SHA512:
6
- metadata.gz: ca048733118764ce88990487ceec91f39732a5ba6e84de4dbecc9bb2c9f306ebbb0296726c50582e0c3487d00a41870bd229365774dd605fecebdb284f57db67
7
- data.tar.gz: 0604ebbbd9e25c9cdca72ba0143f871a8df9eb211073de53d6864c5e276139601f26a47272d9458de8c6925431fc04f960d5a3c541ff29cad0f680b2ca5c43cc
6
+ metadata.gz: f20ccf58b1661fe3082f9d0487979c42146b21115df430269ca6d7a3a35dfa2f44cb04c1f4f3eb01eaf00bd360f4823d00106101c38bb80a8c278e4d9b764ed4
7
+ data.tar.gz: beb69b97fb7f92d970fae59bfefff484b1f59973bfcf26b049ecbc738a61db9044e660040531b0f959cb50f17f6ec5412ee8b1f226ba30b0cec359e902ac9bfa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,100 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.4.2.0
4
+ * Fixed missed `-webkit-` prefix for `width: stretch`.
5
+ * Fixed `::file-selector-button` data (by Luke Warlow).
6
+ * Ensure sprockets-rails is loaded before autoprefixer-rails (by Thomas Morgan)
7
+
8
+ ## 10.4.0.0
9
+ * Added `:autofill` support (by Luke Warlow).
10
+
11
+ ## 10.3.3.0
12
+ * Fixed `::file-selector-button` support (by Usman Yunusov).
13
+ * Fixed wrong `-moz-` prefix from `::file-selector-button` (by Usman Yunusov).
14
+
15
+ ## 10.3.1.0
16
+ * Added `::file-selector-button` support (by Luke Warlow).
17
+ * Fixed adding wrong prefixes to `content` (by Luke Warlow).
18
+ * Fix `ReferenceError: Can't find variable: URL` (#213)
19
+
20
+ ## 10.2.5.1
21
+ * Remove nodejs version check via ExecJS, to be compatible with 2.8.1 (#203)
22
+
23
+ ## 10.2.5.0
24
+ * Fixed `:` support in `@supports` (by Dmitry Semigradsky).
25
+ * Update Can I Use data.
26
+ * Lock to execjs < 2.8.0 for now (#203)
27
+
28
+ ## 10.2.4.0
29
+ * Fixed `transition-property` warnings (by @Sheraff).
30
+
31
+ ## 10.2.0.0 "Sub rosa"
32
+ * Added TypeScript definitions (by Dmitry Semigradsky).
33
+ * Fixed docs (by Florian Pellet).
34
+ * Update Can I Use data.
35
+ * Update postcss to 8.2.2
36
+
37
+ ## 10.1.0.0 "Pula"
38
+ * Fixed `Cannot read property 'proxyOf' of undefined` error (by Igor Kamyshev).
39
+ * Added `dpcm` unit support to `min-resolution: 2dppx` (by Robert Eisele).
40
+ * Fixed rational approximation in `min-resolution` (by Robert Eisele).
41
+
42
+ ## 10.0.3.0
43
+ * Fixed `substract` to `subtract` value for `mask-composite` (by Michelle Enos).
44
+ * Update Can I Use data
45
+
46
+ ## 10.0.2.0
47
+ * Removed -ms-user-select: all because IE and old Edge don’t support it.
48
+ * Fixed Grid Layout warning.
49
+ * Update Can I Use data
50
+
51
+ ## 10.0.1.3
52
+ * Fix `fileURL.replace is not a function` when reporting warnings (#194)
53
+
54
+ ## 10.0.1.2
55
+ * Workaround `existsSync not a function` (#193)
56
+
57
+ ## 10.0.1.1
58
+ * Update Can I Use data.
59
+ * Update postcss to 8.1.4
60
+ * Fix issue with source map (#190)
61
+
62
+ ## 10.0.1.0
63
+ * Update Can I Use data.
64
+ * Update autoprefixer to 10.0.1
65
+ * Update postcss to 8.1.1
66
+
67
+ ## 10.0.0.2
68
+ * Update postcss to 8.0.5
69
+ * Update browserslist & caniuse-lite
70
+
71
+ ## 10.0.0.1
72
+ * Improved error message for old environments.
73
+ * Reduced gem file size.
74
+
75
+ ## 10.0 “Alis volat propriis”
76
+ * Removed support for Node.js 6.x, 8.x, 11.x.
77
+ * Moved to PostCSS 8.
78
+
79
+ ## 9.8.6.5
80
+ * Fix `9.8.6.4` regression.
81
+
82
+ ## 9.8.6.4
83
+ * Remove deprecation warnings.
84
+
85
+ ## 9.8.6.3
86
+ * Fix deprecation warning for non-Rails environment.
87
+
88
+ ## 9.8.6.2
89
+ * Print deprecation warning only once.
90
+
91
+ ## 9.8.6.1
92
+ * Improve deprecated warnings.
93
+
94
+ ## 9.8.6
95
+ * Fixed `env` option.
96
+ * Added deprecation warning.
97
+
3
98
  ## 9.8.5
4
99
  * Improved Grid Layout warnings (by Daniel Tonon).
5
100
 
data/README.md CHANGED
@@ -5,17 +5,18 @@
5
5
  title="Autoprefixer logo by Anton Lovchikov">
6
6
 
7
7
  [Autoprefixer] is a tool to parse CSS and add vendor prefixes to CSS rules
8
- using values from the [Can I Use] database. This gem provides Ruby and Ruby on Rails
9
- integration with this JavaScript tool.
8
+ using values from the [Can I Use] database. This gem provides Ruby
9
+ and Ruby on Rails integration with this JavaScript tool.
10
10
 
11
11
  <a href="https://evilmartians.com/?utm_source=autoprefixer-rails">
12
12
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
13
13
  </a>
14
14
 
15
- [Autoprefixer]: https://github.com/postcss/autoprefixer
16
- [Can I Use]: http://caniuse.com/
17
- [ci-img]: https://travis-ci.org/ai/autoprefixer-rails.svg
18
- [ci]: https://travis-ci.org/ai/autoprefixer-rails
15
+ [Autoprefixer]: https://github.com/postcss/autoprefixer
16
+ [Can I Use]: http://caniuse.com/
17
+ [PostCSS]: https://postcss.org/
18
+ [ci-img]: https://travis-ci.org/ai/autoprefixer-rails.svg
19
+ [ci]: https://travis-ci.org/ai/autoprefixer-rails
19
20
 
20
21
  ## Differences
21
22
 
@@ -32,8 +33,8 @@ Windows users should install [Node.js]. Autoprefixer Rails doesn’t work with
32
33
  old JScript in Windows.
33
34
 
34
35
  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].
36
+ runtime. Currently this gem is tested to work with Node.js version 10 and up
37
+ and with [mini_racer], but will not work with [therubyracer].
37
38
 
38
39
  [Node.js]: http://nodejs.org/
39
40
  [ExecJS]: https://github.com/rails/execjs
@@ -1,12 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pathname"
2
4
  require "execjs"
3
5
  require "json"
4
6
 
5
- IS_SECTION = /^\s*\[(.+)\]\s*$/
7
+ IS_SECTION = /^\s*\[(.+)\]\s*$/.freeze
6
8
 
7
9
  module AutoprefixerRails
8
10
  # Ruby to JS wrapper for Autoprefixer processor instance
9
11
  class Processor
12
+ SUPPORTED_RUNTIMES = [ExecJS::Runtimes::Node, ExecJS::Runtimes::MiniRacer]
13
+
10
14
  def initialize(params = {})
11
15
  @params = params || {}
12
16
  end
@@ -20,23 +24,18 @@ module AutoprefixerRails
20
24
  def process(css, opts = {})
21
25
  opts = convert_options(opts)
22
26
 
23
- apply_wrapper =
24
- "(function(opts, pluginOpts) {" \
25
- "return eval(process.apply(this, opts, pluginOpts));" \
26
- "})"
27
-
28
27
  plugin_opts = params_with_browsers(opts[:from]).merge(opts)
29
28
  process_opts = {
30
29
  from: plugin_opts.delete(:from),
31
30
  to: plugin_opts.delete(:to),
32
- map: plugin_opts.delete(:map),
31
+ map: plugin_opts.delete(:map)
33
32
  }
34
33
 
35
34
  begin
36
- result = runtime.call(apply_wrapper, [css, process_opts, plugin_opts])
35
+ result = runtime.call("autoprefixer.process", css, process_opts, plugin_opts)
37
36
  rescue ExecJS::ProgramError => e
38
37
  contry_error = "BrowserslistError: " \
39
- "Country statistics is not supported " \
38
+ "Country statistics are not supported " \
40
39
  "in client-side build of Browserslist"
41
40
  if e.message == contry_error
42
41
  raise "Country statistics is not supported in AutoprefixerRails. " \
@@ -51,18 +50,18 @@ module AutoprefixerRails
51
50
 
52
51
  # Return, which browsers and prefixes will be used
53
52
  def info
54
- runtime.eval("autoprefixer(#{js_params}).info()")
53
+ runtime.call("autoprefixer.info", params_with_browsers)
55
54
  end
56
55
 
57
56
  # Parse Browserslist config
58
57
  def parse_config(config)
59
- sections = {"defaults" => []}
58
+ sections = { "defaults" => [] }
60
59
  current = "defaults"
61
60
  config.gsub(/#[^\n]*/, "")
62
- .split(/\n/)
63
- .map(&:strip)
64
- .reject(&:empty?)
65
- .each do |line|
61
+ .split(/\n/)
62
+ .map(&:strip)
63
+ .reject(&:empty?)
64
+ .each do |line|
66
65
  if IS_SECTION =~ line
67
66
  current = line.match(IS_SECTION)[1].strip
68
67
  sections[current] ||= []
@@ -77,10 +76,10 @@ module AutoprefixerRails
77
76
 
78
77
  def params_with_browsers(from = nil)
79
78
  from ||= if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
80
- Rails.root.join("app/assets/stylesheets").to_s
81
- else
82
- "."
83
- end
79
+ Rails.root.join("app/assets/stylesheets").to_s
80
+ else
81
+ "."
82
+ end
84
83
 
85
84
  params = @params
86
85
  if !params.key?(:browsers) && !params.key?(:overrideBrowserslist) && from
@@ -96,13 +95,6 @@ module AutoprefixerRails
96
95
  params
97
96
  end
98
97
 
99
- # Convert params to JS string and add browsers from Browserslist config
100
- def js_params
101
- "{ " +
102
- params_with_browsers.map { |k, v| "#{k}: #{v.inspect}"}.join(", ") +
103
- " }"
104
- end
105
-
106
98
  # Convert ruby_options to jsOptions
107
99
  def convert_options(opts)
108
100
  converted = {}
@@ -138,57 +130,36 @@ module AutoprefixerRails
138
130
  # Lazy load for JS library
139
131
  def runtime
140
132
  @runtime ||= begin
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
158
- end
159
-
160
133
  ExecJS.compile(build_js)
134
+ rescue ExecJS::RuntimeError
135
+ # Only complain about unsupported runtimes when it failed to parse our script.
136
+
137
+ case ExecJS.runtime
138
+ when ExecJS::Runtimes::Node
139
+ node_command = ExecJS.runtime.send(:binary) rescue "Unknown"
140
+
141
+ raise <<~MSG
142
+ Your nodejs binary failed to load autoprefixer script file,
143
+ please check if you're running a supported version (10, 12, 14+)
144
+
145
+ ENV["PATH"] = #{ENV["PATH"]}
146
+ binary = #{node_command}
147
+ MSG
148
+ when *SUPPORTED_RUNTIMES
149
+ raise
150
+ else
151
+ raise <<~MSG
152
+ Your ExecJS runtime #{ExecJS.runtime.name} isn't supported by autoprefixer-rails,
153
+ please switch to #{SUPPORTED_RUNTIMES.map(&:name).join(' or ')}
154
+ MSG
155
+ end
161
156
  end
162
157
  end
163
158
 
164
- # Cache autoprefixer.js content
165
- def read_js
166
- @@js ||= begin
167
- root = Pathname(File.dirname(__FILE__))
168
- path = root.join("../../vendor/autoprefixer.js")
169
- path.read
170
- end
171
- end
172
-
173
- # Return processor JS with some extra methods
174
159
  def build_js
175
- "var global = this;" + read_js + process_proxy
176
- end
177
-
178
- # Return JS code for process method proxy
179
- def process_proxy
180
- <<-JS
181
- var processor;
182
- var process = function() {
183
- var result = autoprefixer.process.apply(autoprefixer, arguments);
184
- var warns = result.warnings().map(function (i) {
185
- delete i.plugin;
186
- return i.toString();
187
- });
188
- var map = result.map ? result.map.toString() : null;
189
- return { css: result.css, map: map, warnings: warns };
190
- };
191
- JS
160
+ root = Pathname(File.dirname(__FILE__))
161
+ path = root.join("../../vendor/autoprefixer.js")
162
+ path.read
192
163
  end
193
164
  end
194
165
  end
@@ -1,8 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "yaml"
4
+ begin
5
+ require "sprockets/railtie"
6
+ rescue LoadError
7
+ end
2
8
 
3
9
  begin
4
10
  module AutoprefixedRails
5
- class Railtie < ::Rails::Railtie
11
+ class Railtie < ::Rails::Railtie # :nodoc:
6
12
  rake_tasks do |app|
7
13
  require "rake/autoprefixer_tasks"
8
14
  Rake::AutoprefixerTasks.new(config) if defined? app.assets
@@ -14,9 +20,7 @@ begin
14
20
  end
15
21
  else
16
22
  initializer :setup_autoprefixer, group: :all do |app|
17
- if defined?(app.assets) && !app.assets.nil?
18
- AutoprefixerRails.install(app.assets, config)
19
- end
23
+ AutoprefixerRails.install(app.assets, config) if defined?(app.assets) && !app.assets.nil?
20
24
  end
21
25
  end
22
26
 
@@ -27,13 +31,14 @@ begin
27
31
  roots.each do |root|
28
32
  file = File.join(root, "config/autoprefixer.yml")
29
33
 
30
- if File.exist?(file)
31
- parsed = ::YAML.load_file(file)
32
- next unless parsed
33
- params = parsed
34
+ next unless File.exist?(file)
35
+
36
+ parsed = ::YAML.load_file(file)
37
+ next unless parsed
38
+
39
+ params = parsed
34
40
 
35
- break
36
- end
41
+ break
37
42
  end
38
43
 
39
44
  params = params.symbolize_keys
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AutoprefixerRails
2
4
  # Container of prefixed CSS and source map with changes
3
5
  class Result
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pathname"
2
4
 
3
5
  module AutoprefixerRails
@@ -30,10 +32,10 @@ module AutoprefixerRails
30
32
  def self.install(env)
31
33
  if ::Sprockets::VERSION.to_f < 4
32
34
  env.register_postprocessor("text/css",
33
- ::AutoprefixerRails::Sprockets)
35
+ ::AutoprefixerRails::Sprockets)
34
36
  else
35
37
  env.register_bundle_processor("text/css",
36
- ::AutoprefixerRails::Sprockets)
38
+ ::AutoprefixerRails::Sprockets)
37
39
  end
38
40
  end
39
41
 
@@ -41,10 +43,10 @@ module AutoprefixerRails
41
43
  def self.uninstall(env)
42
44
  if ::Sprockets::VERSION.to_f < 4
43
45
  env.unregister_postprocessor("text/css",
44
- ::AutoprefixerRails::Sprockets)
46
+ ::AutoprefixerRails::Sprockets)
45
47
  else
46
48
  env.unregister_bundle_processor("text/css",
47
- ::AutoprefixerRails::Sprockets)
49
+ ::AutoprefixerRails::Sprockets)
48
50
  end
49
51
  end
50
52
 
@@ -55,7 +57,7 @@ module AutoprefixerRails
55
57
  end
56
58
 
57
59
  # Sprockets 2 API new and render
58
- def render(_, _)
60
+ def render(*)
59
61
  self.class.run(@filename, @source)
60
62
  end
61
63
  end
@@ -1,3 +1,5 @@
1
- module AutoprefixerRails
2
- VERSION = "9.8.5".freeze unless defined? AutoprefixerRails::VERSION
1
+ # frozen_string_literal: true
2
+
3
+ module AutoprefixerRails # :nodoc:
4
+ VERSION = "10.4.2.0" unless defined? AutoprefixerRails::VERSION
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Ruby integration with Autoprefixer JS library, which parse CSS and adds
2
4
  # only actual prefixed
3
5
  module AutoprefixerRails
@@ -6,9 +8,7 @@ module AutoprefixerRails
6
8
  # Add prefixes to `css`. See `Processor#process` for options.
7
9
  def self.process(css, opts = {})
8
10
  params = {}
9
- if opts.key?(:overrideBrowserslist)
10
- params[:overrideBrowserslist] = opts.delete(:overrideBrowserslist)
11
- end
11
+ params[:overrideBrowserslist] = opts.delete(:overrideBrowserslist) if opts.key?(:overrideBrowserslist)
12
12
  params[:browsers] = opts.delete(:browsers) if opts.key?(:browsers)
13
13
  params[:cascade] = opts.delete(:cascade) if opts.key?(:cascade)
14
14
  params[:remove] = opts.delete(:remove) if opts.key?(:remove)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rake"
2
4
  require "rake/tasklib"
3
5
  require "autoprefixer-rails"