plugin-build-guide-block 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/node_modules/sanitize-html/LICENSE +7 -0
  2. package/dist/node_modules/sanitize-html/index.js +7 -0
  3. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.cjs +34 -0
  4. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.js +34 -0
  5. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.cjs +35 -0
  6. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.d.ts +56 -0
  7. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.js +35 -0
  8. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.native.js +26 -0
  9. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/package.json +12 -0
  10. package/dist/node_modules/sanitize-html/node_modules/nanoid/bin/nanoid.cjs +55 -0
  11. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.cjs +34 -0
  12. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.js +34 -0
  13. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.cjs +45 -0
  14. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.cts +91 -0
  15. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.ts +91 -0
  16. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.js +45 -0
  17. package/dist/node_modules/sanitize-html/node_modules/nanoid/nanoid.js +1 -0
  18. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.cjs +21 -0
  19. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.d.ts +33 -0
  20. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.js +21 -0
  21. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/package.json +6 -0
  22. package/dist/node_modules/sanitize-html/node_modules/nanoid/package.json +88 -0
  23. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.cjs +3 -0
  24. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.js +3 -0
  25. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/package.json +6 -0
  26. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.d.ts +115 -0
  27. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.js +25 -0
  28. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.d.ts +67 -0
  29. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.js +13 -0
  30. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.d.ts +452 -0
  31. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.js +439 -0
  32. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.d.ts +248 -0
  33. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.js +100 -0
  34. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.d.ts +148 -0
  35. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.js +24 -0
  36. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.d.ts +68 -0
  37. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.js +33 -0
  38. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  39. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.js +54 -0
  40. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.d.ts +194 -0
  41. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.js +248 -0
  42. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.d.ts +190 -0
  43. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.js +550 -0
  44. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.d.ts +57 -0
  45. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.js +58 -0
  46. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/map-generator.js +359 -0
  47. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.d.ts +46 -0
  48. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.js +135 -0
  49. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.d.ts +536 -0
  50. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.js +381 -0
  51. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.d.ts +9 -0
  52. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.js +42 -0
  53. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parser.js +610 -0
  54. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.mts +72 -0
  55. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.ts +441 -0
  56. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.js +101 -0
  57. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.d.ts +81 -0
  58. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.js +142 -0
  59. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.d.ts +115 -0
  60. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.js +67 -0
  61. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.d.ts +206 -0
  62. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.js +42 -0
  63. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.d.ts +86 -0
  64. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.js +61 -0
  65. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.d.ts +113 -0
  66. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.js +27 -0
  67. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.d.ts +46 -0
  68. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.js +353 -0
  69. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.d.ts +9 -0
  70. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.js +11 -0
  71. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/symbols.js +5 -0
  72. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/terminal-highlight.js +70 -0
  73. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/tokenize.js +266 -0
  74. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warn-once.js +13 -0
  75. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.d.ts +147 -0
  76. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.js +37 -0
  77. package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid +15 -0
  78. package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid.cmd +7 -0
  79. package/dist/node_modules/sanitize-html/node_modules/postcss/package.json +88 -0
  80. package/dist/node_modules/sanitize-html/package.json +1 -0
  81. package/package.json +9 -1
  82. package/src/client/UserGuideBlock.tsx +53 -0
  83. package/src/client/UserGuideBlockInitializer.tsx +26 -0
  84. package/src/client/UserGuideBlockProvider.tsx +12 -0
  85. package/src/client/UserGuideManager.tsx +133 -0
  86. package/src/client/client.d.ts +249 -0
  87. package/src/client/components/BuildButton.tsx +43 -0
  88. package/src/client/components/LLMServiceSelect.tsx +44 -0
  89. package/src/client/components/ModelSelect.tsx +41 -0
  90. package/src/client/components/StatusTag.tsx +17 -0
  91. package/src/client/index.tsx +1 -0
  92. package/src/client/models/UserGuideBlockModel.ts +47 -0
  93. package/src/client/models/index.ts +12 -0
  94. package/src/client/plugin.tsx +30 -0
  95. package/src/client/schemas/spacesSchema.ts +305 -0
  96. package/src/index.ts +2 -0
  97. package/src/locale/en-US.json +27 -0
  98. package/src/locale/vi-VN.json +27 -0
  99. package/src/locale/zh-CN.json +27 -0
  100. package/src/server/actions/build.ts +171 -0
  101. package/src/server/actions/getHtml.ts +26 -0
  102. package/src/server/collections/.gitkeep +0 -0
  103. package/src/server/collections/ai-build-guide-spaces.ts +49 -0
  104. package/src/server/index.ts +1 -0
  105. package/src/server/plugin.ts +42 -0
