autoprefixer-rails 6.3.3 → 6.3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cb8b6be1d9e61502beb9790cd3997c014bcf317
4
- data.tar.gz: 2c554af33c11f0a144aa90bb4b3b8e7d8e50cbd0
3
+ metadata.gz: ebd6d11f1a873676d34a44eb9023636aa1099f66
4
+ data.tar.gz: 3579bb17eb9980966b440351a61cd2d10b2af552
5
5
  SHA512:
6
- metadata.gz: 376407e780c2c79668449f58f98b303fbe0c39025db0548df1276b50156e603f7e9c402b42bb43ab073245b3c958d611cc3668140449aeea67ecad78eee1f0f7
7
- data.tar.gz: 7478f0959afdfac5563b90e4b79f8c7cc9553a2d7402fbdd36999ee7a0a26f34c8308daa944721dfe421020d8ca3fdf852ca6a4a67f67fbc77325ccf0e5b24f2
6
+ metadata.gz: 0a4094f4fc6a81fa5ca93b5ddabdf19179385e51b2dd5d5299ec61e0f8cb6d3900493a49a4319114d26cc747eeb6fa0efed0ce3d20fcfa6a536bc097fb9f406f
7
+ data.tar.gz: 76a49779c906862692e7229591a48189ac91ed1fd5a02bf25513fa520ef38d21550e4f5010a4e9b28ad35adfc1700c6f0c2990876991a26fafbc82e91a88eda0
data/.gitignore CHANGED
@@ -4,5 +4,4 @@
4
4
  pkg/
5
5
 
6
6
  .bundle
7
- Gemfile.lock
8
- Gemfile.rails3.lock
7
+ *.lock
data/.travis.yml CHANGED
@@ -1,12 +1,24 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - "2.0"
5
- - "2.1"
6
- - "2.2"
4
+ - "2.0.0"
5
+ - "2.1.8"
6
+ - "2.2.4"
7
7
  - "2.3.0"
8
- - jruby-21mode
9
-
8
+ - "jruby-21mode"
9
+ cache: bundler
10
+ gemfile:
11
+ - sprockets2.gemfile
12
+ - sprockets3.gemfile
13
+ - sprockets4.gemfile
10
14
  env:
11
15
  - EXECJS_RUNTIME=Node
12
16
  - EXECJS_RUNTIME= # Rubyracer or rubyrhino depending on platform
17
+ matrix:
18
+ exclude:
19
+ - rvm: "2.0.0"
20
+ gemfile: sprockets4.gemfile
21
+ - rvm: "2.1.8"
22
+ gemfile: sprockets4.gemfile
23
+ - rvm: "jruby-21mode"
24
+ gemfile: sprockets4.gemfile
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 6.3.3.1
2
+ * Add Sprockets 4 support (by Richard Schneeman).
3
+ * Add `AutoprefixerRails.uninstall()`.
4
+ * Use `bundle_processor` for Sprockets 4 (by Adam Becker).
5
+ * Clean gem dependency from `json` (by deepj).
6
+
1
7
  ## 6.3.3
2
8
  * Fix transition warning.
3
9
 
data/Gemfile CHANGED
@@ -1,19 +1 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
- gem 'rake'
5
- gem 'rails'
6
- gem 'compass'
7
- gem 'sass-rails'
8
- gem 'rspec-rails'
9
-
10
- gem 'execjs'
11
- gem 'sprockets'
12
-
13
- gem 'therubyrhino', platforms: 'jruby'
14
- gem 'therubyracer', platforms: ['mri', 'rbx']
15
-
16
- gem 'racc', platforms: 'rbx'
17
- gem 'rubysl', platforms: 'rbx'
18
-
19
- gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
1
+ eval_gemfile "#{ File.dirname(__FILE__) }/sprockets4.gemfile"
data/README.md CHANGED
@@ -106,7 +106,7 @@ rake autoprefixer:info
106
106
  To disable Autoprefixer just remove postprocessor:
107
107
 
108
108
  ```ruby
109
- Rails.application.assets.unregister_postprocessor('text/css', :autoprefixer)
109
+ AutoprefixerRails.uninstall(Rails.application.assets)
110
110
  ```
111
111
 
112
112
  [Browserslist docs]: https://github.com/ai/browserslist
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require 'rubygems'
2
3
 
3
4
  require 'bundler/setup'
@@ -13,3 +14,35 @@ end
13
14
 
14
15
  desc 'Delete all generated files'
15
16
  task :clobber => [:clobber_package]
17
+
18
+ desc 'Test all Gemfiles from spec/*.gemfile'
19
+ task :test_all do
20
+ require 'pty'
21
+ require 'shellwords'
22
+ cmd = 'bundle update && bundle exec rake --trace'
23
+ statuses = Dir.glob('./sprockets*.gemfile').map do |gemfile|
24
+ Bundler.with_clean_env do
25
+ env = { 'BUNDLE_GEMFILE' => gemfile }
26
+ $stderr.puts "Testing #{ File.basename(gemfile) }:"
27
+ $stderr.puts " export BUNDLE_GEMFILE=#{ gemfile }"
28
+ $stderr.puts " #{ cmd }"
29
+ PTY.spawn(env, cmd) do |r, _w, pid|
30
+ begin
31
+ r.each_line { |l| puts l }
32
+ rescue Errno::EIO
33
+ # Errno:EIO error means that the process has finished giving output.
34
+ ensure
35
+ ::Process.wait pid
36
+ end
37
+ end
38
+ [$? && $?.exitstatus == 0, gemfile]
39
+ end
40
+ end
41
+ failed = statuses.reject(&:first).map(&:last)
42
+ if failed.empty?
43
+ $stderr.puts "✓ Tests pass with all #{ statuses.size } gemfiles"
44
+ else
45
+ $stderr.puts "❌ FAILING #{ failed * "\n" }"
46
+ exit 1
47
+ end
48
+ end
@@ -20,5 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.license = 'MIT'
21
21
 
