@yahoo/uds 3.162.1 → 3.163.0

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 (97) hide show
  1. package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
  2. package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
  3. package/dist/cli/commands/sync.cjs +1 -1
  4. package/dist/cli/commands/sync.js +1 -1
  5. package/dist/cli/dist/commands/editor-rules.cjs +1 -1
  6. package/dist/cli/dist/commands/editor-rules.js +1 -1
  7. package/dist/cli/dist/utils/rules/config.cjs +1 -1
  8. package/dist/cli/dist/utils/rules/config.js +1 -1
  9. package/dist/components/client/Popover/UDSPopoverConfigProvider.d.cts +1 -1
  10. package/dist/components/client/Popover/UDSPopoverConfigProvider.d.ts +1 -1
  11. package/dist/components/client/Switch/Switch.cjs +5 -2
  12. package/dist/components/client/Switch/Switch.js +5 -2
  13. package/dist/components/client/Switch/switchStyles.cjs +2 -2
  14. package/dist/components/client/Switch/switchStyles.js +2 -2
  15. package/dist/css/dist/css/generate.cjs +4 -4
  16. package/dist/css/dist/css/generate.helpers.cjs +9 -19
  17. package/dist/css/dist/css/generate.helpers.js +4 -13
  18. package/dist/css/dist/css/generate.js +3 -3
  19. package/dist/css/dist/css/nodeUtils.cjs +3 -3
  20. package/dist/css/dist/css/nodeUtils.js +2 -2
  21. package/dist/css/dist/css/runner.cjs +2 -2
  22. package/dist/css/dist/css/runner.js +2 -2
  23. package/dist/css/dist/css/theme.d.cts +1 -1
  24. package/dist/css/dist/css/theme.d.ts +1 -1
  25. package/dist/css/dist/postcss/pruneVars.cjs +53 -0
  26. package/dist/css/dist/postcss/pruneVars.d.cts +33 -0
  27. package/dist/css/dist/postcss/pruneVars.d.ts +33 -0
  28. package/dist/css/dist/postcss/pruneVars.js +50 -0
  29. package/dist/css/dist/postcss.d.cts +3 -0
  30. package/dist/css/dist/postcss.d.ts +3 -0
  31. package/dist/css/dist/purger/optimized/ast/expressions.cjs +2 -2
  32. package/dist/css/dist/purger/optimized/ast/expressions.js +1 -1
  33. package/dist/css/dist/purger/optimized/purge.cjs +3 -3
  34. package/dist/css/dist/purger/optimized/purge.js +2 -2
  35. package/dist/css/dist/purger/optimized/utils/safelist.cjs +1 -1
  36. package/dist/css/dist/purger/optimized/utils/safelist.js +1 -1
  37. package/dist/hooks/useRtl.cjs +4 -8
  38. package/dist/hooks/useRtl.js +4 -8
  39. package/dist/postcss.cjs +4 -0
  40. package/dist/postcss.d.cts +4 -0
  41. package/dist/postcss.d.ts +4 -0
  42. package/dist/postcss.js +3 -0
  43. package/dist/styles/styler.d.cts +5 -5
  44. package/dist/styles/styler.d.ts +5 -5
  45. package/dist/tailwind-internal/dist/utils/entryPoints.cjs +2 -2
  46. package/dist/tailwind-internal/dist/utils/entryPoints.js +1 -1
  47. package/dist/tailwind-internal/dist/utils/getShadowStyles.d.cts +2 -2
  48. package/dist/tailwind-internal/dist/utils/getShadowStyles.d.ts +2 -2
  49. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/LICENSE +1 -1
  50. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/README.md +6 -10
  51. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/at-rule.d.ts +0 -1
  52. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/comment.d.ts +0 -1
  53. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/container.d.ts +1 -6
  54. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/container.js +81 -34
  55. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/css-syntax-error.d.ts +0 -1
  56. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/declaration.d.ts +0 -1
  57. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/document.d.ts +0 -1
  58. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/fromJSON.d.ts +1 -1
  59. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/fromJSON.js +76 -23
  60. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/input.d.ts +0 -1
  61. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/input.js +22 -5
  62. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/lazy-result.d.ts +3 -4
  63. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/lazy-result.js +68 -13
  64. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/list.d.ts +1 -1
  65. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/map-generator.js +9 -1
  66. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/no-work-result.d.ts +0 -1
  67. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/no-work-result.js +3 -4
  68. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/node.d.ts +0 -1
  69. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/node.js +105 -60
  70. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/parse.d.ts +1 -1
  71. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/parser.js +37 -30
  72. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/postcss.d.mts +0 -3
  73. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/postcss.d.ts +10 -4
  74. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/previous-map.d.ts +0 -1
  75. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/previous-map.js +32 -6
  76. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/processor.d.ts +0 -1
  77. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/processor.js +1 -1
  78. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/result.d.ts +0 -1
  79. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/root.d.ts +0 -1
  80. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/rule.d.ts +12 -12
  81. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/stringifier.d.ts +0 -1
  82. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/stringifier.js +118 -32
  83. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/stringify.d.ts +1 -1
  84. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/tokenize.js +4 -0
  85. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/lib/warning.d.ts +0 -1
  86. package/dist/tailwind-internal/dist/vendor/node_modules/postcss/package.json +44 -44
  87. package/dist/tailwind-v3/dist/purger/legacy/purgeCSS.cjs +1 -1
  88. package/dist/tailwind-v3/dist/purger/legacy/purgeCSS.js +1 -1
  89. package/dist/uds/generated/componentData.cjs +142 -140
  90. package/dist/uds/generated/componentData.js +142 -140
  91. package/dist/uds/generated/tailwindPurge.cjs +1 -1
  92. package/dist/uds/generated/tailwindPurge.js +1 -1
  93. package/dist/uds/package.cjs +11 -1
  94. package/dist/uds/package.js +11 -1
  95. package/generated/componentData.json +186 -184
  96. package/generated/tailwindPurge.ts +1 -1
  97. package/package.json +12 -2