@@ -0,0 +1,441 @@
1
+ import { RawSourceMap, SourceMapGenerator } from 'source-map-js'
2
+
3
+ import AtRule, { AtRuleProps } from './at-rule.js'
4
+ import Comment, { CommentProps } from './comment.js'
5
+ import Container, { ContainerProps } from './container.js'
6
+ import CssSyntaxError from './css-syntax-error.js'
7
+ import Declaration, { DeclarationProps } from './declaration.js'
8
+ import Document, { DocumentProps } from './document.js'
9
+ import Input, { FilePosition } from './input.js'
10
+ import LazyResult from './lazy-result.js'
11
+ import list from './list.js'
12
+ import Node, {
13
+ AnyNode,
14
+ ChildNode,
15
+ ChildProps,
16
+ NodeErrorOptions,
17
+ NodeProps,
18
+ Position,
19
+ Source
20
+ } from './node.js'
21
+ import Processor from './processor.js'
22
+ import Result, { Message } from './result.js'
23
+ import Root, { RootProps } from './root.js'
24
+ import Rule, { RuleProps } from './rule.js'
25
+ import Warning, { WarningOptions } from './warning.js'
26
+
27
+ type DocumentProcessor = (
28
+ document: Document,
29
+ helper: postcss.Helpers
30
+ ) => Promise<void> | void
31
+ type RootProcessor = (root: Root, helper: postcss.Helpers) => Promise<void> | void
32
+ type DeclarationProcessor = (
33
+ decl: Declaration,
34
+ helper: postcss.Helpers
35
+ ) => Promise<void> | void
36
+ type RuleProcessor = (rule: Rule, helper: postcss.Helpers) => Promise<void> | void
37
+ type AtRuleProcessor = (atRule: AtRule, helper: postcss.Helpers) => Promise<void> | void
38
+ type CommentProcessor = (
39
+ comment: Comment,
40
+ helper: postcss.Helpers
41
+ ) => Promise<void> | void
42
+
43
+ interface Processors {
44
+ /**
45
+ * Will be called on all`AtRule` nodes.
46
+ *
47
+ * Will be called again on node or children changes.
48
+ */
49
+ AtRule?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
50
+
51
+ /**
52
+ * Will be called on all `AtRule` nodes, when all children will be processed.
53
+ *
54
+ * Will be called again on node or children changes.
55
+ */
56
+ AtRuleExit?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
57
+
58
+ /**
59
+ * Will be called on all `Comment` nodes.
60
+ *
61
+ * Will be called again on node or children changes.
62
+ */
63
+ Comment?: CommentProcessor
64
+
65
+ /**
66
+ * Will be called on all `Comment` nodes after listeners
67
+ * for `Comment` event.
68
+ *
69
+ * Will be called again on node or children changes.
70
+ */
71
+ CommentExit?: CommentProcessor
72
+
73
+ /**
74
+ * Will be called on all `Declaration` nodes after listeners
75
+ * for `Declaration` event.
76
+ *
77
+ * Will be called again on node or children changes.
78
+ */
79
+ Declaration?: { [prop: string]: DeclarationProcessor } | DeclarationProcessor
80
+
81
+ /**
82
+ * Will be called on all `Declaration` nodes.
83
+ *
84
+ * Will be called again on node or children changes.
85
+ */
86
+ DeclarationExit?:
87
+ | { [prop: string]: DeclarationProcessor }
88
+ | DeclarationProcessor
89
+
90
+ /**
91
+ * Will be called on `Document` node.
92
+ *
93
+ * Will be called again on children changes.
94
+ */
95
+ Document?: DocumentProcessor
96
+
97
+ /**
98
+ * Will be called on `Document` node, when all children will be processed.
99
+ *
100
+ * Will be called again on children changes.
101
+ */
102
+ DocumentExit?: DocumentProcessor
103
+
104
+ /**
105
+ * Will be called on `Root` node once.
106
+ */
107
+ Once?: RootProcessor
108
+
109
+ /**
110
+ * Will be called on `Root` node once, when all children will be processed.
111
+ */
112
+ OnceExit?: RootProcessor
113
+
114
+ /**
115
+ * Will be called on `Root` node.
116
+ *
117
+ * Will be called again on children changes.
118
+ */
119
+ Root?: RootProcessor
120
+
121
+ /**
122
+ * Will be called on `Root` node, when all children will be processed.
123
+ *
124
+ * Will be called again on children changes.
125
+ */
126
+ RootExit?: RootProcessor
127
+
128
+ /**
129
+ * Will be called on all `Rule` nodes.
130
+ *
131
+ * Will be called again on node or children changes.
132
+ */
133
+ Rule?: RuleProcessor
134
+
135
+ /**
136
+ * Will be called on all `Rule` nodes, when all children will be processed.
137
+ *
138
+ * Will be called again on node or children changes.
139
+ */
140
+ RuleExit?: RuleProcessor
141
+ }
142
+
143
+ declare namespace postcss {
144
+ export {
145
+ AnyNode,
146
+ AtRule,
147
+ AtRuleProps,
148
+ ChildNode,
149
+ ChildProps,
150
+ Comment,
151
+ CommentProps,
152
+ Container,
153
+ ContainerProps,
154
+ CssSyntaxError,
155
+ Declaration,
156
+ DeclarationProps,
157
+ Document,
158
+ DocumentProps,
159
+ FilePosition,
160
+ Input,
161
+ LazyResult,
162
+ list,
163
+ Message,
164
+ Node,
165
+ NodeErrorOptions,
166
+ NodeProps,
167
+ Position,
168
+ Processor,
169
+ Result,
170
+ Root,
171
+ RootProps,
172
+ Rule,
173
+ RuleProps,
174
+ Source,
175
+ Warning,
176
+ WarningOptions
177
+ }
178
+
179
+ export type SourceMap = SourceMapGenerator & {
180
+ toJSON(): RawSourceMap
181
+ }
182
+
183
+ export type Helpers = { postcss: Postcss; result: Result } & Postcss
184
+
185
+ export interface Plugin extends Processors {
186
+ postcssPlugin: string
187
+ prepare?: (result: Result) => Processors
188
+ }
189
+
190
+ export interface PluginCreator<PluginOptions> {
191
+ (opts?: PluginOptions): Plugin | Processor
192
+ postcss: true
193
+ }
194
+
195
+ export interface Transformer extends TransformCallback {
196
+ postcssPlugin: string
197
+ postcssVersion: string
198
+ }
199
+
200
+ export interface TransformCallback {
201
+ (root: Root, result: Result): Promise<void> | void
202
+ }
203
+
204
+ export interface OldPlugin<T> extends Transformer {
205
+ (opts?: T): Transformer
206
+ postcss: Transformer
207
+ }
208
+
209
+ export type AcceptedPlugin =
210
+ | {
211
+ postcss: Processor | TransformCallback
212
+ }
213
+ | OldPlugin<any>
214
+ | Plugin
215
+ | PluginCreator<any>
216
+ | Processor
217
+ | TransformCallback
218
+
219
+ export interface Parser<RootNode = Document | Root> {
220
+ (
221
+ css: { toString(): string } | string,
222
+ opts?: Pick<ProcessOptions, 'from' | 'map'>
223
+ ): RootNode
224
+ }
225
+
226
+ export interface Builder {
227
+ (part: string, node?: AnyNode, type?: 'end' | 'start'): void
228
+ }
229
+
230
+ export interface Stringifier {
231
+ (node: AnyNode, builder: Builder): void
232
+ }
233
+
234
+ export interface JSONHydrator {
235
+ (data: object): Node
236
+ (data: object[]): Node[]
237
+ }
238
+
239
+ export interface Syntax<RootNode = Document | Root> {
240
+ /**
241
+ * Function to generate AST by string.
242
+ */
243
+ parse?: Parser<RootNode>
244
+
245
+ /**
246
+ * Class to generate string by AST.
247
+ */
248
+ stringify?: Stringifier
249
+ }
250
+
251
+ export interface SourceMapOptions {
252
+ /**
253
+ * Use absolute path in generated source map.
254
+ */
255
+ absolute?: boolean
256
+
257
+ /**
258
+ * Indicates that PostCSS should add annotation comments to the CSS.
259
+ * By default, PostCSS will always add a comment with a path
260
+ * to the source map. PostCSS will not add annotations to CSS files
261
+ * that do not contain any comments.
262
+ *
263
+ * By default, PostCSS presumes that you want to save the source map as
264
+ * `opts.to + '.map'` and will use this path in the annotation comment.
265
+ * A different path can be set by providing a string value for annotation.
266
+ *
267
+ * If you have set `inline: true`, annotation cannot be disabled.
268
+ */
269
+ annotation?: ((file: string, root: Root) => string) | boolean | string
270
+
271
+ /**
272
+ * Override `from` in map’s sources.
273
+ */
274
+ from?: string
275
+
276
+ /**
277
+ * Indicates that the source map should be embedded in the output CSS
278
+ * as a Base64-encoded comment. By default, it is `true`.
279
+ * But if all previous maps are external, not inline, PostCSS will not embed
280
+ * the map even if you do not set this option.
281
+ *
282
+ * If you have an inline source map, the result.map property will be empty,
283
+ * as the source map will be contained within the text of `result.css`.
284
+ */
285
+ inline?: boolean
286
+
287
+ /**
288
+ * Source map content from a previous processing step (e.g., Sass).
289
+ *
290
+ * PostCSS will try to read the previous source map
291
+ * automatically (based on comments within the source CSS), but you can use
292
+ * this option to identify it manually.
293
+ *
294
+ * If desired, you can omit the previous map with prev: `false`.
295
+ */
296
+ prev?: ((file: string) => string) | boolean | object | string
297
+
298
+ /**
299
+ * Indicates that PostCSS should set the origin content (e.g., Sass source)
300
+ * of the source map. By default, it is true. But if all previous maps do not
301
+ * contain sources content, PostCSS will also leave it out even if you
302
+ * do not set this option.
303
+ */
304
+ sourcesContent?: boolean
305
+ }
306
+
307
+ export interface ProcessOptions<RootNode = Document | Root> {
308
+ /**
309
+ * The path of the CSS source file. You should always set `from`,
310
+ * because it is used in source map generation and syntax error messages.
311
+ */
312
+ from?: string | undefined
313
+
314
+ /**
315
+ * Source map options
316
+ */
317
+ map?: boolean | SourceMapOptions
318
+
319
+ /**
320
+ * Function to generate AST by string.
321
+ */
322
+ parser?: Parser<RootNode> | Syntax<RootNode>
323
+
324
+ /**
325
+ * Class to generate string by AST.
326
+ */
327
+ stringifier?: Stringifier | Syntax<RootNode>
328
+
329
+ /**
330
+ * Object with parse and stringify.
331
+ */
332
+ syntax?: Syntax<RootNode>
333
+
334
+ /**
335
+ * The path where you'll put the output CSS file. You should always set `to`
336
+ * to generate correct source maps.
337
+ */
338
+ to?: string
339
+ }
340
+
341
+ export type Postcss = typeof postcss
342
+
343
+ /**
344
+ * Default function to convert a node tree into a CSS string.
345
+ */
346
+ export let stringify: Stringifier
347
+
348
+ /**
349
+ * Parses source css and returns a new `Root` or `Document` node,
350
+ * which contains the source CSS nodes.
351
+ *
352
+ * ```js
353
+ * // Simple CSS concatenation with source map support
354
+ * const root1 = postcss.parse(css1, { from: file1 })
355
+ * const root2 = postcss.parse(css2, { from: file2 })
356
+ * root1.append(root2).toResult().css
357
+ * ```
358
+ */
359
+ export let parse: Parser<Root>
360
+
361
+ /**
362
+ * Rehydrate a JSON AST (from `Node#toJSON`) back into the AST classes.
363
+ *
364
+ * ```js
365
+ * const json = root.toJSON()
366
+ * // save to file, send by network, etc
367
+ * const root2 = postcss.fromJSON(json)
368
+ * ```
369
+ */
370
+ export let fromJSON: JSONHydrator
371
+
372
+ /**
373
+ * Creates a new `Comment` node.
374
+ *
375
+ * @param defaults Properties for the new node.
376
+ * @return New comment node
377
+ */
378
+ export function comment(defaults?: CommentProps): Comment
379
+
380
+ /**
381
+ * Creates a new `AtRule` node.
382
+ *
383
+ * @param defaults Properties for the new node.
384
+ * @return New at-rule node.
385
+ */
386
+ export function atRule(defaults?: AtRuleProps): AtRule
387
+
388
+ /**
389
+ * Creates a new `Declaration` node.
390
+ *
391
+ * @param defaults Properties for the new node.
392
+ * @return New declaration node.
393
+ */
394
+ export function decl(defaults?: DeclarationProps): Declaration
395
+
396
+ /**
397
+ * Creates a new `Rule` node.
398
+ *
399
+ * @param default Properties for the new node.
400
+ * @return New rule node.
401
+ */
402
+ export function rule(defaults?: RuleProps): Rule
403
+
404
+ /**
405
+ * Creates a new `Root` node.
406
+ *
407
+ * @param defaults Properties for the new node.
408
+ * @return New root node.
409
+ */
410
+ export function root(defaults?: RootProps): Root
411
+
412
+ /**
413
+ * Creates a new `Document` node.
414
+ *
415
+ * @param defaults Properties for the new node.
416
+ * @return New document node.
417
+ */
418
+ export function document(defaults?: DocumentProps): Document
419
+
420
+ export { postcss as default }
421
+ }
422
+
423
+ /**
424
+ * Create a new `Processor` instance that will apply `plugins`
425
+ * as CSS processors.
426
+ *
427
+ * ```js
428
+ * let postcss = require('postcss')
429
+ *
430
+ * postcss(plugins).process(css, { from, to }).then(result => {
431
+ * console.log(result.css)
432
+ * })
433
+ * ```
434
+ *
435
+ * @param plugins PostCSS plugins.
436
+ * @return Processor to process multiple CSS.
437
+ */
438
+ declare function postcss(plugins?: postcss.AcceptedPlugin[]): Processor
439
+ declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
440
+
441
+ export = postcss
@@ -0,0 +1,101 @@
1
+ 'use strict'
2
+
3
+ let CssSyntaxError = require('./css-syntax-error')
4
+ let Declaration = require('./declaration')
5
+ let LazyResult = require('./lazy-result')
6
+ let Container = require('./container')
7
+ let Processor = require('./processor')
8
+ let stringify = require('./stringify')
9
+ let fromJSON = require('./fromJSON')
10
+ let Document = require('./document')
11
+ let Warning = require('./warning')
12
+ let Comment = require('./comment')
13
+ let AtRule = require('./at-rule')
14
+ let Result = require('./result.js')
15
+ let Input = require('./input')
16
+ let parse = require('./parse')
17
+ let list = require('./list')
18
+ let Rule = require('./rule')
19
+ let Root = require('./root')
20
+ let Node = require('./node')
21
+
22
+ function postcss(...plugins) {
23
+ if (plugins.length === 1 && Array.isArray(plugins[0])) {
24
+ plugins = plugins[0]
25
+ }
26
+ return new Processor(plugins)
27
+ }
28
+
29
+ postcss.plugin = function plugin(name, initializer) {
30
+ let warningPrinted = false
31
+ function creator(...args) {
32
+ // eslint-disable-next-line no-console
33
+ if (console && console.warn && !warningPrinted) {
34
+ warningPrinted = true
35
+ // eslint-disable-next-line no-console
36
+ console.warn(
37
+ name +
38
+ ': postcss.plugin was deprecated. Migration guide:\n' +
39
+ 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
40
+ )
41
+ if (process.env.LANG && process.env.LANG.startsWith('cn')) {
42
+ /* c8 ignore next 7 */
43
+ // eslint-disable-next-line no-console
44
+ console.warn(
45
+ name +
46
+ ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
47
+ 'https://www.w3ctech.com/topic/2226'
48
+ )
49
+ }
50
+ }
51
+ let transformer = initializer(...args)
52
+ transformer.postcssPlugin = name
53
+ transformer.postcssVersion = new Processor().version
54
+ return transformer
55
+ }
56
+
57
+ let cache
58
+ Object.defineProperty(creator, 'postcss', {
59
+ get() {
60
+ if (!cache) cache = creator()
61
+ return cache
62
+ }
63
+ })
64
+
65
+ creator.process = function (css, processOpts, pluginOpts) {
66
+ return postcss([creator(pluginOpts)]).process(css, processOpts)
67
+ }
68
+
69
+ return creator
70
+ }
71
+
72
+ postcss.stringify = stringify
73
+ postcss.parse = parse
74
+ postcss.fromJSON = fromJSON
75
+ postcss.list = list
76
+
77
+ postcss.comment = defaults => new Comment(defaults)
78
+ postcss.atRule = defaults => new AtRule(defaults)
79
+ postcss.decl = defaults => new Declaration(defaults)
80
+ postcss.rule = defaults => new Rule(defaults)
81
+ postcss.root = defaults => new Root(defaults)
82
+ postcss.document = defaults => new Document(defaults)
83
+
84
+ postcss.CssSyntaxError = CssSyntaxError
85
+ postcss.Declaration = Declaration
86
+ postcss.Container = Container
87
+ postcss.Processor = Processor
88
+ postcss.Document = Document
89
+ postcss.Comment = Comment
90
+ postcss.Warning = Warning
91
+ postcss.AtRule = AtRule
92
+ postcss.Result = Result
93
+ postcss.Input = Input
94
+ postcss.Rule = Rule
95
+ postcss.Root = Root
96
+ postcss.Node = Node
97
+
98
+ LazyResult.registerPostcss(postcss)
99
+
100
+ module.exports = postcss
101
+ postcss.default = postcss
@@ -0,0 +1,81 @@
1
+ import { SourceMapConsumer } from 'source-map-js'
2
+
3
+ import { ProcessOptions } from './postcss.js'
4
+
5
+ declare namespace PreviousMap {
6
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
7
+ export { PreviousMap_ as default }
8
+ }
9
+
10
+ /**
11
+ * Source map information from input CSS.
12
+ * For example, source map after Sass compiler.
13
+ *
14
+ * This class will automatically find source map in input CSS or in file system
15
+ * near input file (according `from` option).
16
+ *
17
+ * ```js
18
+ * const root = parse(css, { from: 'a.sass.css' })
19
+ * root.input.map //=> PreviousMap
20
+ * ```
21
+ */
22
+ declare class PreviousMap_ {
23
+ /**
24
+ * `sourceMappingURL` content.
25
+ */
26
+ annotation?: string
27
+
28
+ /**
29
+ * The CSS source identifier. Contains `Input#file` if the user
30
+ * set the `from` option, or `Input#id` if they did not.
31
+ */
32
+ file?: string
33
+
34
+ /**
35
+ * Was source map inlined by data-uri to input CSS.
36
+ */
37
+ inline: boolean
38
+
39
+ /**
40
+ * Path to source map file.
41
+ */
42
+ mapFile?: string
43
+
44
+ /**
45
+ * The directory with source map file, if source map is in separated file.
46
+ */
47
+ root?: string
48
+
49
+ /**
50
+ * Source map file content.
51
+ */
52
+ text?: string
53
+
54
+ /**
55
+ * @param css Input CSS source.
56
+ * @param opts Process options.
57
+ */
58
+ constructor(css: string, opts?: ProcessOptions)
59
+
60
+ /**
61
+ * Create a instance of `SourceMapGenerator` class
62
+ * from the `source-map` library to work with source map information.
63
+ *
64
+ * It is lazy method, so it will create object only on first call
65
+ * and then it will use cache.
66
+ *
67
+ * @return Object with source map information.
68
+ */
69
+ consumer(): SourceMapConsumer
70
+
71
+ /**
72
+ * Does source map contains `sourcesContent` with input source text.
73
+ *
74
+ * @return Is `sourcesContent` present.
75
+ */
76
+ withContent(): boolean
77
+ }
78
+
79
+ declare class PreviousMap extends PreviousMap_ {}
80
+
81
+ export = PreviousMap