plugin-build-guide-block 1.1.5 → 1.1.7

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 (123) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/index.js +2 -2
  4. package/dist/client-v2/73.6b8b2eda7d969c69.js +10 -0
  5. package/dist/client-v2/index.js +10 -0
  6. package/dist/externalVersion.js +9 -8
  7. package/dist/node_modules/sanitize-html/index.js +2 -2
  8. package/dist/node_modules/sanitize-html/package.json +1 -1
  9. package/dist/server/actions/build.js +687 -85
  10. package/dist/server/collections/ai-build-guide-spaces.js +20 -0
  11. package/dist/server/plugin.js +21 -19
  12. package/dist/server/tools/search-guides.js +41 -30
  13. package/package.json +7 -3
  14. package/src/client/components/BuildButton.tsx +20 -9
  15. package/src/client-v2/plugin.tsx +24 -0
  16. package/src/server/actions/build.ts +774 -88
  17. package/src/server/collections/ai-build-guide-spaces.ts +77 -57
  18. package/src/server/plugin.ts +170 -163
  19. package/src/server/tools/search-guides.ts +113 -95
  20. package/dist/client/UserGuideBlock.d.ts +0 -2
  21. package/dist/client/UserGuideBlockInitializer.d.ts +0 -2
  22. package/dist/client/UserGuideBlockProvider.d.ts +0 -2
  23. package/dist/client/UserGuideManager.d.ts +0 -2
  24. package/dist/client/components/BuildButton.d.ts +0 -2
  25. package/dist/client/components/LLMServiceSelect.d.ts +0 -2
  26. package/dist/client/components/ModelSelect.d.ts +0 -2
  27. package/dist/client/components/SpaceSelect.d.ts +0 -2
  28. package/dist/client/components/StatusTag.d.ts +0 -2
  29. package/dist/client/locale.d.ts +0 -3
  30. package/dist/client/models/UserGuideBlockModel.d.ts +0 -9
  31. package/dist/client/models/index.d.ts +0 -9
  32. package/dist/client/plugin.d.ts +0 -5
  33. package/dist/client/schemaSettings.d.ts +0 -2
  34. package/dist/client/schemas/spacesSchema.d.ts +0 -437
  35. package/dist/index.d.ts +0 -2
  36. package/dist/locale/namespace.d.ts +0 -6
  37. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.cjs +0 -34
  38. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.browser.js +0 -34
  39. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.cjs +0 -35
  40. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.d.ts +0 -56
  41. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.js +0 -35
  42. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/index.native.js +0 -26
  43. package/dist/node_modules/sanitize-html/node_modules/nanoid/async/package.json +0 -12
  44. package/dist/node_modules/sanitize-html/node_modules/nanoid/bin/nanoid.cjs +0 -55
  45. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.cjs +0 -34
  46. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.browser.js +0 -34
  47. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.cjs +0 -45
  48. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.cts +0 -91
  49. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.d.ts +0 -91
  50. package/dist/node_modules/sanitize-html/node_modules/nanoid/index.js +0 -45
  51. package/dist/node_modules/sanitize-html/node_modules/nanoid/nanoid.js +0 -1
  52. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.cjs +0 -21
  53. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.d.ts +0 -33
  54. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/index.js +0 -21
  55. package/dist/node_modules/sanitize-html/node_modules/nanoid/non-secure/package.json +0 -6
  56. package/dist/node_modules/sanitize-html/node_modules/nanoid/package.json +0 -88
  57. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.cjs +0 -3
  58. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/index.js +0 -3
  59. package/dist/node_modules/sanitize-html/node_modules/nanoid/url-alphabet/package.json +0 -6
  60. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.d.ts +0 -115
  61. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/at-rule.js +0 -25
  62. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.d.ts +0 -67
  63. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/comment.js +0 -13
  64. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.d.ts +0 -452
  65. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/container.js +0 -439
  66. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.d.ts +0 -248
  67. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/css-syntax-error.js +0 -100
  68. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.d.ts +0 -148
  69. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/declaration.js +0 -24
  70. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.d.ts +0 -68
  71. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/document.js +0 -33
  72. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  73. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/fromJSON.js +0 -54
  74. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.d.ts +0 -194
  75. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/input.js +0 -248
  76. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.d.ts +0 -190
  77. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/lazy-result.js +0 -550
  78. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.d.ts +0 -57
  79. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/list.js +0 -58
  80. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/map-generator.js +0 -359
  81. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.d.ts +0 -46
  82. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/no-work-result.js +0 -135
  83. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.d.ts +0 -536
  84. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/node.js +0 -381
  85. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.d.ts +0 -9
  86. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parse.js +0 -42
  87. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/parser.js +0 -610
  88. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.mts +0 -72
  89. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.d.ts +0 -441
  90. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/postcss.js +0 -101
  91. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.d.ts +0 -81
  92. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/previous-map.js +0 -142
  93. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.d.ts +0 -115
  94. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/processor.js +0 -67
  95. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.d.ts +0 -206
  96. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/result.js +0 -42
  97. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.d.ts +0 -86
  98. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/root.js +0 -61
  99. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.d.ts +0 -113
  100. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/rule.js +0 -27
  101. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.d.ts +0 -46
  102. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringifier.js +0 -353
  103. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.d.ts +0 -9
  104. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/stringify.js +0 -11
  105. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/symbols.js +0 -5
  106. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/terminal-highlight.js +0 -70
  107. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/tokenize.js +0 -266
  108. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warn-once.js +0 -13
  109. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.d.ts +0 -147
  110. package/dist/node_modules/sanitize-html/node_modules/postcss/lib/warning.js +0 -37
  111. package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid +0 -15
  112. package/dist/node_modules/sanitize-html/node_modules/postcss/node_modules/.bin/nanoid.cmd +0 -7
  113. package/dist/node_modules/sanitize-html/node_modules/postcss/package.json +0 -88
  114. package/dist/server/actions/build.d.ts +0 -2
  115. package/dist/server/actions/getHtml.d.ts +0 -2
  116. package/dist/server/actions/getMarkdown.d.ts +0 -2
  117. package/dist/server/collections/ai-build-guide-pages.d.ts +0 -2
  118. package/dist/server/collections/ai-build-guide-spaces.d.ts +0 -2
  119. package/dist/server/index.d.ts +0 -2
  120. package/dist/server/plugin.d.ts +0 -16
  121. package/dist/server/tools/index.d.ts +0 -1
  122. package/dist/server/tools/search-guides.d.ts +0 -28
  123. /package/{dist/client/index.d.ts → src/client-v2/index.tsx} +0 -0