@@ -8,18 +8,25 @@ let { isClean, my } = require('./symbols')
8
8
  let AtRule, parse, Root, Rule
9
9
 
10
10
  function cleanSource(nodes) {
11
- return nodes.map(i => {
12
- if (i.nodes) i.nodes = cleanSource(i.nodes)
13
- delete i.source
14
- return i
15
- })
11
+ let stack = nodes.slice()
12
+ while (stack.length > 0) {
13
+ let node = stack.pop()
14
+ delete node.source
15
+ if (node.nodes) {
16
+ node.nodes = node.nodes.slice()
17
+ for (let i of node.nodes) stack.push(i)
18
+ }
19
+ }
20
+ return nodes.slice()
16
21
  }
17
22
 
18
23
  function markTreeDirty(node) {
19
- node[isClean] = false
20
- if (node.proxyOf.nodes) {
21
- for (let i of node.proxyOf.nodes) {
22
- markTreeDirty(i)
24
+ let stack = [node]
25
+ while (stack.length > 0) {
26
+ let next = stack.pop()
27
+ next[isClean] = false
28
+ if (next.proxyOf.nodes) {
29
+ for (let i of next.proxyOf.nodes) stack.push(i)
23
30
  }
24
31
  }
25
32
  }
@@ -47,9 +54,18 @@ class Container extends Node {
47
54
  }
48
55
 
49
56
  cleanRaws(keepBetween) {
50
- super.cleanRaws(keepBetween)
51
- if (this.nodes) {
52
- for (let node of this.nodes) node.cleanRaws(keepBetween)
57
+ let stack = [this]
58
+ while (stack.length > 0) {
59
+ let node = stack.pop()
60
+ if (node !== this && node.cleanRaws !== Container.prototype.cleanRaws) {
61
+ // Subclass with own logic; let it handle its subtree
62
+ node.cleanRaws(keepBetween)
63
+ continue
64
+ }
65
+ Node.prototype.cleanRaws.call(node, keepBetween)
66
+ if (node.nodes) {
67
+ for (let child of node.nodes) stack.push(child)
68
+ }
53
69
  }
54
70
  }
55
71
 
@@ -309,19 +325,48 @@ class Container extends Node {
309
325
  }
310
326
 
311
327
  walk(callback) {
312
- return this.each((child, i) => {
328
+ if (!this.proxyOf.nodes) return undefined
329
+
330
+ // An explicit stack instead of recursive `each()` calls to survive
331
+ // deeply nested trees. Each frame keeps a live `indexes` slot, so
332
+ // insertion and removal during the walk behave like `each()`: the
333
+ // slot stays at the current child until its subtree is finished.
334
+ let stack = [{ iterator: this.getIterator(), node: this.proxyOf }]
335
+
336
+ while (stack.length > 0) {
337
+ let { iterator, node } = stack[stack.length - 1]
338
+ let index = node.indexes[iterator]
339
+
340
+ if (index >= node.proxyOf.nodes.length) {
341
+ delete node.indexes[iterator]
342
+ stack.pop()
343
+ let parent = stack[stack.length - 1]
344
+ // Finish the parent’s step for the child subtree we just left
345
+ if (parent) parent.node.indexes[parent.iterator] += 1
346
+ continue
347
+ }
348
+
349
+ let child = node.proxyOf.nodes[index]
313
350
  let result
314
351
  try {
315
- result = callback(child, i)
352
+ result = callback(child, index)
316
353
  } catch (e) {
317
354
  throw child.addToError(e)
318
355
  }
319
- if (result !== false && child.walk) {
320
- result = child.walk(callback)
356
+ if (result === false) {
357
+ for (let opened of stack) {
358
+ delete opened.node.indexes[opened.iterator]
359
+ }
360
+ return false
361
+ }
362
+ if (child.walk && child.proxyOf.nodes) {
363
+ stack.push({ iterator: child.getIterator(), node: child })
364
+ } else {
365
+ node.indexes[iterator] += 1
321
366
  }
367
+ }
322
368
 
323
- return result
324
- })
369
+ return undefined
325
370
  }
326
371
 
327
372
  walkAtRules(name, callback) {
@@ -424,24 +469,26 @@ Container.default = Container
424
469
 
425
470
  /* c8 ignore start */
426
471
  Container.rebuild = node => {
427
- if (node.type === 'atrule') {
428
- Object.setPrototypeOf(node, AtRule.prototype)
429
- } else if (node.type === 'rule') {
430
- Object.setPrototypeOf(node, Rule.prototype)
431
- } else if (node.type === 'decl') {
432
- Object.setPrototypeOf(node, Declaration.prototype)
433
- } else if (node.type === 'comment') {
434
- Object.setPrototypeOf(node, Comment.prototype)
435
- } else if (node.type === 'root') {
436
- Object.setPrototypeOf(node, Root.prototype)
437
- }
472
+ let stack = [node]
473
+ while (stack.length > 0) {
474
+ let next = stack.pop()
475
+ if (next.type === 'atrule') {
476
+ Object.setPrototypeOf(next, AtRule.prototype)
477
+ } else if (next.type === 'rule') {
478
+ Object.setPrototypeOf(next, Rule.prototype)
479
+ } else if (next.type === 'decl') {
480
+ Object.setPrototypeOf(next, Declaration.prototype)
481
+ } else if (next.type === 'comment') {
482
+ Object.setPrototypeOf(next, Comment.prototype)
483
+ } else if (next.type === 'root') {
484
+ Object.setPrototypeOf(next, Root.prototype)
485
+ }
438
486
 
439
- node[my] = true
487
+ next[my] = true
440
488
 
441
- if (node.nodes) {
442
- node.nodes.forEach(child => {
443
- Container.rebuild(child)
444
- })
489
+ if (next.nodes) {
490
+ for (let child of next.nodes) stack.push(child)
491
+ }
445
492
  }
446
493
  }
447
494
  /* c8 ignore stop */
@@ -16,7 +16,6 @@ declare namespace CssSyntaxError {
16
16
  line: number
17
17
  }
18
18
 
19
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
20
19
  export { CssSyntaxError_ as default }
21
20
  }
22
21
 
@@ -39,7 +39,6 @@ declare namespace Declaration {
39
39
  value: string
40
40
  }
41
41
 
42
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
42
  export { Declaration_ as default }
44
43
  }
45
44
 
@@ -16,7 +16,6 @@ declare namespace Document {
16
16
  raws?: Record<string, any>
17
17
  }
18
18
 
19
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
20
19
  export { Document_ as default }
21
20
  }
22
21
 
@@ -4,6 +4,6 @@ interface FromJSON extends JSONHydrator {
4
4
  default: FromJSON
5
5
  }
6
6
 
7
- declare const fromJSON: FromJSON
7
+ declare let fromJSON: FromJSON
8
8
 
9
9
  export = fromJSON
@@ -8,26 +8,24 @@ let PreviousMap = require('./previous-map')
8
8
  let Root = require('./root')
9
9
  let Rule = require('./rule')
10
10
 
11
- function fromJSON(json, inputs) {
12
- if (Array.isArray(json)) return json.map(n => fromJSON(n))
13
-
14
- let { inputs: ownInputs, ...defaults } = json
15
- if (ownInputs) {
16
- inputs = []
17
- for (let input of ownInputs) {
18
- let inputHydrated = { ...input, __proto__: Input.prototype }
19
- if (inputHydrated.map) {
20
- inputHydrated.map = {
21
- ...inputHydrated.map,
22
- __proto__: PreviousMap.prototype
23
- }
11
+ function hydrateInputs(json, inputs) {
12
+ if (!json.inputs) return inputs
13
+ return json.inputs.map(input => {
14
+ let inputHydrated = { ...input, __proto__: Input.prototype }
15
+ if (inputHydrated.map) {
16
+ inputHydrated.map = {
17
+ ...inputHydrated.map,
18
+ __proto__: PreviousMap.prototype
24
19
  }
25
- inputs.push(inputHydrated)
26
20
  }
27
- }
28
- if (defaults.nodes) {
29
- defaults.nodes = json.nodes.map(n => fromJSON(n, inputs))
30
- }
21
+ return inputHydrated
22
+ })
23
+ }
24
+
25
+ function constructNode(json, inputs, children) {
26
+ let defaults = { ...json }
27
+ delete defaults.inputs
28
+ delete defaults.nodes
31
29
  if (defaults.source) {
32
30
  let { inputId, ...source } = defaults.source
33
31
  defaults.source = source
@@ -35,19 +33,74 @@ function fromJSON(json, inputs) {
35
33
  defaults.source.input = inputs[inputId]
36
34
  }
37
35
  }
36
+
37
+ let node
38
38
  if (defaults.type === 'root') {
39
- return new Root(defaults)
39
+ node = new Root(defaults)
40
40
  } else if (defaults.type === 'decl') {
41
- return new Declaration(defaults)
41
+ node = new Declaration(defaults)
42
42
  } else if (defaults.type === 'rule') {
43
- return new Rule(defaults)
43
+ node = new Rule(defaults)
44
44
  } else if (defaults.type === 'comment') {
45
- return new Comment(defaults)
45
+ node = new Comment(defaults)
46
46
  } else if (defaults.type === 'atrule') {
47
- return new AtRule(defaults)
47
+ node = new AtRule(defaults)
48
48
  } else {
49
49
  throw new Error('Unknown node type: ' + json.type)
50
50
  }
51
+
52
+ // Rehydrated children are attached after construction. Passing them
53
+ // through the container constructor would re-run insertion spacing
54
+ // normalization and overwrite each child's own `raws.before`.
55
+ if (children) {
56
+ node.nodes = children
57
+ for (let child of children) child.parent = node
58
+ }
59
+
60
+ return node
61
+ }
62
+
63
+ function fromJSON(json, inputs) {
64
+ if (Array.isArray(json)) return json.map(n => fromJSON(n))
65
+
66
+ // An explicit stack instead of recursive calls to survive deeply
67
+ // nested trees. Children are rehydrated before their parent node
68
+ // is constructed.
69
+ let result
70
+ let stack = [
71
+ { childIndex: 0, children: [], inputs: hydrateInputs(json, inputs), json }
72
+ ]
73
+
74
+ while (stack.length > 0) {
75
+ let frame = stack[stack.length - 1]
76
+ let jsonNodes = frame.json.nodes
77
+
78
+ if (jsonNodes && frame.childIndex < jsonNodes.length) {
79
+ let childJson = jsonNodes[frame.childIndex]
80
+ frame.childIndex += 1
81
+ stack.push({
82
+ childIndex: 0,
83
+ children: [],
84
+ inputs: hydrateInputs(childJson, frame.inputs),
85
+ json: childJson
86
+ })
87
+ continue
88
+ }
89
+
90
+ stack.pop()
91
+ let node = constructNode(
92
+ frame.json,
93
+ frame.inputs,
94
+ jsonNodes ? frame.children : undefined
95
+ )
96
+ if (stack.length > 0) {
97
+ stack[stack.length - 1].children.push(node)
98
+ } else {
99
+ result = node
100
+ }
101
+ }
102
+
103
+ return result
51
104
  }
52
105
 
53
106
  module.exports = fromJSON
@@ -49,7 +49,6 @@ declare namespace Input {
49
49
  url: string
50
50
  }
51
51
 
52
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
53
52
  export { Input_ as default }
54
53
  }
55
54
 
@@ -142,7 +142,15 @@ class Input {
142
142
  )
143
143
  }
144
144
 
145
- result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css }
145
+ result.input = {
146
+ column,
147
+ endColumn,
148
+ endLine,
149
+ endOffset,
150
+ line,
151
+ offset,
152
+ source: this.css
153
+ }
146
154
  if (this.file) {
147
155
  if (pathToFileURL) {
148
156
  result.input.url = pathToFileURL(this.file).toString()
@@ -198,12 +206,21 @@ class Input {
198
206
  if (!this.map) return false
199
207
  let consumer = this.map.consumer()
200
208
 
201
- let from = consumer.originalPositionFor({ column, line })
209
+ let from = consumer.originalPositionFor({ column: column - 1, line })
202
210
  if (!from.source) return false
203
211
 
204
212
  let to
205
213
  if (typeof endLine === 'number') {
206
- to = consumer.originalPositionFor({ column: endColumn, line: endLine })
214
+ let toPosition = consumer.originalPositionFor({
215
+ column: endColumn - 1,
216
+ line: endLine
217
+ })
218
+ // The source map may not have a mapping that covers the end position
219
+ // (`originalPositionFor()` then returns `null` for `line`/`column`
220
+ // instead of omitting them). Treat that the same as not requesting
221
+ // an end position at all, so `endLine`/`endColumn` stay a consistent
222
+ // `undefined` pair instead of a mix of `null` and a bogus number.
223
+ if (toPosition.source) to = toPosition
207
224
  }
208
225
 
209
226
  let fromUrl
@@ -218,8 +235,8 @@ class Input {
218
235
  }
219
236
 
220
237
  let result = {
221
- column: from.column,
222
- endColumn: to && to.column,
238
+ column: from.column + 1,
239
+ endColumn: to && to.column + 1,
223
240
  endLine: to && to.line,
224
241
  line: from.line,
225
242
  url: fromUrl.toString()
@@ -6,7 +6,6 @@ import Root from './root.js'
6
6
  import Warning from './warning.js'
7
7
 
8
8
  declare namespace LazyResult {
9
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
10
9
  export { LazyResult_ as default }
11
10
  }
12
11
 
@@ -19,9 +18,9 @@ declare namespace LazyResult {
19
18
  * const lazy = postcss([autoprefixer]).process(css)
20
19
  * ```
21
20
  */
22
- declare class LazyResult_<RootNode = Document | Root>
23
- implements PromiseLike<Result<RootNode>>
24
- {
21
+ declare class LazyResult_<RootNode = Document | Root> implements PromiseLike<
22
+ Result<RootNode>
23
+ > {
25
24
  /**
26
25
  * Processes input CSS through synchronous and asynchronous plugins
27
26
  * and calls onRejected for each error thrown in any plugin.
@@ -97,8 +97,14 @@ function toStack(node) {
97
97
  }
98
98
 
99
99
  function cleanMarks(node) {
100
- node[isClean] = false
101
- if (node.nodes) node.nodes.forEach(i => cleanMarks(i))
100
+ let stack = [node]
101
+ while (stack.length > 0) {
102
+ let next = stack.pop()
103
+ next[isClean] = false
104
+ if (next.nodes) {
105
+ for (let i of next.nodes) stack.push(i)
106
+ }
107
+ }
102
108
  return node
103
109
  }
104
110
 
@@ -378,6 +384,19 @@ class LazyResult {
378
384
  if (opts.stringifier) str = opts.stringifier
379
385
  if (str.stringify) str = str.stringify
380
386
 
387
+ let rootSource = this.result.root.source
388
+ if (
389
+ opts.map === undefined &&
390
+ !(rootSource && rootSource.input && rootSource.input.map)
391
+ ) {
392
+ let result = ''
393
+ str(this.result.root, i => {
394
+ result += i
395
+ })
396
+ this.result.css = result
397
+ return this.result
398
+ }
399
+
381
400
  let map = new MapGenerator(str, this.result.root, this.result.opts)
382
401
  let data = map.generate()
383
402
  this.result.css = data[0]
@@ -516,21 +535,57 @@ class LazyResult {
516
535
  }
517
536
 
518
537
  walkSync(node) {
538
+ // An explicit stack like in async `visitTick()` to survive deeply
539
+ // nested trees. Unlike `visitTick()`, nodes are marked clean only
540
+ // on entering, so a node dirtied by its own visitors is revisited
541
+ // on the next pass.
519
542
  node[isClean] = true
520
- let events = getEvents(node)
521
- for (let event of events) {
522
- if (event === CHILDREN) {
523
- if (node.nodes) {
524
- node.each(child => {
525
- if (!child[isClean]) this.walkSync(child)
526
- })
543
+ let stack = [{ eventIndex: 0, events: getEvents(node), iterator: 0, node }]
544
+
545
+ while (stack.length > 0) {
546
+ let visit = stack[stack.length - 1]
547
+ let visitNode = visit.node
548
+
549
+ if (visit.iterator !== 0) {
550
+ let iterator = visit.iterator
551
+ let child
552
+ let descended = false
553
+ while ((child = visitNode.nodes[visitNode.indexes[iterator]])) {
554
+ visitNode.indexes[iterator] += 1
555
+ if (!child[isClean]) {
556
+ child[isClean] = true
557
+ stack.push({
558
+ eventIndex: 0,
559
+ events: getEvents(child),
560
+ iterator: 0,
561
+ node: child
562
+ })
563
+ descended = true
564
+ break
565
+ }
527
566
  }
528
- } else {
529
- let visitors = this.listeners[event]
530
- if (visitors) {
531
- if (this.visitSync(visitors, node.toProxy())) return
567
+ if (descended) continue
568
+ visit.iterator = 0
569
+ delete visitNode.indexes[iterator]
570
+ }
571
+
572
+ if (visit.eventIndex < visit.events.length) {
573
+ let event = visit.events[visit.eventIndex]
574
+ visit.eventIndex += 1
575
+ if (event === CHILDREN) {
576
+ if (visitNode.nodes && visitNode.nodes.length) {
577
+ visit.iterator = visitNode.getIterator()
578
+ }
579
+ } else {
580
+ let visitors = this.listeners[event]
581
+ if (visitors) {
582
+ if (this.visitSync(visitors, visitNode.toProxy())) stack.pop()
583
+ }
532
584
  }
585
+ continue
533
586
  }
587
+
588
+ stack.pop()
534
589
  }
535
590
  }
536
591
 
@@ -55,6 +55,6 @@ declare namespace list {
55
55
  }
56
56
  }
57
57
 
58
- declare const list: list.List
58
+ declare let list: list.List
59
59
 
60
60
  export = list
@@ -75,7 +75,15 @@ class MapGenerator {
75
75
  }
76
76
  }
77
77
  } else if (this.css) {
78
- this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '')
78
+ let startIndex
79
+ while ((startIndex = this.css.lastIndexOf('/*#')) !== -1) {
80
+ let endIndex = this.css.indexOf('*/', startIndex + 3)
81
+ if (endIndex === -1) break
82
+ while (startIndex > 0 && this.css[startIndex - 1] === '\n') {
83
+ startIndex--
84
+ }
85
+ this.css = this.css.slice(0, startIndex) + this.css.slice(endIndex + 2)
86
+ }
79
87
  }
80
88
  }
81
89
 
@@ -6,7 +6,6 @@ import Root from './root.js'
6
6
  import Warning from './warning.js'
7
7
 
8
8
  declare namespace NoWorkResult {
9
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
10
9
  export { NoWorkResult_ as default }
11
10
  }
12
11
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  let MapGenerator = require('./map-generator')
4
4
  let parse = require('./parse')
5
- const Result = require('./result')
5
+ let Result = require('./result')
6
6
  let stringify = require('./stringify')
7
7
  let warnOnce = require('./warn-once')
8
8
 
@@ -65,10 +65,9 @@ class NoWorkResult {
65
65
  this._css = css
66
66
  this._opts = opts
67
67
  this._map = undefined
68
- let root
69
68
 
70
69
  let str = stringify
71
- this.result = new Result(this._processor, root, this._opts)
70
+ this.result = new Result(this._processor, undefined, this._opts)
72
71
  this.result.css = css
73
72
 
74
73
  let self = this
@@ -78,7 +77,7 @@ class NoWorkResult {
78
77
  }
79
78
  })
80
79
 
81
- let map = new MapGenerator(str, root, this._opts, css)
80
+ let map = new MapGenerator(str, undefined, this._opts, css)
82
81
  if (map.isMap()) {
83
82
  let [generatedCSS, generatedMap] = map.generate()
84
83
  if (generatedCSS) {
@@ -126,7 +126,6 @@ declare namespace Node {
126
126
  word?: string
127
127
  }
128
128
 
129
- // eslint-disable-next-line @typescript-eslint/no-shadow
130
129
  class Node extends Node_ {}
131
130
  export { Node as default }
132
131
  }