22
22
  s.add_dependency 'execjs', '>= 0'
23
- s.add_dependency 'json', '>= 0'
23
+
24
+ s.add_development_dependency 'rake'
25
+ s.add_development_dependency 'rails'
26
+ s.add_development_dependency 'compass'
27
+ s.add_development_dependency 'rspec-rails'
24
28
  end
@@ -15,7 +15,13 @@ module AutoprefixerRails
15
15
  # Add Autoprefixer for Sprockets environment in `assets`.
16
16
  # You can specify `browsers` actual in your project.
17
17
  def self.install(assets, params = { })
18
- Sprockets.new( processor(params) ).install(assets)
18
+ Sprockets.register_processor(processor(params))
19
+ Sprockets.install(assets)
20
+ end
21
+
22
+ # Disable installed Autoprefixer
23
+ def self.uninstall(assets)
24
+ Sprockets.uninstall(assets)
19
25
  end
20
26
 
21
27
  # Cache processor instances
@@ -3,15 +3,26 @@ require 'pathname'
3
3
  module AutoprefixerRails
4
4
  # Register autoprefixer postprocessor in Sprockets and fix common issues
5
5
  class Sprockets
6
- def initialize(processor)
6
+ def self.register_processor(processor)
7
7
  @processor = processor
8
8
  end
9
9
 
10
- # Add prefixes for `css`
11
- def process(context, css)
12
- input = context.pathname.to_s
13
- output = input.chomp(File.extname(input)) + '.css'
14
- result = @processor.process(css, from: input, to: output)
10
+ # Sprockets 3 and 4 API
11
+ def self.call(input)
12
+ filename = input[:source_path] || input[:filename]
13
+ source = input[:data]
14
+ run(filename, source)
15
+ end
16
+
17
+ # Sprockets 2 compatibility
18
+ def self.process(context, css)
19
+ self.run(context.pathname.to_s, css)
20
+ end
21
+
22
+ # Add prefixes to `css`
23
+ def self.run(filename, css)
24
+ output = filename.chomp(File.extname(filename)) + '.css'
25
+ result = @processor.process(css, from: filename, to: output)
15
26
 
16
27
  result.warnings.each do |warning|
17
28
  $stderr.puts "autoprefixer: #{ warning }"
@@ -21,10 +32,36 @@ module AutoprefixerRails
21
32
  end
22
33
 
23
34
  # Register postprocessor in Sprockets depend on issues with other gems
24
- def install(assets)
25
- assets.register_postprocessor('text/css', :autoprefixer) do |context, css|
26
- process(context, css)
35
+ def self.install(env)
36
+ if ::Sprockets::VERSION.to_i < 4
37
+ env.register_postprocessor('text/css', :autoprefixer) do |context, css|
38
+ process(context, css)
39
+ end
40
+ else
41
+ env.register_bundle_processor('text/css',
42
+ ::AutoprefixerRails::Sprockets)
43
+ end
44
+ end
45
+
46
+ # Register postprocessor in Sprockets depend on issues with other gems
47
+ def self.uninstall(env)
48
+ if ::Sprockets::VERSION.to_i < 4
49
+ env.unregister_postprocessor('text/css', :autoprefixer)
50
+ else
51
+ env.unregister_bundle_processor('text/css',
52
+ ::AutoprefixerRails::Sprockets)
27
53
  end
28
54
  end
55
+
56
+ # Sprockets 2 API new and render
57
+ def initialize(filename, &block)
58
+ @filename = filename
59
+ @source = block.call
60
+ end
61
+
62
+ # Sprockets 2 API new and render
63
+ def render(_, _)
64
+ self.class.run(@filename, @source)
65
+ end
29
66
  end
30
67
  end
@@ -1,3 +1,3 @@
1
1
  module AutoprefixerRails
2
- VERSION = '6.3.3'.freeze unless defined? AutoprefixerRails::VERSION
2
+ VERSION = '6.3.3.1'.freeze unless defined? AutoprefixerRails::VERSION
3
3
  end
data/shared.gemfile ADDED
@@ -0,0 +1,7 @@
1
+ gem 'therubyrhino', platforms: 'jruby'
2
+ gem 'therubyracer', platforms: ['mri', 'rbx']
3
+
4
+ gem 'racc', platforms: 'rbx'
5
+ gem 'rubysl', platforms: 'rbx'
6
+
7
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
@@ -0,0 +1 @@
1
+ <%= evaluate 'test.css' %>
@@ -1,6 +1,6 @@
1
1
  class CssController < ApplicationController
2
2
  def test
3
3
  file = params[:file] + '.css'
4
- render text: Rails.application.assets[file]
4
+ render plain: Rails.application.assets[file]
5
5
  end
6
6
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require "action_controller/railtie"
4
- require "sprockets/railtie"
3
+ require 'action_controller/railtie'
4
+ require 'sprockets/railtie'
5
5
 
6
6
  if defined?(Bundler)
7
7
  Bundler.require(*Rails.groups(assets: %w(development test)))
@@ -10,6 +10,5 @@ end
10
10
  module App
11
11
  class Application < Rails::Application
12
12
  config.assets.enabled = true
13
- config.sass.line_comments = false
14
13
  end
15
14
  end
@@ -1,6 +1,5 @@
1
1
  App::Application.configure do
2
2
  config.cache_classes = true
