Table of contents
Processor
Creates aProcessor
instance. This instance can be used on multiple Stylesheets.postcss
default export function returns aProcessor
instance. The main purpose of this module is to process the plugins, which is calledNormalization
here, add to theplugins
data member for storage and return aLazyResult
promise.
Data members
plugins -Array<Plugin|Transformer|TransformCallback>
stores a list of plugins added to thisProcessor
instance.
Methods
use
takes in a plugin to append to the list of plugins and returns instance ofProcessor
.
process
Parses CSS (can be passed in as various types) to returnLazyResult
promise.
normalize
Takes inArray< plugin >
are argument. For each of the plugin, the following steps are done:
- Normalization involves a preprocessing step where
- if
postcss === true
, it is executed immediately as function without argument. - if
postcss
contains any other truthy value, then the object is destructured to setpostcss
as top level value.
- if
- Next step involves added the plugins to normalized list.
- if
plugin
isobject
- and
plugin.plugins
isArray
, the plugins are merged to the normalized plugin list. - and
plugin.postcssPlugin
is truthy, it is appended to normalized plugin list.
- and
type
'function'
directs becomes eligible to be added in normalized list.
- if
- Other types are naturally eligible to enter the error conditions.
LazyResult
constructor
Takes in CSS either asstring
or already parsedNode
|Root
, to passRoot
to new instance ofResult
. Along withResult
,helpers
andplugins
are also added as data members to this.
Result
This is a very simple data structure to store fields (like a POJO):
processor
Array<Warning>
asmessages
root
css
map
opts
Main processing logic is present in other modules. Here, bothcontent
andtoString
returns the sameResult.css
.
Plugins
Extends fromProcessors
. If they areasync
, thenPromise
must be returned.
prepare
takes inResult
and returnsProcessors
Warning
A simple structure that is used to get debug info i.e. source and location of the error and the plugin that is causing this. It has got a self-explanatorytoString
method.
Other Entities
AcceptedPlugin
Processor
takes an Array ofAcceptedPlugin
which can be of type:
Plugin
PluginCreator<any>
OldPlugin<any>
TransformCallback
{postcss: TransformCallback|Processor}
Processor
- The currentProcessor
instance will copy thisProcessor
's plugins
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse