source: trip-planner-front/node_modules/postcss/lib/postcss.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[6a3a178]1'use strict'
2
3let CssSyntaxError = require('./css-syntax-error')
4let Declaration = require('./declaration')
5let LazyResult = require('./lazy-result')
6let Container = require('./container')
7let Processor = require('./processor')
8let stringify = require('./stringify')
9let fromJSON = require('./fromJSON')
10let Document = require('./document')
11let Warning = require('./warning')
12let Comment = require('./comment')
13let AtRule = require('./at-rule')
14let Result = require('./result.js')
15let Input = require('./input')
16let parse = require('./parse')
17let list = require('./list')
18let Rule = require('./rule')
19let Root = require('./root')
20let Node = require('./node')
21
22function postcss(...plugins) {
23 if (plugins.length === 1 && Array.isArray(plugins[0])) {
24 plugins = plugins[0]
25 }
26 return new Processor(plugins)
27}
28
29postcss.plugin = function plugin(name, initializer) {
30 if (console && console.warn) {
31 console.warn(
32 name +
33 ': postcss.plugin was deprecated. Migration guide:\n' +
34 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
35 )
36 if (process.env.LANG && process.env.LANG.startsWith('cn')) {
37 // istanbul ignore next
38 console.warn(
39 name +
40 ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
41 'https://www.w3ctech.com/topic/2226'
42 )
43 }
44 }
45 function creator(...args) {
46 let transformer = initializer(...args)
47 transformer.postcssPlugin = name
48 transformer.postcssVersion = new Processor().version
49 return transformer
50 }
51
52 let cache
53 Object.defineProperty(creator, 'postcss', {
54 get() {
55 if (!cache) cache = creator()
56 return cache
57 }
58 })
59
60 creator.process = function (css, processOpts, pluginOpts) {
61 return postcss([creator(pluginOpts)]).process(css, processOpts)
62 }
63
64 return creator
65}
66
67postcss.stringify = stringify
68postcss.parse = parse
69postcss.fromJSON = fromJSON
70postcss.list = list
71
72postcss.comment = defaults => new Comment(defaults)
73postcss.atRule = defaults => new AtRule(defaults)
74postcss.decl = defaults => new Declaration(defaults)
75postcss.rule = defaults => new Rule(defaults)
76postcss.root = defaults => new Root(defaults)
77postcss.document = defaults => new Document(defaults)
78
79postcss.CssSyntaxError = CssSyntaxError
80postcss.Declaration = Declaration
81postcss.Container = Container
82postcss.Document = Document
83postcss.Comment = Comment
84postcss.Warning = Warning
85postcss.AtRule = AtRule
86postcss.Result = Result
87postcss.Input = Input
88postcss.Rule = Rule
89postcss.Root = Root
90postcss.Node = Node
91
92LazyResult.registerPostcss(postcss)
93
94module.exports = postcss
95postcss.default = postcss
Note: See TracBrowser for help on using the repository browser.