3
- config.static_cache_control = "public, max-age=3600"
4
3
  config.eager_load = false
5
4
  config.consider_all_requests_local = true
6
5
  config.action_controller.perform_caching = false
@@ -69,7 +69,7 @@ describe AutoprefixerRails do
69
69
  end
70
70
 
71
71
  context 'Sprockets' do
72
- before :all do
72
+ before :each do
73
73
  @assets = Sprockets::Environment.new
74
74
  @assets.append_path(@dir.join('app/app/assets/stylesheets'))
75
75
  AutoprefixerRails.install(@assets, browsers: ['chrome 25'])
@@ -84,7 +84,15 @@ describe AutoprefixerRails do
84
84
  end
85
85
 
86
86
  it "shows file name from Sprockets", not_jruby: true do
87
- expect { @assets['wrong.css'] }.to raise_error(/wrong.css:/)
87
+ expect { @assets['wrong.css'] }.to raise_error(/wrong/)
88
+ end
89
+
90
+ it "supports disabling", not_jruby: true do
91
+ AutoprefixerRails.uninstall(@assets)
92
+ css = @assets['test.css'].to_s
93
+ expect(css).to eq "a {\n" +
94
+ " mask: none\n" +
95
+ "}\n"
88
96
  end
89
97
 
90
98
  end
data/spec/rails_spec.rb CHANGED
@@ -12,6 +12,15 @@ describe CssController, type: :controller do
12
12
  clear_css = response.body.gsub("\n", " ").squeeze(" ").strip
13
13
  expect(clear_css).to eq "a { -webkit-mask: none; mask: none; }"
14
14
  end
15
+
16
+ if Sprockets::Context.instance_methods.include?(:evaluate)
17
+ it 'supports evaluate' do
18
+ get :test, file: 'evaluate'
19
+ expect(response).to be_success
20
+ clear_css = response.body.gsub("\n", ' ').squeeze(' ').strip
21
+ expect(clear_css).to eq 'a { -webkit-mask: none; mask: none }'
22
+ end
23
+ end
15
24
  end
16
25
 
17
26
  describe 'Rake task' do
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '< 5'
6
+ gem 'sprockets', '>= 2.12.4', '< 3.0'
7
+
8
+ eval_gemfile "#{ File.dirname(__FILE__) }/shared.gemfile"
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '< 5'
6
+ gem 'sprockets', '>= 3.4.0', '< 4.0'
7
+
8
+ eval_gemfile "#{ File.dirname(__FILE__) }/shared.gemfile"
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'execjs'
6
+ gem 'rails', '>= 5.0.0.beta2'
7
+ gem 'sprockets', '>= 4.0.0.beta1'
8
+
9
+ eval_gemfile "#{ File.dirname(__FILE__) }/shared.gemfile"
@@ -5990,6 +5990,14 @@ function fromJsonObject (that, object) {
5990
5990
  if (Buffer.TYPED_ARRAY_SUPPORT) {
5991
5991
  Buffer.prototype.__proto__ = Uint8Array.prototype
5992
5992
  Buffer.__proto__ = Uint8Array
5993
+ if (typeof Symbol !== 'undefined' && Symbol.species &&
5994
+ Buffer[Symbol.species] === Buffer) {
5995
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
5996
+ Object.defineProperty(Buffer, Symbol.species, {
5997
+ value: null,
5998
+ configurable: true
5999
+ })
6000
+ }
5993
6001
  } else {
5994
6002
  // pre-set for values that may exist in the future
5995
6003
  Buffer.prototype.length = undefined
@@ -21741,360 +21749,364 @@ var substr = 'ab'.substr(-1) === 'b'
21741
21749
 
21742
21750
  }).call(this,require('_process'))
