Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

285 lines
19 KiB

"use strict";
exports.__esModule = true;
exports.default = void 0;
var _declaration = _interopRequireDefault(require("./declaration"));
var _processor = _interopRequireDefault(require("./processor"));
var _stringify = _interopRequireDefault(require("./stringify"));
var _comment = _interopRequireDefault(require("./comment"));
var _atRule = _interopRequireDefault(require("./at-rule"));
var _vendor = _interopRequireDefault(require("./vendor"));
var _parse = _interopRequireDefault(require("./parse"));
var _list = _interopRequireDefault(require("./list"));
var _rule = _interopRequireDefault(require("./rule"));
var _root = _interopRequireDefault(require("./root"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Create a new {@link Processor} instance that will apply `plugins`
* as CSS processors.
*
* @param {Array.<Plugin|pluginFunction>|Processor} plugins PostCSS plugins.
* See {@link Processor#use} for plugin format.
*
* @return {Processor} Processor to process multiple CSS.
*
* @example
* import postcss from 'postcss'
*
* postcss(plugins).process(css, { from, to }).then(result => {
* console.log(result.css)
* })
*
* @namespace postcss
*/
function postcss() {
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
plugins[_key] = arguments[_key];
}
if (plugins.length === 1 && Array.isArray(plugins[0])) {
plugins = plugins[0];
}
return new _processor.default(plugins);
}
/**
* Creates a PostCSS plugin with a standard API.
*
* The newly-wrapped function will provide both the name and PostCSS
* version of the plugin.
*
* ```js
* const processor = postcss([replace])
* processor.plugins[0].postcssPlugin //=> 'postcss-replace'
* processor.plugins[0].postcssVersion //=> '6.0.0'
* ```
*
* The plugin function receives 2 arguments: {@link Root}
* and {@link Result} instance. The function should mutate the provided
* `Root` node. Alternatively, you can create a new `Root` node
* and override the `result.root` property.
*
* ```js
* const cleaner = postcss.plugin('postcss-cleaner', () => {
* return (root, result) => {
* result.root = postcss.root()
* }
* })
* ```
*
* As a convenience, plugins also expose a `process` method so that you can use
* them as standalone tools.
*
* ```js
* cleaner.process(css, processOpts, pluginOpts)
* // This is equivalent to:
* postcss([ cleaner(pluginOpts) ]).process(css, processOpts)
* ```
*
* Asynchronous plugins should return a `Promise` instance.
*
* ```js
* postcss.plugin('postcss-import', () => {
* return (root, result) => {
* return new Promise( (resolve, reject) => {
* fs.readFile('base.css', (base) => {
* root.prepend(base)
* resolve()
* })
* })
* }
* })
* ```
*
* Add warnings using the {@link Node#warn} method.
* Send data to other plugins using the {@link Result#messages} array.
*
* ```js
* postcss.plugin('postcss-caniuse-test', () => {
* return (root, result) => {
* root.walkDecls(decl => {
* if (!caniuse.support(decl.prop)) {
* decl.warn(result, 'Some browsers do not support ' + decl.prop)
* }
* })
* }
* })
* ```
*
* @param {string} name PostCSS plugin name. Same as in `name`
* property in `package.json`. It will be saved
* in `plugin.postcssPlugin` property.
* @param {function} initializer Will receive plugin options
* and should return {@link pluginFunction}
*
* @return {Plugin} PostCSS plugin.
*/
postcss.plugin = function plugin(name, initializer) {
function creator() {
var transformer = initializer.apply(void 0, arguments);
transformer.postcssPlugin = name;
transformer.postcssVersion = new _processor.default().version;
return transformer;
}
var cache;
Object.defineProperty(creator, 'postcss', {
get: function get() {
if (!cache) cache = creator();
return cache;
}
});
creator.process = function (css, processOpts, pluginOpts) {
return postcss([creator(pluginOpts)]).process(css, processOpts);
};
return creator;
};
/**
* Default function to convert a node tree into a CSS string.
*
* @param {Node} node Start node for stringifing. Usually {@link Root}.
* @param {builder} builder Function to concatenate CSS from node’s parts
* or generate string and source map.
*
* @return {void}
*
* @function
*/
postcss.stringify = _stringify.default;
/**
* Parses source css and returns a new {@link Root} node,
* which contains the source CSS nodes.
*
* @param {string|toString} css String with input CSS or any object
* with toString() method, like a Buffer
* @param {processOptions} [opts] Options with only `from` and `map` keys.
*
* @return {Root} PostCSS AST.
*
* @example
* // Simple CSS concatenation with source map support
* const root1 = postcss.parse(css1, { from: file1 })
* const root2 = postcss.parse(css2, { from: file2 })
* root1.append(root2).toResult().css
*
* @function
*/
postcss.parse = _parse.default;
/**
* Contains the {@link vendor} module.
*
* @type {vendor}
*
* @example
* postcss.vendor.unprefixed('-moz-tab') //=> ['tab']
*/
postcss.vendor = _vendor.default;
/**
* Contains the {@link list} module.
*
* @member {list}
*
* @example
* postcss.list.space('5px calc(10% + 5px)') //=> ['5px', 'calc(10% + 5px)']
*/
postcss.list = _list.default;
/**
* Creates a new {@link Comment} node.
*
* @param {object} [defaults] Properties for the new node.
*
* @return {Comment} New comment node
*
* @example
* postcss.comment({ text: 'test' })
*/
postcss.comment = function (defaults) {
return new _comment.default(defaults);
};
/**
* Creates a new {@link AtRule} node.
*
* @param {object} [defaults] Properties for the new node.
*
* @return {AtRule} new at-rule node
*
* @example
* postcss.atRule({ name: 'charset' }).toString() //=> "@charset"
*/
postcss.atRule = function (defaults) {
return new _atRule.default(defaults);
};
/**
* Creates a new {@link Declaration} node.
*
* @param {object} [defaults] Properties for the new node.
*
* @return {Declaration} new declaration node
*
* @example
* postcss.decl({ prop: 'color', value: 'red' }).toString() //=> "color: red"
*/
postcss.decl = function (defaults) {
return new _declaration.default(defaults);
};
/**
* Creates a new {@link Rule} node.
*
* @param {object} [defaults] Properties for the new node.
*
* @return {Rule} new rule node
*
* @example
* postcss.rule({ selector: 'a' }).toString() //=> "a {\n}"
*/
postcss.rule = function (defaults) {
return new _rule.default(defaults);
};
/**
* Creates a new {@link Root} node.
*
* @param {object} [defaults] Properties for the new node.
*
* @return {Root} new root node.
*
* @example
* postcss.root({ after: '\n' }).toString() //=> "\n"
*/
postcss.root = function (defaults) {
return new _root.default(defaults);
};
var _default = postcss;
exports.default = _default;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBvc3Rjc3MuZXM2Il0sIm5hbWVzIjpbInBvc3Rjc3MiLCJwbHVnaW5zIiwibGVuZ3RoIiwiQXJyYXkiLCJpc0FycmF5IiwiUHJvY2Vzc29yIiwicGx1Z2luIiwibmFtZSIsImluaXRpYWxpemVyIi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