postcss.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _declaration = require('./declaration');
  4. var _declaration2 = _interopRequireDefault(_declaration);
  5. var _processor = require('./processor');
  6. var _processor2 = _interopRequireDefault(_processor);
  7. var _stringify = require('./stringify');
  8. var _stringify2 = _interopRequireDefault(_stringify);
  9. var _comment = require('./comment');
  10. var _comment2 = _interopRequireDefault(_comment);
  11. var _atRule = require('./at-rule');
  12. var _atRule2 = _interopRequireDefault(_atRule);
  13. var _vendor = require('./vendor');
  14. var _vendor2 = _interopRequireDefault(_vendor);
  15. var _parse = require('./parse');
  16. var _parse2 = _interopRequireDefault(_parse);
  17. var _list = require('./list');
  18. var _list2 = _interopRequireDefault(_list);
  19. var _rule = require('./rule');
  20. var _rule2 = _interopRequireDefault(_rule);
  21. var _root = require('./root');
  22. var _root2 = _interopRequireDefault(_root);
  23. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24. /**
  25. * Create a new {@link Processor} instance that will apply `plugins`
  26. * as CSS processors.
  27. *
  28. * @param {Array.<Plugin|pluginFunction>|Processor} plugins - PostCSS
  29. * plugins. See {@link Processor#use} for plugin format.
  30. *
  31. * @return {Processor} Processor to process multiple CSS
  32. *
  33. * @example
  34. * import postcss from 'postcss';
  35. *
  36. * postcss(plugins).process(css, { from, to }).then(result => {
  37. * console.log(result.css);
  38. * });
  39. *
  40. * @namespace postcss
  41. */
  42. function postcss() {
  43. for (var _len = arguments.length, plugins = Array(_len), _key = 0; _key < _len; _key++) {
  44. plugins[_key] = arguments[_key];
  45. }
  46. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  47. plugins = plugins[0];
  48. }
  49. return new _processor2.default(plugins);
  50. }
  51. /**
  52. * Creates a PostCSS plugin with a standard API.
  53. *
  54. * The newly-wrapped function will provide both the name and PostCSS
  55. * version of the plugin.
  56. *
  57. * ```js
  58. * const processor = postcss([replace]);
  59. * processor.plugins[0].postcssPlugin //=> 'postcss-replace'
  60. * processor.plugins[0].postcssVersion //=> '5.1.0'
  61. * ```
  62. *
  63. * The plugin function receives 2 arguments: {@link Root}
  64. * and {@link Result} instance. The function should mutate the provided
  65. * `Root` node. Alternatively, you can create a new `Root` node
  66. * and override the `result.root` property.
  67. *
  68. * ```js
  69. * const cleaner = postcss.plugin('postcss-cleaner', () => {
  70. * return (root, result) => {
  71. * result.root = postcss.root();
  72. * };
  73. * });
  74. * ```
  75. *
  76. * As a convenience, plugins also expose a `process` method so that you can use
  77. * them as standalone tools.
  78. *
  79. * ```js
  80. * cleaner.process(css, options);
  81. * // This is equivalent to:
  82. * postcss([ cleaner(options) ]).process(css);
  83. * ```
  84. *
  85. * Asynchronous plugins should return a `Promise` instance.
  86. *
  87. * ```js
  88. * postcss.plugin('postcss-import', () => {
  89. * return (root, result) => {
  90. * return new Promise( (resolve, reject) => {
  91. * fs.readFile('base.css', (base) => {
  92. * root.prepend(base);
  93. * resolve();
  94. * });
  95. * });
  96. * };
  97. * });
  98. * ```
  99. *
  100. * Add warnings using the {@link Node#warn} method.
  101. * Send data to other plugins using the {@link Result#messages} array.
  102. *
  103. * ```js
  104. * postcss.plugin('postcss-caniuse-test', () => {
  105. * return (root, result) => {
  106. * css.walkDecls(decl => {
  107. * if ( !caniuse.support(decl.prop) ) {
  108. * decl.warn(result, 'Some browsers do not support ' + decl.prop);
  109. * }
  110. * });
  111. * };
  112. * });
  113. * ```
  114. *
  115. * @param {string} name - PostCSS plugin name. Same as in `name`
  116. * property in `package.json`. It will be saved
  117. * in `plugin.postcssPlugin` property.
  118. * @param {function} initializer - will receive plugin options
  119. * and should return {@link pluginFunction}
  120. *
  121. * @return {Plugin} PostCSS plugin
  122. */
  123. postcss.plugin = function plugin(name, initializer) {
  124. var creator = function creator() {
  125. var transformer = initializer.apply(undefined, arguments);
  126. transformer.postcssPlugin = name;
  127. transformer.postcssVersion = new _processor2.default().version;
  128. return transformer;
  129. };
  130. var cache = void 0;
  131. Object.defineProperty(creator, 'postcss', {
  132. get: function get() {
  133. if (!cache) cache = creator();
  134. return cache;
  135. }
  136. });
  137. creator.process = function (root, opts) {
  138. return postcss([creator(opts)]).process(root, opts);
  139. };
  140. return creator;
  141. };
  142. /**
  143. * Default function to convert a node tree into a CSS string.
  144. *
  145. * @param {Node} node - start node for stringifing. Usually {@link Root}.
  146. * @param {builder} builder - function to concatenate CSS from node’s parts
  147. * or generate string and source map
  148. *
  149. * @return {void}
  150. *
  151. * @function
  152. */
  153. postcss.stringify = _stringify2.default;
  154. /**
  155. * Parses source css and returns a new {@link Root} node,
  156. * which contains the source CSS nodes.
  157. *
  158. * @param {string|toString} css - string with input CSS or any object
  159. * with toString() method, like a Buffer
  160. * @param {processOptions} [opts] - options with only `from` and `map` keys
  161. *
  162. * @return {Root} PostCSS AST
  163. *
  164. * @example
  165. * // Simple CSS concatenation with source map support
  166. * const root1 = postcss.parse(css1, { from: file1 });
  167. * const root2 = postcss.parse(css2, { from: file2 });
  168. * root1.append(root2).toResult().css;
  169. *
  170. * @function
  171. */
  172. postcss.parse = _parse2.default;
  173. /**
  174. * @member {vendor} - Contains the {@link vendor} module.
  175. *
  176. * @example
  177. * postcss.vendor.unprefixed('-moz-tab') //=> ['tab']
  178. */
  179. postcss.vendor = _vendor2.default;
  180. /**
  181. * @member {list} - Contains the {@link list} module.
  182. *
  183. * @example
  184. * postcss.list.space('5px calc(10% + 5px)') //=> ['5px', 'calc(10% + 5px)']
  185. */
  186. postcss.list = _list2.default;
  187. /**
  188. * Creates a new {@link Comment} node.
  189. *
  190. * @param {object} [defaults] - properties for the new node.
  191. *
  192. * @return {Comment} new Comment node
  193. *
  194. * @example
  195. * postcss.comment({ text: 'test' })
  196. */
  197. postcss.comment = function (defaults) {
  198. return new _comment2.default(defaults);
  199. };
  200. /**
  201. * Creates a new {@link AtRule} node.
  202. *
  203. * @param {object} [defaults] - properties for the new node.
  204. *
  205. * @return {AtRule} new AtRule node
  206. *
  207. * @example
  208. * postcss.atRule({ name: 'charset' }).toString() //=> "@charset"
  209. */
  210. postcss.atRule = function (defaults) {
  211. return new _atRule2.default(defaults);
  212. };
  213. /**
  214. * Creates a new {@link Declaration} node.
  215. *
  216. * @param {object} [defaults] - properties for the new node.
  217. *
  218. * @return {Declaration} new Declaration node
  219. *
  220. * @example
  221. * postcss.decl({ prop: 'color', value: 'red' }).toString() //=> "color: red"
  222. */
  223. postcss.decl = function (defaults) {
  224. return new _declaration2.default(defaults);
  225. };
  226. /**
  227. * Creates a new {@link Rule} node.
  228. *
  229. * @param {object} [defaults] - properties for the new node.
  230. *
  231. * @return {AtRule} new Rule node
  232. *
  233. * @example
  234. * postcss.rule({ selector: 'a' }).toString() //=> "a {\n}"
  235. */
  236. postcss.rule = function (defaults) {
  237. return new _rule2.default(defaults);
  238. };
  239. /**
  240. * Creates a new {@link Root} node.
  241. *
  242. * @param {object} [defaults] - properties for the new node.
  243. *
  244. * @return {Root} new Root node
  245. *
  246. * @example
  247. * postcss.root({ after: '\n' }).toString() //=> "\n"
  248. */
  249. postcss.root = function (defaults) {
  250. return new _root2.default(defaults);
  251. };
  252. exports.default = postcss;
  253. module.exports = exports['default'];
  254. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBvc3Rjc3MuZXM2Il0sIm5hbWVzIjpbInBvc3Rjc3MiLCJwbHVnaW5zIiwibGVuZ3RoIiwiQXJyYXkiLCJpc0FycmF5IiwicGx1Z2luIiwibmFtZSIsImluaXRpYWxpemVyIiwiY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