postcss 5.0.10 → 5.0.14
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 +16 -0
- package/README.md +178 -695
- package/d.ts/at-rule.d.ts +0 -2
- package/d.ts/css-syntax-error.d.ts +0 -1
- package/d.ts/parser.d.ts +0 -1
- package/docs/api.md +4 -4
- package/docs/guidelines/plugin.md +3 -3
- package/docs/plugins.md +572 -0
- package/docs/source-maps.md +68 -0
- package/docs/writing-a-plugin.md +27 -0
- package/lib/at-rule.js +36 -31
- package/lib/comment.js +33 -18
- package/lib/container.js +62 -36
- package/lib/css-syntax-error.js +13 -23
- package/lib/declaration.js +33 -18
- package/lib/input.js +17 -17
- package/lib/lazy-result.js +25 -20
- package/lib/list.js +1 -5
- package/lib/map-generator.js +34 -33
- package/lib/node.js +66 -44
- package/lib/parse.js +6 -6
- package/lib/parser.js +17 -39
- package/lib/postcss.js +14 -14
- package/lib/previous-map.js +20 -18
- package/lib/processor.js +9 -11
- package/lib/result.js +8 -8
- package/lib/root.js +22 -13
- package/lib/rule.js +25 -16
- package/lib/stringifier.js +2 -4
- package/lib/stringify.js +4 -5
- package/lib/tokenize.js +2 -3
- package/lib/vendor.js +1 -4
- package/lib/warn-once.js +3 -2
- package/lib/warning.js +7 -3
- package/package.json +21 -18
package/lib/declaration.js
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5
|
+
exports.__esModule = true;
|
12
6
|
|
13
7
|
var _warnOnce = require('./warn-once');
|
14
8
|
|
@@ -18,40 +12,61 @@ var _node = require('./node');
|
|
18
12
|
|
19
13
|
var _node2 = _interopRequireDefault(_node);
|
20
14
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18
|
+
|
19
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
20
|
+
|
21
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
22
|
+
|
21
23
|
var Declaration = (function (_Node) {
|
22
24
|
_inherits(Declaration, _Node);
|
23
25
|
|
24
26
|
function Declaration(defaults) {
|
25
27
|
_classCallCheck(this, Declaration);
|
26
28
|
|
27
|
-
_Node.call(this, defaults);
|
28
|
-
|
29
|
+
var _this = _possibleConstructorReturn(this, _Node.call(this, defaults));
|
30
|
+
|
31
|
+
_this.type = 'decl';
|
32
|
+
return _this;
|
29
33
|
}
|
30
34
|
|
35
|
+
/* istanbul ignore next */
|
36
|
+
|
31
37
|
_createClass(Declaration, [{
|
32
38
|
key: '_value',
|
33
39
|
get: function get() {
|
34
|
-
_warnOnce2
|
40
|
+
(0, _warnOnce2.default)('Node#_value was deprecated. Use Node#raws.value');
|
35
41
|
return this.raws.value;
|
36
|
-
}
|
42
|
+
}
|
43
|
+
|
44
|
+
/* istanbul ignore next */
|
45
|
+
,
|
37
46
|
set: function set(val) {
|
38
|
-
_warnOnce2
|
47
|
+
(0, _warnOnce2.default)('Node#_value was deprecated. Use Node#raws.value');
|
39
48
|
this.raws.value = val;
|
40
49
|
}
|
50
|
+
|
51
|
+
/* istanbul ignore next */
|
52
|
+
|
41
53
|
}, {
|
42
54
|
key: '_important',
|
43
55
|
get: function get() {
|
44
|
-
_warnOnce2
|
56
|
+
(0, _warnOnce2.default)('Node#_important was deprecated. Use Node#raws.important');
|
45
57
|
return this.raws.important;
|
46
|
-
}
|
58
|
+
}
|
59
|
+
|
60
|
+
/* istanbul ignore next */
|
61
|
+
,
|
47
62
|
set: function set(val) {
|
48
|
-
_warnOnce2
|
63
|
+
(0, _warnOnce2.default)('Node#_important was deprecated. Use Node#raws.important');
|
49
64
|
this.raws.important = val;
|
50
65
|
}
|
51
66
|
}]);
|
52
67
|
|
53
68
|
return Declaration;
|
54
|
-
})(_node2
|
69
|
+
})(_node2.default);
|
55
70
|
|
56
|
-
exports
|
71
|
+
exports.default = Declaration;
|
57
72
|
module.exports = exports['default'];
|
package/lib/input.js
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
5
|
+
exports.__esModule = true;
|
10
6
|
|
11
7
|
var _cssSyntaxError = require('./css-syntax-error');
|
12
8
|
|
@@ -20,6 +16,10 @@ var _path = require('path');
|
|
20
16
|
|
21
17
|
var _path2 = _interopRequireDefault(_path);
|
22
18
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
|
+
|
21
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
22
|
+
|
23
23
|
var sequence = 0;
|
24
24
|
|
25
25
|
var Input = (function () {
|
@@ -34,9 +34,9 @@ var Input = (function () {
|
|
34
34
|
this.css = this.css.slice(1);
|
35
35
|
}
|
36
36
|
|
37
|
-
if (opts.from) this.file = _path2
|
37
|
+
if (opts.from) this.file = _path2.default.resolve(opts.from);
|
38
38
|
|
39
|
-
var map = new _previousMap2
|
39
|
+
var map = new _previousMap2.default(this.css, opts);
|
40
40
|
if (map.text) {
|
41
41
|
this.map = map;
|
42
42
|
var file = map.consumer().file;
|
@@ -53,18 +53,18 @@ var Input = (function () {
|
|
53
53
|
Input.prototype.error = function error(message, line, column) {
|
54
54
|
var opts = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
|
55
55
|
|
56
|
-
var
|
56
|
+
var result = undefined;
|
57
57
|
var origin = this.origin(line, column);
|
58
58
|
if (origin) {
|
59
|
-
|
59
|
+
result = new _cssSyntaxError2.default(message, origin.line, origin.column, origin.source, origin.file, opts.plugin);
|
60
60
|
} else {
|
61
|
-
|
61
|
+
result = new _cssSyntaxError2.default(message, line, column, this.css, this.file, opts.plugin);
|
62
62
|
}
|
63
63
|
|
64
|
-
|
65
|
-
if (this.file)
|
64
|
+
result.input = { line: line, column: column, source: this.css };
|
65
|
+
if (this.file) result.input.file = this.file;
|
66
66
|
|
67
|
-
return
|
67
|
+
return result;
|
68
68
|
};
|
69
69
|
|
70
70
|
Input.prototype.origin = function origin(line, column) {
|
@@ -80,14 +80,14 @@ var Input = (function () {
|
|
80
80
|
column: from.column
|
81
81
|
};
|
82
82
|
|
83
|
-
var source = consumer.sourceContentFor(
|
83
|
+
var source = consumer.sourceContentFor(from.source);
|
84
84
|
if (source) result.source = source;
|
85
85
|
|
86
86
|
return result;
|
87
87
|
};
|
88
88
|
|
89
89
|
Input.prototype.mapResolve = function mapResolve(file) {
|
90
|
-
return _path2
|
90
|
+
return _path2.default.resolve(this.map.consumer().sourceRoot || '.', file);
|
91
91
|
};
|
92
92
|
|
93
93
|
_createClass(Input, [{
|
@@ -100,5 +100,5 @@ var Input = (function () {
|
|
100
100
|
return Input;
|
101
101
|
})();
|
102
102
|
|
103
|
-
exports
|
103
|
+
exports.default = Input;
|
104
104
|
module.exports = exports['default'];
|
package/lib/lazy-result.js
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
3
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
5
|
+
exports.__esModule = true;
|
10
6
|
|
11
7
|
var _mapGenerator = require('./map-generator');
|
12
8
|
|
@@ -28,8 +24,14 @@ var _parse = require('./parse');
|
|
28
24
|
|
29
25
|
var _parse2 = _interopRequireDefault(_parse);
|
30
26
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
28
|
+
|
29
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
30
|
+
|
31
|
+
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
|
32
|
+
|
31
33
|
function isPromise(obj) {
|
32
|
-
return typeof obj === 'object' && typeof obj.then === 'function';
|
34
|
+
return (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && typeof obj.then === 'function';
|
33
35
|
}
|
34
36
|
|
35
37
|
var LazyResult = (function () {
|
@@ -40,15 +42,17 @@ var LazyResult = (function () {
|
|
40
42
|
this.processed = false;
|
41
43
|
|
42
44
|
var root = undefined;
|
43
|
-
if (typeof css === 'object' && css.type === 'root') {
|
45
|
+
if ((typeof css === 'undefined' ? 'undefined' : _typeof(css)) === 'object' && css.type === 'root') {
|
44
46
|
root = css;
|
45
|
-
} else if (css instanceof LazyResult || css instanceof _result2
|
47
|
+
} else if (css instanceof LazyResult || css instanceof _result2.default) {
|
46
48
|
root = css.root;
|
47
|
-
if (css.map
|
48
|
-
opts.map
|
49
|
+
if (css.map) {
|
50
|
+
if (typeof opts.map === 'undefined') opts.map = {};
|
51
|
+
if (!opts.map.inline) opts.map.inline = false;
|
52
|
+
opts.map.prev = css.map;
|
49
53
|
}
|
50
54
|
} else {
|
51
|
-
var parser = _parse2
|
55
|
+
var parser = _parse2.default;
|
52
56
|
if (opts.syntax) parser = opts.syntax.parse;
|
53
57
|
if (opts.parser) parser = opts.parser;
|
54
58
|
if (parser.parse) parser = parser.parse;
|
@@ -60,7 +64,7 @@ var LazyResult = (function () {
|
|
60
64
|
}
|
61
65
|
}
|
62
66
|
|
63
|
-
this.result = new _result2
|
67
|
+
this.result = new _result2.default(processor, root, opts);
|
64
68
|
}
|
65
69
|
|
66
70
|
LazyResult.prototype.warnings = function warnings() {
|
@@ -75,8 +79,8 @@ var LazyResult = (function () {
|
|
75
79
|
return this.async().then(onFulfilled, onRejected);
|
76
80
|
};
|
77
81
|
|
78
|
-
LazyResult.prototype
|
79
|
-
return this.async()
|
82
|
+
LazyResult.prototype.catch = function _catch(onRejected) {
|
83
|
+
return this.async().catch(onRejected);
|
80
84
|
};
|
81
85
|
|
82
86
|
LazyResult.prototype.handleError = function handleError(error, plugin) {
|
@@ -93,10 +97,11 @@ var LazyResult = (function () {
|
|
93
97
|
var b = runtimeVer.split('.');
|
94
98
|
|
95
99
|
if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
|
96
|
-
_warnOnce2
|
100
|
+
(0, _warnOnce2.default)('Your current PostCSS version is ' + runtimeVer + ', ' + ('but ' + pluginName + ' uses ' + pluginVer + '. Perhaps ') + 'this is the source of the error below.');
|
97
101
|
}
|
98
102
|
}
|
99
103
|
} catch (err) {
|
104
|
+
/* istanbul ignore next */
|
100
105
|
if (console && console.error) console.error(err);
|
101
106
|
}
|
102
107
|
};
|
@@ -118,7 +123,7 @@ var LazyResult = (function () {
|
|
118
123
|
if (isPromise(promise)) {
|
119
124
|
promise.then(function () {
|
120
125
|
_this.asyncTick(resolve, reject);
|
121
|
-
})
|
126
|
+
}).catch(function (error) {
|
122
127
|
_this.handleError(error, plugin);
|
123
128
|
_this.processed = true;
|
124
129
|
reject(error);
|
@@ -212,12 +217,12 @@ var LazyResult = (function () {
|
|
212
217
|
this.sync();
|
213
218
|
|
214
219
|
var opts = this.result.opts;
|
215
|
-
var str = _stringify3
|
220
|
+
var str = _stringify3.default;
|
216
221
|
if (opts.syntax) str = opts.syntax.stringify;
|
217
222
|
if (opts.stringifier) str = opts.stringifier;
|
218
223
|
if (str.stringify) str = str.stringify;
|
219
224
|
|
220
|
-
var map = new _mapGenerator2
|
225
|
+
var map = new _mapGenerator2.default(str, this.result.root, this.result.opts);
|
221
226
|
var data = map.generate();
|
222
227
|
this.result.css = data[0];
|
223
228
|
this.result.map = data[1];
|
@@ -265,5 +270,5 @@ var LazyResult = (function () {
|
|
265
270
|
return LazyResult;
|
266
271
|
})();
|
267
272
|
|
268
|
-
exports
|
273
|
+
exports.default = LazyResult;
|
269
274
|
module.exports = exports['default'];
|
package/lib/list.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
var list = {
|
5
|
-
|
6
5
|
split: function split(string, separators, last) {
|
7
6
|
var array = [];
|
8
7
|
var current = '';
|
@@ -45,18 +44,15 @@ var list = {
|
|
45
44
|
if (last || current !== '') array.push(current.trim());
|
46
45
|
return array;
|
47
46
|
},
|
48
|
-
|
49
47
|
space: function space(string) {
|
50
48
|
var spaces = [' ', '\n', '\t'];
|
51
49
|
return list.split(string, spaces);
|
52
50
|
},
|
53
|
-
|
54
51
|
comma: function comma(string) {
|
55
52
|
var comma = ',';
|
56
53
|
return list.split(string, [comma], true);
|
57
54
|
}
|
58
|
-
|
59
55
|
};
|
60
56
|
|
61
|
-
exports
|
57
|
+
exports.default = list;
|
62
58
|
module.exports = exports['default'];
|
package/lib/map-generator.js
CHANGED
@@ -2,11 +2,7 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
8
|
-
|
9
|
-
var _jsBase64 = require('js-base64');
|
5
|
+
var _jsBase = require('js-base64');
|
10
6
|
|
11
7
|
var _sourceMap = require('source-map');
|
12
8
|
|
@@ -16,9 +12,13 @@ var _path = require('path');
|
|
16
12
|
|
17
13
|
var _path2 = _interopRequireDefault(_path);
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18
|
+
|
19
|
+
var _class = (function () {
|
20
|
+
function _class(stringify, root, opts) {
|
21
|
+
_classCallCheck(this, _class);
|
22
22
|
|
23
23
|
this.stringify = stringify;
|
24
24
|
this.mapOpts = opts.map || {};
|
@@ -26,7 +26,7 @@ var _default = (function () {
|
|
26
26
|
this.opts = opts;
|
27
27
|
}
|
28
28
|
|
29
|
-
|
29
|
+
_class.prototype.isMap = function isMap() {
|
30
30
|
if (typeof this.opts.map !== 'undefined') {
|
31
31
|
return !!this.opts.map;
|
32
32
|
} else {
|
@@ -34,7 +34,7 @@ var _default = (function () {
|
|
34
34
|
}
|
35
35
|
};
|
36
36
|
|
37
|
-
|
37
|
+
_class.prototype.previous = function previous() {
|
38
38
|
var _this = this;
|
39
39
|
|
40
40
|
if (!this.previousMaps) {
|
@@ -52,7 +52,7 @@ var _default = (function () {
|
|
52
52
|
return this.previousMaps;
|
53
53
|
};
|
54
54
|
|
55
|
-
|
55
|
+
_class.prototype.isInline = function isInline() {
|
56
56
|
if (typeof this.mapOpts.inline !== 'undefined') {
|
57
57
|
return this.mapOpts.inline;
|
58
58
|
}
|
@@ -71,7 +71,7 @@ var _default = (function () {
|
|
71
71
|
}
|
72
72
|
};
|
73
73
|
|
74
|
-
|
74
|
+
_class.prototype.isSourcesContent = function isSourcesContent() {
|
75
75
|
if (typeof this.mapOpts.sourcesContent !== 'undefined') {
|
76
76
|
return this.mapOpts.sourcesContent;
|
77
77
|
}
|
@@ -84,7 +84,7 @@ var _default = (function () {
|
|
84
84
|
}
|
85
85
|
};
|
86
86
|
|
87
|
-
|
87
|
+
_class.prototype.clearAnnotation = function clearAnnotation() {
|
88
88
|
if (this.mapOpts.annotation === false) return;
|
89
89
|
|
90
90
|
var node = undefined;
|
@@ -97,7 +97,7 @@ var _default = (function () {
|
|
97
97
|
}
|
98
98
|
};
|
99
99
|
|
100
|
-
|
100
|
+
_class.prototype.setSourcesContent = function setSourcesContent() {
|
101
101
|
var _this2 = this;
|
102
102
|
|
103
103
|
var already = {};
|
@@ -113,7 +113,7 @@ var _default = (function () {
|
|
113
113
|
});
|
114
114
|
};
|
115
115
|
|
116
|
-
|
116
|
+
_class.prototype.applyPrevMaps = function applyPrevMaps() {
|
117
117
|
for (var _iterator = this.previous(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
118
118
|
var _ref;
|
119
119
|
|
@@ -129,11 +129,11 @@ var _default = (function () {
|
|
129
129
|
var prev = _ref;
|
130
130
|
|
131
131
|
var from = this.relative(prev.file);
|
132
|
-
var root = prev.root || _path2
|
132
|
+
var root = prev.root || _path2.default.dirname(prev.file);
|
133
133
|
var map = undefined;
|
134
134
|
|
135
135
|
if (this.mapOpts.sourcesContent === false) {
|
136
|
-
map = new _sourceMap2
|
136
|
+
map = new _sourceMap2.default.SourceMapConsumer(prev.text);
|
137
137
|
if (map.sourcesContent) {
|
138
138
|
map.sourcesContent = map.sourcesContent.map(function () {
|
139
139
|
return null;
|
@@ -147,7 +147,7 @@ var _default = (function () {
|
|
147
147
|
}
|
148
148
|
};
|
149
149
|
|
150
|
-
|
150
|
+
_class.prototype.isAnnotation = function isAnnotation() {
|
151
151
|
if (this.isInline()) {
|
152
152
|
return true;
|
153
153
|
} else if (typeof this.mapOpts.annotation !== 'undefined') {
|
@@ -161,11 +161,11 @@ var _default = (function () {
|
|
161
161
|
}
|
162
162
|
};
|
163
163
|
|
164
|
-
|
164
|
+
_class.prototype.addAnnotation = function addAnnotation() {
|
165
165
|
var content = undefined;
|
166
166
|
|
167
167
|
if (this.isInline()) {
|
168
|
-
content = 'data:application/json;base64,' +
|
168
|
+
content = 'data:application/json;base64,' + _jsBase.Base64.encode(this.map.toString());
|
169
169
|
} else if (typeof this.mapOpts.annotation === 'string') {
|
170
170
|
content = this.mapOpts.annotation;
|
171
171
|
} else {
|
@@ -178,7 +178,7 @@ var _default = (function () {
|
|
178
178
|
this.css += eol + '/*# sourceMappingURL=' + content + ' */';
|
179
179
|
};
|
180
180
|
|
181
|
-
|
181
|
+
_class.prototype.outputFile = function outputFile() {
|
182
182
|
if (this.opts.to) {
|
183
183
|
return this.relative(this.opts.to);
|
184
184
|
} else if (this.opts.from) {
|
@@ -188,7 +188,7 @@ var _default = (function () {
|
|
188
188
|
}
|
189
189
|
};
|
190
190
|
|
191
|
-
|
191
|
+
_class.prototype.generateMap = function generateMap() {
|
192
192
|
this.generateString();
|
193
193
|
if (this.isSourcesContent()) this.setSourcesContent();
|
194
194
|
if (this.previous().length > 0) this.applyPrevMaps();
|
@@ -201,30 +201,31 @@ var _default = (function () {
|
|
201
201
|
}
|
202
202
|
};
|
203
203
|
|
204
|
-
|
205
|
-
var from = this.opts.to ? _path2
|
204
|
+
_class.prototype.relative = function relative(file) {
|
205
|
+
var from = this.opts.to ? _path2.default.dirname(this.opts.to) : '.';
|
206
206
|
|
207
207
|
if (typeof this.mapOpts.annotation === 'string') {
|
208
|
-
from = _path2
|
208
|
+
from = _path2.default.dirname(_path2.default.resolve(from, this.mapOpts.annotation));
|
209
209
|
}
|
210
210
|
|
211
|
-
file = _path2
|
212
|
-
|
211
|
+
file = _path2.default.relative(from, file);
|
212
|
+
/* istanbul ignore next */
|
213
|
+
if (_path2.default.sep === '\\') {
|
213
214
|
return file.replace(/\\/g, '/');
|
214
215
|
} else {
|
215
216
|
return file;
|
216
217
|
}
|
217
218
|
};
|
218
219
|
|
219
|
-
|
220
|
+
_class.prototype.sourcePath = function sourcePath(node) {
|
220
221
|
return this.relative(node.source.input.from);
|
221
222
|
};
|
222
223
|
|
223
|
-
|
224
|
+
_class.prototype.generateString = function generateString() {
|
224
225
|
var _this3 = this;
|
225
226
|
|
226
227
|
this.css = '';
|
227
|
-
this.map = new _sourceMap2
|
228
|
+
this.map = new _sourceMap2.default.SourceMapGenerator({ file: this.outputFile() });
|
228
229
|
|
229
230
|
var line = 1;
|
230
231
|
var column = 1;
|
@@ -267,7 +268,7 @@ var _default = (function () {
|
|
267
268
|
});
|
268
269
|
};
|
269
270
|
|
270
|
-
|
271
|
+
_class.prototype.generate = function generate() {
|
271
272
|
this.clearAnnotation();
|
272
273
|
|
273
274
|
if (this.isMap()) {
|
@@ -281,8 +282,8 @@ var _default = (function () {
|
|
281
282
|
}
|
282
283
|
};
|
283
284
|
|
284
|
-
return
|
285
|
+
return _class;
|
285
286
|
})();
|
286
287
|
|
287
|
-
exports
|
288
|
+
exports.default = _class;
|
288
289
|
module.exports = exports['default'];
|