@@ -1,115 +0,0 @@
1
- import Container, { ContainerProps } from './container.js'
2
-
3
- declare namespace AtRule {
4
- export interface AtRuleRaws extends Record<string, unknown> {
5
- /**
6
- * The space symbols after the last child of the node to the end of the node.
7
- */
8
- after?: string
9
-
10
- /**
11
- * The space between the at-rule name and its parameters.
12
- */
13
- afterName?: string
14
-
15
- /**
16
- * The space symbols before the node. It also stores `*`
17
- * and `_` symbols before the declaration (IE hack).
18
- */
19
- before?: string
20
-
21
- /**
22
- * The symbols between the last parameter and `{` for rules.
23
- */
24
- between?: string
25
-
26
- /**
27
- * The rule’s selector with comments.
28
- */
29
- params?: {
30
- raw: string
31
- value: string
32
- }
33
-
34
- /**
35
- * Contains `true` if the last child has an (optional) semicolon.
36
- */
37
- semicolon?: boolean
38
- }
39
-
40
- export interface AtRuleProps extends ContainerProps {
41
- /** Name of the at-rule. */
42
- name: string
43
- /** Parameters following the name of the at-rule. */
44
- params?: number | string
45
- /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
46
- raws?: AtRuleRaws
47
- }
48
-
49
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
50
- export { AtRule_ as default }
51
- }
52
-
53
- /**
54
- * Represents an at-rule.
55
- *
56
- * ```js
57
- * Once (root, { AtRule }) {
58
- * let media = new AtRule({ name: 'media', params: 'print' })
59
- * media.append(…)
60
- * root.append(media)
61
- * }
62
- * ```
63
- *
64
- * If it’s followed in the CSS by a `{}` block, this node will have
65
- * a nodes property representing its children.
66
- *
67
- * ```js
68
- * const root = postcss.parse('@charset "UTF-8"; @media print {}')
69
- *
70
- * const charset = root.first
71
- * charset.type //=> 'atrule'
72
- * charset.nodes //=> undefined
73
- *
74
- * const media = root.last
75
- * media.nodes //=> []
76
- * ```
77
- */
78
- declare class AtRule_ extends Container {
79
- /**
80
- * The at-rule’s name immediately follows the `@`.
81
- *
82
- * ```js
83
- * const root = postcss.parse('@media print {}')
84
- * media.name //=> 'media'
85
- * const media = root.first
86
- * ```
87
- */
88
- name: string
89
- /**
90
- * The at-rule’s parameters, the values that follow the at-rule’s name
91
- * but precede any `{}` block.
92
- *
93
- * ```js
94
- * const root = postcss.parse('@media print, screen {}')
95
- * const media = root.first
96
- * media.params //=> 'print, screen'
97
- * ```
98
- */
99
- params: string
100
- parent: Container | undefined
101
-
102
- raws: AtRule.AtRuleRaws
103
-
104
- type: 'atrule'
105
-
106
- constructor(defaults?: AtRule.AtRuleProps)
107
- assign(overrides: AtRule.AtRuleProps | object): this
108
- clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
109
- cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
110
- cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
111
- }
112
-
113
- declare class AtRule extends AtRule_ {}
114
-
115
- export = AtRule
@@ -1,25 +0,0 @@
1
- 'use strict'
2
-
3
- let Container = require('./container')
4
-
5
- class AtRule extends Container {
6
- constructor(defaults) {
7
- super(defaults)
8
- this.type = 'atrule'
9
- }
10
-
11
- append(...children) {
12
- if (!this.proxyOf.nodes) this.nodes = []
13
- return super.append(...children)
14
- }
15
-
16
- prepend(...children) {
17
- if (!this.proxyOf.nodes) this.nodes = []
18
- return super.prepend(...children)
19
- }
20
- }
21
-
22
- module.exports = AtRule
23
- AtRule.default = AtRule
24
-
25
- Container.registerAtRule(AtRule)
@@ -1,67 +0,0 @@
1
- import Container from './container.js'
2
- import Node, { NodeProps } from './node.js'
3
-
4
- declare namespace Comment {
5
- export interface CommentRaws extends Record<string, unknown> {
6
- /**
7
- * The space symbols before the node.
8
- */
9
- before?: string
10
-
11
- /**
12
- * The space symbols between `/*` and the comment’s text.
13
- */
14
- left?: string
15
-
16
- /**
17
- * The space symbols between the comment’s text.
18
- */
19
- right?: string
20
- }
21
-
22
- export interface CommentProps extends NodeProps {
23
- /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
24
- raws?: CommentRaws
25
- /** Content of the comment. */
26
- text: string
27
- }
28
-
29
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
30
- export { Comment_ as default }
31
- }
32
-
33
- /**
34
- * It represents a class that handles
35
- * [CSS comments](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
36
- *
37
- * ```js
38
- * Once (root, { Comment }) {
39
- * const note = new Comment({ text: 'Note: …' })
40
- * root.append(note)
41
- * }
42
- * ```
43
- *
44
- * Remember that CSS comments inside selectors, at-rule parameters,
45
- * or declaration values will be stored in the `raws` properties
46
- * explained above.
47
- */
48
- declare class Comment_ extends Node {
49
- parent: Container | undefined
50
- raws: Comment.CommentRaws
51
- /**
52
- * The comment's text.
53
- */
54
- text: string
55
-
56
- type: 'comment'
57
-
58
- constructor(defaults?: Comment.CommentProps)
59
- assign(overrides: Comment.CommentProps | object): this
60
- clone(overrides?: Partial<Comment.CommentProps>): Comment
61
- cloneAfter(overrides?: Partial<Comment.CommentProps>): Comment
62
- cloneBefore(overrides?: Partial<Comment.CommentProps>): Comment
63
- }
64
-
65
- declare class Comment extends Comment_ {}
66
-
67
- export = Comment
@@ -1,13 +0,0 @@
1
- 'use strict'
2
-
3
- let Node = require('./node')
4
-
5
- class Comment extends Node {
6
- constructor(defaults) {
7
- super(defaults)
8
- this.type = 'comment'
9
- }
10
- }
11
-
12
- module.exports = Comment
13
- Comment.default = Comment
@@ -1,452 +0,0 @@
1
- import AtRule from './at-rule.js'
2
- import Comment from './comment.js'
3
- import Declaration from './declaration.js'
4
- import Node, { ChildNode, ChildProps, NodeProps } from './node.js'
5
- import Rule from './rule.js'
6
-
7
- declare namespace Container {
8
- export interface ValueOptions {
9
- /**
10
- * String that’s used to narrow down values and speed up the regexp search.
11
- */
12
- fast?: string
13
-
14
- /**
15
- * An array of property names.
16
- */
17
- props?: string[]
18
- }
19
-
20
- export interface ContainerProps extends NodeProps {
21
- nodes?: (ChildNode | ChildProps)[]
22
- }
23
-
24
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
25
- export { Container_ as default }
26
- }
27
-
28
- /**
29
- * The `Root`, `AtRule`, and `Rule` container nodes
30
- * inherit some common methods to help work with their children.
31
- *
32
- * Note that all containers can store any content. If you write a rule inside
33
- * a rule, PostCSS will parse it.
34
- */
35
- declare abstract class Container_<Child extends Node = ChildNode> extends Node {
36
- /**
37
- * An array containing the container’s children.
38
- *
39
- * ```js
40
- * const root = postcss.parse('a { color: black }')
41
- * root.nodes.length //=> 1
42
- * root.nodes[0].selector //=> 'a'
43
- * root.nodes[0].nodes[0].prop //=> 'color'
44
- * ```
45
- */
46
- nodes: Child[]
47
-
48
- /**
49
- * Inserts new nodes to the end of the container.
50
- *
51
- * ```js
52
- * const decl1 = new Declaration({ prop: 'color', value: 'black' })
53
- * const decl2 = new Declaration({ prop: 'background-color', value: 'white' })
54
- * rule.append(decl1, decl2)
55
- *
56
- * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
57
- * root.append({ selector: 'a' }) // rule
58
- * rule.append({ prop: 'color', value: 'black' }) // declaration
59
- * rule.append({ text: 'Comment' }) // comment
60
- *
61
- * root.append('a {}')
62
- * root.first.append('color: black; z-index: 1')
63
- * ```
64
- *
65
- * @param nodes New nodes.
66
- * @return This node for methods chain.
67
- */
68
- append(
69
- ...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
70
- ): this
71
-
72
- assign(overrides: Container.ContainerProps | object): this
73
- clone(overrides?: Partial<Container.ContainerProps>): Container<Child>
74
- cloneAfter(overrides?: Partial<Container.ContainerProps>): Container<Child>
75
- cloneBefore(overrides?: Partial<Container.ContainerProps>): Container<Child>
76
-
77
- /**
78
- * Iterates through the container’s immediate children,
79
- * calling `callback` for each child.
80
- *
81
- * Returning `false` in the callback will break iteration.
82
- *
83
- * This method only iterates through the container’s immediate children.
84
- * If you need to recursively iterate through all the container’s descendant
85
- * nodes, use `Container#walk`.
86
- *
87
- * Unlike the for `{}`-cycle or `Array#forEach` this iterator is safe
88
- * if you are mutating the array of child nodes during iteration.
89
- * PostCSS will adjust the current index to match the mutations.
90
- *
91
- * ```js
92
- * const root = postcss.parse('a { color: black; z-index: 1 }')
93
- * const rule = root.first
94
- *
95
- * for (const decl of rule.nodes) {
96
- * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
97
- * // Cycle will be infinite, because cloneBefore moves the current node
98
- * // to the next index
99
- * }
100
- *
101
- * rule.each(decl => {
102
- * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
103
- * // Will be executed only for color and z-index
104
- * })
105
- * ```
106
- *
107
- * @param callback Iterator receives each node and index.
108
- * @return Returns `false` if iteration was broke.
109
- */
110
- each(
111
- callback: (node: Child, index: number) => false | void
112
- ): false | undefined
113
-
114
- /**
115
- * Returns `true` if callback returns `true`
116
- * for all of the container’s children.
117
- *
118
- * ```js
119
- * const noPrefixes = rule.every(i => i.prop[0] !== '-')
120
- * ```
121
- *
122
- * @param condition Iterator returns true or false.
123
- * @return Is every child pass condition.
124
- */
125
- every(
126
- condition: (node: Child, index: number, nodes: Child[]) => boolean
127
- ): boolean
128
- /**
129
- * Returns a `child`’s index within the `Container#nodes` array.
130
- *
131
- * ```js
132
- * rule.index( rule.nodes[2] ) //=> 2
133
- * ```
134
- *
135
- * @param child Child of the current container.
136
- * @return Child index.
137
- */
138
- index(child: Child | number): number
139
-
140
- /**
141
- * Insert new node after old node within the container.
142
- *
143
- * @param oldNode Child or child’s index.
144
- * @param newNode New node.
145
- * @return This node for methods chain.
146
- */
147
- insertAfter(
148
- oldNode: Child | number,
149
- newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
150
- ): this
151
- /**
152
- * Insert new node before old node within the container.
153
- *
154
- * ```js
155
- * rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
156
- * ```
157
- *
158
- * @param oldNode Child or child’s index.
159
- * @param newNode New node.
160
- * @return This node for methods chain.
161
- */
162
- insertBefore(
163
- oldNode: Child | number,
164
- newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
165
- ): this
166
-
167
- /**
168
- * Traverses the container’s descendant nodes, calling callback
169
- * for each comment node.
170
- *
171
- * Like `Container#each`, this method is safe
172
- * to use if you are mutating arrays during iteration.
173
- *
174
- * ```js
175
- * root.walkComments(comment => {
176
- * comment.remove()
177
- * })
178
- * ```
179
- *
180
- * @param callback Iterator receives each node and index.
181
- * @return Returns `false` if iteration was broke.
182
- */
183
-
184
- /**
185
- * Inserts new nodes to the start of the container.
186
- *
187
- * ```js
188
- * const decl1 = new Declaration({ prop: 'color', value: 'black' })
189
- * const decl2 = new Declaration({ prop: 'background-color', value: 'white' })
190
- * rule.prepend(decl1, decl2)
191
- *
192
- * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
193
- * root.append({ selector: 'a' }) // rule
194
- * rule.append({ prop: 'color', value: 'black' }) // declaration
195
- * rule.append({ text: 'Comment' }) // comment
196
- *
197
- * root.append('a {}')
198
- * root.first.append('color: black; z-index: 1')
199
- * ```
200
- *
201
- * @param nodes New nodes.
202
- * @return This node for methods chain.
203
- */
204
- prepend(
205
- ...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
206
- ): this
207
- /**
208
- * Add child to the end of the node.
209
- *
210
- * ```js
211
- * rule.push(new Declaration({ prop: 'color', value: 'black' }))
212
- * ```
213
- *
214
- * @param child New node.
215
- * @return This node for methods chain.
216
- */
217
- push(child: Child): this
218
-
219
- /**
220
- * Removes all children from the container
221
- * and cleans their parent properties.
222
- *
223
- * ```js
224
- * rule.removeAll()
225
- * rule.nodes.length //=> 0
226
- * ```
227
- *
228
- * @return This node for methods chain.
229
- */
230
- removeAll(): this
231
-
232
- /**
233
- * Removes node from the container and cleans the parent properties
234
- * from the node and its children.
235
- *
236
- * ```js
237
- * rule.nodes.length //=> 5
238
- * rule.removeChild(decl)
239
- * rule.nodes.length //=> 4
240
- * decl.parent //=> undefined
241
- * ```
242
- *
243
- * @param child Child or child’s index.
244
- * @return This node for methods chain.
245
- */
246
- removeChild(child: Child | number): this
247
-
248
- replaceValues(
249
- pattern: RegExp | string,
250
- replaced: { (substring: string, ...args: any[]): string } | string
251
- ): this
252
-
253
- /**
254
- * Passes all declaration values within the container that match pattern
255
- * through callback, replacing those values with the returned result
256
- * of callback.
257
- *
258
- * This method is useful if you are using a custom unit or function
259
- * and need to iterate through all values.
260
- *
261
- * ```js
262
- * root.replaceValues(/\d+rem/, { fast: 'rem' }, string => {
263
- * return 15 * parseInt(string) + 'px'
264
- * })
265
- * ```
266
- *
267
- * @param pattern Replace pattern.
268
- * @param {object} opts Options to speed up the search.
269
- * @param callback String to replace pattern or callback
270
- * that returns a new value. The callback
271
- * will receive the same arguments
272
- * as those passed to a function parameter
273
- * of `String#replace`.
274
- * @return This node for methods chain.
275
- */
276
- replaceValues(
277
- pattern: RegExp | string,
278
- options: Container.ValueOptions,
279
- replaced: { (substring: string, ...args: any[]): string } | string
280
- ): this
281
-
282
- /**
283
- * Returns `true` if callback returns `true` for (at least) one
284
- * of the container’s children.
285
- *
286
- * ```js
287
- * const hasPrefix = rule.some(i => i.prop[0] === '-')
288
- * ```
289
- *
290
- * @param condition Iterator returns true or false.
291
- * @return Is some child pass condition.
292
- */
293
- some(
294
- condition: (node: Child, index: number, nodes: Child[]) => boolean
295
- ): boolean
296
-
297
- /**
298
- * Traverses the container’s descendant nodes, calling callback
299
- * for each node.
300
- *
301
- * Like container.each(), this method is safe to use
302
- * if you are mutating arrays during iteration.
303
- *
304
- * If you only need to iterate through the container’s immediate children,
305
- * use `Container#each`.
306
- *
307
- * ```js
308
- * root.walk(node => {
309
- * // Traverses all descendant nodes.
310
- * })
311
- * ```
312
- *
313
- * @param callback Iterator receives each node and index.
314
- * @return Returns `false` if iteration was broke.
315
- */
316
- walk(
317
- callback: (node: ChildNode, index: number) => false | void
318
- ): false | undefined
319
-
320
- /**
321
- * Traverses the container’s descendant nodes, calling callback
322
- * for each at-rule node.
323
- *
324
- * If you pass a filter, iteration will only happen over at-rules
325
- * that have matching names.
326
- *
327
- * Like `Container#each`, this method is safe
328
- * to use if you are mutating arrays during iteration.
329
- *
330
- * ```js
331
- * root.walkAtRules(rule => {
332
- * if (isOld(rule.name)) rule.remove()
333
- * })
334
- *
335
- * let first = false
336
- * root.walkAtRules('charset', rule => {
337
- * if (!first) {
338
- * first = true
339
- * } else {
340
- * rule.remove()
341
- * }
342
- * })
343
- * ```
344
- *
345
- * @param name String or regular expression to filter at-rules by name.
346
- * @param callback Iterator receives each node and index.
347
- * @return Returns `false` if iteration was broke.
348
- */
349
- walkAtRules(
350
- nameFilter: RegExp | string,
351
- callback: (atRule: AtRule, index: number) => false | void
352
- ): false | undefined
353
-
354
- walkAtRules(
355
- callback: (atRule: AtRule, index: number) => false | void
356
- ): false | undefined
357
- walkComments(
358
- callback: (comment: Comment, indexed: number) => false | void
359
- ): false | undefined
360
-
361
- walkComments(
362
- callback: (comment: Comment, indexed: number) => false | void
363
- ): false | undefined
364
-
365
- /**
366
- * Traverses the container’s descendant nodes, calling callback
367
- * for each declaration node.
368
- *
369
- * If you pass a filter, iteration will only happen over declarations
370
- * with matching properties.
371
- *
372
- * ```js
373
- * root.walkDecls(decl => {
374
- * checkPropertySupport(decl.prop)
375
- * })
376
- *
377
- * root.walkDecls('border-radius', decl => {
378
- * decl.remove()
379
- * })
380
- *
381
- * root.walkDecls(/^background/, decl => {
382
- * decl.value = takeFirstColorFromGradient(decl.value)
383
- * })
384
- * ```
385
- *
386
- * Like `Container#each`, this method is safe
387
- * to use if you are mutating arrays during iteration.
388
- *
389
- * @param prop String or regular expression to filter declarations
390
- * by property name.
391
- * @param callback Iterator receives each node and index.
392
- * @return Returns `false` if iteration was broke.
393
- */
394
- walkDecls(
395
- propFilter: RegExp | string,
396
- callback: (decl: Declaration, index: number) => false | void
397
- ): false | undefined
398
-
399
- walkDecls(
400
- callback: (decl: Declaration, index: number) => false | void
401
- ): false | undefined
402
-
403
- /**
404
- * Traverses the container’s descendant nodes, calling callback
405
- * for each rule node.
406
- *
407
- * If you pass a filter, iteration will only happen over rules
408
- * with matching selectors.
409
- *
410
- * Like `Container#each`, this method is safe
411
- * to use if you are mutating arrays during iteration.
412
- *
413
- * ```js
414
- * const selectors = []
415
- * root.walkRules(rule => {
416
- * selectors.push(rule.selector)
417
- * })
418
- * console.log(`Your CSS uses ${ selectors.length } selectors`)
419
- * ```
420
- *
421
- * @param selector String or regular expression to filter rules by selector.
422
- * @param callback Iterator receives each node and index.
423
- * @return Returns `false` if iteration was broke.
424
- */
425
- walkRules(
426
- selectorFilter: RegExp | string,
427
- callback: (rule: Rule, index: number) => false | void
428
- ): false | undefined
429
- walkRules(
430
- callback: (rule: Rule, index: number) => false | void
431
- ): false | undefined
432
- /**
433
- * The container’s first child.
434
- *
435
- * ```js
436
- * rule.first === rules.nodes[0]
437
- * ```
438
- */
439
- get first(): Child | undefined
440
- /**
441
- * The container’s last child.
442
- *
443
- * ```js
444
- * rule.last === rule.nodes[rule.nodes.length - 1]
445
- * ```
446
- */
447
- get last(): Child | undefined
448
- }
449
-
450
- declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}
451
-
452
- export = Container