21743
21751
  },{"_process":151}],122:[function(require,module,exports){
21744
- var parse = require('./parse');
21745
- var walk = require('./walk');
21746
- var stringify = require('./stringify');
21747
-
21748
- function ValueParser(value) {
21749
- if (!(this instanceof ValueParser)) {
21750
- return new ValueParser(value);
21751
- }
21752
- this.nodes = parse(value);
21753
- }
21754
-
21755
- ValueParser.prototype.toString = function () {
21756
- return Array.isArray(this.nodes) ? stringify(this.nodes) : '';
21757
- };
21758
-
21759
- ValueParser.prototype.walk = function (cb, bubble) {
21760
- walk(this.nodes, cb, bubble);
21761
- return this;
21762
- };
21763
-
21764
- ValueParser.unit = require('./unit');
21765
-
21766
- ValueParser.walk = walk;
21767
-
21768
- ValueParser.stringify = stringify;
21769
-
21770
- module.exports = ValueParser;
21752
+ var parse = require('./parse');
21753
+ var walk = require('./walk');
21754
+ var stringify = require('./stringify');
21755
+
21756
+ function ValueParser(value) {
21757
+ if (this instanceof ValueParser) {
21758
+ this.nodes = parse(value);
21759
+ return this;
21760
+ }
21761
+ return new ValueParser(value);
21762
+ }
21763
+
21764
+ ValueParser.prototype.toString = function () {
21765
+ return Array.isArray(this.nodes) ? stringify(this.nodes) : '';
21766
+ };
21767
+
21768
+ ValueParser.prototype.walk = function (cb, bubble) {
21769
+ walk(this.nodes, cb, bubble);
21770
+ return this;
21771
+ };
21772
+
21773
+ ValueParser.unit = require('./unit');
21774
+
21775
+ ValueParser.walk = walk;
21776
+
21777
+ ValueParser.stringify = stringify;
21778
+
21779
+ module.exports = ValueParser;
21771
21780
 
21772
21781
  },{"./parse":123,"./stringify":124,"./unit":125,"./walk":126}],123:[function(require,module,exports){
21773
- var openParentheses = '('.charCodeAt(0);
21774
- var closeParentheses = ')'.charCodeAt(0);
21775
- var singleQuote = '\''.charCodeAt(0);
21776
- var doubleQuote = '"'.charCodeAt(0);
21777
- var backslash = '\\'.charCodeAt(0);
21778
- var slash = '/'.charCodeAt(0);
21779
- var comma = ','.charCodeAt(0);
21780
- var colon = ':'.charCodeAt(0);
21781
- var star = '*'.charCodeAt(0);
21782
-
21783
- module.exports = function (input) {
21784
- var tokens = [];
21785
- var value = input;
21786
-
21787
- var next, quote, prev, token, escape, escapePos, whitespacePos;
21788
- var pos = 0;
21789
- var code = value.charCodeAt(pos);
21790
- var max = value.length;
21791
- var stack = [{ nodes: tokens }];
21792
- var balanced = 0;
21793
- var parent;
21794
-
21795
- var name = '';
21796
- var before = '';
21797
- var after = '';
21798
-
21799
- while (pos < max) {
21800
- // Whitespaces
21801
- if (code <= 32) {
21802
- next = pos;
21803
- do {
21804
- next += 1;
21805
- code = value.charCodeAt(next);
21806
- } while (code <= 32);
21807
- token = value.slice(pos, next);
21808
-
21809
- prev = tokens[tokens.length - 1];
21810
- if (code === closeParentheses && balanced) {
21811
- after = token;
21812
- } else if (prev && prev.type === 'div') {
21813
- prev.after = token;
21814
- } else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star) {
21815
- before = token;
21816
- } else {
21817
- tokens.push({
21818
- type: 'space',
21819
- sourceIndex: pos,
21820
- value: token
21821
- });
21822
- }
21823
-
21824
- pos = next;
21825
-
21826
- // Quotes
21827
- } else if (code === singleQuote || code === doubleQuote) {
21828
- next = pos;
21829
- quote = code === singleQuote ? '\'' : '"';
21830
- token = {
21831
- type: 'string',
21832
- sourceIndex: pos,
21833
- quote: quote
21834
- };
21835
- do {
21836
- escape = false;
21837
- next = value.indexOf(quote, next + 1);
21838
- if (~next) {
21839
- escapePos = next;
21840
- while (value.charCodeAt(escapePos - 1) === backslash) {
21841
- escapePos -= 1;
21842
- escape = !escape;
21843
- }
21844
- } else {
21845
- value += quote;
21846
- next = value.length - 1;
21847
- token.unclosed = true;
21848
- }
21849
- } while (escape);
21850
- token.value = value.slice(pos + 1, next);
21851
-
21852
- tokens.push(token);
21853
- pos = next + 1;
21854
- code = value.charCodeAt(pos);
21855
-
21856
- //Comments
21857
- } else if (code === slash && value.charCodeAt(pos + 1) === star) {
21858
- token = {
21859
- type: 'comment',
21860
- sourceIndex: pos
21861
- };
21862
-
21863
- next = value.indexOf('*/', pos);
21864
- if (next === -1) {
21865
- token.unclosed = true;
21866
- next = value.length;
21867
- }
21868
-
21869
- token.value = value.slice(pos + 2, next);
21870
- tokens.push(token);
21871
-
21872
- pos = next + 2;
21873
- code = value.charCodeAt(pos);
21874
-
21875
- // Dividers
21876
- } else if (code === slash || code === comma || code === colon) {
21877
- token = value[pos];
21878
-
21879
- tokens.push({
21880
- type: 'div',
21881
- sourceIndex: pos - before.length,
21882
- value: token,
21883
- before: before,
21884
- after: ''
21885
- });
21886
- before = '';
21887
-
21888
- pos += 1;
21889
- code = value.charCodeAt(pos);
21890
-
21891
- // Open parentheses
21892
- } else if (openParentheses === code) {
21893
- // Whitespaces after open parentheses
21894
- next = pos;
21895
- do {
21896
- next += 1;
21897
- code = value.charCodeAt(next);
21898
- } while (code <= 32);
21899
- token = {
21900
- type: 'function',
21901
- sourceIndex: pos - name.length,
21902
- value: name,
21903
- before: value.slice(pos + 1, next)
21904
- };
21905
- pos = next;
21906
-
21907
- if (name === 'url' && code !== singleQuote && code !== doubleQuote) {
21908
- next -= 1;
21909
- do {
21910
- escape = false;
21911
- next = value.indexOf(')', next + 1);
21912
- if (~next) {
21913
- escapePos = next;
21914
- while (value.charCodeAt(escapePos - 1) === backslash) {
21915
- escapePos -= 1;
21916
- escape = !escape;
21917
- }
21918
- } else {
21919
- value += ')';
21920
- next = value.length - 1;
21921
- token.unclosed = true;
21922
- }
21923
- } while (escape);
21924
- // Whitespaces before closed
21925
- whitespacePos = next;
21926
- do {
21927
- whitespacePos -= 1;
21928
- code = value.charCodeAt(whitespacePos);
21929
- } while (code <= 32);
21930
- if (pos !== whitespacePos + 1) {
21931
- token.nodes = [{
21932
- type: 'word',
21933
- sourceIndex: pos,
21934
- value: value.slice(pos, whitespacePos + 1)
21935
- }];
21936
- } else {
21937
- token.nodes = [];
21938
- }
21939
- if (token.unclosed && whitespacePos + 1 !== next) {
21940
- token.after = '';
21941
- token.nodes.push({
21942
- type: 'space',
21943
- sourceIndex: whitespacePos + 1,
21944
- value: value.slice(whitespacePos + 1, next)
21945
- });
21946
- } else {
21947
- token.after = value.slice(whitespacePos + 1, next);
21948
- }
21949
- pos = next + 1;
21950
- code = value.charCodeAt(pos);
21951
- tokens.push(token);
21952
- } else {
21953
- balanced += 1;
21954
- token.after = '';
21955
- tokens.push(token);
21956
- stack.push(token);
21957
- tokens = token.nodes = [];
21958
- parent = token;
21959
- }
21960
- name = '';
21961
-
21962
- // Close parentheses
21963
- } else if (closeParentheses === code && balanced) {
21964
- pos += 1;
21965
- code = value.charCodeAt(pos);
21966
-
21967
- parent.after = after;
21968
- after = '';
21969
- balanced -= 1;
21970
- stack.pop();
21971
- parent = stack[balanced];
21972
- tokens = parent.nodes;
21973
-
21974
- // Words
21975
- } else {
21976
- next = pos;
21977
- do {
21978
- if (code === backslash) {
21979
- next += 1;
21980
- }
21981
- next += 1;
21982
- code = value.charCodeAt(next);
21983
- } while (next < max && !(
21984
- code <= 32 ||
21985
- code === singleQuote ||
21986
- code === doubleQuote ||
21987
- code === comma ||
21988
- code === colon ||
21989
- code === slash ||
21990
- code === openParentheses ||
21991
- code === closeParentheses && balanced
21992
- ));
21993
- token = value.slice(pos, next);
21994
-
21995
- if (openParentheses === code) {
21996
- name = token;
21997
- } else {
21998
- tokens.push({
21999
- type: 'word',
22000
- sourceIndex: pos,
22001
- value: token
22002
- });
22003
- }
22004
-
22005
- pos = next;
22006
- }
22007
- }
22008
-
22009
- for (pos = stack.length - 1; pos; pos -= 1) {
22010
- stack[pos].unclosed = true;
22011
- }
22012
-
22013
- return stack[0].nodes;
22014
- };
21782
+ var openParentheses = '('.charCodeAt(0);
21783
+ var closeParentheses = ')'.charCodeAt(0);
21784
+ var singleQuote = '\''.charCodeAt(0);
21785
+ var doubleQuote = '"'.charCodeAt(0);
21786
+ var backslash = '\\'.charCodeAt(0);
21787
+ var slash = '/'.charCodeAt(0);
21788
+ var comma = ','.charCodeAt(0);
21789
+ var colon = ':'.charCodeAt(0);
21790
+ var star = '*'.charCodeAt(0);
21791
+
21792
+ module.exports = function (input) {
21793
+ var tokens = [];
21794
+ var value = input;
22015
21795
 
22016
- },{}],124:[function(require,module,exports){
22017
- function stringifyNode(node) {
22018
- var type = node.type;
22019
- var value = node.value;
22020
- var buf;
21796
+ var next, quote, prev, token, escape, escapePos, whitespacePos;
21797
+ var pos = 0;
21798
+ var code = value.charCodeAt(pos);
21799
+ var max = value.length;
21800
+ var stack = [{ nodes: tokens }];
21801
+ var balanced = 0;
21802
+ var parent;
21803
+
21804
+ var name = '';
21805
+ var before = '';
21806
+ var after = '';
21807
+
21808
+ while (pos < max) {
21809
+ // Whitespaces
21810
+ if (code <= 32) {
21811
+ next = pos;
21812
+ do {
21813
+ next += 1;
21814
+ code = value.charCodeAt(next);
21815
+ } while (code <= 32);
21816
+ token = value.slice(pos, next);
21817
+
21818
+ prev = tokens[tokens.length - 1];
21819
+ if (code === closeParentheses && balanced) {
21820
+ after = token;
21821
+ } else if (prev && prev.type === 'div') {
21822
+ prev.after = token;
21823
+ } else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star) {
21824
+ before = token;
21825
+ } else {
21826
+ tokens.push({
21827
+ type: 'space',
21828
+ sourceIndex: pos,
21829
+ value: token
21830
+ });
21831
+ }
22021
21832
 
22022
- if (type === 'word' || type === 'space') {
22023
- return value;
22024
- } else if (type === 'string') {
22025
- buf = node.quote || '';
22026
- return buf + value + (node.unclosed ? '' : buf);
22027
- } else if (type === 'comment') {
22028
- return '/*' + value + (node.unclosed ? '' : '*/');
22029
- } else if (type === 'div') {
22030
- return (node.before || '') + value + (node.after || '');
22031
- } else if (Array.isArray(node.nodes)) {
22032
- buf = stringify(node.nodes);
22033
- if (type !== 'function') {
22034
- return buf;
22035
- }
22036
- return value + '(' + (node.before || '') + buf + (node.after || '') + (node.unclosed ? '' : ')');
22037
- }
22038
- return value;
22039
- }
21833
+ pos = next;
21834
+
21835
+ // Quotes
21836
+ } else if (code === singleQuote || code === doubleQuote) {
21837
+ next = pos;
21838
+ quote = code === singleQuote ? '\'' : '"';
21839
+ token = {
21840
+ type: 'string',
21841
+ sourceIndex: pos,
21842
+ quote: quote
21843
+ };
21844
+ do {
21845
+ escape = false;
21846
+ next = value.indexOf(quote, next + 1);
21847
+ if (~next) {
21848
+ escapePos = next;
21849
+ while (value.charCodeAt(escapePos - 1) === backslash) {
21850
+ escapePos -= 1;
21851
+ escape = !escape;
21852
+ }
21853
+ } else {
21854
+ value += quote;
21855
+ next = value.length - 1;
21856
+ token.unclosed = true;
21857
+ }
21858
+ } while (escape);
21859
+ token.value = value.slice(pos + 1, next);
21860
+
21861
+ tokens.push(token);
21862
+ pos = next + 1;
21863
+ code = value.charCodeAt(pos);
21864
+
21865
+ // Comments
21866
+ } else if (code === slash && value.charCodeAt(pos + 1) === star) {
21867
+ token = {
21868
+ type: 'comment',
21869
+ sourceIndex: pos
21870
+ };
21871
+
21872
+ next = value.indexOf('*/', pos);
21873
+ if (next === -1) {
21874
+ token.unclosed = true;
21875
+ next = value.length;
21876
+ }
22040
21877
 
22041
- function stringify(nodes) {
22042
- var result, i;
21878
+ token.value = value.slice(pos + 2, next);
21879
+ tokens.push(token);
22043
21880
 
22044
- if (Array.isArray(nodes)) {
22045
- result = '';
22046
- for (var i = nodes.length - 1; ~i; i -= 1) {
22047
- result = stringifyNode(nodes[i]) + result;
21881
+ pos = next + 2;
21882
+ code = value.charCodeAt(pos);
21883
+
21884
+ // Dividers
21885
+ } else if (code === slash || code === comma || code === colon) {
21886
+ token = value[pos];
21887
+
21888
+ tokens.push({
21889
+ type: 'div',
21890
+ sourceIndex: pos - before.length,
21891
+ value: token,
21892
+ before: before,
21893
+ after: ''
21894
+ });
21895
+ before = '';
21896
+
21897
+ pos += 1;
21898
+ code = value.charCodeAt(pos);
21899
+
21900
+ // Open parentheses
21901
+ } else if (openParentheses === code) {
21902
+ // Whitespaces after open parentheses
21903
+ next = pos;
21904
+ do {
21905
+ next += 1;
21906
+ code = value.charCodeAt(next);
21907
+ } while (code <= 32);
21908
+ token = {
21909
+ type: 'function',
21910
+ sourceIndex: pos - name.length,
21911
+ value: name,
21912
+ before: value.slice(pos + 1, next)
21913
+ };
21914
+ pos = next;
21915
+
21916
+ if (name === 'url' && code !== singleQuote && code !== doubleQuote) {
21917
+ next -= 1;
21918
+ do {
21919
+ escape = false;
21920
+ next = value.indexOf(')', next + 1);
21921
+ if (~next) {
21922
+ escapePos = next;
21923
+ while (value.charCodeAt(escapePos - 1) === backslash) {
21924
+ escapePos -= 1;
21925
+ escape = !escape;
21926
+ }
21927
+ } else {
21928
+ value += ')';
21929
+ next = value.length - 1;
21930
+ token.unclosed = true;
21931
+ }
21932
+ } while (escape);
21933
+ // Whitespaces before closed
21934
+ whitespacePos = next;
21935
+ do {
21936
+ whitespacePos -= 1;
21937
+ code = value.charCodeAt(whitespacePos);
21938
+ } while (code <= 32);
21939
+ if (pos !== whitespacePos + 1) {
21940
+ token.nodes = [{
21941
+ type: 'word',
21942
+ sourceIndex: pos,
21943
+ value: value.slice(pos, whitespacePos + 1)
21944
+ }];
21945
+ } else {
21946
+ token.nodes = [];
21947
+ }
21948
+ if (token.unclosed && whitespacePos + 1 !== next) {
21949
+ token.after = '';
21950
+ token.nodes.push({
21951
+ type: 'space',
21952
+ sourceIndex: whitespacePos + 1,
21953
+ value: value.slice(whitespacePos + 1, next)
21954
+ });
21955
+ } else {
21956
+ token.after = value.slice(whitespacePos + 1, next);
21957
+ }
21958
+ pos = next + 1;
21959
+ code = value.charCodeAt(pos);
21960
+ tokens.push(token);
21961
+ } else {
21962
+ balanced += 1;
21963
+ token.after = '';
21964
+ tokens.push(token);
21965
+ stack.push(token);
21966
+ tokens = token.nodes = [];
21967
+ parent = token;
21968
+ }
21969
+ name = '';
21970
+
21971
+ // Close parentheses
21972
+ } else if (closeParentheses === code && balanced) {
21973
+ pos += 1;
21974
+ code = value.charCodeAt(pos);
21975
+
21976
+ parent.after = after;
21977
+ after = '';
21978
+ balanced -= 1;
21979
+ stack.pop();
21980
+ parent = stack[balanced];
21981
+ tokens = parent.nodes;
21982
+
21983
+ // Words
21984
+ } else {
21985
+ next = pos;
21986
+ do {
21987
+ if (code === backslash) {
21988
+ next += 1;
21989
+ }
21990
+ next += 1;
21991
+ code = value.charCodeAt(next);
21992
+ } while (next < max && !(
21993
+ code <= 32 ||
21994
+ code === singleQuote ||
21995
+ code === doubleQuote ||
21996
+ code === comma ||
21997
+ code === colon ||
21998
+ code === slash ||
21999
+ code === openParentheses ||
22000
+ code === closeParentheses && balanced
22001
+ ));
22002
+ token = value.slice(pos, next);
22003
+
22004
+ if (openParentheses === code) {
22005
+ name = token;
22006
+ } else {
22007
+ tokens.push({
22008
+ type: 'word',
22009
+ sourceIndex: pos,
22010
+ value: token
22011
+ });
22012
+ }
22013
+
22014
+ pos = next;
22048
22015
  }
22049
- return result;
22050
22016
  }
22051
- return stringifyNode(nodes);
22052
- };
22053
22017
 
22054
- module.exports = stringify;
22018
+ for (pos = stack.length - 1; pos; pos -= 1) {
22019
+ stack[pos].unclosed = true;
22020
+ }
22055
22021
 
22056
- },{}],125:[function(require,module,exports){
22057
- var minus = '-'.charCodeAt(0);
22058
- var plus = '+'.charCodeAt(0);
22059
- var dot = '.'.charCodeAt(0);
22022
+ return stack[0].nodes;
22023
+ };
22024
+
22025
+ },{}],124:[function(require,module,exports){
22026
+ function stringifyNode(node, custom) {
22027
+ var type = node.type;
22028
+ var value = node.value;
22029
+ var buf;
22030
+ var customResult;
22060
22031
 
22061
- module.exports = function (value) {
22062
- var pos = 0;
22063
- var length = value.length;
22064
- var dotted = false;
22065
- var containsNumber = false;
22066
- var code;
22067
- var number = '';
22032
+ if (custom && (customResult = custom(node)) !== undefined) {
22033
+ return customResult;
22034
+ } else if (type === 'word' || type === 'space') {
22035
+ return value;
22036
+ } else if (type === 'string') {
22037
+ buf = node.quote || '';
22038
+ return buf + value + (node.unclosed ? '' : buf);
22039
+ } else if (type === 'comment') {
22040
+ return '/*' + value + (node.unclosed ? '' : '*/');
22041
+ } else if (type === 'div') {
22042
+ return (node.before || '') + value + (node.after || '');
22043
+ } else if (Array.isArray(node.nodes)) {
22044
+ buf = stringify(node.nodes);
22045
+ if (type !== 'function') {
22046
+ return buf;
22047
+ }
22048
+ return value + '(' + (node.before || '') + buf + (node.after || '') + (node.unclosed ? '' : ')');
22049
+ }
22050
+ return value;
22051
+ }
22068
22052
 
22069
- while (pos < length) {
22070
- code = value.charCodeAt(pos);
22053
+ function stringify(nodes, custom) {
22054
+ var result, i;
22071
22055
 
22072
- if (48 <= code && code <= 57) {
22073
- number += value[pos];
22074
- containsNumber = true;
22075
- } else if (code === dot) {
22076
- if (dotted) {
22077
- break;
22078
- }
22079
- dotted = true;
22080
- number += value[pos];
22081
- } else if (code === plus || code === minus) {
22082
- if (pos !== 0) {
22083
- break;
22084
- }
22085
- number += value[pos];
22086
- } else {
22087
- break;
22056
+ if (Array.isArray(nodes)) {
22057
+ result = '';
22058
+ for (i = nodes.length - 1; ~i; i -= 1) {
22059
+ result = stringifyNode(nodes[i], custom) + result;
22088
22060
  }
22089
-
22090
- pos += 1;
22061
+ return result;
22091
22062
  }
22063
+ return stringifyNode(nodes, custom);
22064
+ }
22092
22065
 
22093
- return containsNumber ? {
22094
- number: number,
22095
- unit: value.slice(pos)
22096
- } : false;
22097
- };
22066
+ module.exports = stringify;
22067
+
22068
+ },{}],125:[function(require,module,exports){
22069
+ var minus = '-'.charCodeAt(0);
22070
+ var plus = '+'.charCodeAt(0);
22071
+ var dot = '.'.charCodeAt(0);
22072
+
22073
+ module.exports = function (value) {
22074
+ var pos = 0;
22075
+ var length = value.length;
22076
+ var dotted = false;
22077
+ var containsNumber = false;
22078
+ var code;
22079
+ var number = '';
22080
+
22081
+ while (pos < length) {
22082
+ code = value.charCodeAt(pos);
22083
+
22084
+ if (code >= 48 && code <= 57) {
22085
+ number += value[pos];
22086
+ containsNumber = true;
22087
+ } else if (code === dot) {
22088
+ if (dotted) {
22089
+ break;
22090
+ }
22091
+ dotted = true;
22092
+ number += value[pos];
22093
+ } else if (code === plus || code === minus) {
22094
+ if (pos !== 0) {
22095
+ break;
22096
+ }
22097
+ number += value[pos];
22098
+ } else {
22099
+ break;
22100
+ }
22101
+
22102
+ pos += 1;
22103
+ }
22104
+
22105
+ return containsNumber ? {
22106
+ number: number,
22107
+ unit: value.slice(pos)
22108
+ } : false;
22109
+ };
22098
22110
 
22099
22111
  },{}],126:[function(require,module,exports){
22100
22112
  module.exports = function walk(nodes, cb, bubble) {
@@ -22356,18 +22368,16 @@ var Container = function (_Node) {
22356
22368
 
22357
22369
  delete this.indexes[id];
22358
22370
 
22359
- if (result === false) return false;
22371
+ return result;
22360
22372
  };
22361
22373
 
22362
22374
  Container.prototype.walk = function walk(callback) {
22363
22375
  return this.each(function (child, i) {
22364
22376
  var result = callback(child, i);
22365
-
22366
22377
  if (result !== false && child.walk) {
22367
22378
  result = child.walk(callback);
22368
22379
  }
22369
-
22370
- if (result === false) return result;
22380
+ return result;
22371
22381
  });
22372
22382
  };
22373
22383
 
@@ -22376,22 +22386,19 @@ var Container = function (_Node) {
22376
22386
  callback = prop;
22377
22387
  return this.walk(function (child, i) {
22378
22388
  if (child.type === 'decl') {
22379
- var result = callback(child, i);
22380
- if (result === false) return result;
22389
+ return callback(child, i);
22381
22390
  }
22382
22391
  });
22383
22392
  } else if (prop instanceof RegExp) {
22384
22393
  return this.walk(function (child, i) {
22385
22394
  if (child.type === 'decl' && prop.test(child.prop)) {
22386
- var result = callback(child, i);
22387
- if (result === false) return result;
22395
+ return callback(child, i);
22388
22396
  }
22389
22397
  });
22390
22398
  } else {
22391
22399
  return this.walk(function (child, i) {
22392
22400
  if (child.type === 'decl' && child.prop === prop) {
22393
- var result = callback(child, i);
22394
- if (result === false) return result;
22401
+ return callback(child, i);
22395
22402
  }
22396
22403
  });
22397
22404
  }
@@ -22403,22 +22410,19 @@ var Container = function (_Node) {
22403
22410
 
22404
22411
  return this.walk(function (child, i) {
22405
22412
  if (child.type === 'rule') {
22406
- var result = callback(child, i);
22407
- if (result === false) return result;
22413
+ return callback(child, i);
22408
22414
  }
22409
22415
  });
22410
22416
  } else if (selector instanceof RegExp) {
22411
22417
  return this.walk(function (child, i) {
22412
22418
  if (child.type === 'rule' && selector.test(child.selector)) {
22413
- var result = callback(child, i);
22414
- if (result === false) return result;
22419
+ return callback(child, i);
22415
22420
  }
22416
22421
  });
22417
22422
  } else {
22418
22423
  return this.walk(function (child, i) {
22419
22424
  if (child.type === 'rule' && child.selector === selector) {
22420
- var result = callback(child, i);
22421
- if (result === false) return result;
22425
+ return callback(child, i);
22422
22426
  }
22423
22427
  });
22424
22428
  }
@@ -22429,22 +22433,19 @@ var Container = function (_Node) {
22429
22433
  callback = name;
22430
22434
  return this.walk(function (child, i) {
22431
22435
  if (child.type === 'atrule') {
22432
- var result = callback(child, i);
22433
- if (result === false) return result;
22436
+ return callback(child, i);
22434
22437
  }
22435
22438
  });
22436
22439
  } else if (name instanceof RegExp) {
22437
22440
  return this.walk(function (child, i) {
22438
22441
  if (child.type === 'atrule' && name.test(child.name)) {
22439
- var result = callback(child, i);
22440
- if (result === false) return result;
22442
+ return callback(child, i);
22441
22443
  }
22442
22444
  });
22443
22445
  } else {
22444
22446
  return this.walk(function (child, i) {
22445
22447
  if (child.type === 'atrule' && child.name === name) {
22446
- var result = callback(child, i);
22447
- if (result === false) return result;
22448
+ return callback(child, i);
22448
22449
  }
22449
22450
  });
22450
22451
  }
@@ -22453,8 +22454,7 @@ var Container = function (_Node) {
22453
22454
  Container.prototype.walkComments = function walkComments(callback) {
22454
22455
  return this.walk(function (child, i) {
22455
22456
  if (child.type === 'comment') {
22456
- var result = callback(child, i);
22457
- if (result === false) return result;
22457
+ return callback(child, i);
22458
22458
  }
22459
22459
  });
22460
22460
  };
@@ -23247,7 +23247,7 @@ var LazyResult = function () {
23247
23247
  var b = runtimeVer.split('.');
23248
23248
 
23249
23249
  if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
23250
- (0, _warnOnce2.default)('Your current PostCSS version is ' + runtimeVer + ', ' + ('but ' + pluginName + ' uses ' + pluginVer + '. Perhaps ') + 'this is the source of the error below.');
23250
+ (0, _warnOnce2.default)('Your current PostCSS version ' + 'is ' + runtimeVer + ', but ' + pluginName + ' ' + 'uses ' + pluginVer + '. Perhaps this is ' + 'the source of the error below.');
23251
23251
  }
23252
23252
  }
23253
23253
  } catch (err) {
@@ -23760,7 +23760,7 @@ var _class = function () {
23760
23760
  } else {
23761
23761
  var result = '';
23762
23762
  this.stringify(this.root, function (i) {
23763
- return result += i;
23763
+ result += i;
23764
23764
  });
23765
23765
  return [result];
23766
23766
  }
@@ -23867,7 +23867,7 @@ var Node = function () {
23867
23867
  if (stringifier.stringify) stringifier = stringifier.stringify;
23868
23868
  var result = '';
23869
23869
  stringifier(this, function (i) {
23870
- return result += i;
23870
+ result += i;
23871
23871
  });
23872
23872
  return result;
23873
23873
  };
@@ -25658,7 +25658,22 @@ function tokenize(input) {
25658
25658
  }
25659
25659
  } while (escaped);
25660
25660
 
25661
- tokens.push(['string', css.slice(pos, next + 1), line, pos - offset, line, next - offset]);
25661
+ content = css.slice(pos, next + 1);
25662
+ lines = content.split('\n');
25663
+ last = lines.length - 1;
25664
+
25665
+ if (last > 0) {
25666
+ nextLine = line + last;
25667
+ nextOffset = next - lines[last].length;
25668
+ } else {
25669
+ nextLine = line;
25670
+ nextOffset = offset;
25671
+ }
25672
+
25673
+ tokens.push(['string', css.slice(pos, next + 1), line, pos - offset, nextLine, next - nextOffset]);
25674
+
25675
+ offset = nextOffset;
25676
+ line = nextLine;
25662
25677
  pos = next;
25663
25678
  break;
25664
25679