postcss 2.2.2 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of postcss might be problematic. Click here for more details.
- package/ChangeLog.md +13 -0
- package/README.md +309 -241
- package/lib/at-rule.js +15 -15
- package/lib/comment.js +7 -7
- package/lib/container.js +58 -58
- package/lib/css-syntax-error.js +7 -7
- package/lib/declaration.js +9 -9
- package/lib/list.js +2 -2
- package/lib/map-generator.js +42 -40
- package/lib/node.js +21 -21
- package/lib/parse.js +73 -73
- package/lib/postcss.js +12 -11
- package/lib/previous-map.js +17 -17
- package/lib/result.js +7 -7
- package/lib/root.js +11 -11
- package/lib/rule.js +9 -9
- package/package.json +10 -10
package/lib/map-generator.js
CHANGED
@@ -5,24 +5,24 @@ var Base64 = require('js-base64').Base64;
|
|
5
5
|
var path = require('path');
|
6
6
|
|
7
7
|
// All tools to generate source maps
|
8
|
-
var MapGenerator = (function(){var DP$0 = Object.defineProperty;
|
8
|
+
var MapGenerator = (function(){"use strict";var PRS$0 = (function(o,t){o["__proto__"]={"a":t};return o["a"]===t})({},{});var DP$0 = Object.defineProperty;var GOPD$0 = Object.getOwnPropertyDescriptor;var MIXIN$0 = function(t,s){for(var p in s){if(s.hasOwnProperty(p)){DP$0(t,p,GOPD$0(s,p));}}return t};var proto$0={};
|
9
9
|
function MapGenerator(root, opts) {
|
10
10
|
this.root = root;
|
11
11
|
this.opts = opts;
|
12
12
|
this.mapOpts = opts.map || { };
|
13
|
-
}DP$0(MapGenerator,
|
13
|
+
}DP$0(MapGenerator,"prototype",{"configurable":false,"enumerable":false,"writable":false});
|
14
14
|
|
15
15
|
// Should map be generated
|
16
|
-
|
16
|
+
proto$0.isMap = function() {
|
17
17
|
if ( typeof(this.opts.map) != 'undefined' ) {
|
18
18
|
return !!this.opts.map;
|
19
19
|
} else {
|
20
20
|
return this.previous().length > 0;
|
21
21
|
}
|
22
|
-
}
|
22
|
+
};
|
23
23
|
|
24
24
|
// Return source map arrays from previous compilation step (like Sass)
|
25
|
-
|
25
|
+
proto$0.previous = function() {var this$0 = this;
|
26
26
|
if ( !this.previousMaps ) {
|
27
27
|
this.previousMaps = [];
|
28
28
|
this.root.eachInside( function(node) {
|
@@ -35,26 +35,26 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
35
35
|
}
|
36
36
|
|
37
37
|
return this.previousMaps;
|
38
|
-
}
|
38
|
+
};
|
39
39
|
|
40
40
|
// Should we inline source map to annotation comment
|
41
|
-
|
41
|
+
proto$0.isInline = function() {
|
42
42
|
if ( typeof(this.mapOpts.inline) != 'undefined' ) {
|
43
43
|
return this.mapOpts.inline;
|
44
44
|
}
|
45
45
|
return this.previous().some( function(i ) {return i.inline} );
|
46
|
-
}
|
46
|
+
};
|
47
47
|
|
48
48
|
// Should we set sourcesContent
|
49
|
-
|
49
|
+
proto$0.isSourcesContent = function() {
|
50
50
|
if ( typeof(this.mapOpts.sourcesContent) != 'undefined' ) {
|
51
51
|
return this.mapOpts.sourcesContent;
|
52
52
|
}
|
53
53
|
return this.previous().some( function(i ) {return i.withContent()} );
|
54
|
-
}
|
54
|
+
};
|
55
55
|
|
56
56
|
// Clear source map annotation comment
|
57
|
-
|
57
|
+
proto$0.clearAnnotation = function() {
|
58
58
|
var last = this.root.last;
|
59
59
|
if ( !last ) return;
|
60
60
|
if ( last.type != 'comment' ) return;
|
@@ -62,24 +62,26 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
62
62
|
if ( last.text.match(/^# sourceMappingURL=/) ) {
|
63
63
|
last.removeSelf();
|
64
64
|
}
|
65
|
-
}
|
65
|
+
};
|
66
66
|
|
67
67
|
// Set origin CSS content
|
68
|
-
|
68
|
+
proto$0.setSourcesContent = function() {var this$0 = this;
|
69
69
|
var already = { };
|
70
70
|
this.root.eachInside( function(node) {
|
71
|
-
|
72
|
-
|
73
|
-
already[file]
|
74
|
-
|
75
|
-
|
71
|
+
if ( node.source ) {
|
72
|
+
var file = node.source.file || node.source.id;
|
73
|
+
if ( file && !already[file] ) {
|
74
|
+
already[file] = true;
|
75
|
+
var relative = this$0.relative(file);
|
76
|
+
this$0.map.setSourceContent(relative, node.source.content);
|
77
|
+
}
|
76
78
|
}
|
77
79
|
});
|
78
|
-
}
|
80
|
+
};
|
79
81
|
|
80
82
|
// Apply source map from previous compilation step (like Sass)
|
81
|
-
|
82
|
-
$D$3 = (this.previous());$D$0 = GET_ITER$0($D$3);$D$2 = $D$0 === 0;$D$1 = ($D$2 ? $D$3.length : void 0);for ( var prev
|
83
|
+
proto$0.applyPrevMaps = function() {var S_ITER$0 = typeof Symbol!=='undefined'&&Symbol&&Symbol.iterator||'@@iterator';var S_MARK$0 = typeof Symbol!=='undefined'&&Symbol&&Symbol["__setObjectSetter__"];function GET_ITER$0(v){if(v){if(Array.isArray(v))return 0;var f;if(S_MARK$0)S_MARK$0(v);if(typeof v==='object'&&typeof (f=v[S_ITER$0])==='function'){if(S_MARK$0)S_MARK$0(void 0);return f.call(v);}if(S_MARK$0)S_MARK$0(void 0);if((v+'')==='[object Generator]')return v;}throw new Error(v+' is not iterable')};var $D$0;var $D$1;var $D$2;var $D$3;
|
84
|
+
$D$3 = (this.previous());$D$0 = GET_ITER$0($D$3);$D$2 = $D$0 === 0;$D$1 = ($D$2 ? $D$3.length : void 0);for ( var prev ;$D$2 ? ($D$0 < $D$1) : !($D$1 = $D$0["next"]())["done"];){prev = ($D$2 ? $D$3[$D$0++] : $D$1["value"]);
|
83
85
|
var from = this.relative(prev.file);
|
84
86
|
var root = prev.root || path.dirname(prev.file);
|
85
87
|
var map;
|
@@ -93,10 +95,10 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
93
95
|
|
94
96
|
this.map.applySourceMap(map, from, this.relative(root));
|
95
97
|
};$D$0 = $D$1 = $D$2 = $D$3 = void 0;
|
96
|
-
}
|
98
|
+
};
|
97
99
|
|
98
100
|
// Should we add annotation comment
|
99
|
-
|
101
|
+
proto$0.isAnnotation = function() {
|
100
102
|
if ( this.isInline() ) {
|
101
103
|
return true ;
|
102
104
|
} else if ( typeof(this.mapOpts.annotation) != 'undefined' ) {
|
@@ -106,10 +108,10 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
106
108
|
} else {
|
107
109
|
return true;
|
108
110
|
}
|
109
|
-
}
|
111
|
+
};
|
110
112
|
|
111
113
|
// Add source map annotation comment if it is needed
|
112
|
-
|
114
|
+
proto$0.addAnnotation = function() {
|
113
115
|
var content;
|
114
116
|
|
115
117
|
if ( this.isInline() ) {
|
@@ -124,15 +126,15 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
124
126
|
}
|
125
127
|
|
126
128
|
this.css += "\n/*# sourceMappingURL=" + content + " */";
|
127
|
-
}
|
129
|
+
};
|
128
130
|
|
129
131
|
// Return output CSS file path
|
130
|
-
|
132
|
+
proto$0.outputFile = function() {
|
131
133
|
return this.opts.to ? this.relative(this.opts.to) : 'to.css';
|
132
|
-
}
|
134
|
+
};
|
133
135
|
|
134
136
|
// Return Result object with map
|
135
|
-
|
137
|
+
proto$0.generateMap = function() {
|
136
138
|
this.stringify();
|
137
139
|
if ( this.isSourcesContent() ) this.setSourcesContent();
|
138
140
|
if ( this.previous().length > 0 ) this.applyPrevMaps();
|
@@ -143,10 +145,10 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
143
145
|
} else {
|
144
146
|
return [this.css, this.map];
|
145
147
|
}
|
146
|
-
}
|
148
|
+
};
|
147
149
|
|
148
150
|
// Return path relative from output CSS file
|
149
|
-
|
151
|
+
proto$0.relative = function(file) {
|
150
152
|
var from = this.opts.to ? path.dirname(this.opts.to) : '.';
|
151
153
|
|
152
154
|
if ( typeof(this.mapOpts.annotation) == 'string' ) {
|
@@ -155,19 +157,19 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
155
157
|
|
156
158
|
file = path.relative(from, file);
|
157
159
|
if ( path.sep == '\\' ) {
|
158
|
-
return file.replace(
|
160
|
+
return file.replace(/\\/g, '/');
|
159
161
|
} else {
|
160
162
|
return file;
|
161
163
|
}
|
162
|
-
}
|
164
|
+
};
|
163
165
|
|
164
166
|
// Return path of node source for map
|
165
|
-
|
167
|
+
proto$0.sourcePath = function(node) {
|
166
168
|
return this.relative(node.source.file || node.source.id);
|
167
|
-
}
|
169
|
+
};
|
168
170
|
|
169
171
|
// Return CSS string and source map
|
170
|
-
|
172
|
+
proto$0.stringify = function() {var this$0 = this;
|
171
173
|
this.css = '';
|
172
174
|
this.map = new mozilla.SourceMapGenerator({ file: this.outputFile() });
|
173
175
|
|
@@ -217,10 +219,10 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
217
219
|
};
|
218
220
|
|
219
221
|
this.root.stringify(builder);
|
220
|
-
}
|
222
|
+
};
|
221
223
|
|
222
224
|
// Return Result object with or without map
|
223
|
-
|
225
|
+
proto$0.generate = function() {
|
224
226
|
this.clearAnnotation();
|
225
227
|
|
226
228
|
if ( this.isMap() ) {
|
@@ -228,7 +230,7 @@ var MapGenerator = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
228
230
|
} else {
|
229
231
|
return [this.root.toString()];
|
230
232
|
}
|
231
|
-
}
|
232
|
-
;return MapGenerator;})();
|
233
|
+
};
|
234
|
+
MIXIN$0(MapGenerator.prototype,proto$0);proto$0=void 0;return MapGenerator;})();
|
233
235
|
|
234
236
|
module.exports = MapGenerator;
|
package/lib/node.js
CHANGED
@@ -38,12 +38,12 @@ var keys = function (obj, keys) {
|
|
38
38
|
};
|
39
39
|
|
40
40
|
// Some common methods for all CSS nodes
|
41
|
-
var Node = (function(){var DP$0 = Object.defineProperty;
|
41
|
+
var Node = (function(){"use strict";var PRS$0 = (function(o,t){o["__proto__"]={"a":t};return o["a"]===t})({},{});var DP$0 = Object.defineProperty;var GOPD$0 = Object.getOwnPropertyDescriptor;var MIXIN$0 = function(t,s){for(var p in s){if(s.hasOwnProperty(p)){DP$0(t,p,GOPD$0(s,p));}}return t};var proto$0={};
|
42
42
|
function Node() {var defaults = arguments[0];if(defaults === void 0)defaults = { };
|
43
43
|
for ( var name in defaults ) {
|
44
44
|
this[name] = defaults[name];
|
45
45
|
}
|
46
|
-
}DP$0(Node,
|
46
|
+
}DP$0(Node,"prototype",{"configurable":false,"enumerable":false,"writable":false});
|
47
47
|
|
48
48
|
// Remove this node from parent
|
49
49
|
//
|
@@ -52,31 +52,31 @@ var Node = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
52
52
|
// Note, that removing by index is faster:
|
53
53
|
//
|
54
54
|
// rule.each( (decl, i) => rule.remove(i) );
|
55
|
-
|
55
|
+
proto$0.removeSelf = function() {
|
56
56
|
if ( this.parent ) {
|
57
57
|
this.parent.remove(this);
|
58
58
|
}
|
59
59
|
return this;
|
60
|
-
}
|
60
|
+
};
|
61
61
|
|
62
62
|
// Shortcut to insert nodes before and remove self.
|
63
63
|
//
|
64
64
|
// importNode.replace( loadedRoot );
|
65
|
-
|
65
|
+
proto$0.replace = function(nodes) {
|
66
66
|
this.parent.insertBefore(this, nodes);
|
67
67
|
this.parent.remove(this);
|
68
68
|
return this;
|
69
|
-
}
|
69
|
+
};
|
70
70
|
|
71
71
|
// Return CSS string of current node
|
72
72
|
//
|
73
73
|
// decl.toString(); //=> " color: black"
|
74
|
-
|
74
|
+
proto$0.toString = function() {
|
75
75
|
var result = '';
|
76
76
|
var builder = function(str) {return result += str};
|
77
77
|
this.stringify(builder);
|
78
78
|
return result;
|
79
|
-
}
|
79
|
+
};
|
80
80
|
|
81
81
|
// Clone current node
|
82
82
|
//
|
@@ -85,16 +85,16 @@ var Node = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
85
85
|
// You can override properties while cloning:
|
86
86
|
//
|
87
87
|
// rule.append( decl.clone({ value: '0' }) );
|
88
|
-
|
88
|
+
proto$0.clone = function() {var overrides = arguments[0];if(overrides === void 0)overrides = { };
|
89
89
|
var cloned = clone(this);
|
90
90
|
for ( var name in overrides ) {
|
91
91
|
cloned[name] = overrides[name];
|
92
92
|
}
|
93
93
|
return cloned;
|
94
|
-
}
|
94
|
+
};
|
95
95
|
|
96
96
|
// Remove `parent` node on cloning to fix circular structures
|
97
|
-
|
97
|
+
proto$0.toJSON = function() {
|
98
98
|
var fixed = { };
|
99
99
|
|
100
100
|
for ( var name in this ) {
|
@@ -114,21 +114,21 @@ var Node = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
114
114
|
}
|
115
115
|
|
116
116
|
return fixed;
|
117
|
-
}
|
117
|
+
};
|
118
118
|
|
119
119
|
// Default code style
|
120
|
-
|
120
|
+
proto$0.defaultStyle = function() {
|
121
121
|
return { };
|
122
|
-
}
|
122
|
+
};
|
123
123
|
|
124
124
|
// Allow to split node with same type by other critera.
|
125
125
|
// For example, to use different style for bodiless at-rules.
|
126
|
-
|
126
|
+
proto$0.styleType = function() {
|
127
127
|
return this.type;
|
128
|
-
}
|
128
|
+
};
|
129
129
|
|
130
130
|
// Copy code style from first node with same type
|
131
|
-
|
131
|
+
proto$0.style = function() {var this$0 = this;
|
132
132
|
var type = this.styleType();
|
133
133
|
var defaults = this.defaultStyle(type);
|
134
134
|
|
@@ -171,10 +171,10 @@ var Node = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
171
171
|
}
|
172
172
|
|
173
173
|
return merge;
|
174
|
-
}
|
174
|
+
};
|
175
175
|
|
176
176
|
// Use raw value if origin was not changed
|
177
|
-
|
177
|
+
proto$0.stringifyRaw = function(prop) {
|
178
178
|
var value = this[prop];
|
179
179
|
var raw = this['_' + prop];
|
180
180
|
if ( raw && raw.value === value ) {
|
@@ -182,7 +182,7 @@ var Node = (function(){var DP$0 = Object.defineProperty;"use strict";
|
|
182
182
|
} else {
|
183
183
|
return value;
|
184
184
|
}
|
185
|
-
}
|
186
|
-
;return Node;})();
|
185
|
+
};
|
186
|
+
MIXIN$0(Node.prototype,proto$0);proto$0=void 0;return Node;})();
|
187
187
|
|
188
188
|
module.exports = Node;
|