added whole system from ola4doc

This commit is contained in:
Bachir Soussi Chiadmi
2017-12-14 17:06:06 +01:00
parent 9646c74be1
commit 0611418f7a
8725 changed files with 817688 additions and 2 deletions
+423
View File
@@ -0,0 +1,423 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 5.2.6
* Fix `postcss.vendor` for values with spaces (by 刘祺).
## 5.2.5
* Better error message on unclosed string (by Ben Briggs).
## 5.2.4
* Improve terminal CSS syntax highlight (by Simon Lydell).
## 5.2.3
* Better color highlight in syntax error code frame.
* Fix color highlight support in old systems.
## 5.2.2
* Update `Processor#version`.
## 5.2.1
* Fix source map path for CSS without `from` option (by Michele Locati).
## 5.2 “Duke Vapula”
* Add syntax highlight to code frame in syntax error (by Andrey Popp).
* Use Babel code frame style and size in syntax error.
* Add `[` and `]` tokens to parse `[attr=;] {}` correctly.
* Add `ignoreErrors` options to tokenizer (by Andrey Popp).
* Fix error position on tab indent (by Simon Lydell).
## 5.1.2
* Suggests SCSS/Less parsers on parse errors depends on file extension.
## 5.1.1
* Fix TypeScript definitions (by Efremov Alexey).
## 5.1 “King and President Zagan”
* Add URI in source map support (by Mark Finger).
* Add `map.from` option (by Mark Finger).
* Add `<no source>` mappings for nodes without source (by Bogdan Chadkin).
* Add function value support to `map.prev` option (by Chris Montoro).
* Add declaration value type check in shortcut creating (by 刘祺).
* `Result#warn` now returns new created warning.
* Dont call plugin creator in `postcss.plugin` call.
* Add source maps to PostCSS ES5 build.
* Add JSDoc to PostCSS classes.
* Clean npm package from unnecessary docs.
## 5.0.21
* Fix support with input source mao with `utf8` encoding name.
## 5.0.20
* Fix between raw value parsing (by David Clark).
* Update TypeScript definitions (by Jed Mao).
* Clean fake node.source after `append(string)`.
## 5.0.19
* Fix indent-based syntaxes support.
## 5.0.18
* Parse new lines according W3C CSS syntax specification.
## 5.0.17
* Fix options argument in `Node#warn` (by Ben Briggs).
* Fix TypeScript definitions (by Jed Mao).
## 5.0.16
* Fix CSS syntax error position on unclosed quotes.
## 5.0.15
* Fix `Node#clone()` on `null` value somewhere in node.
## 5.0.14
* Allow to use PostCSS in webpack bundle without JSON loader.
## 5.0.13
* Fix `index` and `word` options in `Warning#toString` (by Bogdan Chadkin).
* Fix input source content loading in errors.
* Fix map options on using `LazyResult` as input CSS.
* 100% test coverage.
* Use Babel 6.
## 5.0.12
* Allow passing a previous map with no mappings (by Andreas Lind).
## 5.0.11
* Increase plugins performance by 1.5 times.
## 5.0.10
* Fix warning from nodes without source.
## 5.0.9
* Fix source map type detection (by @asan).
## 5.0.8
* Fixed a missed step in `5.0.7` that caused the module to be published as
ES6 code.
## 5.0.7
* PostCSS now requires that node 0.12 is installed via the engines property
in package.json (by Howard Zuo).
## 5.0.6
* Fix parsing nested at-rule without semicolon (by Matt Drake).
* Trim `Declaration#value` (by Bogdan Chadkin).
## 5.0.5
* Fix multi-tokens property parsing (by Matt Drake).
## 5.0.4
* Fix start position in `Root#source`.
* Fix source map annotation, when CSS uses `\r\n` (by Mohammad Younes).
## 5.0.3
* Fix `url()` parsing.
* Fix using `selectors` in `Rule` constructor.
* Add start source to `Root` node.
## 5.0.2
* Fix `remove(index)` to be compatible with 4.x plugin.
## 5.0.1
* Fix PostCSS 4.x plugins compatibility.
* Fix type definition loading (by Jed Mao).
## 5.0 “President Valac”
* Remove `safe` option. Move Safe Parser to separate project.
* `Node#toString` does not include `before` for root nodes.
* Remove plugin returning `Root` API.
* Remove Promise polyfill for node.js 0.10.
* Deprecate `eachInside`, `eachDecl`, `eachRule`, `eachAtRule` and `eachComment`
in favor of `walk`, `walkDecls`, `walkRules`, `walkAtRules` and `walkComments`
(by Jed Mao).
* Deprecate `Container#remove` and `Node#removeSelf`
in favor of `Container#removeChild` and `Node#remove` (by Ben Briggs).
* Deprecate `Node#replace` in favor of `replaceWith` (by Ben Briggs).
* Deprecate raw properties in favor of `Node#raws` object.
* Deprecate `Node#style` in favor of `raw`.
* Deprecate `CssSyntaxError#generated` in favor of `input`.
* Deprecate `Node#cleanStyles` in favor of `cleanRaws`.
* Deprecate `Root#prevMap` in favor of `Root.source.input.map`.
* Add `syntax`, `parser` and `stringifier` options for Custom Syntaxes.
* Add stringifier option to `Node#toString`.
* Add `Result#content` alias for non-CSS syntaxes.
* Add `plugin.process(css)` shortcut to every plugin function (by Ben Briggs).
* Add multiple nodes support to insert methods (by Jonathan Neal).
* Add `Node#warn` shortcut (by Ben Briggs).
* Add `word` and `index` options to errors and warnings (by David Clark).
* Add `line`, `column` properties to `Warning`.
* Use `supports-color` library to detect color support in error output.
* Add type definitions for TypeScript plugin developers (by Jed Mao).
* `Rule#selectors` setter detects separators.
* Add `postcss.stringify` method.
* Throw descriptive errors for incorrectly formatted plugins.
* Add docs to npm release.
* Fix `url()` parsing.
* Fix Windows support (by Jed Mao).
## 4.1.16
* Fix errors without stack trace.
## 4.1.15
* Allow asynchronous plugins to change processor plugins list (by Ben Briggs).
## 4.1.14
* Fix for plugins packs defined by `postcss.plugin`.
## 4.1.13
* Fix input inlined source maps with UTF-8 encoding.
## 4.1.12
* Update Promise polyfill.
## 4.1.11
* Fix error message on wrong plugin format.
## 4.1.10
* Fix Promise behavior on sync plugin errors.
* Automatically fill `plugin` field in `CssSyntaxError`.
* Fix warning message (by Ben Briggs).
## 4.1.9
* Speed up `node.clone()`.
## 4.1.8
* Accepts `Processor` instance in `postcss()` constructor too.
## 4.1.7
* Speed up `postcss.list` (by Bogdan Chadkin).
## 4.1.6
* Fix Promise behavior on parsing error.
## 4.1.5
* Parse at-words in declaration values.
## 4.1.4
* Fix Promise polyfill dependency (by Anton Yakushev and Matija Marohnić).
## 4.1.3
* Add Promise polyfill for node.js 0.10 and IE.
## 4.1.2
* List helpers can be accessed independently `var space = postcss.list.space`.
## 4.1.1
* Show deprecated message only once.
## 4.1 “Marquis Andras”
* Asynchronous plugin support.
* Add warnings from plugins and `Result#messages`.
* Add `postcss.plugin()` to create plugins with a standard API.
* Insert nodes by CSS string.
* Show version warning message on error from an outdated plugin.
* Send `Result` instance to plugins as the second argument.
* Add `CssSyntaxError#plugin`.
* Add `CssSyntaxError#showSourceCode()`.
* Add `postcss.list` and `postcss.vendor` aliases.
* Add `Processor#version`.
* Parse wrong closing bracket.
* Parse `!important` statement with spaces and comments inside (by Ben Briggs).
* Throw an error on declaration without `prop` or `value` (by Philip Peterson).
* Fix source map mappings position.
* Add indexed source map support.
* Always set `error.generated`.
* Clean all source map annotation comments.
## 4.0.6
* Remove `babel` from released package dependencies (by Andres Suarez).
## 4.0.5
* Fix error message on double colon in declaration.
## 4.0.4
* Fix indent detection in some rare cases.
## 4.0.3
* Faster API with 6to5 Loose mode.
* Fix indexed source maps support.
## 4.0.2
* Do not copy IE hacks to code style.
## 4.0.1
* Add `source.input` to `Root` too.
## 4.0 “Duke Flauros”
* Rename `Container#childs` to `nodes`.
* Rename `PostCSS#processors` to `plugins`.
* Add `Node#replaceValues()` method.
* Add `Node#moveTo()`, `moveBefore()` and `moveAfter()` methods.
* Add `Node#cloneBefore()` and `cloneAfter()` shortcuts.
* Add `Node#next()`, `prev()` and `root()` shortcuts.
* Add `Node#replaceWith()` method.
* Add `Node#error()` method.
* Add `Container#removeAll()` method.
* Add filter argument to `eachDecl()` and `eachAtRule()`.
* Add `Node#source.input` and move `source.file` or `source.id` to `input`.
* Change code indent, when node was moved.
* Better fix code style on `Rule`, `AtRule` and `Comment` nodes changes.
* Allow to create rules and at-rules by hash shortcut in append methods.
* Add class name to CSS syntax error output.
## 3.0.7
* Fix IE filter parsing with multiple commands.
* Safer way to consume PostCSS object as plugin (by Maxime Thirouin).
## 3.0.6
* Fix missing semicolon when comment comes after last declaration.
* Fix Safe Mode declaration parsing on unclosed blocks.
## 3.0.5
* Fix parser to support difficult cases with backslash escape and brackets.
* Add `CssSyntaxError#stack` (by Maxime Thirouin).
## 3.0.4
* Fix Safe Mode on unknown word before declaration.
## 3.0.3
* Increase tokenizer speed (by Roman Dvornov).
## 3.0.2
* Fix empty comment parsing.
* Fix `Root#normalize` in some inserts.
## 3.0.1
* Fix Rhino JS runtime support.
* Typo in deprecated warning (by Maxime Thirouin).
## 3.0 “Marquis Andrealphus”
* New parser, which become the fastest ever CSS parser written in JavaScript.
* Parser can now parse declarations and rules in one parent (like in `@page`)
and nested declarations for plugins like `postcss-nested`.
* Child nodes array is now in `childs` property, instead of `decls` and `rules`.
* `map.inline` and `map.sourcesContent` options are now `true` by default.
* Fix iterators (`each`, `insertAfter`) on children array changes.
* Use previous source map to show origin source of CSS syntax error.
* Use 6to5 ES6 compiler, instead of ES6 Transpiler.
* Use code style for manually added rules from existing rules.
* Use `from` option from previous source map `file` field.
* Set `to` value to `from` if `to` option is missing.
* Use better node source name when missing `from` option.
* Show a syntax error when `;` is missed between declarations.
* Allow to pass `PostCSS` instance or list of plugins to `use()` method.
* Allow to pass `Result` instance to `process()` method.
* Trim Unicode BOM on source maps parsing.
* Parse at-rules without spaces like `@import"file"`.
* Better previous `sourceMappingURL` annotation comment cleaning.
* Do not remove previous `sourceMappingURL` comment on `map.annotation: false`.
* Parse nameless at-rules in Safe Mode.
* Fix source map generation for nodes without source.
* Fix next child `before` if `Root` first child got removed.
## 2.2.6
* Fix map generation for nodes without source (by Josiah Savary).
## 2.2.5
* Fix source map with BOM marker support (by Mohammad Younes).
* Fix source map paths (by Mohammad Younes).
## 2.2.4
* Fix `prepend()` on empty `Root`.
## 2.2.3
* Allow to use object shortcut in `use()` with functions like `autoprefixer`.
## 2.2.2
* Add shortcut to set processors in `use()` via object with `.postcss` property.
## 2.2.1
* Send `opts` from `Processor#process(css, opts)` to processors.
## 2.2 “Marquis Cimeies”
* Use GNU style syntax error messages.
* Add `Node#replace` method.
* Add `CssSyntaxError#reason` property.
## 2.1.2
* Fix UTF-8 support in inline source map.
* Fix source map `sourcesContent` if there is no `from` and `to` options.
## 2.1.1
* Allow to miss `to` and `from` options for inline source maps.
* Add `Node#source.id` if file name is unknown.
* Better detect splitter between rules in CSS concatenation tools.
* Automatically clone node in insert methods.
## 2.1 “King Amdusias”
* Change Traceur ES6 compiler to ES6 Transpiler.
* Show broken CSS line in syntax error.
## 2.0 “King Belial”
* Project was rewritten from CoffeeScript to ES6.
* Add Safe Mode to works with live input or with hacks from legacy code.
* More safer parser to pass all hacks from Browserhacks.com.
* Use real properties instead of magic getter/setter for raw properties.
## 1.0 “Marquis Decarabia”
* Save previous source map for each node to support CSS concatenation
with multiple previous maps.
* Add `map.sourcesContent` option to add origin content to `sourcesContent`
inside map.
* Allow to set different place of output map in annotation comment.
* Allow to use arrays and `Root` in `Container#append` and same methods.
* Add `Root#prevMap` with information about previous map.
* Allow to use latest PostCSS from GitHub by npm.
* `Result` now is lazy and it will generate output CSS only if you use `css`
or `map` property.
* Use separated `map.prev` option to set previous map.
* Rename `inlineMap` option to `map.inline`.
* Rename `mapAnnotation` option to `map.annotation`.
* `Result#map` now return `SourceMapGenerator` object, instead of string.
* Run previous map autodetect only if input CSS contains annotation comment.
* Add `map: 'inline'` shortcut for `map: { inline: true }` option.
* `Node#source.file` now will contains absolute path.
* Clean `Declaration#between` style on node clone.
## 0.3.5
* Allow to use `Root` or `Result` as first argument in `process()`.
* Save parsed AST to `Result#root`.
## 0.3.4
* Better space symbol detect to read UTF-8 BOM correctly.
## 0.3.3
* Remove source map hacks by using new Mozillas `source-map` (by Simon Lydell).
## 0.3.2
* Add URI encoding support for inline source maps.
## 0.3.1
* Fix relative paths from previous source map.
* Safer space split in `Rule#selectors` (by Simon Lydell).
## 0.3 “Prince Seere”
* Add `Comment` node for comments between declarations or rules.
* Add source map annotation comment to output CSS.
* Allow to inline source map to annotation comment by data:uri.
* Fix source maps on Windows.
* Fix source maps for subdirectory (by Dmitry Nikitenko and Simon Lydell).
* Autodetect previous source map.
* Add `first` and `last` shortcuts to container nodes.
* Parse `!important` to separated property in `Declaration`.
* Allow to break iteration by returning `false`.
* Copy code style to new nodes.
* Add `eachInside` method to recursively iterate all nodes.
* Add `selectors` shortcut to get selectors array.
* Add `toResult` method to `Rule` to simplify work with several input files.
* Clean declarations `value`, rules `selector` and at-rules `params`
by storing spaces in `between` property.
## 0.2 “Duke Dantalion”
* Add source map support.
* Add shortcuts to create nodes.
* Method `process()` now returns object with `css` and `map` keys.
* Origin CSS file option was renamed from `file` to `from`.
* Rename `Node#remove()` method to `removeSelf()` to fix name conflict.
* Node source was moved to `source` property with origin file
and node end position.
* You can set own CSS generate function.
## 0.1 “Count Andromalius”
* Initial release.
+20
View File
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+331
View File
@@ -0,0 +1,331 @@
# PostCSS [![Travis Build Status][travis-img]][travis] [![AppVeyor Build Status][appveyor-img]][appveyor] [![Gitter][chat-img]][chat]
<img align="right" width="95" height="95"
title="Philosophers stone, logo of PostCSS"
src="http://postcss.github.io/postcss/logo.svg">
[appveyor-img]: https://img.shields.io/appveyor/ci/ai/postcss.svg?label=windows
[travis-img]: https://img.shields.io/travis/postcss/postcss.svg?label=unix
[chat-img]: https://img.shields.io/badge/Gitter-Join_the_PostCSS_chat-brightgreen.svg
[appveyor]: https://ci.appveyor.com/project/ai/postcss
[travis]: https://travis-ci.org/postcss/postcss
[chat]: https://gitter.im/postcss/postcss
PostCSS is a tool for transforming styles with JS plugins.
These plugins can lint your CSS, support variables and mixins,
transpile future CSS syntax, inline images, and more.
PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba,
and JetBrains. The [Autoprefixer] PostCSS plugin is one of the most popular
CSS processors.
Twitter account: [@postcss](https://twitter.com/postcss).
VK.com page: [postcss](https://vk.com/postcss).
Support / Discussion: [Gitter](https://gitter.im/postcss/postcss).
For PostCSS commercial support (consulting, improving the front-end culture
of your company, PostCSS plugins), contact Evil Martians
at <surrender@evilmartians.com>.
[Autoprefixer]: https://github.com/postcss/autoprefixer
<a href="https://evilmartians.com/?utm_source=postcss">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians" width="236" height="54">
</a>
## Plugins
Currently, PostCSS has more than 200 plugins. You can find all of the plugins
in the [plugins list] or in the [searchable catalog]. Below is a list
of our favorite plugins — the best demonstrations of what can be built
on top of PostCSS.
If you have any new ideas, [PostCSS plugin development] is really easy.
[searchable catalog]: http://postcss.parts
[plugins list]: https://github.com/postcss/postcss/blob/master/docs/plugins.md
### Solve Global CSS Problem
* [`postcss-use`] allows you to explicitly set PostCSS plugins within CSS
and execute them only for the current file.
* [`postcss-modules`] and [`react-css-modules`] automatically isolate
selectors within components.
* [`postcss-autoreset`] is an alternative to using a global reset
that is better for isolatable components.
* [`postcss-initial`] adds `all: initial` support, which resets
all inherited styles.
* [`cq-prolyfill`] adds container query support, allowing styles that respond
to the width of the parent.
### Use Future CSS, Today
* [`autoprefixer`] adds vendor prefixes, using data from Can I Use.
* [`postcss-cssnext`] allows you to use future CSS features today
(includes `autoprefixer`).
### Better CSS Readability
* [`precss`] contains plugins for Sass-like features, like variables, nesting,
and mixins.
* [`postcss-sorting`] sorts the content of rules and at-rules.
* [`postcss-utilities`] includes the most commonly used shortcuts and helpers.
* [`short`] adds and extends numerous shorthand properties.
### Images and Fonts
* [`postcss-assets`] inserts image dimensions and inlines files.
* [`postcss-sprites`] generates image sprites.
* [`font-magician`] generates all the `@font-face` rules needed in CSS.
* [`postcss-inline-svg`] allows you to inline SVG and customize its styles.
* [`postcss-write-svg`] allows you to write simple SVG directly in your CSS.
### Linters
* [`stylelint`] is a modular stylesheet linter.
* [`stylefmt`] is a tool that automatically formats CSS
according `stylelint` rules.
* [`doiuse`] lints CSS for browser support, using data from Can I Use.
* [`colorguard`] helps you maintain a consistent color palette.
### Other
* [`postcss-rtl`] combines both-directional (left-to-right and right-to-left) styles in one CSS file.
* [`cssnano`] is a modular CSS minifier.
* [`lost`] is a feature-rich `calc()` grid system.
* [`rtlcss`] mirrors styles for right-to-left locales.
[PostCSS plugin development]: https://github.com/postcss/postcss/blob/master/docs/writing-a-plugin.md
[`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg
[`react-css-modules`]: https://github.com/gajus/react-css-modules
[`postcss-autoreset`]: https://github.com/maximkoretskiy/postcss-autoreset
[`postcss-write-svg`]: https://github.com/jonathantneal/postcss-write-svg
[`postcss-utilities`]: https://github.com/ismamz/postcss-utilities
[`postcss-initial`]: https://github.com/maximkoretskiy/postcss-initial
[`postcss-sprites`]: https://github.com/2createStudio/postcss-sprites
[`postcss-modules`]: https://github.com/outpunk/postcss-modules
[`postcss-sorting`]: https://github.com/hudochenkov/postcss-sorting
[`postcss-cssnext`]: http://cssnext.io
[`postcss-assets`]: https://github.com/assetsjs/postcss-assets
[`font-magician`]: https://github.com/jonathantneal/postcss-font-magician
[`autoprefixer`]: https://github.com/postcss/autoprefixer
[`cq-prolyfill`]: https://github.com/ausi/cq-prolyfill
[`postcss-rtl`]: https://github.com/vkalinichev/postcss-rtl
[`postcss-use`]: https://github.com/postcss/postcss-use
[`css-modules`]: https://github.com/css-modules/css-modules
[`colorguard`]: https://github.com/SlexAxton/css-colorguard
[`stylelint`]: https://github.com/stylelint/stylelint
[`stylefmt`]: https://github.com/morishitter/stylefmt
[`cssnano`]: http://cssnano.co
[`precss`]: https://github.com/jonathantneal/precss
[`doiuse`]: https://github.com/anandthakker/doiuse
[`rtlcss`]: https://github.com/MohammadYounes/rtlcss
[`short`]: https://github.com/jonathantneal/postcss-short
[`lost`]: https://github.com/peterramsing/lost
## Syntaxes
PostCSS can transform styles in any syntax, not just CSS.
If there is not yet support for your favorite syntax,
you can write a parser and/or stringifier to extend PostCSS.
* [`sugarss`] is a indent-based syntax like Sass or Stylus.
* [`postcss-scss`] allows you to work with SCSS
*(but does not compile SCSS to CSS)*.
* [`postcss-less`] allows you to work with Less
*(but does not compile LESS to CSS)*.
* [`postcss-less-engine`] allows you to work with Less
*(and DOES compile LESS to CSS using true Less.js evaluation)*.
* [`postcss-js`] allows you to write styles in JS or transform
React Inline Styles, Radium or JSS.
* [`postcss-safe-parser`] finds and fixes CSS syntax errors.
* [`midas`] converts a CSS string to highlighted HTML.
[`postcss-safe-parser`]: https://github.com/postcss/postcss-safe-parser
[`postcss-less`]: https://github.com/webschik/postcss-less
[`postcss-less-engine`]: https://github.com/Crunch/postcss-less
[`postcss-scss`]: https://github.com/postcss/postcss-scss
[`postcss-js`]: https://github.com/postcss/postcss-js
[`sugarss`]: https://github.com/postcss/sugarss
[`midas`]: https://github.com/ben-eb/midas
## Articles
* [Some things you may think about PostCSS… and you might be wrong](http://julian.io/some-things-you-may-think-about-postcss-and-you-might-be-wrong)
* [What PostCSS Really Is; What It Really Does](http://davidtheclark.com/its-time-for-everyone-to-learn-about-postcss)
* [PostCSS Guides](http://webdesign.tutsplus.com/series/postcss-deep-dive--cms-889)
* [Mastering PostCSS for Web Design](https://www.packtpub.com/web-development/mastering-postcss-web-design)
More articles and videos you can find on [awesome-postcss](https://github.com/jjaderg/awesome-postcss) list.
## Usage
You can start using PostCSS in just two steps:
1. Find and add PostCSS extensions for your build tool.
2. [Select plugins] and add them to your PostCSS process.
[Select plugins]: http://postcss.parts
### Gulp
Use [`gulp-postcss`] and [`gulp-sourcemaps`].
```js
gulp.task('css', function () {
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
return gulp.src('src/**/*.css')
.pipe( sourcemaps.init() )
.pipe( postcss([ require('autoprefixer'), require('precss') ]) )
.pipe( sourcemaps.write('.') )
.pipe( gulp.dest('build/') );
});
```
[`gulp-sourcemaps`]: https://github.com/floridoo/gulp-sourcemaps
[`gulp-postcss`]: https://github.com/postcss/gulp-postcss
### Webpack
Use [`postcss-loader`]:
```js
module.exports = {
module: {
loaders: [
{
test: /\.css$/,
loader: "style-loader!css-loader!postcss-loader"
}
]
},
postcss: function () {
return [require('autoprefixer'), require('precss')];
}
}
```
[`postcss-loader`]: https://github.com/postcss/postcss-loader
### npm run / CLI
To use PostCSS from your command-line interface or with npm scripts
there is [`postcss-cli`].
```sh
postcss --use autoprefixer -c options.json -o main.css css/*.css
```
[`postcss-cli`]: https://github.com/postcss/postcss-cli
### Browser
If you want to compile CSS string in browser (for instance, in live edit
tools like CodePen), just use [Browserify] or [webpack]. They will pack
PostCSS and plugins files into a single file.
To apply PostCSS plugins to React Inline Styles, JSS, Radium
and other CSS-in-JS, you can use [`postcss-js`] and transforms style objects.
```js
var postcss = require('postcss-js');
var prefixer = postcss.sync([ require('autoprefixer') ]);
prefixer({ display: 'flex' }); //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
```
[`postcss-js`]: https://github.com/postcss/postcss-js
[Browserify]: http://browserify.org/
[webpack]: https://webpack.github.io/
### Runners
* **Grunt**: [`grunt-postcss`](https://github.com/nDmitry/grunt-postcss)
* **HTML**: [`posthtml-postcss`](https://github.com/posthtml/posthtml-postcss)
* **Stylus**: [`poststylus`](https://github.com/seaneking/poststylus)
* **Rollup**: [`rollup-plugin-postcss`](https://github.com/egoist/rollup-plugin-postcss)
* **Brunch**: [`postcss-brunch`](https://github.com/brunch/postcss-brunch)
* **Broccoli**: [`broccoli-postcss`](https://github.com/jeffjewiss/broccoli-postcss)
* **Meteor**: [`postcss`](https://atmospherejs.com/juliancwirko/postcss)
* **ENB**: [`enb-postcss`](https://github.com/awinogradov/enb-postcss)
* **Fly**: [`fly-postcss`](https://github.com/postcss/fly-postcss)
* **Start**: [`start-postcss`](https://github.com/start-runner/postcss)
* **Connect/Express**: [`postcss-middleware`](https://github.com/jedmao/postcss-middleware)
### JS API
For other environments, you can use the JS API:
```js
var postcss = require('postcss');
postcss([ require('autoprefixer'), require('cssnano') ])
.process(css, { from: 'src/app.css', to: 'app.css' })
.then(function (result) {
fs.writeFileSync('app.css', result.css);
if ( result.map ) fs.writeFileSync('app.css.map', result.map);
});
```
Read the [PostCSS API documentation] for more details about the JS API.
All PostCSS runners should pass [PostCSS Runner Guidelines].
[PostCSS Runner Guidelines]: https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md
[PostCSS API documentation]: http://api.postcss.org/postcss.html
### Options
Most PostCSS runners accept two parameters:
* An array of plugins.
* An object of options.
Common options:
* `syntax`: an object providing a syntax parser and a stringifier.
* `parser`: a special syntax parser (for example, [SCSS]).
* `stringifier`: a special syntax output generator (for example, [Midas]).
* `map`: [source map options].
* `from`: the input file name (most runners set it automatically).
* `to`: the output file name (most runners set it automatically).
[source map options]: https://github.com/postcss/postcss/blob/master/docs/source-maps.md
[Midas]: https://github.com/ben-eb/midas
[SCSS]: https://github.com/postcss/postcss-scss
### Node.js 0.10 and the Promise API
If you want to run PostCSS in Node.js 0.10, add the [Promise polyfill]:
```js
require('es6-promise').polyfill();
var postcss = require('postcss');
```
[Promise polyfill]: https://github.com/jakearchibald/es6-promise
## IDE Integration
### Atom
* [`language-postcss`] adds PostCSS and [SugarSS] highlight.
* [`source-preview-postcss`] previews your output CSS in a separate, live pane.
[SugarSS]: https://github.com/postcss/sugarss
### Sublime Text
* [`Syntax-highlighting-for-PostCSS`] adds PostCSS highlight.
[`Syntax-highlighting-for-PostCSS`]: https://github.com/hudochenkov/Syntax-highlighting-for-PostCSS
[`source-preview-postcss`]: https://atom.io/packages/source-preview-postcss
[`language-postcss`]: https://atom.io/packages/language-postcss
### WebStorm
WebStorm 2016.3 [has] built-in PostCSS support.
[has]: https://blog.jetbrains.com/webstorm/2016/08/webstorm-2016-3-early-access-preview/
+39
View File
@@ -0,0 +1,39 @@
import Container from './container';
import * as postcss from './postcss';
export default class AtRule extends Container implements postcss.AtRule {
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
/**
* Contains information to generate byte-to-byte equal node string as it
* was in origin input.
*/
raws: postcss.AtRuleRaws;
/**
* The identifier that immediately follows the @.
*/
name: string;
/**
* These are the values that follow the at-rule's name, but precede any {}
* block. The spec refers to this area as the at-rule's "prelude".
*/
params: string;
/**
* Represents an at-rule. If it's followed in the CSS by a {} block, this
* node will have a nodes property representing its children.
*/
constructor(defaults?: postcss.AtRuleNewProps);
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): AtRule;
toJSON(): postcss.JsonAtRule;
append(...children: any[]): this;
prepend(...children: any[]): this;
afterName: string;
_params: string;
}
+28
View File
@@ -0,0 +1,28 @@
import * as postcss from './postcss';
import Node from './node';
export default class Comment extends Node implements postcss.Comment {
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
/**
* The comment's text.
*/
text: string;
/**
* Represents a comment between declarations or statements (rule and at-rules).
* Comments inside selectors, at-rule parameters, or declaration values will
* be stored in the Node#raws properties.
*/
constructor(defaults?: postcss.CommentNewProps);
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): any;
toJSON(): postcss.JsonComment;
left: string;
right: string;
}
+224
View File
@@ -0,0 +1,224 @@
import Comment from './comment';
import * as postcss from './postcss';
import AtRule from './at-rule';
import Node from './node';
import Rule from './rule';
/**
* Containers can store any content. If you write a rule inside a rule,
* PostCSS will parse it.
*/
export default class Container extends Node implements postcss.Container {
private indexes;
private lastEach;
/**
* Contains the container's children.
*/
nodes: Node[];
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): any;
toJSON(): postcss.JsonContainer;
push(child: any): this;
/**
* Iterates through the container's immediate children, calling the
* callback function for each child. If you need to recursively iterate
* through all the container's descendant nodes, use container.walk().
* Unlike the for {} -cycle or Array#forEach() this iterator is safe if you
* are mutating the array of child nodes during iteration.
* @param callback Iterator. Returning false will break iteration. Safe
* if you are mutating the array of child nodes during iteration. PostCSS
* will adjust the current index to match the mutations.
*/
each(callback: (node: Node, index: number) => any): boolean | void;
/**
* Traverses the container's descendant nodes, calling `callback` for each
* node. Like container.each(), this method is safe to use if you are
* mutating arrays during iteration. If you only need to iterate through
* the container's immediate children, use container.each().
* @param callback Iterator.
*/
walk(callback: (node: Node, index: number) => any): boolean | void;
/**
* Traverses the container's descendant nodes, calling `callback` for each
* declaration. Like container.each(), this method is safe to use if you
* are mutating arrays during iteration.
* @param propFilter Filters declarations by property name. Only those
* declarations whose property matches propFilter will be iterated over.
* @param callback Called for each declaration node within the container.
*/
walkDecls(propFilter: string | RegExp, callback?: (decl: postcss.Declaration, index: number) => any): boolean | void;
walkDecls(callback: (decl: postcss.Declaration, index: number) => any): boolean | void;
/**
* Traverses the container's descendant nodes, calling `callback` for each
* rule. Like container.each(), this method is safe to use if you are
* mutating arrays during iteration.
* @param selectorFilter Filters rules by selector. If provided, iteration
* will only happen over rules that have matching names.
* @param callback Iterator called for each rule node within the
* container.
*/
walkRules(selectorFilter: string | RegExp, callback: (atRule: Rule, index: number) => any): boolean | void;
walkRules(callback: (atRule: Rule, index: number) => any): boolean | void;
/**
* Traverses the container's descendant nodes, calling `callback` for each
* at-rule. Like container.each(), this method is safe to use if you are
* mutating arrays during iteration.
* @param nameFilter Filters at-rules by name. If provided, iteration will
* only happen over at-rules that have matching names.
* @param callback Iterator called for each at-rule node within the
* container.
*/
walkAtRules(nameFilter: string | RegExp, callback: (atRule: AtRule, index: number) => any): boolean | void;
walkAtRules(callback: (atRule: AtRule, index: number) => any): boolean | void;
/**
* Traverses the container's descendant nodes, calling `callback` for each
* commennt. Like container.each(), this method is safe to use if you are
* mutating arrays during iteration.
* @param callback Iterator called for each comment node within the container.
*/
walkComments(callback: (comment: Comment, indexed: number) => any): void | boolean;
/**
* Inserts new nodes to the end of the container.
* Because each node class is identifiable by unique properties, use the
* following shortcuts to create nodes in insert methods:
* root.append({ name: '@charset', params: '"UTF-8"' }); // at-rule
* root.append({ selector: 'a' }); // rule
* rule.append({ prop: 'color', value: 'black' }); // declaration
* rule.append({ text: 'Comment' }) // comment
* A string containing the CSS of the new element can also be used. This
* approach is slower than the above shortcuts.
* root.append('a {}');
* root.first.append('color: black; z-index: 1');
* @param nodes New nodes.
* @returns This container for chaining.
*/
append(...nodes: (Node | Object | string)[]): this;
/**
* Inserts new nodes to the beginning of the container.
* Because each node class is identifiable by unique properties, use the
* following shortcuts to create nodes in insert methods:
* root.prepend({ name: 'charset', params: '"UTF-8"' }); // at-rule
* root.prepend({ selector: 'a' }); // rule
* rule.prepend({ prop: 'color', value: 'black' }); // declaration
* rule.prepend({ text: 'Comment' }) // comment
* A string containing the CSS of the new element can also be used. This
* approach is slower than the above shortcuts.
* root.prepend('a {}');
* root.first.prepend('color: black; z-index: 1');
* @param nodes New nodes.
* @returns This container for chaining.
*/
prepend(...nodes: (Node | Object | string)[]): this;
cleanRaws(keepBetween?: boolean): void;
/**
* Insert newNode before oldNode within the container.
* @param oldNode Child or child's index.
* @returns This container for chaining.
*/
insertBefore(oldNode: Node | number, newNode: Node | Object | string): this;
/**
* Insert newNode after oldNode within the container.
* @param oldNode Child or child's index.
* @returns This container for chaining.
*/
insertAfter(oldNode: Node | number, newNode: Node | Object | string): this;
/**
* Removes the container from its parent and cleans the parent property in the
* container and its children.
* @returns This container for chaining.
*/
remove(): any;
/**
* Removes child from the container and clean the parent properties from the
* node and its children.
* @param child Child or child's index.
* @returns This container for chaining.
*/
removeChild(child: Node | number): this;
/**
* Removes all children from the container and cleans their parent
* properties.
* @returns This container for chaining.
*/
removeAll(): this;
/**
* Passes all declaration values within the container that match pattern
* through the callback, replacing those values with the returned result of
* callback. This method is useful if you are using a custom unit or
* function and need to iterate through all values.
* @param pattern Pattern that we need to replace.
* @param options Options to speed up the search.
* @param callbackOrReplaceValue String to replace pattern or callback
* that will return a new value. The callback will receive the same
* arguments as those passed to a function parameter of String#replace.
*/
replaceValues(pattern: string | RegExp, options: {
/**
* Property names. The method will only search for values that match
* regexp within declarations of listed properties.
*/
props?: string[];
/**
* Used to narrow down values and speed up the regexp search. Searching
* every single value with a regexp can be slow. If you pass a fast
* string, PostCSS will first check whether the value contains the fast
* string; and only if it does will PostCSS check that value against
* regexp. For example, instead of just checking for /\d+rem/ on all
* values, set fast: 'rem' to first check whether a value has the rem
* unit, and only if it does perform the regexp check.
*/
fast?: string;
}, callbackOrReplaceValue: string | {
(substring: string, ...args: any[]): string;
}): Container;
replaceValues(pattern: string | RegExp, callbackOrReplaceValue: string | {
(substring: string, ...args: any[]): string;
}): Container;
/**
* Determines whether all child nodes satisfy the specified test.
* @param callback A function that accepts up to three arguments. The
* every method calls the callback function for each node until the
* callback returns false, or until the end of the array.
* @returns True if the callback returns true for all of the container's
* children.
*/
every(callback: (node: Node, index: number, nodes: Node[]) => any, thisArg?: any): boolean;
/**
* Determines whether the specified callback returns true for any child node.
* @param callback A function that accepts up to three arguments. The some
* method calls the callback for each node until the callback returns true,
* or until the end of the array.
* @param thisArg An object to which the this keyword can refer in the
* callback function. If thisArg is omitted, undefined is used as the
* this value.
* @returns True if callback returns true for (at least) one of the
* container's children.
*/
some(callback: (node: Node, index: number, nodes: Node[]) => boolean, thisArg?: any): boolean;
/**
* @param child Child of the current container.
* @returns The child's index within the container's "nodes" array.
*/
index(child: Node | number): number;
/**
* @returns The container's first child.
*/
first: Node;
/**
* @returns The container's last child.
*/
last: Node;
protected normalize(node: Node | string, sample?: Node, type?: string | boolean): Node[];
protected normalize(props: postcss.AtRuleNewProps | postcss.RuleNewProps | postcss.DeclarationNewProps | postcss.CommentNewProps, sample?: Node, type?: string | boolean): Node[];
rebuild(node: Node, parent?: Container): any;
eachInside(callback: any): any;
eachDecl(propFilter: any, callback?: any): any;
eachRule(selectorFilter: any, callback?: any): any;
eachAtRule(nameFilter: any, callback?: any): any;
eachComment(selectorFilter: any, callback?: any): any;
semicolon: boolean;
after: string;
}
+125
View File
@@ -0,0 +1,125 @@
import * as postcss from './postcss';
export default class CssSyntaxError implements postcss.CssSyntaxError, SyntaxError {
/**
* Contains full error text in the GNU error format.
*/
message: string;
/**
* Contains the source line of the error. PostCSS will use the input
* source map to detect the original error location. If you wrote a
* Sass file, compiled it to CSS and then parsed it with PostCSS,
* PostCSS will show the original position in the Sass file. If you need
* position in PostCSS input (e.g., to debug previous compiler), use
* error.generated.line.
*/
line: number;
/**
* Contains the source column of the error. PostCSS will use the input
* source map to detect the original error location. If you wrote a
* Sass file, compiled it to CSS and then parsed it with PostCSS,
* PostCSS will show the original position in the Sass file. If you
* need position in PostCSS input (e.g., to debug previous compiler),
* use error.generated.column.
*/
column: number;
/**
* Contains the source code of the broken file. PostCSS will use the
* input source map to detect the original error location. If you wrote
* a Sass file, compiled it to CSS and then parsed it with PostCSS,
* PostCSS will show the original position in the Sass file. If you
* need position in PostCSS input (e.g., to debug previous compiler),
* use error.generated.source.
*/
source: string;
/**
* If parser's from option is set, contains the absolute path to the
* broken file. PostCSS will use the input source map to detect the
* original error location. If you wrote a Sass file, compiled it
* to CSS and then parsed it with PostCSS, PostCSS will show the
* original position in the Sass file. If you need the position in
* PostCSS input (e.g., to debug previous compiler), use
* error.generated.file.
*/
file: string;
/**
* Contains the PostCSS plugin name if the error didn't come from the
* CSS parser.
*/
plugin: string;
name: string;
/**
* Contains only the error description.
*/
reason: string;
private columnNumber;
private description;
private lineNumber;
private fileName;
input: postcss.InputOrigin;
/**
* The CSS parser throws this error for broken CSS.
*/
constructor(
/**
* Contains full error text in the GNU error format.
*/
message: string,
/**
* Contains the source line of the error. PostCSS will use the input
* source map to detect the original error location. If you wrote a
* Sass file, compiled it to CSS and then parsed it with PostCSS,
* PostCSS will show the original position in the Sass file. If you need
* position in PostCSS input (e.g., to debug previous compiler), use
* error.generated.line.
*/
line?: number,
/**
* Contains the source column of the error. PostCSS will use the input
* source map to detect the original error location. If you wrote a
* Sass file, compiled it to CSS and then parsed it with PostCSS,
* PostCSS will show the original position in the Sass file. If you
* need position in PostCSS input (e.g., to debug previous compiler),
* use error.generated.column.
*/
column?: number,
/**
* Contains the source code of the broken file. PostCSS will use the
* input source map to detect the original error location. If you wrote
* a Sass file, compiled it to CSS and then parsed it with PostCSS,
* PostCSS will show the original position in the Sass file. If you
* need position in PostCSS input (e.g., to debug previous compiler),
* use error.generated.source.
*/
source?: string,
/**
* If parser's from option is set, contains the absolute path to the
* broken file. PostCSS will use the input source map to detect the
* original error location. If you wrote a Sass file, compiled it
* to CSS and then parsed it with PostCSS, PostCSS will show the
* original position in the Sass file. If you need the position in
* PostCSS input (e.g., to debug previous compiler), use
* error.generated.file.
*/
file?: string,
/**
* Contains the PostCSS plugin name if the error didn't come from the
* CSS parser.
*/
plugin?: string);
private setMessage();
/**
* @param color Whether arrow should be colored red by terminal color codes.
* By default, PostCSS will use process.stdout.isTTY and
* process.env.NODE_DISABLE_COLORS.
* @returns A few lines of CSS source that caused the error. If CSS has
* input source map without sourceContent this method will return an empty
* string.
*/
showSourceCode(color?: boolean): string;
/**
*
* @returns Error position, message and source code of broken part.
*/
toString(): string;
generated: postcss.InputOrigin;
}
+42
View File
@@ -0,0 +1,42 @@
import * as postcss from './postcss';
import Node from './node';
export default class Declaration extends Node implements postcss.Declaration {
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
/**
* Contains information to generate byte-to-byte equal node string as it
* was in origin input.
*/
raws: postcss.DeclarationRaws;
/**
* The declaration's property name.
*/
prop: string;
/**
* The declaration's value. This value will be cleaned of comments. If the
* source value contained comments, those comments will be available in the
* _value.raws property. If you have not changed the value, the result of
* decl.toString() will include the original raws value (comments and all).
*/
value: string;
/**
* True if the declaration has an !important annotation.
*/
important: boolean;
/**
* Represents a CSS declaration.
*/
constructor(defaults?: postcss.DeclarationNewProps);
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): any;
toJSON(): postcss.JsonDeclaration;
_value: string;
_important: string;
}
+46
View File
@@ -0,0 +1,46 @@
import CssSyntaxError from './css-syntax-error';
import PreviousMap from './previous-map';
import LazyResult from './lazy-result';
import * as postcss from './postcss';
import Result from './result';
export default class Input implements postcss.Input {
/**
* The absolute path to the CSS source file defined with the "from" option.
*/
file: string;
/**
* The unique ID of the CSS source. Used if "from" option is not provided
* (because PostCSS does not know the file path).
*/
id: string;
/**
* Represents the input source map passed from a compilation step before
* PostCSS (e.g., from the Sass compiler).
*/
map: PreviousMap;
css: string;
/**
* Represents the source CSS.
*/
constructor(css: string | {
toString(): string;
} | LazyResult | Result, opts?: {
safe?: boolean | any;
from?: string;
});
/**
* The CSS source identifier. Contains input.file if the user set the "from"
* option, or input.id if they did not.
*/
from: string;
error(message: string, line: number, column: number, opts?: {
plugin?: string;
}): CssSyntaxError;
/**
* Reads the input source map.
* @returns A symbol position in the input source (e.g., in a Sass file
* that was compiled to CSS before being passed to PostCSS):
*/
origin(line: number, column: number): postcss.InputOrigin;
private mapResolve(file);
}
+92
View File
@@ -0,0 +1,92 @@
import Processor from './processor';
import * as postcss from './postcss';
import Result from './result';
import Root from './root';
export default class LazyResult implements postcss.LazyResult {
private stringified;
private processed;
private result;
private error;
private plugin;
private processing;
/**
* A promise proxy for the result of PostCSS transformations.
*/
constructor(processor: Processor,
/**
* String with input CSS or any object with toString() method, like a Buffer.
* Optionally, send Result instance and the processor will take the existing
* [Root] parser from it.
*/
css: string | {
toString(): string;
} | LazyResult | Result, opts?: postcss.ProcessOptions);
/**
* @returns A processor used for CSS transformations.
*/
processor: Processor;
/**
* @returns Options from the Processor#process(css, opts) call that produced
* this Result instance.
*/
opts: postcss.ResultOptions;
/**
* Processes input CSS through synchronous plugins and converts Root to a
* CSS string. This property will only work with synchronous plugins. If
* the processor contains any asynchronous plugins it will throw an error.
* In this case, you should use LazyResult#then() instead.
*/
css: string;
/**
* Alias for css property to use when syntaxes generate non-CSS output.
*/
content: string;
/**
* Processes input CSS through synchronous plugins. This property will
* only work with synchronous plugins. If the processor contains any
* asynchronous plugins it will throw an error. In this case, you should
* use LazyResult#then() instead.
*/
map: postcss.ResultMap;
/**
* Processes input CSS through synchronous plugins. This property will only
* work with synchronous plugins. If the processor contains any asynchronous
* plugins it will throw an error. In this case, you should use
* LazyResult#then() instead.
*/
root: Root;
/**
* Processes input CSS through synchronous plugins. This property will only
* work with synchronous plugins. If the processor contains any asynchronous
* plugins it will throw an error. In this case, you should use
* LazyResult#then() instead.
*/
messages: postcss.ResultMessage[];
/**
* Processes input CSS through synchronous plugins and calls Result#warnings().
* This property will only work with synchronous plugins. If the processor
* contains any asynchronous plugins it will throw an error. In this case, you
* You should use LazyResult#then() instead.
*/
warnings(): postcss.ResultMessage[];
/**
* Alias for css property.
*/
toString(): string;
/**
* Processes input CSS through synchronous and asynchronous plugins.
* @param onRejected Called if any plugin throws an error.
*/
then(onFulfilled: (result: Result) => void, onRejected?: (error: Error) => void): Function | any;
/**
* Processes input CSS through synchronous and asynchronous plugins.
* @param onRejected Called if any plugin throws an error.
*/
catch(onRejected: (error: Error) => void): Function | any;
private handleError(error, plugin);
private asyncTick(resolve, reject);
private async();
sync(): Result;
private run(plugin);
stringify(): Result;
}
+17
View File
@@ -0,0 +1,17 @@
/**
* Contains helpers for safely splitting lists of CSS values, preserving
* parentheses and quotes.
*/
declare module List {
/**
* Safely splits space-separated values (such as those for background,
* border-radius and other shorthand properties).
*/
function space(str: string): string[];
/**
* Safely splits comma-separated values (such as those for transition-* and
* background properties).
*/
function comma(str: string): string[];
}
export default List;
+26
View File
@@ -0,0 +1,26 @@
import Root from './root';
export default class MapGenerator {
private stringify;
private root;
private opts;
private mapOpts;
private previousMaps;
private map;
private css;
constructor(stringify: any, root: Root, opts: any);
isMap(): boolean;
previous(): any;
isInline(): any;
isSourcesContent(): any;
clearAnnotation(): void;
setSourcesContent(): void;
applyPrevMaps(): void;
isAnnotation(): any;
addAnnotation(): void;
outputFile(): any;
generateMap(): any[];
relative(file: any): any;
sourcePath(node: any): any;
generateString(): void;
generate(): any[];
}
+160
View File
@@ -0,0 +1,160 @@
import Container from './container';
import CssSyntaxError from './css-syntax-error';
import * as postcss from './postcss';
import Result from './result';
export default class Node implements postcss.Node {
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
/**
* Unique node ID
*/
id: string;
/**
* Contains information to generate byte-to-byte equal node string as it
* was in origin input.
*/
raws: postcss.NodeRaws;
/**
* Returns the node's parent node.
*/
parent: Container;
/**
* Returns the input source of the node. The property is used in source map
* generation. If you create a node manually (e.g., with postcss.decl() ),
* that node will not have a source property and will be absent from the
* source map. For this reason, the plugin developer should consider cloning
* nodes to create new ones (in which case the new node's source will
* reference the original, cloned node) or setting the source property
* manually.
*/
source: postcss.NodeSource;
constructor(defaults?: Object);
/**
* This method produces very useful error messages. If present, an input
* source map will be used to get the original position of the source, even
* from a previous compilation step (e.g., from Sass compilation).
* @returns The original position of the node in the source, showing line
* and column numbers and also a small excerpt to facilitate debugging.
*/
error(
/**
* Error description.
*/
message: string, options?: postcss.NodeErrorOptions): CssSyntaxError;
/**
* Creates an instance of Warning and adds it to messages. This method is
* provided as a convenience wrapper for Result#warn.
* Note that `opts.node` is automatically passed to Result#warn for you.
* @param result The result that will receive the warning.
* @param text Warning message. It will be used in the `text` property of
* the message object.
* @param opts Properties to assign to the message object.
*/
warn(result: Result, text: string, opts?: postcss.WarningOptions): void;
/**
* Removes the node from its parent and cleans the parent property in the
* node and its children.
* @returns This node for chaining.
*/
remove(): this;
/**
* @returns A CSS string representing the node.
*/
toString(stringifier?: any): string;
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): Node;
/**
* Shortcut to clone the node and insert the resulting cloned node before
* the current node.
* @param overrides New Properties to override in the clone.
* @returns The cloned node.
*/
cloneBefore(overrides?: Object): Node;
/**
* Shortcut to clone the node and insert the resulting cloned node after
* the current node.
* @param overrides New Properties to override in the clone.
* @returns The cloned node.
*/
cloneAfter(overrides?: Object): Node;
/**
* Inserts node(s) before the current node and removes the current node.
* @returns This node for chaining.
*/
replaceWith(...nodes: (Node | Object)[]): this;
/**
* Removes the node from its current parent and inserts it at the end of
* newParent. This will clean the before and after code style properties
* from the node and replace them with the indentation style of newParent.
* It will also clean the between property if newParent is in another Root.
* @param newParent Where the current node will be moved.
* @returns This node for chaining.
*/
moveTo(newParent: Container): this;
/**
* Removes the node from its current parent and inserts it into a new
* parent before otherNode. This will also clean the node's code style
* properties just as it would in node.moveTo(newParent).
* @param otherNode Will be after the current node after moving.
* @returns This node for chaining.
*/
moveBefore(otherNode: Node): this;
/**
* Removes the node from its current parent and inserts it into a new
* parent after otherNode. This will also clean the node's code style
* properties just as it would in node.moveTo(newParent).
* @param otherNode Will be before the current node after moving.
* @returns This node for chaining.
*/
moveAfter(otherNode: Node): this;
/**
* @returns The next child of the node's parent; or, returns undefined if
* the current node is the last child.
*/
next(): Node;
/**
* @returns The previous child of the node's parent; or, returns undefined
* if the current node is the first child.
*/
prev(): Node;
toJSON(): postcss.JsonNode;
/**
* @param prop Name or code style property.
* @param defaultType Name of default value. It can be easily missed if the
* value is the same as prop.
* @returns A code style property value. If the node is missing the code
* style property (because the node was manually built or cloned), PostCSS
* will try to autodetect the code style property by looking at other nodes
* in the tree.
*/
raw(prop: string, defaultType?: string): any;
/**
* @returns The Root instance of the node's tree.
*/
root(): any;
cleanRaws(keepBetween?: boolean): void;
positionInside(index: number): {
line: number;
column: number;
};
positionBy(options: any): {
column: number;
line: number;
};
/**
* Deprecated. Use Node#remove.
*/
removeSelf(): void;
replace(nodes: any): this;
style(prop: string, defaultType?: string): any;
cleanStyles(keepBetween?: boolean): void;
before: string;
between: string;
}
+20
View File
@@ -0,0 +1,20 @@
import LazyResult from './lazy-result';
import * as postcss from './postcss';
import Result from './result';
import Root from './root';
/**
* Parses source CSS.
* @param css The CSS to parse.
* @param options
* @returns {} A new Root node, which contains the source CSS nodes.
*/
declare function parse(css: string | {
toString(): string;
} | LazyResult | Result, options?: {
from?: string;
map?: postcss.SourceMapOptions;
}): Root;
declare module parse {
var parse: postcss.Syntax | postcss.Parse;
}
export default parse;
+37
View File
@@ -0,0 +1,37 @@
import Input from './input';
import Node from './node';
import Root from './root';
export default class Parser {
input: Input;
pos: number;
root: Root;
spaces: string;
semicolon: boolean;
private current;
private tokens;
constructor(input: Input);
tokenize(): void;
loop(): void;
comment(token: any): void;
emptyRule(token: any): void;
word(): void;
rule(tokens: any): void;
decl(tokens: any): void;
atrule(token: any): void;
end(token: any): void;
endFile(): void;
init(node: Node, line?: number, column?: number): void;
raw(node: any, prop: any, tokens: any): void;
spacesFromEnd(tokens: any): string;
spacesFromStart(tokens: any): string;
stringFrom(tokens: any, from: any): string;
colon(tokens: any): number | boolean;
unclosedBracket(bracket: any): void;
unknownWord(start: any): void;
unexpectedClose(token: any): void;
unclosedBlock(): void;
doubleColon(token: any): void;
unnamedAtrule(node: any, token: any): void;
precheckMissedSemicolon(tokens: any): void;
checkMissedSemicolon(tokens: any): void;
}
+1250
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
export default class PreviousMap {
private inline;
annotation: string;
root: string;
private consumerCache;
text: string;
file: string;
constructor(css: any, opts: any);
consumer(): any;
withContent(): boolean;
startWith(string: any, start: any): boolean;
loadAnnotation(css: any): void;
decodeInline(text: any): any;
loadMap(file: any, prev: any): any;
isMap(map: any): boolean;
}
+31
View File
@@ -0,0 +1,31 @@
import LazyResult from './lazy-result';
import * as postcss from './postcss';
import Result from './result';
export default class Processor implements postcss.Processor {
/**
* Contains the current version of PostCSS (e.g., "5.0.19").
*/
version: '5.0.19';
/**
* Contains plugins added to this processor.
*/
plugins: postcss.Plugin<any>[];
constructor(plugins?: (typeof postcss.acceptedPlugin)[]);
/**
* Adds a plugin to be used as a CSS processor. Plugins can also be
* added by passing them as arguments when creating a postcss instance.
*/
use(plugin: typeof postcss.acceptedPlugin): this;
/**
* Parses source CSS. Because some plugins can be asynchronous it doesn't
* make any transformations. Transformations will be applied in LazyResult's
* methods.
* @param css Input CSS or any object with toString() method, like a file
* stream. If a Result instance is passed the processor will take the
* existing Root parser from it.
*/
process(css: string | {
toString(): string;
} | Result, options?: postcss.ProcessOptions): LazyResult;
private normalize(plugins);
}
+75
View File
@@ -0,0 +1,75 @@
import Processor from './processor';
import * as postcss from './postcss';
import Root from './root';
export default class Result implements postcss.Result {
/**
* The Processor instance used for this transformation.
*/
processor: Processor;
/**
* Contains the Root node after all transformations.
*/
root: Root;
/**
* Options from the Processor#process(css, opts) or Root#toResult(opts) call
* that produced this Result instance.
*/
opts: postcss.ResultOptions;
/**
* A CSS string representing this Result's Root instance.
*/
css: string;
/**
* An instance of the SourceMapGenerator class from the source-map library,
* representing changes to the Result's Root instance.
* This property will have a value only if the user does not want an inline
* source map. By default, PostCSS generates inline source maps, written
* directly into the processed CSS. The map property will be empty by default.
* An external source map will be generated — and assigned to map — only if
* the user has set the map.inline option to false, or if PostCSS was passed
* an external input source map.
*/
map: postcss.ResultMap;
/**
* Contains messages from plugins (e.g., warnings or custom messages).
* Add a warning using Result#warn() and get all warnings
* using the Result#warnings() method.
*/
messages: postcss.ResultMessage[];
lastPlugin: postcss.Transformer;
/**
* Provides the result of the PostCSS transformations.
*/
constructor(
/**
* The Processor instance used for this transformation.
*/
processor?: Processor,
/**
* Contains the Root node after all transformations.
*/
root?: Root,
/**
* Options from the Processor#process(css, opts) or Root#toResult(opts) call
* that produced this Result instance.
*/
opts?: postcss.ResultOptions);
/**
* Alias for css property.
*/
toString(): string;
/**
* Creates an instance of Warning and adds it to messages.
* @param message Used in the text property of the message object.
* @param options Properties for Message object.
*/
warn(message: string, options?: postcss.WarningOptions): void;
/**
* @returns Warnings from plugins, filtered from messages.
*/
warnings(): postcss.ResultMessage[];
/**
* Alias for css property to use with syntaxes that generate non-CSS output.
*/
content: string;
}
+54
View File
@@ -0,0 +1,54 @@
import PreviousMap from './previous-map';
import Container from './container';
import * as postcss from './postcss';
import Result from './result';
import Node from './node';
export default class Root extends Container implements postcss.Root {
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
rawCache: {
[key: string]: any;
};
/**
* Represents a CSS file and contains all its parsed nodes.
*/
constructor(defaults?: postcss.RootNewProps);
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): Root;
toJSON(): postcss.JsonRoot;
/**
* Removes child from the root node, and the parent properties of node and
* its children.
* @param child Child or child's index.
* @returns This root node for chaining.
*/
removeChild(child: Node | number): this;
protected normalize(node: Node | string, sample: Node, type?: string): Node[];
protected normalize(props: postcss.AtRuleNewProps | postcss.RuleNewProps | postcss.DeclarationNewProps | postcss.CommentNewProps, sample: Node, type?: string): Node[];
/**
* @returns A Result instance representing the root's CSS.
*/
toResult(options?: {
/**
* The path where you'll put the output CSS file. You should always
* set "to" to generate correct source maps.
*/
to?: string;
map?: postcss.SourceMapOptions;
}): Result;
/**
* Deprecated. Use Root#removeChild.
*/
remove(child?: Node | number): Root;
/**
* Deprecated. Use Root#source.input.map.
*/
prevMap(): PreviousMap;
}
+36
View File
@@ -0,0 +1,36 @@
import Container from './container';
import * as postcss from './postcss';
export default class Rule extends Container implements postcss.Rule {
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
/**
* Contains information to generate byte-to-byte equal node string as it
* was in origin input.
*/
raws: postcss.RuleRaws;
/**
* The rule's full selector. If there are multiple comma-separated selectors,
* the entire group will be included.
*/
selector: string;
/**
* Represents a CSS rule: a selector followed by a declaration block.
*/
constructor(defaults?: postcss.RuleNewProps);
/**
* @param overrides New properties to override in the clone.
* @returns A clone of this node. The node and its (cloned) children will
* have a clean parent and code style properties.
*/
clone(overrides?: Object): Rule;
toJSON(): postcss.JsonRule;
/**
* @returns An array containing the rule's individual selectors.
* Groups of selectors are split at commas.
*/
selectors: string[];
_selector: string;
}
+31
View File
@@ -0,0 +1,31 @@
import Node from './node';
declare class Stringifier {
builder: Stringifier.Builder;
constructor(builder?: Stringifier.Builder);
stringify(node: Node, semicolon?: boolean): void;
root(node: any): void;
comment(node: any): void;
decl(node: any, semicolon: any): void;
rule(node: any): void;
atrule(node: any, semicolon: any): void;
body(node: any): void;
block(node: any, start: any): void;
raw(node: Node, own: string, detect?: string): any;
rawSemicolon(root: any): any;
rawEmptyBody(root: any): any;
rawIndent(root: any): any;
rawBeforeComment(root: any, node: any): any;
rawBeforeDecl(root: any, node: any): any;
rawBeforeRule(root: any): any;
rawBeforeClose(root: any): any;
rawBeforeOpen(root: any): any;
rawColon(root: any): any;
beforeAfter(node: any, detect: any): any;
rawValue(node: any, prop: any): any;
}
declare module Stringifier {
interface Builder {
(str: string, node?: Node, str2?: string): void;
}
}
export default Stringifier;
+11
View File
@@ -0,0 +1,11 @@
import Stringifier from './stringifier';
import * as postcss from './postcss';
import Node from './node';
/**
* Default function to convert a node tree into a CSS string.
*/
declare function stringify(node: Node, builder: Stringifier.Builder): void;
declare module stringify {
var stringify: postcss.Syntax | postcss.Stringify;
}
export default stringify;
+1
View File
@@ -0,0 +1 @@
export default function tokenize(input: any): any[];
+14
View File
@@ -0,0 +1,14 @@
/**
* Contains helpers for working with vendor prefixes.
*/
declare module Vendor {
/**
* @returns The vendor prefix extracted from the input string.
*/
function prefix(prop: string): string;
/**
* @returns The input string stripped of its vendor prefix.
*/
function unprefixed(prop: string): string;
}
export default Vendor;
+2
View File
@@ -0,0 +1,2 @@
declare var _default: (message: string) => void;
export default _default;
+42
View File
@@ -0,0 +1,42 @@
import * as postcss from './postcss';
import Node from './node';
export default class Warning implements postcss.Warning {
/**
* Contains the warning message.
*/
text: string;
/**
* Returns a string representing the node's type. Possible values are
* root, atrule, rule, decl or comment.
*/
type: string;
/**
* Contains the name of the plugin that created this warning. When you
* call Node#warn(), it will fill this property automatically.
*/
plugin: string;
/**
* The CSS node that caused the warning.
*/
node: Node;
/**
* The line in the input file with this warning's source.
*/
line: number;
/**
* Column in the input file with this warning's source.
*/
column: number;
/**
* Represents a plugin warning. It can be created using Node#warn().
*/
constructor(
/**
* Contains the warning message.
*/
text: string, options?: postcss.WarningOptions);
/**
* @returns Error position, message.
*/
toString(): string;
}
+195
View File
@@ -0,0 +1,195 @@
# PostCSS Plugin Guidelines
A PostCSS plugin is a function that receives and, usually,
transforms a CSS AST from the PostCSS parser.
The rules below are *mandatory* for all PostCSS plugins.
See also [ClojureWerkzs recommendations] for open source projects.
[ClojureWerkzs recommendations]: http://blog.clojurewerkz.org/blog/2013/04/20/how-to-make-your-open-source-project-really-awesome/
## 1. API
### 1.1 Clear name with `postcss-` prefix
The plugins purpose should be clear just by reading its name.
If you wrote a transpiler for CSS 4 Custom Media, `postcss-custom-media`
would be a good name. If you wrote a plugin to support mixins,
`postcss-mixins` would be a good name.
The prefix `postcss-` shows that the plugin is part of the PostCSS ecosystem.
This rule is not mandatory for plugins that can run as independent tools,
without the user necessarily knowing that it is powered by
PostCSS — for example, [cssnext] and [Autoprefixer].
[Autoprefixer]: https://github.com/postcss/autoprefixer
[cssnext]: http://cssnext.io/
### 1.2. Do one thing, and do it well
Do not create multitool plugins. Several small, one-purpose plugins bundled into
a plugin pack is usually a better solution.
For example, [cssnext] contains many small plugins,
one for each W3C specification. And [cssnano] contains a separate plugin
for each of its optimization.
[cssnext]: http://cssnext.io/
[cssnano]: https://github.com/ben-eb/cssnano
### 1.3. Do not use mixins
Preprocessors libraries like Compass provide an API with mixins.
PostCSS plugins are different.
A plugin cannot be just a set of mixins for [postcss-mixins].
To achieve your goal, consider transforming valid CSS
or using custom at-rules and custom properties.
[postcss-mixins]: https://github.com/postcss/postcss-mixins
### 1.4. Create plugin by `postcss.plugin`
By wrapping your function in this method,
you are hooking into a common plugin API:
```js
module.exports = postcss.plugin('plugin-name', function (opts) {
return function (root, result) {
// Plugin code
};
});
```
## 2. Processing
### 2.1. Plugin must be tested
A CI service like [Travis] is also recommended for testing code in
different environments. You should test in (at least) Node.js 0.12 and stable.
[Travis]: https://travis-ci.org/
### 2.2. Use asynchronous methods whenever possible
For example, use `fs.writeFile` instead of `fs.writeFileSync`:
```js
postcss.plugin('plugin-sprite', function (opts) {
return function (root, result) {
return new Promise(function (resolve, reject) {
var sprite = makeSprite();
fs.writeFile(opts.file, function (err) {
if ( err ) return reject(err);
resolve();
})
});
};
});
```
### 2.3. Set `node.source` for new nodes
Every node must have a relevant `source` so PostCSS can generate
an accurate source map.
So if you add new declaration based on some existing declaration, you should
clone the existing declaration in order to save that original `source`.
```js
if ( needPrefix(decl.prop) ) {
decl.cloneBefore({ prop: '-webkit-' + decl.prop });
}
```
You can also set `source` directly, copying from some existing node:
```js
if ( decl.prop === 'animation' ) {
var keyframe = createAnimationByName(decl.value);
keyframes.source = decl.source;
decl.root().append(keyframes);
}
```
### 2.4. Use only the public PostCSS API
PostCSS plugins must not rely on undocumented properties or methods,
which may be subject to change in any minor release. The public API
is described in [API docs].
[API docs]: http://api.postcss.org/
## 3. Errors
### 3.1. Use `node.error` on CSS relevant errors
If you have an error because of input CSS (like an unknown name
in a mixin plugin) you should use `node.error` to create an error
that includes source position:
```js
if ( typeof mixins[name] === 'undefined' ) {
throw decl.error('Unknown mixin ' + name, { plugin: 'postcss-mixins' });
}
```
### 3.2. Use `result.warn` for warnings
Do not print warnings with `console.log` or `console.warn`,
because some PostCSS runner may not allow console output.
```js
if ( outdated(decl.prop) ) {
result.warn(decl.prop + ' is outdated', { node: decl });
}
```
If CSS input is a source of the warning, the plugin must set the `node` option.
## 4. Documentation
### 4.1. Document your plugin in English
PostCSS plugins must have their `README.md` written in English. Do not be afraid
of your English skills, as the open source community will fix your errors.
Of course, you are welcome to write documentation in other languages;
just name them appropriately (e.g. `README.ja.md`).
### 4.2. Include input and output examples
The plugin's `README.md` must contain example input and output CSS.
A clear example is the best way to describe how your plugin works.
The first section of the `README.md` is a good place to put examples.
See [postcss-opacity](https://github.com/iamvdo/postcss-opacity) for an example.
Of course, this guideline does not apply if your plugin does not
transform the CSS.
### 4.3. Maintain a changelog
PostCSS plugins must describe the changes of all their releases
in a separate file, such as `CHANGELOG.md`, `History.md`, or [GitHub Releases].
Visit [Keep A Changelog] for more information about how to write one of these.
Of course, you should be using [SemVer].
[Keep A Changelog]: http://keepachangelog.com/
[GitHub Releases]: https://help.github.com/articles/creating-releases/
[SemVer]: http://semver.org/
### 4.4. Include `postcss-plugin` keyword in `package.json`
PostCSS plugins written for npm must have the `postcss-plugin` keyword
in their `package.json`. This special keyword will be useful for feedback about
the PostCSS ecosystem.
For packages not published to npm, this is not mandatory, but is recommended
if the package format can contain keywords.
+143
View File
@@ -0,0 +1,143 @@
# PostCSS Runner Guidelines
A PostCSS runner is a tool that processes CSS through a user-defined list
of plugins; for example, [`postcss-cli`] or [`gulppostcss`].
These rules are mandatory for any such runners.
For single-plugin tools, like [`gulp-autoprefixer`],
these rules are not mandatory but are highly recommended.
See also [ClojureWerkzs recommendations] for open source projects.
[ClojureWerkzs recommendations]: http://blog.clojurewerkz.org/blog/2013/04/20/how-to-make-your-open-source-project-really-awesome/
[`gulp-autoprefixer`]: https://github.com/sindresorhus/gulp-autoprefixer
[`gulppostcss`]: https://github.com/w0rm/gulp-postcss
[`postcss-cli`]: https://github.com/postcss/postcss-cli
## 1. API
### 1.1. Accept functions in plugin parameters
If your runner uses a config file, it must be written in JavaScript, so that
it can support plugins which accept a function, such as [`postcss-assets`]:
```js
module.exports = [
require('postcss-assets')({
cachebuster: function (file) {
return fs.statSync(file).mtime.getTime().toString(16);
}
})
];
```
[`postcss-assets`]: https://github.com/borodean/postcss-assets
## 2. Processing
### 2.1. Set `from` and `to` processing options
To ensure that PostCSS generates source maps and displays better syntax errors,
runners must specify the `from` and `to` options. If your runner does not handle
writing to disk (for example, a gulp transform), you should set both options
to point to the same file:
```js
processor.process({ from: file.path, to: file.path });
```
### 2.2. Use only the asynchronous API
PostCSS runners must use only the asynchronous API.
The synchronous API is provided only for debugging, is slower,
and cant work with asynchronous plugins.
```js
processor.process(opts).then(function (result) {
// processing is finished
});
```
### 2.3. Use only the public PostCSS API
PostCSS runners must not rely on undocumented properties or methods,
which may be subject to change in any minor release. The public API
is described in [API docs].
[API docs]: http://api.postcss.org/
## 3. Output
### 3.1. Dont show JS stack for `CssSyntaxError`
PostCSS runners must not show a stack trace for CSS syntax errors,
as the runner can be used by developers who are not familiar with JavaScript.
Instead, handle such errors gracefully:
```js
processor.process(opts).catch(function (error) {
if ( error.name === 'CssSyntaxError' ) {
process.stderr.write(error.message + error.showSourceCode());
} else {
throw error;
}
});
```
### 3.2. Display `result.warnings()`
PostCSS runners must output warnings from `result.warnings()`:
```js
result.warnings().forEach(function (warn) {
process.stderr.write(warn.toString());
});
```
See also [postcss-log-warnings] and [postcss-messages] plugins.
[postcss-log-warnings]: https://github.com/davidtheclark/postcss-log-warnings
[postcss-messages]: https://github.com/postcss/postcss-messages
### 3.3. Allow the user to write source maps to different files
PostCSS by default will inline source maps in the generated file; however,
PostCSS runners must provide an option to save the source map in a different
file:
```js
if ( result.map ) {
fs.writeFile(opts.to + '.map', result.map.toString());
}
```
## 4. Documentation
### 4.1. Document your runner in English
PostCSS runners must have their `README.md` written in English. Do not be afraid
of your English skills, as the open source community will fix your errors.
Of course, you are welcome to write documentation in other languages;
just name them appropriately (e.g. `README.ja.md`).
### 4.2. Maintain a changelog
PostCSS runners must describe changes of all releases in a separate file,
such as `ChangeLog.md`, `History.md`, or with [GitHub Releases].
Visit [Keep A Changelog] for more information on how to write one of these.
Of course you should use [SemVer].
[Keep A Changelog]: http://keepachangelog.com/
[GitHub Releases]: https://help.github.com/articles/creating-releases/
[SemVer]: http://semver.org/
### 4.3. `postcss-runner` keyword in `package.json`
PostCSS runners written for npm must have the `postcss-runner` keyword
in their `package.json`. This special keyword will be useful for feedback about
the PostCSS ecosystem.
For packages not published to npm, this is not mandatory, but recommended
if the package format is allowed to contain keywords.
+72
View File
@@ -0,0 +1,72 @@
# PostCSS and Source Maps
PostCSS has great [source maps] support. It can read and interpret maps
from previous transformation steps, autodetect the format that you expect,
and output both external and inline maps.
To ensure that you generate an accurate source map, you must indicate the input
and output CSS file paths — using the options `from` and `to`, respectively.
To generate a new source map with the default options, simply set `map: true`.
This will generate an inline source map that contains the source content.
If you dont want the map inlined, you can set `map.inline: false`.
```js
processor
.process(css, {
from: 'app.sass.css',
to: 'app.css',
map: { inline: false },
})
.then(function (result) {
result.map //=> '{ "version":3,
// "file":"app.css",
// "sources":["app.sass"],
// "mappings":"AAAA,KAAI" }'
});
```
If PostCSS finds source maps from a previous transformation,
it will automatically update that source map with the same options.
## Options
If you want more control over source map generation, you can define the `map`
option as an object with the following parameters:
* `inline` boolean: indicates that the source map should be embedded
in the output CSS as a Base64-encoded comment. By default, it is `true`.
But if all previous maps are external, not inline, PostCSS will not embed
the map even if you do not set this option.
If you have an inline source map, the `result.map` property will be empty,
as the source map will be contained within the text of `result.css`.
* `prev` string, object, boolean or function: source map content from
a previous processing step (for example, Sass compilation).
PostCSS will try to read the previous source map automatically
(based on comments within the source CSS), but you can use this option
to identify it manually. If desired, you can omit the previous map
with `prev: false`.
* `sourcesContent` boolean: indicates that PostCSS should set the origin
content (for example, Sass source) of the source map. By default,
it is `true`. But if all previous maps do not contain sources content,
PostCSS will also leave it out even if you do not set this option.
* `annotation` boolean or string: indicates that PostCSS should add annotation
comments to the CSS. By default, PostCSS will always add a comment with a path
to the source map. PostCSS will not add annotations to CSS files that
do not contain any comments.
By default, PostCSS presumes that you want to save the source map as
`opts.to + '.map'` and will use this path in the annotation comment.
A different path can be set by providing a string value for `annotation`.
If you have set `inline: true`, annotation cannot be disabled.
* `from` string: by default, PostCSS will set the `sources` property of the map
to the value of the `from` option. If you want to override this behaviour, you
can use `map.from` to explicitly set the source map's `sources` property.
[source maps]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
+231
View File
@@ -0,0 +1,231 @@
# How to Write Custom Syntax
PostCSS can transform styles in any syntax, and is not limited to just CSS.
By writing a custom syntax, you can transform styles in any desired format.
Writing a custom syntax is much harder than writing a PostCSS plugin, but
it is an awesome adventure.
There are 3 types of PostCSS syntax packages:
* **Parser** to parse input string to nodes tree.
* **Stringifier** to generate output string by nodes tree.
* **Syntax** contains both parser and stringifier.
## Syntax
A good example of a custom syntax is [SCSS]. Some users may want to transform
SCSS sources with PostCSS plugins, for example if they need to add vendor
prefixes or change the property order. So this syntax should output SCSS from
an SCSS input.
The syntax API is a very simple plain object, with `parse` & `stringify`
functions:
```js
module.exports = {
parse: require('./parse'),
stringify: require('./stringify')
};
```
[SCSS]: https://github.com/postcss/postcss-scss
## Parser
A good example of a parser is [Safe Parser], which parses malformed/broken CSS.
Because there is no point to generate broken output, this package only provides
a parser.
The parser API is a function which receives a string & returns a [`Root`] node.
The second argument is a function which receives an object with PostCSS options.
```js
var postcss = require('postcss');
module.exports = function (css, opts) {
var root = postcss.root();
// Add other nodes to root
return root;
};
```
[Safe Parser]: https://github.com/postcss/postcss-safe-parser
[`Root`]: http://api.postcss.org/Root.html
### Main Theory
There are many books about parsers; but do not worry because CSS syntax is
very easy, and so the parser will be much simpler than a programming language
parser.
The default PostCSS parser contains two steps:
1. [Tokenizer] which reads input string character by character and builds a
tokens array. For example, it joins space symbols to a `['space', '\n ']`
token, and detects strings to a `['string', '"\"{"']` token.
2. [Parser] which reads the tokens array, creates node instances and
builds a tree.
[Tokenizer]: https://github.com/postcss/postcss/blob/master/lib/tokenize.es6
[Parser]: https://github.com/postcss/postcss/blob/master/lib/parser.es6
### Performance
Parsing input is often the most time consuming task in CSS processors. So it
is very important to have a fast parser.
The main rule of optimization is that there is no performance without a
benchmark. You can look at [PostCSS benchmarks] to build your own.
Of parsing tasks, the tokenize step will often take the most time, so its
performance should be prioritized. Unfortunately, classes, functions and
high level structures can slow down your tokenizer. Be ready to write dirty
code with repeated statements. This is why it is difficult to extend the
default [PostCSS tokenizer]; copy & paste will be a necessary evil.
Second optimization is using character codes instead of strings.
```js
// Slow
string[i] === '{';
// Fast
const OPEN_CURLY = 123; // `{'
string.charCodeAt(i) === OPEN_CURLY;
```
Third optimization is “fast jumps”. If you find open quotes, you can find
next closing quote much faster by `indexOf`:
```js
// Simple jump
next = string.indexOf('"', currentPosition + 1);
// Jump by RegExp
regexp.lastIndex = currentPosion + 1;
regexp.text(string);
next = regexp.lastIndex;
```
The parser can be a well written class. There is no need in copy-paste and
hardcore optimization there. You can extend the default [PostCSS parser].
[PostCSS benchmarks]: https://github.com/postcss/benchmark
[PostCSS tokenizer]: https://github.com/postcss/postcss/blob/master/lib/tokenize.es6
[PostCSS parser]: https://github.com/postcss/postcss/blob/master/lib/parser.es6
### Node Source
Every node should have `source` property to generate correct source map.
This property contains `start` and `end` properties with `{ line, column }`,
and `input` property with an [`Input`] instance.
Your tokenizer should save the original position so that you can propagate
the values to the parser, to ensure that the source map is correctly updated.
[`Input`]: https://github.com/postcss/postcss/blob/master/lib/input.es6
### Raw Values
A good PostCSS parser should provide all information (including spaces symbols)
to generate byte-to-byte equal output. It is not so difficult, but respectful
for user input and allow integration smoke tests.
A parser should save all additional symbols to `node.raws` object.
It is an open structure for you, you can add additional keys.
For example, [SCSS parser] saves comment types (`/* */` or `//`)
in `node.raws.inline`.
The default parser cleans CSS values from comments and spaces.
It saves the original value with comments to `node.raws.value.raw` and uses it,
if the node value was not changed.
[SCSS parser]: https://github.com/postcss/postcss-scss
### Tests
Of course, all parsers in the PostCSS ecosystem must have tests.
If your parser just extends CSS syntax (like [SCSS] or [Safe Parser]),
you can use the [PostCSS Parser Tests]. It contains unit & integration tests.
[PostCSS Parser Tests]: https://github.com/postcss/postcss-parser-tests
## Stringifier
A style guide generator is a good example of a stringifier. It generates output
HTML which contains CSS components. For this use case, a parser isn't necessary,
so the package should just contain a stringifier.
The Stringifier API is little bit more complicated, than the parser API.
PostCSS generates a source map, so a stringifier cant just return a string.
It must link every substring with its source node.
A Stringifier is a function which receives [`Root`] node and builder callback.
Then it calls builder with every nodes string and node instance.
```js
module.exports = function (root, builder) {
// Some magic
var string = decl.prop + ':' + decl.value + ';';
builder(string, decl);
// Some science
};
```
### Main Theory
PostCSS [default stringifier] is just a class with a method for each node type
and many methods to detect raw properties.
In most cases it will be enough just to extend this class,
like in [SCSS stringifier].
[default stringifier]: https://github.com/postcss/postcss/blob/master/lib/stringifier.es6
[SCSS stringifier]: https://github.com/postcss/postcss-scss/blob/master/lib/scss-stringifier.es6
### Builder Function
A builder function will be passed to `stringify` function as second argument.
For example, the default PostCSS stringifier class saves it
to `this.builder` property.
Builder receives output substring and source node to append this substring
to the final output.
Some nodes contain other nodes in the middle. For example, a rule has a `{`
at the beginning, many declarations inside and a closing `}`.
For these cases, you should pass a third argument to builder function:
`'start'` or `'end'` string:
```js
this.builder(rule.selector + '{', rule, 'start');
// Stringify declarations inside
this.builder('}', rule, 'end');
```
### Raw Values
A good PostCSS custom syntax saves all symbols and provide byte-to-byte equal
output if there were no changes.
This is why every node has `node.raws` object to store space symbol, etc.
Be careful, because sometimes these raw properties will not be present; some
nodes may be built manually, or may lose their indentation when they are moved
to another parent node.
This is why the default stringifier has a `raw()` method to autodetect raw
properties by other nodes. For example, it will look at other nodes to detect
indent size and them multiply it with the current node depth.
### Tests
A stringifier must have tests too.
You can use unit and integration test cases from [PostCSS Parser Tests].
Just compare input CSS with CSS after your parser and stringifier.
[PostCSS Parser Tests]: https://github.com/postcss/postcss-parser-tests
+159
View File
File diff suppressed because one or more lines are too long
+89
View File
@@ -0,0 +1,89 @@
'use strict';
exports.__esModule = true;
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; }; }();
var _warnOnce = require('./warn-once');
var _warnOnce2 = _interopRequireDefault(_warnOnce);
var _node = require('./node');
var _node2 = _interopRequireDefault(_node);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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; }
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; }
/**
* Represents a comment between declarations or statements (rule and at-rules).
*
* Comments inside selectors, at-rule parameters, or declaration values
* will be stored in the `raws` properties explained above.
*
* @extends Node
*/
var Comment = function (_Node) {
_inherits(Comment, _Node);
function Comment(defaults) {
_classCallCheck(this, Comment);
var _this = _possibleConstructorReturn(this, _Node.call(this, defaults));
_this.type = 'comment';
return _this;
}
_createClass(Comment, [{
key: 'left',
get: function get() {
(0, _warnOnce2.default)('Comment#left was deprecated. Use Comment#raws.left');
return this.raws.left;
},
set: function set(val) {
(0, _warnOnce2.default)('Comment#left was deprecated. Use Comment#raws.left');
this.raws.left = val;
}
}, {
key: 'right',
get: function get() {
(0, _warnOnce2.default)('Comment#right was deprecated. Use Comment#raws.right');
return this.raws.right;
},
set: function set(val) {
(0, _warnOnce2.default)('Comment#right was deprecated. Use Comment#raws.right');
this.raws.right = val;
}
/**
* @memberof Comment#
* @member {string} text - the comments text
*/
/**
* @memberof Comment#
* @member {object} raws - Information to generate byte-to-byte equal
* node string as it was in the origin input.
*
* Every parser saves its own properties,
* but the default CSS parser uses:
*
* * `before`: the space symbols before the node.
* * `left`: the space symbols between `/*` and the comments text.
* * `right`: the space symbols between the comments text.
*/
}]);
return Comment;
}(_node2.default);
exports.default = Comment;
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbW1lbnQuZXM2Il0sIm5hbWVzIjpbIkNvbW1lbnQiLCJkZWZhdWx0cyIsInR5cGUiLCJyYXdzIiwibGVmdCIsInZhbCIsInJpZ2h0Il0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTs7OztBQUNBOzs7Ozs7Ozs7Ozs7QUFFQTs7Ozs7Ozs7SUFRTUEsTzs7O0FBRUYscUJBQVlDLFFBQVosRUFBc0I7QUFBQTs7QUFBQSxxREFDbEIsaUJBQU1BLFFBQU4sQ0FEa0I7O0FBRWxCLGNBQUtDLElBQUwsR0FBWSxTQUFaO0FBRmtCO0FBR3JCOzs7OzRCQUVVO0FBQ1Asb0NBQVMsb0RBQVQ7QUFDQSxtQkFBTyxLQUFLQyxJQUFMLENBQVVDLElBQWpCO0FBQ0gsUzswQkFFUUMsRyxFQUFLO0FBQ1Ysb0NBQVMsb0RBQVQ7QUFDQSxpQkFBS0YsSUFBTCxDQUFVQyxJQUFWLEdBQWlCQyxHQUFqQjtBQUNIOzs7NEJBRVc7QUFDUixvQ0FBUyxzREFBVDtBQUNBLG1CQUFPLEtBQUtGLElBQUwsQ0FBVUcsS0FBakI7QUFDSCxTOzBCQUVTRCxHLEVBQUs7QUFDWCxvQ0FBUyxzREFBVDtBQUNBLGlCQUFLRixJQUF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gKiAqIGByaWdodGA6IHRoZSBzcGFjZSBzeW1ib2xzIGJldHdlZW4gdGhlIGNvbW1lbnTigJlzIHRleHQuXG4gICAgICovXG59XG5cbmV4cG9ydCBkZWZhdWx0IENvbW1lbnQ7XG4iXX0=
+935
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+131
View File
File diff suppressed because one or more lines are too long
+198
View File
File diff suppressed because one or more lines are too long
+434
View File
File diff suppressed because one or more lines are too long
+95
View File
File diff suppressed because one or more lines are too long
+312
View File
File diff suppressed because one or more lines are too long
+669
View File
File diff suppressed because one or more lines are too long
+41
View File
@@ -0,0 +1,41 @@
'use strict';
exports.__esModule = true;
exports.default = parse;
var _parser = require('./parser');
var _parser2 = _interopRequireDefault(_parser);
var _input = require('./input');
var _input2 = _interopRequireDefault(_input);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function parse(css, opts) {
if (opts && opts.safe) {
throw new Error('Option safe was removed. ' + 'Use parser: require("postcss-safe-parser")');
}
var input = new _input2.default(css, opts);
var parser = new _parser2.default(input);
try {
parser.tokenize();
parser.loop();
} catch (e) {
if (e.name === 'CssSyntaxError' && opts && opts.from) {
if (/\.scss$/i.test(opts.from)) {
e.message += '\nYou tried to parse SCSS with ' + 'the standard CSS parser; ' + 'try again with the postcss-scss parser';
} else if (/\.less$/i.test(opts.from)) {
e.message += '\nYou tried to parse Less with ' + 'the standard CSS parser; ' + 'try again with the postcss-less parser';
}
}
throw e;
}
return parser.root;
}
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBhcnNlLmVzNiJdLCJuYW1lcyI6WyJwYXJzZSIsImNzcyIsIm9wdHMiLCJzYWZlIiwiRXJyb3IiLCJpbnB1dCIsInBhcnNlciIsInRva2VuaXplIiwibG9vcCIsImUiLCJuYW1lIiwiZnJvbSIsInRlc3QiLCJtZXNzYWdlIiwicm9vdCJdLCJtYX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Q1NTIHBhcnNlcjsgJyArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICd0cnkgYWdhaW4gd2l0aCB0aGUgcG9zdGNzcy1sZXNzIHBhcnNlcic7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhyb3cgZTtcbiAgICB9XG5cbiAgICByZXR1cm4gcGFyc2VyLnJvb3Q7XG59XG4iXX0=
+503
View File
File diff suppressed because one or more lines are too long
+292
View File
File diff suppressed because one or more lines are too long
+162
View File
File diff suppressed because one or more lines are too long
+238
View File
File diff suppressed because one or more lines are too long
+206
View File
File diff suppressed because one or more lines are too long
+143
View File
File diff suppressed because one or more lines are too long
+136
View File
File diff suppressed because one or more lines are too long
+335
View File
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
'use strict';
exports.__esModule = true;
exports.default = stringify;
var _stringifier = require('./stringifier');
var _stringifier2 = _interopRequireDefault(_stringifier);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function stringify(node, builder) {
var str = new _stringifier2.default(builder);
str.stringify(node);
}
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0cmluZ2lmeS5lczYiXSwibmFtZXMiOlsic3RyaW5naWZ5Iiwibm9kZSIsImJ1aWxkZXIiLCJzdHIiXSwibWFwcGluZ3MiOiI7OztrQkFFd0JBLFM7O0FBRnhCOzs7Ozs7QUFFZSxTQUFTQSxTQUFULENBQW1CQyxJQUFuQixFQUF5QkMsT0FBekIsRUFBa0M7QUFDN0MsUUFBSUMsTUFBTSwwQkFBZ0JELE9BQWhCLENBQVY7QUFDQUMsUUFBSUgsU0FBSixDQUFjQyxJQUFkO0FBQ0giLCJmaWxlIjoic3RyaW5naWZ5LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFN0cmluZ2lmaWVyIGZyb20gJy4vc3RyaW5naWZpZXInO1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBzdHJpbmdpZnkobm9kZSwgYnVpbGRlcikge1xuICAgIGxldCBzdHIgPSBuZXcgU3RyaW5naWZpZXIoYnVpbGRlcik7XG4gICAgc3RyLnN0cmluZ2lmeShub2RlKTtcbn1cbiJdfQ==
+76
View File
@@ -0,0 +1,76 @@
'use strict';
exports.__esModule = true;
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _tokenize = require('./tokenize');
var _tokenize2 = _interopRequireDefault(_tokenize);
var _input = require('./input');
var _input2 = _interopRequireDefault(_input);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var colors = new _chalk2.default.constructor({ enabled: true });
var HIGHLIGHT_THEME = {
'brackets': colors.cyan,
'at-word': colors.cyan,
'call': colors.cyan,
'comment': colors.gray,
'string': colors.green,
'class': colors.yellow,
'hash': colors.magenta,
'(': colors.cyan,
')': colors.cyan,
'{': colors.yellow,
'}': colors.yellow,
'[': colors.yellow,
']': colors.yellow,
':': colors.yellow,
';': colors.yellow
};
function getTokenType(_ref, index, tokens) {
var type = _ref[0],
value = _ref[1];
if (type === 'word') {
if (value[0] === '.') {
return 'class';
}
if (value[0] === '#') {
return 'hash';
}
}
var nextToken = tokens[index + 1];
if (nextToken && (nextToken[0] === 'brackets' || nextToken[0] === '(')) {
return 'call';
}
return type;
}
function terminalHighlight(css) {
var tokens = (0, _tokenize2.default)(new _input2.default(css), { ignoreErrors: true });
return tokens.map(function (token, index) {
var color = HIGHLIGHT_THEME[getTokenType(token, index, tokens)];
if (color) {
return token[1].split(/\r?\n/).map(function (i) {
return color(i);
}).join('\n');
} else {
return token[1];
}
}).join('');
}
exports.default = terminalHighlight;
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlcm1pbmFsLWhpZ2hsaWdodC5lczYiXSwibmFtZXMiOlsiY29sb3JzIiwiY29uc3RydW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idGVybWluYWwtaGlnaGxpZ2h0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGNoYWxrIGZyb20gJ2NoYWxrJztcblxuaW1wb3J0IHRva2VuaXplIGZyb20gJy4vdG9rZW5pemUnO1xuaW1wb3J0IElucHV0ICAgIGZyb20gJy4vaW5wdXQnO1xuXG5sZXQgY29sb3JzID0gbmV3IGNoYWxrLmNvbnN0cnVjdG9yKHsgZW5hYmxlZDogdHJ1ZSB9KTtcblxuY29uc3QgSElHSExJR0hUX1RIRU1FID0ge1xuICAgICdicmFja2V0cyc6IGNvbG9ycy5jeWFuLFxuICAgICdhdC13b3JkJzogIGNvbG9ycy5jeWFuLFxuICAgICdjYWxsJzogICAgIGNvbG9ycy5jeWFuLFxuICAgICdjb21tZW50JzogIGNvbG9ycy5ncmF5LFxuICAgICdzdHJpbmcnOiAgIGNvbG9ycy5ncmVlbixcbiAgICAnY2xhc3MnOiAgICBjb2xvcnMueWVsbG93LFxuICAgICdoYXNoJzogICAgIGNvbG9ycy5tYWdlbnRhLFxuICAgICcoJzogICAgICAgIGNvbG9ycy5jeWFuLFxuICAgICcpJzogICAgICAgIGNvbG9ycy5jeWFuLFxuICAgICd7JzogICAgICAgIGNvbG9ycy55ZWxsb3csXG4gICAgJ30nOiAgICAgICAgY29sb3JzLnllbGxvdyxcbiAgICAnWyc6ICAgICAgICBjb2xvcnMueWVsbG93LFxuICAgICddJzogICAgICAgIGNvbG9ycy55ZWxsb3csXG4gICAgJzonOiAgICAgICAgY29sb3JzLnllbGxvdyxcbiAgICAnOyc6ICAgICAgICBjb2xvcnMueWVsbG93XG59O1xuXG5mdW5jdGlvbiBnZXRUb2tlblR5cGUoW3R5cGUsIHZhbHVlXSwgaW5kZXgsIHRva2Vucykge1xuICAgIGlmICh0eXBlID09PSAnd29yZCcpIHtcbiAgICAgICAgaWYgKHZhbHVlWzBdID09PSAnLicpIHtcbiAgICAgICAgICAgIHJldHVybiAnY2xhc3MnO1xuICAgICAgICB9XG4gICAgICAgIGlmICh2YWx1ZVswXSA9PT0gJyMnKSB7XG4gICAgICAgICAgICByZXR1cm4gJ2hhc2gnO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgbGV0IG5leHRUb2tlbiA9IHRva2Vuc1tpbmRleCArIDFdO1xuICAgIGlmIChuZXh0VG9rZW4gJiYgKG5leHRUb2tlblswXSA9PT0gJ2JyYWNrZXRzJyB8fCBuZXh0VG9rZW5bMF0gPT09ICcoJykpIHtcbiAgICAgICAgcmV0dXJuICdjYWxsJztcbiAgICB9XG5cbiAgICByZXR1cm4gdHlwZTtcbn1cblxuZnVuY3Rpb24gdGVybWluYWxIaWdobGlnaHQoY3NzKSB7XG4gICAgbGV0IHRva2VucyA9IHRva2VuaXplKG5ldyBJbnB1dChjc3MpLCB7IGlnbm9yZUVycm9yczogdHJ1ZSB9KTtcbiAgICByZXR1cm4gdG9rZW5zLm1hcCgodG9rZW4sIGluZGV4KSA9PiB7XG4gICAgICAgIGxldCBjb2xvciA9IEhJR0hMSUdIVF9USEVNRVtnZXRUb2tlblR5cGUodG9rZW4sIGluZGV4LCB0b2tlbnMpXTtcbiAgICAgICAgaWYgKCBjb2xvciApIHtcbiAgICAgICAgICAgIHJldHVybiB0b2tlblsxXS5zcGxpdCgvXFxyP1xcbi8pXG4gICAgICAgICAgICAgIC5tYXAoIGkgPT4gY29sb3IoaSkgKVxuICAgICAgICAgICAgICAuam9pbignXFxuJyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdG9rZW5bMV07XG4gICAgICAgIH1cbiAgICB9KS5qb2luKCcnKTtcbn1cblxuZXhwb3J0IGRlZmF1bHQgdGVybWluYWxIaWdobGlnaHQ7XG4iXX0=
+273
View File
File diff suppressed because one or more lines are too long
+52
View File
@@ -0,0 +1,52 @@
'use strict';
exports.__esModule = true;
/**
* Contains helpers for working with vendor prefixes.
*
* @example
* const vendor = postcss.vendor;
*
* @namespace vendor
*/
var vendor = {
/**
* Returns the vendor prefix extracted from an input string.
*
* @param {string} prop - string with or without vendor prefix
*
* @return {string} vendor prefix or empty string
*
* @example
* postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
* postcss.vendor.prefix('tab-size') //=> ''
*/
prefix: function prefix(prop) {
var match = prop.match(/^(-\w+-)/);
if (match) {
return match[0];
} else {
return '';
}
},
/**
* Returns the input string stripped of its vendor prefix.
*
* @param {string} prop - string with or without vendor prefix
*
* @return {string} string name without vendor prefixes
*
* @example
* postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
*/
unprefixed: function unprefixed(prop) {
return prop.replace(/^-\w+-/, '');
}
};
exports.default = vendor;
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInZlbmRvci5lczYiXSwibmFtZXMiOlsidmVuZG9yIiwicHJlZml4IiwicHJvcCIsIm1hdGNoIiwidW5wcmVmaXhlZCIsInJlcGxhY2UiXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7Ozs7OztBQVFBLElBQUlBLFNBQVM7O0FBRVQ7Ozs7Ozs7Ozs7O0FBV0FDLFVBYlMsa0JBYUZDLElBYkUsRUFhSTtBQUNULFlBQUlDLFFBQVFELEtBQUtDLEtBQUwsQ0FBVyxVQUFYLENBQVo7QUFDQSxZQUFLQSxLQUFMLEVBQWE7QUFDVCxtQkFBT0EsTUFBTSxDQUFOLENBQVA7QUFDSCxTQUZELE1BRU87QUFDSCxtQkFBTyxFQUFQO0FBQ0g7QUFDSixLQXBCUTs7O0FBc0JUOzs7Ozs7Ozs7O0FBVUFDLGNBaENTLHNCQWdDRUYsSUFoQ0YsRUFnQ1E7QUFDYixlQUFPQSxLQUFLRyxPQUFMLENBQWEsUUFBYixFQUF1QixFQUF2QixDQUFQO0FBQ0g7QUFsQ1EsQ0FBYjs7a0JBc0NlTCxNIiwiZmlsZSI6InZlbmRvci5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQ29udGFpbnMgaGVscGVycyBmb3Igd29ya2luZyB3aXRoIHZlbmRvciBwcmVmaXhlcy5cbiAqXG4gKiBAZXhhbXBsZVxuICogY29uc3QgdmVuZG9yID0gcG9zdGNzcy52ZW5kb3I7XG4gKlxuICogQG5hbWVzcGFjZSB2ZW5kb3JcbiAqL1xubGV0IHZlbmRvciA9IHtcblxuICAgIC8qKlxuICAgICAqIFJldHVybnMgdGhlIHZlbmRvciBwcmVmaXggZXh0cmFjdGVkIGZyb20gYW4gaW5wdXQgc3RyaW5nLlxuICAgICAqXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IHByb3AgLSBzdHJpbmcgd2l0aCBvciB3aXRob3V0IHZlbmRvciBwcmVmaXhcbiAgICAgKlxuICAgICAqIEByZXR1cm4ge3N0cmluZ30gdmVuZG9yIHByZWZpeCBvciBlbXB0eSBzdHJpbmdcbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogcG9zdGNzcy52ZW5kb3IucHJlZml4KCctbW96LXRhYi1zaXplJykgLy89PiAnLW1vei0nXG4gICAgICogcG9zdGNzcy52ZW5kb3IucHJlZml4KCd0YWItc2l6ZScpICAgICAgLy89PiAnJ1xuICAgICAqL1xuICAgIHByZWZpeChwcm9wKSB7XG4gICAgICAgIGxldCBtYXRjaCA9IHByb3AubWF0Y2goL14oLVxcdystKS8pO1xuICAgICAgICBpZiAoIG1hdGNoICkge1xuICAgICAgICAgICAgcmV0dXJuIG1hdGNoWzBdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuICcnO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIFJldHVybnMgdGhlIGlucHV0IHN0cmluZyBzdHJpcHBlZCBvZiBpdHMgdmVuZG9yIHByZWZpeC5cbiAgICAgKlxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSBwcm9wIC0gc3RyaW5nIHdpdGggb3Igd2l0aG91dCB2ZW5kb3IgcHJlZml4XG4gICAgICpcbiAgICAgKiBAcmV0dXJuIHtzdHJpbmd9IHN0cmluZyBuYW1lIHdpdGhvdXQgdmVuZG9yIHByZWZpeGVzXG4gICAgICpcbiAgICAgKiBAZXhhbXBsZVxuICAgICAqIHBvc3Rjc3MudmVuZG9yLnVucHJlZml4ZWQoJy1tb3otdGFiLXNpemUnKSAvLz0+ICd0YWItc2l6ZSdcbiAgICAgKi9cbiAgICB1bnByZWZpeGVkKHByb3ApIHtcbiAgICAgICAgcmV0dXJuIHByb3AucmVwbGFjZSgvXi1cXHcrLS8sICcnKTtcbiAgICB9XG5cbn07XG5cbmV4cG9ydCBkZWZhdWx0IHZlbmRvcjtcbiJdfQ==
+14
View File
@@ -0,0 +1,14 @@
'use strict';
exports.__esModule = true;
exports.default = warnOnce;
var printed = {};
function warnOnce(message) {
if (printed[message]) return;
printed[message] = true;
if (typeof console !== 'undefined' && console.warn) console.warn(message);
}
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndhcm4tb25jZS5lczYiXSwibmFtZXMiOlsid2Fybk9uY2UiLCJwcmludGVkIiwibWVzc2FnZSIsImNvbnNvbGUiLCJ3YXJuIl0sIm1hcHBpbmdzIjoiOzs7a0JBRXdCQSxRO0FBRnhCLElBQUlDLFVBQVUsRUFBZDs7QUFFZSxTQUFTRCxRQUFULENBQWtCRSxPQUFsQixFQUEyQjtBQUN0QyxRQUFLRCxRQUFRQyxPQUFSLENBQUwsRUFBd0I7QUFDeEJELFlBQVFDLE9BQVIsSUFBbUIsSUFBbkI7O0FBRUEsUUFBSyxPQUFPQyxPQUFQLEtBQW1CLFdBQW5CLElBQWtDQSxRQUFRQyxJQUEvQyxFQUFzREQsUUFBUUMsSUFBUixDQUFhRixPQUFiO0FBQ3pEIiwiZmlsZSI6Indhcm4tb25jZS5qcyIsInNvdXJjZXNDb250ZW50IjpbImxldCBwcmludGVkID0geyB9O1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiB3YXJuT25jZShtZXNzYWdlKSB7XG4gICAgaWYgKCBwcmludGVkW21lc3NhZ2VdICkgcmV0dXJuO1xuICAgIHByaW50ZWRbbWVzc2FnZV0gPSB0cnVlO1xuXG4gICAgaWYgKCB0eXBlb2YgY29uc29sZSAhPT0gJ3VuZGVmaW5lZCcgJiYgY29uc29sZS53YXJuICkgY29uc29sZS53YXJuKG1lc3NhZ2UpO1xufVxuIl19
+122
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
'use strict';
module.exports = false;
+72
View File
@@ -0,0 +1,72 @@
'use strict';
var hasFlag = require('has-flag');
var support = function (level) {
if (level === 0) {
return false;
}
return {
level: level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3
};
};
var supportLevel = (function () {
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return 0;
}
if (hasFlag('color=16m') ||
hasFlag('color=full') ||
hasFlag('color=truecolor')) {
return 3;
}
if (hasFlag('color=256')) {
return 2;
}
if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return 1;
}
if (process.stdout && !process.stdout.isTTY) {
return 0;
}
if (process.platform === 'win32') {
return 1;
}
if ('COLORTERM' in process.env) {
return 1;
}
if (process.env.TERM === 'dumb') {
return 0;
}
if (/^xterm-256(?:color)?/.test(process.env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return 1;
}
return 0;
})();
if (supportLevel === 0 && 'FORCE_COLOR' in process.env) {
supportLevel = 1;
}
module.exports = process && support(supportLevel);
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+128
View File
@@ -0,0 +1,128 @@
{
"_args": [
[
{
"raw": "supports-color@^3.1.2",
"scope": null,
"escapedName": "supports-color",
"name": "supports-color",
"rawSpec": "^3.1.2",
"spec": ">=3.1.2 <4.0.0",
"type": "range"
},
"/mnt/Data/bach/Documents/ola/OLA#3DOC/sys/node_modules/postcss"
]
],
"_from": "supports-color@>=3.1.2 <4.0.0",
"_id": "supports-color@3.1.2",
"_inCache": true,
"_location": "/postcss/supports-color",
"_nodeVersion": "4.1.1",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "2.14.4",
"_phantomChildren": {},
"_requested": {
"raw": "supports-color@^3.1.2",
"scope": null,
"escapedName": "supports-color",
"name": "supports-color",
"rawSpec": "^3.1.2",
"spec": ">=3.1.2 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/postcss"
],
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz",
"_shasum": "72a262894d9d408b956ca05ff37b2ed8a6e2a2d5",
"_shrinkwrap": null,
"_spec": "supports-color@^3.1.2",
"_where": "/mnt/Data/bach/Documents/ola/OLA#3DOC/sys/node_modules/postcss",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"browser": "browser.js",
"bugs": {
"url": "https://github.com/chalk/supports-color/issues"
},
"dependencies": {
"has-flag": "^1.0.0"
},
"description": "Detect whether a terminal supports color",
"devDependencies": {
"mocha": "*",
"require-uncached": "^1.0.2",
"xo": "*"
},
"directories": {},
"dist": {
"shasum": "72a262894d9d408b956ca05ff37b2ed8a6e2a2d5",
"tarball": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz"
},
"engines": {
"node": ">=0.8.0"
},
"files": [
"index.js",
"browser.js"
],
"gitHead": "d9e363732f48ad2bc6b936357246b55e136aa989",
"homepage": "https://github.com/chalk/supports-color",
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect",
"truecolor",
"16m",
"million"
],
"license": "MIT",
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"name": "supports-color",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/supports-color.git"
},
"scripts": {
"test": "xo && mocha",
"travis": "mocha"
},
"version": "3.1.2",
"xo": {
"envs": [
"node",
"mocha"
]
}
}
+60
View File
@@ -0,0 +1,60 @@
# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)
> Detect whether a terminal supports color
## Install
```
$ npm install --save supports-color
```
## Usage
```js
var supportsColor = require('supports-color');
if (supportsColor) {
console.log('Terminal supports color');
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
```
## API
Returns an `object`, or `false` if color is not supported.
The returned object specifies a level of support for color through a `.level` property and a corresponding flag:
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
- `.level = 2` and `.has256 = true`: 256 color support
- `.level = 3` and `.has16m = true`: 16 million (truecolor) support
## Info
It obeys the `--color` and `--no-color` CLI flags.
For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
Explicit 256/truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
+148
View File
@@ -0,0 +1,148 @@
{
"_args": [
[
{
"raw": "postcss@^5.0.4",
"scope": null,
"escapedName": "postcss",
"name": "postcss",
"rawSpec": "^5.0.4",
"spec": ">=5.0.4 <6.0.0",
"type": "range"
},
"/mnt/Data/bach/Documents/ola/OLA#3DOC/sys/node_modules/gulp-autoprefixer"
]
],
"_from": "postcss@>=5.0.4 <6.0.0",
"_id": "postcss@5.2.6",
"_inCache": true,
"_location": "/postcss",
"_nodeVersion": "7.1.0",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/postcss-5.2.6.tgz_1479819351588_0.21716016554273665"
},
"_npmUser": {
"name": "ai",
"email": "andrey@sitnik.ru"
},
"_npmVersion": "3.10.9",
"_phantomChildren": {
"has-flag": "1.0.0"
},
"_requested": {
"raw": "postcss@^5.0.4",
"scope": null,
"escapedName": "postcss",
"name": "postcss",
"rawSpec": "^5.0.4",
"spec": ">=5.0.4 <6.0.0",
"type": "range"
},
"_requiredBy": [
"/autoprefixer",
"/gulp-autoprefixer"
],
"_resolved": "https://registry.npmjs.org/postcss/-/postcss-5.2.6.tgz",
"_shasum": "a252cd67cd52585035f17e9ad12b35137a7bdd9e",
"_shrinkwrap": null,
"_spec": "postcss@^5.0.4",
"_where": "/mnt/Data/bach/Documents/ola/OLA#3DOC/sys/node_modules/gulp-autoprefixer",
"author": {
"name": "Andrey Sitnik",
"email": "andrey@sitnik.ru"
},
"bugs": {
"url": "https://github.com/postcss/postcss/issues"
},
"dependencies": {
"chalk": "^1.1.3",
"js-base64": "^2.1.9",
"source-map": "^0.5.6",
"supports-color": "^3.1.2"
},
"description": "Tool for transforming styles with JS plugins",
"devDependencies": {
"ava": "0.17.0",
"babel-core": "6.18.2",
"babel-eslint": "7.1.1",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-precompile-charcodes": "1.0.0",
"babel-preset-es2015": "6.18.0",
"chalk": "1.1.3",
"concat-with-sourcemaps": "1.0.4",
"del": "2.2.2",
"docdash": "0.4.0",
"eslint": "3.10.2",
"eslint-config-postcss": "2.0.2",
"fs-extra": "1.0.0",
"gulp": "3.9.1",
"gulp-ava": "0.15.0",
"gulp-babel": "6.1.2",
"gulp-changed": "1.3.2",
"gulp-eslint": "3.0.1",
"gulp-run": "1.7.1",
"gulp-sourcemaps": "2.2.0",
"jsdoc": "3.4.3",
"lint-staged": "3.2.1",
"postcss-parser-tests": "5.0.10",
"pre-commit": "1.1.3",
"run-sequence": "1.2.2",
"sinon": "1.17.6",
"strip-ansi": "3.0.1",
"yaspeller": "3.0.0"
},
"directories": {},
"dist": {
"shasum": "a252cd67cd52585035f17e9ad12b35137a7bdd9e",
"tarball": "https://registry.npmjs.org/postcss/-/postcss-5.2.6.tgz"
},
"engines": {
"node": ">=0.12"
},
"homepage": "http://postcss.org/",
"keywords": [
"css",
"postcss",
"rework",
"preprocessor",
"parser",
"source map",
"transform",
"manipulation",
"transpiler"
],
"license": "MIT",
"lint-staged": {
"test/*.js": "eslint",
"lib/*.es6": "eslint",
"*.md": "yaspeller"
},
"main": "lib/postcss",
"maintainers": [
{
"name": "ai",
"email": "andrey@sitnik.ru"
},
{
"name": "beneb",
"email": "beneb.info@gmail.com"
}
],
"name": "postcss",
"optionalDependencies": {},
"pre-commit": [
"lint-staged"
],
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/postcss/postcss.git"
},
"scripts": {
"lint-staged": "lint-staged",
"test": "gulp"
},
"typings": "d.ts/postcss.d.ts",
"version": "5.2.6"
}