@umijs/bundler-webpack 4.0.0-beta.6 → 4.0.0-rc.1

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 (104) hide show
  1. package/compiled/autoprefixer/browserslist/index.d.ts +7 -7
  2. package/compiled/autoprefixer/index.js +3 -3
  3. package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
  4. package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
  5. package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
  6. package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
  7. package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
  8. package/compiled/autoprefixer/postcss/lib/node.d.ts +36 -2
  9. package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
  10. package/compiled/autoprefixer/postcss/lib/processor.d.ts +5 -4
  11. package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
  12. package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
  13. package/compiled/babel-loader/index.js +2 -2
  14. package/compiled/fork-ts-checker-webpack-plugin/LICENSE +21 -0
  15. package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
  16. package/compiled/fork-ts-checker-webpack-plugin/index.js +49 -0
  17. package/compiled/fork-ts-checker-webpack-plugin/package.json +1 -0
  18. package/compiled/mini-css-extract-plugin/index.js +6769 -6731
  19. package/compiled/mini-css-extract-plugin/loader.js +1 -1
  20. package/compiled/mini-css-extract-plugin/utils.js +11 -6
  21. package/compiled/postcss-loader/index.js +1 -1
  22. package/compiled/react-refresh/index.js +3 -3
  23. package/compiled/sass-loader/index.js +1 -1
  24. package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
  25. package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
  26. package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
  27. package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
  28. package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
  29. package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
  30. package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
  31. package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
  32. package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
  33. package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
  34. package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
  35. package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
  36. package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
  37. package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
  38. package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
  39. package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
  40. package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
  41. package/compiled/schema-utils/declarations/validate.d.ts +4 -4
  42. package/compiled/schema-utils/index.js +8 -2
  43. package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
  44. package/compiled/style-loader/index.js +1 -1
  45. package/compiled/terser/index.js +1 -1
  46. package/compiled/terser-webpack-plugin/index.js +328 -451
  47. package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
  48. package/compiled/terser-webpack-plugin/minify.js +6 -1
  49. package/compiled/terser-webpack-plugin/types/index.d.ts +3 -3
  50. package/compiled/terser-webpack-plugin/types/utils.d.ts +9 -12
  51. package/compiled/terser-webpack-plugin/utils.js +113 -17
  52. package/compiled/webpack/index.js +4915 -4485
  53. package/compiled/webpack-dev-middleware/index.js +11 -5
  54. package/compiled/webpack-manifest-plugin/LICENSE +21 -0
  55. package/compiled/webpack-manifest-plugin/index.js +1 -0
  56. package/compiled/webpack-manifest-plugin/package.json +1 -0
  57. package/compiled/webpack-sources/index.js +1 -1
  58. package/dist/build.d.ts +3 -2
  59. package/dist/build.js +1 -0
  60. package/dist/cli.js +4 -7
  61. package/dist/config/assetRules.js +6 -2
  62. package/dist/config/config.d.ts +7 -2
  63. package/dist/config/config.js +46 -5
  64. package/dist/config/cssRules.js +1 -1
  65. package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
  66. package/dist/config/forkTSCheckerPlugin.js +34 -0
  67. package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
  68. package/dist/config/harmonyLinkingErrorPlugin.js +42 -0
  69. package/dist/config/javaScriptRules.d.ts +1 -0
  70. package/dist/config/javaScriptRules.js +34 -20
  71. package/dist/config/manifestPlugin.d.ts +11 -0
  72. package/dist/config/manifestPlugin.js +25 -0
  73. package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
  74. package/dist/config/miniCSSExtractPlugin.js +2 -3
  75. package/dist/config/svgRules.d.ts +1 -0
  76. package/dist/config/svgRules.js +12 -11
  77. package/dist/dev.d.ts +3 -2
  78. package/dist/dev.js +39 -11
  79. package/dist/esbuildHandler/autoCssModules.d.ts +2 -0
  80. package/dist/esbuildHandler/autoCssModules.js +23 -0
  81. package/dist/loader/esbuild.d.ts +5 -0
  82. package/dist/loader/esbuild.js +53 -0
  83. package/dist/loader/svgr.d.ts +4 -0
  84. package/dist/loader/svgr.js +67 -0
  85. package/dist/loader/swc.d.ts +4 -0
  86. package/dist/loader/swc.js +83 -0
  87. package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
  88. package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
  89. package/dist/schema.js +11 -5
  90. package/dist/server/server.js +20 -1
  91. package/dist/server/ws.d.ts +1 -1
  92. package/dist/server/ws.js +1 -1
  93. package/dist/swcPlugins/autoCSSModules.js +6 -4
  94. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  95. package/dist/swcPlugins/lockCoreJS.js +23 -0
  96. package/dist/types.d.ts +18 -0
  97. package/package.json +52 -47
  98. package/compiled/@svgr/webpack/.svgo.yml +0 -75
  99. package/compiled/@svgr/webpack/LICENSE +0 -7
  100. package/compiled/@svgr/webpack/index.js +0 -343
  101. package/compiled/@svgr/webpack/package.json +0 -1
  102. package/compiled/swc-loader/LICENSE +0 -25
  103. package/compiled/swc-loader/index.js +0 -1
  104. package/compiled/swc-loader/package.json +0 -1
