result.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. 'use strict';
  2. exports.__esModule = true;
  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; }; }();
  4. var _warning = require('./warning');
  5. var _warning2 = _interopRequireDefault(_warning);
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8. /**
  9. * Provides the result of the PostCSS transformations.
  10. *
  11. * A Result instance is returned by {@link LazyResult#then}
  12. * or {@link Root#toResult} methods.
  13. *
  14. * @example
  15. * postcss([cssnext]).process(css).then(function (result) {
  16. * console.log(result.css);
  17. * });
  18. *
  19. * @example
  20. * var result2 = postcss.parse(css).toResult();
  21. */
  22. var Result = function () {
  23. /**
  24. * @param {Processor} processor - processor used for this transformation.
  25. * @param {Root} root - Root node after all transformations.
  26. * @param {processOptions} opts - options from the {@link Processor#process}
  27. * or {@link Root#toResult}
  28. */
  29. function Result(processor, root, opts) {
  30. _classCallCheck(this, Result);
  31. /**
  32. * @member {Processor} - The Processor instance used
  33. * for this transformation.
  34. *
  35. * @example
  36. * for ( let plugin of result.processor.plugins) {
  37. * if ( plugin.postcssPlugin === 'postcss-bad' ) {
  38. * throw 'postcss-good is incompatible with postcss-bad';
  39. * }
  40. * });
  41. */
  42. this.processor = processor;
  43. /**
  44. * @member {Message[]} - Contains messages from plugins
  45. * (e.g., warnings or custom messages).
  46. * Each message should have type
  47. * and plugin properties.
  48. *
  49. * @example
  50. * postcss.plugin('postcss-min-browser', () => {
  51. * return (root, result) => {
  52. * var browsers = detectMinBrowsersByCanIUse(root);
  53. * result.messages.push({
  54. * type: 'min-browser',
  55. * plugin: 'postcss-min-browser',
  56. * browsers: browsers
  57. * });
  58. * };
  59. * });
  60. */
  61. this.messages = [];
  62. /**
  63. * @member {Root} - Root node after all transformations.
  64. *
  65. * @example
  66. * root.toResult().root == root;
  67. */
  68. this.root = root;
  69. /**
  70. * @member {processOptions} - Options from the {@link Processor#process}
  71. * or {@link Root#toResult} call
  72. * that produced this Result instance.
  73. *
  74. * @example
  75. * root.toResult(opts).opts == opts;
  76. */
  77. this.opts = opts;
  78. /**
  79. * @member {string} - A CSS string representing of {@link Result#root}.
  80. *
  81. * @example
  82. * postcss.parse('a{}').toResult().css //=> "a{}"
  83. */
  84. this.css = undefined;
  85. /**
  86. * @member {SourceMapGenerator} - An instance of `SourceMapGenerator`
  87. * class from the `source-map` library,
  88. * representing changes
  89. * to the {@link Result#root} instance.
  90. *
  91. * @example
  92. * result.map.toJSON() //=> { version: 3, file: 'a.css', … }
  93. *
  94. * @example
  95. * if ( result.map ) {
  96. * fs.writeFileSync(result.opts.to + '.map', result.map.toString());
  97. * }
  98. */
  99. this.map = undefined;
  100. }
  101. /**
  102. * Returns for @{link Result#css} content.
  103. *
  104. * @example
  105. * result + '' === result.css
  106. *
  107. * @return {string} string representing of {@link Result#root}
  108. */
  109. Result.prototype.toString = function toString() {
  110. return this.css;
  111. };
  112. /**
  113. * Creates an instance of {@link Warning} and adds it
  114. * to {@link Result#messages}.
  115. *
  116. * @param {string} text - warning message
  117. * @param {Object} [opts] - warning options
  118. * @param {Node} opts.node - CSS node that caused the warning
  119. * @param {string} opts.word - word in CSS source that caused the warning
  120. * @param {number} opts.index - index in CSS node string that caused
  121. * the warning
  122. * @param {string} opts.plugin - name of the plugin that created
  123. * this warning. {@link Result#warn} fills
  124. * this property automatically.
  125. *
  126. * @return {Warning} created warning
  127. */
  128. Result.prototype.warn = function warn(text) {
  129. var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  130. if (!opts.plugin) {
  131. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  132. opts.plugin = this.lastPlugin.postcssPlugin;
  133. }
  134. }
  135. var warning = new _warning2.default(text, opts);
  136. this.messages.push(warning);
  137. return warning;
  138. };
  139. /**
  140. * Returns warnings from plugins. Filters {@link Warning} instances
  141. * from {@link Result#messages}.
  142. *
  143. * @example
  144. * result.warnings().forEach(warn => {
  145. * console.warn(warn.toString());
  146. * });
  147. *
  148. * @return {Warning[]} warnings from plugins
  149. */
  150. Result.prototype.warnings = function warnings() {
  151. return this.messages.filter(function (i) {
  152. return i.type === 'warning';
  153. });
  154. };
  155. /**
  156. * An alias for the {@link Result#css} property.
  157. * Use it with syntaxes that generate non-CSS output.
  158. * @type {string}
  159. *
  160. * @example
  161. * result.css === result.content;
  162. */
  163. _createClass(Result, [{
  164. key: 'content',
  165. get: function get() {
  166. return this.css;
  167. }
  168. }]);
  169. return Result;
  170. }();
  171. exports.default = Result;
  172. /**
  173. * @typedef {object} Message
  174. * @property {string} type - message type
  175. * @property {string} plugin - source PostCSS plugin name
  176. */
  177. module.exports = exports['default'];
  178. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJlc3VsdC5lczYiXSwibmFtZXMiOlsiUmVzdWx0IiwicHJvY2Vzc29yIiwicm9vdCIsIm9wdHMiLCJtZXNzYWdlcyIsImNzcyIsInVuZGVmaW5lZCIsIm1hcCIsInRvU3RyaW5nIiwid2FybiIsInRleHQiLCJwbHVnaW4iLCJsYXN0UGx1Z2luIiwicG9zdGNzc1BsdWdpbiIsIndhcm5pbmciLCJwdXNoIiwid2FybmluZ3MiLCJmaWx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ICAgICByb290ICAgICAgLSBSb290IG5vZGUgYWZ0ZXIgYWxsIHRyYW5zZm9ybWF0aW9ucy5cbiAgICAgKiBAcGFyYW0ge3Byb2Nlc3NPcHRpb25zfSBvcHRzIC0gb3B0aW9ucyBmcm9tIHRoZSB7QGxpbmsgUHJvY2Vzc29yI3Byb2Nlc3N9XG4gICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yIHtAbGluayBSb290I3RvUmVzdWx0fVxuICAgICAqL1xuICAgIGNvbnN0cnVjdG9yKHByb2Nlc3Nvciwgcm9vdCwgb3B0cykge1xuICAgICAgICAvKipcbiAgICAgICAgICogQG1lbWJlciB7UHJvY2Vzc29yfSAtIFRoZSBQcm9jZXNzb3IgaW5zdGFuY2UgdXNlZFxuICAgICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgZm9yIHRoaXMgdHJhbnNmb3JtYXRpb24uXG4gICAgICAgICAqXG4gICAgICAgICAqIEBleGFtcGxlXG4gICAgICAgICAqIGZvciAoIGxldCBwbHVnaW4gb2YgcmVzdWx0LnByb2Nlc3Nvci5wbHVnaW5zKSB7XG4gICAgICAgICAqICAgaWYgKCBwbHVnaW4ucG9zdGNzc1BsdWdpbiA9PT0gJ3Bvc3Rjc3MtYmFkJyApIHtcbiAgICAgICAgICogICAgIHRocm93ICdwb3N0Y3NzLWdvb2QgaXMgaW5jb21wYXRpYmxlIHdpdGggcG9zdGNzcy1iYWQnO1xuICAgICAgICAgKiAgIH1cbiAgICAgICAgICogfSk7XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLnByb2Nlc3NvciA9IHByb2Nlc3NvcjtcbiAgICAgICAgLyoqXG4gICAgICAgICAqIEBtZW1iZXIge01lc3NhZ2VbXX0gLSBDb250YWlucyBtZXNzYWdlcyBmcm9tIHBsdWdpbnNcbiAgICAgICAgICogICAgICAgICAgICAgICAgICAgICAgIChlLmcuLCB3YXJuaW5ncyBvciBjdXN0b20gbWVzc2FnZXMpLlxuICAgICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgRWFjaCBtZXNzYWdlIHNob3VsZCBoYXZlIHR5cGVcbiAgICAgICAgICogICAgICAgICAgICAgICAgICAgICAgIGFuZCBwbHVnaW4gcHJvcGVydGllcy5cbiAgICAgICAgICpcbiAgICAgICAgICogQGV4YW1wbGVcbiAgICAgICAgICogcG9zdGNzcy5wbHVnaW4oJ3Bvc3Rjc3MtbWluLWJyb3dzZXInLCAoKSA9PiB7XG4gICAgICAgICAqICAgcmV0dXJuIChyb290LCByZXN1bHQpID0+IHtcbiAgICAgICAgICogICAgIHZhciBicm93c2VycyA9IGRldGVjdE1pbkJyb3dzZXJzQnlDYW5JVXNlKHJvb3QpO1xuICAgICAgICAgKiAgICAgcmVzdWx0Lm1lc3NhZ2VzLnB1c2goe1xuICAgICAgICAgKiAgICAgICB0eXBlOiAgICAnbWluLWJyb3dzZXInLFxuICAgICAgICAgKiAgICAgICBwbHVnaW46ICAncG9zdGNzcy1taW4tYnJvd3NlcicsXG4gICAgICAgICAqICAgICAgIGJyb3dzZXJzOiBicm93c2Vyc1xuICAgICAgICAgKiAgICAgfSk7XG4gICAgICAgICAqICAgfTtcbiAgICAgICAgICogfSk7XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLm1lc3NhZ2VzID0gW107XG4gICAgICAgIC8qKlxuICAgICAgICAgKiBAbWVtYmVyIHtSb290fSAtIFJvb3Qgbm9kZSBhZnRlciBhbGwgdHJhbnNmb3JtYXRpb25zLlxuICAgICAgICAgKlxuICAgICAgICAgKiBAZXhhbXBsZVxuICAgICAgICAgKiByb290LnRvUmVzdWx0KCkucm9vdCA9PSByb290O1xuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5yb290ID0gcm9vdDtcbiAgICAgICAgLyoqXG4gICAgICAgICAqIEBtZW1iZXIge3Byb2Nlc3NPcHRpb25zfSAtIE9wdGlvbnMgZnJvbSB0aGUge0BsaW5rIFByb2Nlc3NvciNwcm9jZXNzfVxuICAgICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvciB7QGxpbmsgUm9vdCN0b1Jlc3VsdH0gY2FsbFxuICAgICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0IHByb2R1Y2VkIHRoaXMgUmVzdWx0IGluc3RhbmNlLlxuICAgICAgICAgKlxuICAgICAgICAgKiBAZXhhbXBsZVxuICAgICAgICAgKiByb290LnRvUmVzdWx0KG9wdHMpLm9wdHMgPT0gb3B0cztcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMub3B0cyA9IG9wdHM7XG4gICAgICAgIC8qKlxuICAgICAgICAgKiBAbWVtYmVyIHtzdHJpbmd9IC0gQSBDU1Mgc3RyaW5nIHJlcHJlc2VudGluZyBvZiB7QGxpbmsgUmVzdWx0I3Jvb3R9LlxuICAgICAgICAgKlxuICAgICAgICAgKiBAZXhhbXBsZVxuICAgICAgICAgKiBwb3N0Y3NzLnBhcnNlKCdhe30nKS50b1Jlc3VsdCgpLmNzcyAvLz0+IFwiYXt9XCJcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuY3NzID0gdW5kZWZpbmVkO1xuICAgICAgICAvKipcbiAgICAgICAgICogQG1lbWJlciB7U291cmNlTWFwR2VuZXJhdG9yfSAtIEFuIGluc3RhbmNlIG9mIGBTb3VyY2VNYXBHZW5lcmF0b3JgXG4gICAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGFzcyBmcm9tIHRoZSBgc291cmNlLW1hcGAgbGlicmFyeSxcbiAgICAgICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcHJlc2VudGluZyBjaGFuZ2VzXG4gICAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0byB0aGUge0BsaW5rIFJlc3VsdCNyb290fSBpbnN0YW5jZS5cbiAgICAgICAgICpcbiAgICAgICAgICogQGV4YW1wbGVcbiAgICAgICAgICogcmVzdWx0Lm1hcC50b0pTT04oKSAvLz0+I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Q1NTIHNvdXJjZSB0aGF0IGNhdXNlZCB0aGUgd2FybmluZ1xuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBvcHRzLmluZGV4ICAtIGluZGV4IGluIENTUyBub2RlIHN0cmluZyB0aGF0IGNhdXNlZFxuICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSB3YXJuaW5nXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IG9wdHMucGx1Z2luIC0gbmFtZSBvZiB0aGUgcGx1Z2luIHRoYXQgY3JlYXRlZFxuICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMgd2FybmluZy4ge0BsaW5rIFJlc3VsdCN3YXJufSBmaWxsc1xuICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMgcHJvcGVydHkgYXV0b21hdGljYWxseS5cbiAgICAgKlxuICAgICAqIEByZXR1cm4ge1dhcm5pbmd9IGNyZWF0ZWQgd2FybmluZ1xuICAgICAqL1xuICAgIHdhcm4odGV4dCwgb3B0cyA9IHsgfSkge1xuICAgICAgICBpZiAoICFvcHRzLnBsdWdpbiApIHtcbiAgICAgICAgICAgIGlmICggdGhpcy5sYXN0UGx1Z2luICYmIHRoaXMubGFzdFBsdWdpbi5wb3N0Y3NzUGx1Z2luICkge1xuICAgICAgICAgICAgICAgIG9wdHMucGx1Z2luID0gdGhpcy5sYXN0UGx1Z2luLnBvc3Rjc3NQbHVnaW47XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgd2FybmluZyA9IG5ldyBXYXJuaW5nKHRleHQsIG9wdHMpO1xuICAgICAgICB0aGlzLm1lc3NhZ2VzLnB1c2god2FybmluZyk7XG5cbiAgICAgICAgcmV0dXJuIHdhcm5pbmc7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmV0dXJucyB3YXJuaW5ncyBmcm9tIHBsdWdpbnMuIEZpbHRlcnMge0BsaW5rIFdhcm5pbmd9IGluc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