@@ -181,10 +181,10 @@ export default abstract class Container<
181
181
  */
182
182
  walkRules(
183
183
  selectorFilter: string | RegExp,
184
- callback: (atRule: Rule, index: number) => false | void
184
+ callback: (rule: Rule, index: number) => false | void
185
185
  ): false | undefined
186
186
  walkRules(
187
- callback: (atRule: Rule, index: number) => false | void
187
+ callback: (rule: Rule, index: number) => false | void
188
188
  ): false | undefined
189
189
 
190
190
  /**
@@ -1,5 +1,20 @@
1
1
  import { FilePosition } from './input'
2
2
 
3
+ /**
4
+ * A position that is part of a range.
5
+ */
6
+ export interface RangePosition {
7
+ /**
8
+ * The line number in the input.
9
+ */
10
+ line: number
11
+
12
+ /**
13
+ * The column number in the input.
14
+ */
15
+ column: number
16
+ }
17
+
3
18
  /**
4
19
  * The CSS parser throws this error for broken CSS.
5
20
  *
@@ -31,17 +46,21 @@ import { FilePosition } from './input'
31
46
  */
32
47
  export default class CssSyntaxError {
33
48
  /**
34
- * @param message Error message.
35
- * @param line Source line of the error.
36
- * @param column Source column of the error.
37
- * @param source Source code of the broken file.
38
- * @param file Absolute path to the broken file.
39
- * @param plugin PostCSS plugin name, if error came from plugin.
49
+ * Instantiates a CSS syntax error. Can be instantiated for a single position
50
+ * or for a range.
51
+ * @param message Error message.
52
+ * @param lineOrStartPos If for a single position, the line number, or if for
53
+ * a range, the inclusive start position of the error.
54
+ * @param columnOrEndPos If for a single position, the column number, or if for
55
+ * a range, the exclusive end position of the error.
56
+ * @param source Source code of the broken file.
57
+ * @param file Absolute path to the broken file.
58
+ * @param plugin PostCSS plugin name, if error came from plugin.
40
59
  */
41
60
  constructor(
42
61
  message: string,
43
- line?: number,
44
- column?: number,
62
+ lineOrStartPos?: number | RangePosition,
63
+ columnOrEndPos?: number | RangePosition,
45
64
  source?: string,
46
65
  file?: string,
47
66
  plugin?: string
@@ -121,6 +140,34 @@ export default class CssSyntaxError {
121
140
  */
122
141
  column?: number
123
142
 
143
+ /**
144
+ * Source line of the error's end, exclusive. Provided if the error pertains
145
+ * to a range.
146
+ *
147
+ * ```js
148
+ * error.endLine //=> 3
149
+ * error.input.endLine //=> 4
150
+ * ```
151
+ *
152
+ * PostCSS will use the input source map to detect the original location.
153
+ * If you need the position in the PostCSS input, use `error.input.endLine`.
154
+ */
155
+ endLine?: number
156
+
157
+ /**
158
+ * Source column of the error's end, exclusive. Provided if the error pertains
159
+ * to a range.
160
+ *
161
+ * ```js
162
+ * error.endColumn //=> 1
163
+ * error.input.endColumn //=> 4
164
+ * ```
165
+ *
166
+ * PostCSS will use the input source map to detect the original location.
167
+ * If you need the position in the PostCSS input, use `error.input.endColumn`.
168
+ */
169
+ endColumn?: number
170
+
124
171
  /**
125
172
  * Source code of the broken file.
126
173
  *
@@ -13,15 +13,25 @@ export interface FilePosition {
13
13
  file?: string
14
14
 
15
15
  /**
16
- * Line in source file.
16
+ * Line of inclusive start position in source file.
17
17
  */
18
18
  line: number
19
19
 
20
20
  /**
21
- * Column in source file.
21
+ * Column of inclusive start position in source file.
22
22
  */
23
23
  column: number
24
24
 
25
+ /**
26
+ * Line of exclusive end position in source file.
27
+ */
28
+ endLine?: number
29
+
30
+ /**
31
+ * Column of exclusive end position in source file.
32
+ */
33
+ endColumn?: number
34
+
25
35
  /**
26
36
  * Source code.
27
37
  */
@@ -108,18 +118,28 @@ export default class Input {
108
118
  /**
109
119
  * Reads the input source map and returns a symbol position
110
120
  * in the input source (e.g., in a Sass file that was compiled
111
- * to CSS before being passed to PostCSS).
121
+ * to CSS before being passed to PostCSS). Optionally takes an
122
+ * end position, exclusive.
112
123
  *
113
124
  * ```js
114
125
  * root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
126
+ * root.source.input.origin(1, 1, 1, 4)
127
+ * //=> { file: 'a.css', line: 3, column: 1, endLine: 3, endColumn: 4 }
115
128
  * ```
116
129
  *
117
- * @param line Line in input CSS.
118
- * @param column Column in input CSS.
130
+ * @param line Line for inclusive start position in input CSS.
131
+ * @param column Column for inclusive start position in input CSS.
132
+ * @param endLine Line for exclusive end position in input CSS.
133
+ * @param endColumn Column for exclusive end position in input CSS.
119
134
  *
120
135
  * @return Position in input source.
121
136
  */
122
- origin(line: number, column: number): FilePosition | false
137
+ origin(
138
+ line: number,
139
+ column: number,
140
+ endLine?: number,
141
+ endColumn?: number
142
+ ): FilePosition | false
123
143
 
124
144
  /**
125
145
  * Converts source offset to line and column.
@@ -89,8 +89,9 @@ export default class LazyResult implements PromiseLike<Result> {
89
89
  *
90
90
  * This property will only work with synchronous plugins.
91
91
  * If the processor contains any asynchronous plugins
92
- * it will throw an error. This is why this method is only
93
- * for debug purpose, you should always use `LazyResult#then`.
92
+ * it will throw an error.
93
+ *
94
+ * PostCSS runners should always use `LazyResult#then`.
94
95
  */
95
96
  get css(): string
96
97
 
@@ -100,8 +101,9 @@ export default class LazyResult implements PromiseLike<Result> {
100
101
  *
101
102
  * This property will only work with synchronous plugins.
102
103
  * If the processor contains any asynchronous plugins
103
- * it will throw an error. This is why this method is only
104
- * for debug purpose, you should always use `LazyResult#then`.
104
+ * it will throw an error.
105
+ *
106
+ * PostCSS runners should always use `LazyResult#then`.
105
107
  */
106
108
  get content(): string
107
109
 
@@ -111,8 +113,9 @@ export default class LazyResult implements PromiseLike<Result> {
111
113
  *
112
114
  * This property will only work with synchronous plugins.
113
115
  * If the processor contains any asynchronous plugins
114
- * it will throw an error. This is why this method is only
115
- * for debug purpose, you should always use `LazyResult#then`.
116
+ * it will throw an error.
117
+ *
118
+ * PostCSS runners should always use `LazyResult#then`.
116
119
  */
117
120
  get map(): SourceMap
118
121
 
@@ -123,8 +126,7 @@ export default class LazyResult implements PromiseLike<Result> {
123
126
  * This property will only work with synchronous plugins. If the processor
124
127
  * contains any asynchronous plugins it will throw an error.
125
128
  *
126
- * This is why this method is only for debug purpose,
127
- * you should always use `LazyResult#then`.
129
+ * PostCSS runners should always use `LazyResult#then`.
128
130
  */
129
131
  get root(): Root
130
132
 
@@ -135,8 +137,7 @@ export default class LazyResult implements PromiseLike<Result> {
135
137
  * This property will only work with synchronous plugins. If the processor
136
138
  * contains any asynchronous plugins it will throw an error.
137
139
  *
138
- * This is why this method is only for debug purpose,
139
- * you should always use `LazyResult#then`.
140
+ * PostCSS runners should always use `LazyResult#then`.
140
141
  */
141
142
  get messages(): Message[]
142
143
 
@@ -0,0 +1,37 @@
1
+ import Result, { Message, ResultOptions } from './result'
2
+ import { SourceMap } from './postcss'
3
+ import Processor from './processor'
4
+ import Warning from './warning'
5
+ import Root from './root'
6
+ import LazyResult from './lazy-result'
7
+
8
+ /**
9
+ * A Promise proxy for the result of PostCSS transformations.
10
+ * This lazy result instance doesn't parse css unless `NoWorkResult#root` or `Result#root`
11
+ * are accessed. See the example below for details.
12
+ * A `NoWork` instance is returned by `Processor#process` ONLY when no plugins defined.
13
+ *
14
+ * ```js
15
+ * const noWorkResult = postcss().process(css) // No plugins are defined.
16
+ * // CSS is not parsed
17
+ * let root = noWorkResult.root // now css is parsed because we accessed the root
18
+ * ```
19
+ */
20
+ export default class NoWorkResult implements LazyResult {
21
+ then: Promise<Result>['then']
22
+ catch: Promise<Result>['catch']
23
+ finally: Promise<Result>['finally']
24
+ constructor(processor: Processor, css: string, opts: ResultOptions)
25
+ get [Symbol.toStringTag](): string
26
+ get processor(): Processor
27
+ get opts(): ResultOptions
28
+ get css(): string
29
+ get content(): string
30
+ get map(): SourceMap
31
+ get root(): Root
32
+ get messages(): Message[]
33
+ warnings(): Warning[]
34
+ toString(): string
35
+ sync(): Result
36
+ async(): Promise<Result>
37
+ }
@@ -38,17 +38,29 @@ export interface Position {
38
38
  line: number
39
39
  }
40
40
 
41
+ export interface Range {
42
+ /**
43
+ * Start position, inclusive.
44
+ */
45
+ start: Position
46
+
47
+ /**
48
+ * End position, exclusive.
49
+ */
50
+ end: Position
51
+ }
52
+
41
53
  export interface Source {
42
54
  /**
43
55
  * The file source of the node.
44
56
  */
45
57
  input: Input
46
58
  /**
47
- * The starting position of the node’s source.
59
+ * The inclusive starting position of the node’s source.
48
60
  */
49
61
  start?: Position
50
62
  /**
51
- * The ending position of the node's source.
63
+ * The inclusive ending position of the node's source.
52
64
  */
53
65
  end?: Position
54
66
  }
@@ -72,6 +84,11 @@ interface NodeErrorOptions {
72
84
  * of error.
73
85
  */
74
86
  index?: number
87
+ /**
88
+ * An ending index inside a node's string that should be highlighted as
89
+ * source of error.
90
+ */
91
+ endIndex?: number
75
92
  }
76
93
 
77
94
  /**
@@ -441,4 +458,21 @@ export default abstract class Node {
441
458
  * @return Symbol position in file.
442
459
  */
443
460
  positionInside(index: number): Position
461
+
462
+ /**
463
+ * Get the position for a word or an index inside the node.
464
+ *
465
+ * @param opts Options.
466
+ * @return Position.
467
+ */
468
+ positionBy(opts?: Pick<WarningOptions, 'word' | 'index'>): Position
469
+
470
+ /**
471
+ * Get the range for a word or start and end index inside the node.
472
+ * The start index is inclusive; the end index is exclusive.
473
+ *
474
+ * @param opts Options.
475
+ * @return Range.
476
+ */
477
+ rangeBy(opts?: Pick<WarningOptions, 'word' | 'index' | 'endIndex'>): Range
444
478
  }
@@ -10,52 +10,53 @@ import Node, {
10
10
  AnyNode
11
11
  } from './node.js'
12
12
  import Declaration, { DeclarationProps } from './declaration'
13
- import Root, { RootProps } from './root'
13
+ import Container, { ContainerProps } from './container'
14
14
  import Document, { DocumentProps } from './document'
15
+ import Warning, { WarningOptions } from './warning'
15
16
  import Comment, { CommentProps } from './comment'
16
17
  import AtRule, { AtRuleProps } from './at-rule'
18
+ import Input, { FilePosition } from './input'
17
19
  import Result, { Message } from './result'
18
- import LazyResult from './lazy-result'
20
+ import Root, { RootProps } from './root'
19
21
  import Rule, { RuleProps } from './rule'
20
- import Container, { ContainerProps } from './container'
21
- import Warning, { WarningOptions } from './warning'
22
- import Input, { FilePosition } from './input'
23
22
  import CssSyntaxError from './css-syntax-error'
24
23
  import list, { List } from './list'
24
+ import LazyResult from './lazy-result'
25
25
  import Processor from './processor'
26
26
 
27
27
  export {
28
- WarningOptions,
29
- FilePosition,
30
- Position,
31
- Source,
32
- ChildNode,
33
- AnyNode,
34
- Message,
35
28
  NodeErrorOptions,
36
- NodeProps,
37
29
  DeclarationProps,
30
+ CssSyntaxError,
38
31
  ContainerProps,
32
+ WarningOptions,
33
+ DocumentProps,
34
+ FilePosition,
39
35
  CommentProps,
40
- RuleProps,
41
- ChildProps,
42
36
  AtRuleProps,
37
+ Declaration,
38
+ ChildProps,
39
+ LazyResult,
40
+ ChildNode,
41
+ NodeProps,
42
+ Processor,
43
+ RuleProps,
43
44
  RootProps,
44
- DocumentProps,
45
- Warning,
46
- CssSyntaxError,
47
- Node,
48
45
  Container,
49
- list,
50
- Declaration,
46
+ Position,
47
+ Document,
48
+ AnyNode,
49
+ Warning,
50
+ Message,
51
51
  Comment,
52
+ Source,
52
53
  AtRule,
53
- Rule,
54
- Root,
55
- Document,
56
54
  Result,
57
- LazyResult,
58
- Input
55
+ Input,
56
+ Node,
57
+ list,
58
+ Rule,
59
+ Root
59
60
  }
60
61
 
61
62
  export type SourceMap = SourceMapGenerator & {
@@ -221,7 +222,7 @@ export type AcceptedPlugin =
221
222
  }
222
223
  | Processor
223
224
 
224
- export interface Parser<RootNode = Root> {
225
+ export interface Parser<RootNode = Root | Document> {
225
226
  (
226
227
  css: string | { toString(): string },
227
228
  opts?: Pick<ProcessOptions, 'map' | 'from'>
@@ -245,7 +246,7 @@ export interface Syntax {
245
246
  /**
246
247
  * Function to generate AST by string.
247
248
  */
248
- parse?: Parser<Root | Document>
249
+ parse?: Parser
249
250
 
250
251
  /**
251
252
  * Class to generate string by AST.
@@ -378,7 +379,7 @@ export interface Postcss {
378
379
  * root1.append(root2).toResult().css
379
380
  * ```
380
381
  */
381
- parse: Parser
382
+ parse: Parser<Root>
382
383
 
383
384
  /**
384
385
  * Rehydrate a JSON AST (from `Node#toJSON`) back into the AST classes.
@@ -458,7 +459,7 @@ export interface Postcss {
458
459
  }
459
460
 
460
461
  export const stringify: Stringifier
461
- export const parse: Parser
462
+ export const parse: Parser<Root>
462
463
  export const fromJSON: JSONHydrator
463
464
 
464
465
  export const comment: Postcss['comment']
@@ -8,13 +8,14 @@ import {
8
8
  import LazyResult from './lazy-result'
9
9
  import Result from './result'
10
10
  import Root from './root'
11
+ import NoWorkResult from './no-work-result'
11
12
 
12
13
  /**
13
14
  * Contains plugins to process CSS. Create one `Processor` instance,
14
15
  * initialize its plugins, and then use that instance on numerous CSS files.
15
16
  *
16
17
  * ```js
17
- * const processor = postcss([autoprefixer, precss])
18
+ * const processor = postcss([autoprefixer, postcssNested])
18
19
  * processor.process(css1).then(result => console.log(result.css))
19
20
  * processor.process(css2).then(result => console.log(result.css))
20
21
  * ```
@@ -35,7 +36,7 @@ export default class Processor {
35
36
  * Plugins added to this processor.
36
37
  *
37
38
  * ```js
38
- * const processor = postcss([autoprefixer, precss])
39
+ * const processor = postcss([autoprefixer, postcssNested])
39
40
  * processor.plugins.length //=> 2
40
41
  * ```
41
42
  */
@@ -67,7 +68,7 @@ export default class Processor {
67
68
  * ```js
68
69
  * const processor = postcss()
69
70
  * .use(autoprefixer)
70
- * .use(precss)
71
+ * .use(postcssNested)
71
72
  * ```
72
73
  *
73
74
  * @param plugin PostCSS plugin or `Processor` with plugins.
@@ -97,5 +98,5 @@ export default class Processor {
97
98
  process(
98
99
  css: string | { toString(): string } | Result | LazyResult | Root,
99
100
  options?: ProcessOptions
100
- ): LazyResult
101
+ ): LazyResult | NoWorkResult
101
102
  }
@@ -4,6 +4,7 @@ import {
4
4
  SourceMap,
5
5
  TransformCallback,
6
6
  Root,
7
+ Document,
7
8
  Node,
8
9
  Warning,
9
10
  WarningOptions
@@ -94,7 +95,7 @@ export default class Result {
94
95
  * root.toResult().root === root
95
96
  * ```
96
97
  */
97
- root: Root
98
+ root: Root | Document
98
99
 
99
100
  /**
100
101
  * Options from the `Processor#process` or `Root#toResult` call
@@ -141,7 +142,7 @@ export default class Result {
141
142
  * @param root Root node after all transformations.
142
143
  * @param opts Options from the `Processor#process` or `Root#toResult`.
143
144
  */
144
- constructor(processor: Processor, root: Root, opts: ResultOptions)
145
+ constructor(processor: Processor, root: Root | Document, opts: ResultOptions)
145
146
 
146
147
  /**
147
148
  * An alias for the `Result#css` property.
@@ -1,3 +1,4 @@
1
+ import { RangePosition } from './css-syntax-error'
1
2
  import Node from './node'
2
3
 
3
4
  export interface WarningOptions {
@@ -12,10 +13,25 @@ export interface WarningOptions {
12
13
  word?: string
13
14
 
14
15
  /**
15
- * Index in CSS node string that caused the warning.
16
+ * Start index, inclusive, in CSS node string that caused the warning.
16
17
  */
17
18
  index?: number
18
19
 
20
+ /**
21
+ * End index, exclusive, in CSS node string that caused the warning.
22
+ */
23
+ endIndex?: number
24
+
25
+ /**
26
+ * Start position, inclusive, in CSS node string that caused the warning.
27
+ */
28
+ start?: RangePosition
29
+
30
+ /**
31
+ * End position, exclusive, in CSS node string that caused the warning.
32
+ */
33
+ end?: RangePosition
34
+
19
35
  /**
20
36
  * Name of the plugin that created this warning. `Result#warn` fills
21
37
  * this property automatically.
@@ -68,7 +84,7 @@ export default class Warning {
68
84
  node: Node
69
85
 
70
86
  /**
71
- * Line in the input file with this warning’s source.
87
+ * Line for inclusive start position in the input file with this warning’s source.
72
88
  *
73
89
  * ```js
74
90
  * warning.line //=> 5
@@ -77,7 +93,7 @@ export default class Warning {
77
93
  line: number
78
94
 
79
95
  /**
80
- * Column in the input file with this warning’s source.
96
+ * Column for inclusive start position in the input file with this warning’s source.
81
97
  *
82
98
  * ```js
83
99
  * warning.column //=> 6
@@ -85,6 +101,24 @@ export default class Warning {
85
101
  */
86
102
  column: number
87
103
 
104
+ /**
105
+ * Line for exclusive end position in the input file with this warning’s source.
106
+ *
107
+ * ```js
108
+ * warning.endLine //=> 6
109
+ * ```
110
+ */
111
+ endLine?: number
112
+
113
+ /**
114
+ * Column for exclusive end position in the input file with this warning’s source.
115
+ *
116
+ * ```js
117
+ * warning.endColumn //=> 4
118
+ * ```
119
+ */
120
+ endColumn?: number
121
+
88
122
  /**
89
123
  * @param text Warning message.
90
124
  * @param opts Warning options.