@vue/compiler-sfc 3.5.39 → 3.5.40

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.39
2
+ * @vue/compiler-sfc v3.5.40
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -26151,7 +26151,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
26151
26151
  return generator.toJSON();
26152
26152
  }
26153
26153
 
26154
- const version = "3.5.39";
26154
+ const version = "3.5.40";
26155
26155
  const parseCache = parseCache$1;
26156
26156
  const errorMessages = {
26157
26157
  ...CompilerDOM.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.39
2
+ * @vue/compiler-sfc v3.5.40
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -19931,6 +19931,9 @@ function getUnnormalizedProps(props, callPath = []) {
19931
19931
  return [props, callPath];
19932
19932
  }
19933
19933
  function injectProp(node, prop, context) {
19934
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
19935
+ return;
19936
+ }
19934
19937
  let propsWithInjection;
19935
19938
  let props = node.type === 13 ? node.props : node.arguments[2];
19936
19939
  let callPath = [];
@@ -19988,6 +19991,24 @@ function injectProp(node, prop, context) {
19988
19991
  }
19989
19992
  }
19990
19993
  }
19994
+ function injectSlotKey(node, prop) {
19995
+ var _a, _b, _c;
19996
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
19997
+ return false;
19998
+ }
19999
+ const props = node.arguments[2];
20000
+ if (props && !isString$1(props)) {
20001
+ const [unnormalizedProps] = getUnnormalizedProps(props);
20002
+ if (unnormalizedProps && !isString$1(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
20003
+ return true;
20004
+ }
20005
+ }
20006
+ (_a = node.arguments)[2] || (_a[2] = "{}");
20007
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
20008
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
20009
+ node.arguments[5] = prop.value;
20010
+ return true;
20011
+ }
19991
20012
  function hasProp(prop, props) {
19992
20013
  let result = false;
19993
20014
  if (prop.key.type === 4) {
@@ -34319,27 +34340,74 @@ function requireStringifier () {
34319
34340
  return str[0].toUpperCase() + str.slice(1)
34320
34341
  }
34321
34342
 
34343
+ function atruleStart(str, node) {
34344
+ let name = '@' + node.name;
34345
+ let params = node.params ? str.rawValue(node, 'params') : '';
34346
+
34347
+ if (typeof node.raws.afterName !== 'undefined') {
34348
+ name += node.raws.afterName;
34349
+ } else if (params) {
34350
+ name += ' ';
34351
+ }
34352
+
34353
+ return name + params
34354
+ }
34355
+
34356
+ function pushBody(str, stack, node) {
34357
+ let nodes = node.nodes;
34358
+ let last = nodes.length - 1;
34359
+ while (last > 0) {
34360
+ if (nodes[last].type !== 'comment') break
34361
+ last -= 1;
34362
+ }
34363
+
34364
+ let semicolon = str.raw(node, 'semicolon');
34365
+ let isDocument = node.type === 'document';
34366
+ for (let i = nodes.length - 1; i >= 0; i--) {
34367
+ stack.push({
34368
+ document: isDocument,
34369
+ node: nodes[i],
34370
+ semicolon: last !== i || semicolon
34371
+ });
34372
+ }
34373
+ }
34374
+
34375
+ function pushBlock(str, stack, node, start) {
34376
+ let between = str.raw(node, 'between', 'beforeOpen');
34377
+ str.builder(escapeHTMLInCSS(start + between) + '{', node, 'start');
34378
+
34379
+ let hasNodes = node.nodes && node.nodes.length;
34380
+ let close = () => {
34381
+ let after = hasNodes
34382
+ ? str.raw(node, 'after')
34383
+ : str.raw(node, 'after', 'emptyBody');
34384
+ if (after) str.builder(escapeHTMLInCSS(after));
34385
+ str.builder('}', node, 'end');
34386
+ if (node.type === 'rule' && node.raws.ownSemicolon) {
34387
+ str.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end');
34388
+ }
34389
+ };
34390
+
34391
+ if (hasNodes) {
34392
+ stack.push(close);
34393
+ pushBody(str, stack, node);
34394
+ } else {
34395
+ close();
34396
+ }
34397
+ }
34398
+
34322
34399
  class Stringifier {
34323
34400
  constructor(builder) {
34324
34401
  this.builder = builder;
34325
34402
  }
34326
34403
 
34327
34404
  atrule(node, semicolon) {
34328
- let raws = node.raws;
34329
- let name = '@' + node.name;
34330
- let params = node.params ? this.rawValue(node, 'params') : '';
34331
-
34332
- if (typeof raws.afterName !== 'undefined') {
34333
- name += raws.afterName;
34334
- } else if (params) {
34335
- name += ' ';
34336
- }
34337
-
34405
+ let start = atruleStart(this, node);
34338
34406
  if (node.nodes) {
34339
- this.block(node, name + params);
34407
+ this.block(node, start);
34340
34408
  } else {
34341
- let end = (raws.between || '') + (semicolon ? ';' : '');
34342
- this.builder(escapeHTMLInCSS(name + params + end), node);
34409
+ let end = (node.raws.between || '') + (semicolon ? ';' : '');
34410
+ this.builder(escapeHTMLInCSS(start + end), node);
34343
34411
  }
34344
34412
  }
34345
34413
 
@@ -34389,20 +34457,38 @@ function requireStringifier () {
34389
34457
  }
34390
34458
 
34391
34459
  body(node) {
34392
- let nodes = node.nodes;
34393
- let last = nodes.length - 1;
34394
- while (last > 0) {
34395
- if (nodes[last].type !== 'comment') break
34396
- last -= 1;
34397
- }
34460
+ // Rules and at-rules are expanded into an explicit stack instead of
34461
+ // recursive `stringify()` calls to survive deeply nested trees.
34462
+ // If a subclass changes the traversal methods, its children go
34463
+ // through `stringify()` to keep the override in charge.
34464
+ let proto = Stringifier.prototype;
34465
+ let expandable = ['atrule', 'block', 'body', 'rule', 'stringify'].every(
34466
+ method => this[method] === proto[method]
34467
+ );
34468
+
34469
+ let stack = [];
34470
+ pushBody(this, stack, node);
34471
+
34472
+ while (stack.length > 0) {
34473
+ let entry = stack.pop();
34474
+ if (typeof entry === 'function') {
34475
+ entry();
34476
+ continue
34477
+ }
34398
34478
 
34399
- let semicolon = this.raw(node, 'semicolon');
34400
- let isDocument = node.type === 'document';
34401
- for (let i = 0; i < nodes.length; i++) {
34402
- let child = nodes[i];
34479
+ let child = entry.node;
34403
34480
  let before = this.raw(child, 'before');
34404
- if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before));
34405
- this.stringify(child, last !== i || semicolon);
34481
+ if (before) {
34482
+ this.builder(entry.document ? before : escapeHTMLInCSS(before));
34483
+ }
34484
+
34485
+ if (expandable && child.type === 'rule') {
34486
+ pushBlock(this, stack, child, this.rawValue(child, 'selector'));
34487
+ } else if (expandable && child.type === 'atrule' && child.nodes) {
34488
+ pushBlock(this, stack, child, atruleStart(this, child));
34489
+ } else {
34490
+ this.stringify(child, entry.semicolon);
34491
+ }
34406
34492
  }
34407
34493
  }
34408
34494
 
@@ -34710,25 +34796,41 @@ function requireNode$2 () {
34710
34796
 
34711
34797
  function cloneNode(obj, parent) {
34712
34798
  let cloned = new obj.constructor();
34713
-
34714
- for (let i in obj) {
34715
- if (!Object.prototype.hasOwnProperty.call(obj, i)) {
34716
- /* c8 ignore next 2 */
34717
- continue
34718
- }
34719
- if (i === 'proxyCache') continue
34720
- let value = obj[i];
34721
- let type = typeof value;
34722
-
34723
- if (i === 'parent' && type === 'object') {
34724
- if (parent) cloned[i] = parent;
34725
- } else if (i === 'source') {
34726
- cloned[i] = value;
34727
- } else if (Array.isArray(value)) {
34728
- cloned[i] = value.map(j => cloneNode(j, cloned));
34729
- } else {
34730
- if (type === 'object' && value !== null) value = cloneNode(value);
34731
- cloned[i] = value;
34799
+ // An explicit stack instead of recursive calls to survive deeply
34800
+ // nested trees. Each entry is [source, its clone, clone's parent].
34801
+ let stack = [[obj, cloned, parent]];
34802
+
34803
+ while (stack.length > 0) {
34804
+ let [source, target, targetParent] = stack.pop();
34805
+ for (let i in source) {
34806
+ if (!Object.prototype.hasOwnProperty.call(source, i)) {
34807
+ /* c8 ignore next 2 */
34808
+ continue
34809
+ }
34810
+ if (i === 'proxyCache') continue
34811
+ let value = source[i];
34812
+ let type = typeof value;
34813
+
34814
+ if (i === 'parent' && type === 'object') {
34815
+ if (targetParent) target[i] = targetParent;
34816
+ } else if (i === 'source') {
34817
+ target[i] = value;
34818
+ } else if (Array.isArray(value)) {
34819
+ let children = [];
34820
+ target[i] = children;
34821
+ for (let j of value) {
34822
+ let childClone = new j.constructor();
34823
+ children.push(childClone);
34824
+ stack.push([j, childClone, target]);
34825
+ }
34826
+ } else {
34827
+ if (type === 'object' && value !== null) {
34828
+ let valueClone = new value.constructor();
34829
+ stack.push([value, valueClone, undefined]);
34830
+ value = valueClone;
34831
+ }
34832
+ target[i] = value;
34833
+ }
34732
34834
  }
34733
34835
  }
34734
34836
 
@@ -34772,11 +34874,15 @@ function requireNode$2 () {
34772
34874
  this[isClean] = false;
34773
34875
  this[my] = true;
34774
34876
 
34775
- for (let name in defaults) {
34877
+ for (let name of Object.keys(defaults)) {
34878
+ if (name === '__proto__') continue
34776
34879
  if (name === 'nodes') {
34777
34880
  this.nodes = [];
34778
34881
  for (let node of defaults[name]) {
34779
- if (typeof node.clone === 'function') {
34882
+ // Clone only nodes that already belong to another tree, so passing a
34883
+ // freshly created (parent-less) node adopts that instance instead of
34884
+ // a copy and keeps the caller's reference usable. See #1987.
34885
+ if (typeof node.clone === 'function' && node.parent) {
34780
34886
  this.append(node.clone());
34781
34887
  } else {
34782
34888
  this.append(node);
@@ -34909,14 +35015,18 @@ function requireNode$2 () {
34909
35015
  }
34910
35016
 
34911
35017
  positionBy(opts = {}) {
34912
- let pos = this.source.start;
35018
+ let inputString =
35019
+ 'document' in this.source.input
35020
+ ? this.source.input.document
35021
+ : this.source.input.css;
35022
+ let pos = {
35023
+ column: this.source.start.column,
35024
+ line: this.source.start.line,
35025
+ offset: sourceOffset(inputString, this.source.start)
35026
+ };
34913
35027
  if (opts.index) {
34914
35028
  pos = this.positionInside(opts.index);
34915
35029
  } else if (opts.word) {
34916
- let inputString =
34917
- 'document' in this.source.input
34918
- ? this.source.input.document
34919
- : this.source.input.css;
34920
35030
  let stringRepresentation = inputString.slice(
34921
35031
  sourceOffset(inputString, this.source.start),
34922
35032
  sourceOffset(inputString, this.source.end)
@@ -35001,7 +35111,7 @@ function requireNode$2 () {
35001
35111
  line: opts.start.line,
35002
35112
  offset: sourceOffset(inputString, opts.start)
35003
35113
  };
35004
- } else if (opts.index) {
35114
+ } else if (typeof opts.index === 'number') {
35005
35115
  start = this.positionInside(opts.index);
35006
35116
  }
35007
35117
 
@@ -35013,7 +35123,7 @@ function requireNode$2 () {
35013
35123
  };
35014
35124
  } else if (typeof opts.endIndex === 'number') {
35015
35125
  end = this.positionInside(opts.endIndex);
35016
- } else if (opts.index) {
35126
+ } else if (typeof opts.index === 'number') {
35017
35127
  end = this.positionInside(opts.index + 1);
35018
35128
  }
35019
35129
  }
@@ -35077,47 +35187,68 @@ function requireNode$2 () {
35077
35187
  }
35078
35188
 
35079
35189
  toJSON(_, inputs) {
35080
- let fixed = {};
35081
35190
  let emitInputs = inputs == null;
35082
35191
  inputs = inputs || new Map();
35083
- let inputsNextIndex = 0;
35084
35192
 
35085
- for (let name in this) {
35086
- if (!Object.prototype.hasOwnProperty.call(this, name)) {
35087
- /* c8 ignore next 2 */
35088
- continue
35089
- }
35090
- if (name === 'parent' || name === 'proxyCache') continue
35091
- let value = this[name];
35193
+ // A worklist instead of recursive `toJSON()` calls to survive deeply
35194
+ // nested trees. Each entry converts one node and writes the result
35195
+ // into the already converted parent by [holder, key].
35196
+ let holderOfRoot = [];
35197
+ let queue = [[this, holderOfRoot, 0]];
35092
35198
 
35093
- if (Array.isArray(value)) {
35094
- fixed[name] = value.map(i => {
35095
- if (typeof i === 'object' && i.toJSON) {
35096
- return i.toJSON(null, inputs)
35199
+ for (let step = 0; step < queue.length; step++) {
35200
+ let [node, holder, key] = queue[step];
35201
+ let fixed = {};
35202
+ holder[key] = fixed;
35203
+
35204
+ for (let name in node) {
35205
+ if (!Object.prototype.hasOwnProperty.call(node, name)) {
35206
+ /* c8 ignore next 2 */
35207
+ continue
35208
+ }
35209
+ if (name === 'parent' || name === 'proxyCache') continue
35210
+ let value = node[name];
35211
+
35212
+ if (Array.isArray(value)) {
35213
+ let fixedArray = [];
35214
+ fixed[name] = fixedArray;
35215
+ for (let i = 0; i < value.length; i++) {
35216
+ let item = value[i];
35217
+ if (typeof item === 'object' && item.toJSON) {
35218
+ if (item.toJSON === Node.prototype.toJSON) {
35219
+ queue.push([item, fixedArray, i]);
35220
+ } else {
35221
+ fixedArray[i] = item.toJSON(null, inputs);
35222
+ }
35223
+ } else {
35224
+ fixedArray[i] = item;
35225
+ }
35226
+ }
35227
+ } else if (typeof value === 'object' && value.toJSON) {
35228
+ if (value.toJSON === Node.prototype.toJSON) {
35229
+ queue.push([value, fixed, name]);
35097
35230
  } else {
35098
- return i
35231
+ fixed[name] = value.toJSON(null, inputs);
35099
35232
  }
35100
- });
35101
- } else if (typeof value === 'object' && value.toJSON) {
35102
- fixed[name] = value.toJSON(null, inputs);
35103
- } else if (name === 'source') {
35104
- if (value == null) continue
35105
- let inputId = inputs.get(value.input);
35106
- if (inputId == null) {
35107
- inputId = inputsNextIndex;
35108
- inputs.set(value.input, inputsNextIndex);
35109
- inputsNextIndex++;
35110
- }
35111
- fixed[name] = {
35112
- end: value.end,
35113
- inputId,
35114
- start: value.start
35115
- };
35116
- } else {
35117
- fixed[name] = value;
35233
+ } else if (name === 'source') {
35234
+ if (value == null) continue
35235
+ let inputId = inputs.get(value.input);
35236
+ if (inputId == null) {
35237
+ inputId = inputs.size;
35238
+ inputs.set(value.input, inputId);
35239
+ }
35240
+ fixed[name] = {
35241
+ end: value.end,
35242
+ inputId,
35243
+ start: value.start
35244
+ };
35245
+ } else {
35246
+ fixed[name] = value;
35247
+ }
35118
35248
  }
35119
35249
  }
35120
35250
 
35251
+ let fixed = holderOfRoot[0];
35121
35252
  if (emitInputs) {
35122
35253
  fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
35123
35254
  }
@@ -35221,18 +35352,25 @@ function requireContainer$1 () {
35221
35352
  let AtRule, parse, Root, Rule;
35222
35353
 
35223
35354
  function cleanSource(nodes) {
35224
- return nodes.map(i => {
35225
- if (i.nodes) i.nodes = cleanSource(i.nodes);
35226
- delete i.source;
35227
- return i
35228
- })
35355
+ let stack = nodes.slice();
35356
+ while (stack.length > 0) {
35357
+ let node = stack.pop();
35358
+ delete node.source;
35359
+ if (node.nodes) {
35360
+ node.nodes = node.nodes.slice();
35361
+ for (let i of node.nodes) stack.push(i);
35362
+ }
35363
+ }
35364
+ return nodes.slice()
35229
35365
  }
35230
35366
 
35231
35367
  function markTreeDirty(node) {
35232
- node[isClean] = false;
35233
- if (node.proxyOf.nodes) {
35234
- for (let i of node.proxyOf.nodes) {
35235
- markTreeDirty(i);
35368
+ let stack = [node];
35369
+ while (stack.length > 0) {
35370
+ let next = stack.pop();
35371
+ next[isClean] = false;
35372
+ if (next.proxyOf.nodes) {
35373
+ for (let i of next.proxyOf.nodes) stack.push(i);
35236
35374
  }
35237
35375
  }
35238
35376
  }
@@ -35260,9 +35398,18 @@ function requireContainer$1 () {
35260
35398
  }
35261
35399
 
35262
35400
  cleanRaws(keepBetween) {
35263
- super.cleanRaws(keepBetween);
35264
- if (this.nodes) {
35265
- for (let node of this.nodes) node.cleanRaws(keepBetween);
35401
+ let stack = [this];
35402
+ while (stack.length > 0) {
35403
+ let node = stack.pop();
35404
+ if (node !== this && node.cleanRaws !== Container.prototype.cleanRaws) {
35405
+ // Subclass with own logic; let it handle its subtree
35406
+ node.cleanRaws(keepBetween);
35407
+ continue
35408
+ }
35409
+ Node.prototype.cleanRaws.call(node, keepBetween);
35410
+ if (node.nodes) {
35411
+ for (let child of node.nodes) stack.push(child);
35412
+ }
35266
35413
  }
35267
35414
  }
35268
35415
 
@@ -35522,19 +35669,48 @@ function requireContainer$1 () {
35522
35669
  }
35523
35670
 
35524
35671
  walk(callback) {
35525
- return this.each((child, i) => {
35672
+ if (!this.proxyOf.nodes) return undefined
35673
+
35674
+ // An explicit stack instead of recursive `each()` calls to survive
35675
+ // deeply nested trees. Each frame keeps a live `indexes` slot, so
35676
+ // insertion and removal during the walk behave like `each()`: the
35677
+ // slot stays at the current child until its subtree is finished.
35678
+ let stack = [{ iterator: this.getIterator(), node: this.proxyOf }];
35679
+
35680
+ while (stack.length > 0) {
35681
+ let { iterator, node } = stack[stack.length - 1];
35682
+ let index = node.indexes[iterator];
35683
+
35684
+ if (index >= node.proxyOf.nodes.length) {
35685
+ delete node.indexes[iterator];
35686
+ stack.pop();
35687
+ let parent = stack[stack.length - 1];
35688
+ // Finish the parent’s step for the child subtree we just left
35689
+ if (parent) parent.node.indexes[parent.iterator] += 1;
35690
+ continue
35691
+ }
35692
+
35693
+ let child = node.proxyOf.nodes[index];
35526
35694
  let result;
35527
35695
  try {
35528
- result = callback(child, i);
35696
+ result = callback(child, index);
35529
35697
  } catch (e) {
35530
35698
  throw child.addToError(e)
35531
35699
  }
35532
- if (result !== false && child.walk) {
35533
- result = child.walk(callback);
35700
+ if (result === false) {
35701
+ for (let opened of stack) {
35702
+ delete opened.node.indexes[opened.iterator];
35703
+ }
35704
+ return false
35534
35705
  }
35706
+ if (child.walk && child.proxyOf.nodes) {
35707
+ stack.push({ iterator: child.getIterator(), node: child });
35708
+ } else {
35709
+ node.indexes[iterator] += 1;
35710
+ }
35711
+ }
35535
35712
 
35536
- return result
35537
- })
35713
+ return undefined
35538
35714
  }
35539
35715
 
35540
35716
  walkAtRules(name, callback) {
@@ -35637,24 +35813,26 @@ function requireContainer$1 () {
35637
35813
 
35638
35814
  /* c8 ignore start */
35639
35815
  Container.rebuild = node => {
35640
- if (node.type === 'atrule') {
35641
- Object.setPrototypeOf(node, AtRule.prototype);
35642
- } else if (node.type === 'rule') {
35643
- Object.setPrototypeOf(node, Rule.prototype);
35644
- } else if (node.type === 'decl') {
35645
- Object.setPrototypeOf(node, Declaration.prototype);
35646
- } else if (node.type === 'comment') {
35647
- Object.setPrototypeOf(node, Comment.prototype);
35648
- } else if (node.type === 'root') {
35649
- Object.setPrototypeOf(node, Root.prototype);
35650
- }
35816
+ let stack = [node];
35817
+ while (stack.length > 0) {
35818
+ let next = stack.pop();
35819
+ if (next.type === 'atrule') {
35820
+ Object.setPrototypeOf(next, AtRule.prototype);
35821
+ } else if (next.type === 'rule') {
35822
+ Object.setPrototypeOf(next, Rule.prototype);
35823
+ } else if (next.type === 'decl') {
35824
+ Object.setPrototypeOf(next, Declaration.prototype);
35825
+ } else if (next.type === 'comment') {
35826
+ Object.setPrototypeOf(next, Comment.prototype);
35827
+ } else if (next.type === 'root') {
35828
+ Object.setPrototypeOf(next, Root.prototype);
35829
+ }
35651
35830
 
35652
- node[my] = true;
35831
+ next[my] = true;
35653
35832
 
35654
- if (node.nodes) {
35655
- node.nodes.forEach(child => {
35656
- Container.rebuild(child);
35657
- });
35833
+ if (next.nodes) {
35834
+ for (let child of next.nodes) stack.push(child);
35835
+ }
35658
35836
  }
35659
35837
  };
35660
35838
  /* c8 ignore stop */
@@ -35788,7 +35966,7 @@ function requirePreviousMap () {
35788
35966
  hasRequiredPreviousMap = 1;
35789
35967
 
35790
35968
  let { existsSync, readFileSync } = require$$0$1;
35791
- let { dirname, join } = require$$1;
35969
+ let { dirname, isAbsolute, join, relative, sep } = require$$1;
35792
35970
  let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
35793
35971
 
35794
35972
  function fromBase64(str) {
@@ -35872,11 +36050,20 @@ function requirePreviousMap () {
35872
36050
  }
35873
36051
 
35874
36052
  loadFile(path, cssFile, trusted) {
35875
- /* c8 ignore next 5 */
35876
36053
  if (!trusted && !this.unsafeMap) {
35877
36054
  if (!/\.map$/i.test(path)) {
35878
36055
  return undefined
35879
36056
  }
36057
+ if (cssFile) {
36058
+ let relativePath = relative(dirname(cssFile), path);
36059
+ if (
36060
+ relativePath === '..' ||
36061
+ relativePath.startsWith('..' + sep) ||
36062
+ isAbsolute(relativePath)
36063
+ ) {
36064
+ return undefined
36065
+ }
36066
+ }
35880
36067
  }
35881
36068
  this.root = dirname(path);
35882
36069
  if (existsSync(path)) {
@@ -36162,12 +36349,21 @@ function requireInput () {
36162
36349
  if (!this.map) return false
36163
36350
  let consumer = this.map.consumer();
36164
36351
 
36165
- let from = consumer.originalPositionFor({ column, line });
36352
+ let from = consumer.originalPositionFor({ column: column - 1, line });
36166
36353
  if (!from.source) return false
36167
36354
 
36168
36355
  let to;
36169
36356
  if (typeof endLine === 'number') {
36170
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
36357
+ let toPosition = consumer.originalPositionFor({
36358
+ column: endColumn - 1,
36359
+ line: endLine
36360
+ });
36361
+ // The source map may not have a mapping that covers the end position
36362
+ // (`originalPositionFor()` then returns `null` for `line`/`column`
36363
+ // instead of omitting them). Treat that the same as not requesting
36364
+ // an end position at all, so `endLine`/`endColumn` stay a consistent
36365
+ // `undefined` pair instead of a mix of `null` and a bogus number.
36366
+ if (toPosition.source) to = toPosition;
36171
36367
  }
36172
36368
 
36173
36369
  let fromUrl;
@@ -36182,8 +36378,8 @@ function requireInput () {
36182
36378
  }
36183
36379
 
36184
36380
  let result = {
36185
- column: from.column,
36186
- endColumn: to && to.column,
36381
+ column: from.column + 1,
36382
+ endColumn: to && to.column + 1,
36187
36383
  endLine: to && to.line,
36188
36384
  line: from.line,
36189
36385
  url: fromUrl.toString()
@@ -36249,6 +36445,19 @@ function requireRoot$1 () {
36249
36445
  }
36250
36446
 
36251
36447
  normalize(child, sample, type) {
36448
+ let keepBefore = new Set();
36449
+ for (let node of Array.isArray(child) ? child : [child]) {
36450
+ if (
36451
+ node &&
36452
+ typeof node === 'object' &&
36453
+ !node.parent &&
36454
+ node.raws &&
36455
+ typeof node.raws.before !== 'undefined'
36456
+ ) {
36457
+ keepBefore.add(node.raws);
36458
+ }
36459
+ }
36460
+
36252
36461
  let nodes = super.normalize(child);
36253
36462
 
36254
36463
  if (sample) {
@@ -36260,7 +36469,9 @@ function requireRoot$1 () {
36260
36469
  }
36261
36470
  } else if (this.first !== sample) {
36262
36471
  for (let node of nodes) {
36263
- node.raws.before = sample.raws.before;
36472
+ if (!keepBefore.has(node.raws)) {
36473
+ node.raws.before = sample.raws.before;
36474
+ }
36264
36475
  }
36265
36476
  }
36266
36477
  }
@@ -36415,26 +36626,24 @@ function requireFromJSON () {
36415
36626
  let Root = /*@__PURE__*/ requireRoot$1();
36416
36627
  let Rule = /*@__PURE__*/ requireRule();
36417
36628
 
36418
- function fromJSON(json, inputs) {
36419
- if (Array.isArray(json)) return json.map(n => fromJSON(n))
36420
-
36421
- let { inputs: ownInputs, ...defaults } = json;
36422
- if (ownInputs) {
36423
- inputs = [];
36424
- for (let input of ownInputs) {
36425
- let inputHydrated = { ...input, __proto__: Input.prototype };
36426
- if (inputHydrated.map) {
36427
- inputHydrated.map = {
36428
- ...inputHydrated.map,
36429
- __proto__: PreviousMap.prototype
36430
- };
36431
- }
36432
- inputs.push(inputHydrated);
36629
+ function hydrateInputs(json, inputs) {
36630
+ if (!json.inputs) return inputs
36631
+ return json.inputs.map(input => {
36632
+ let inputHydrated = { ...input, __proto__: Input.prototype };
36633
+ if (inputHydrated.map) {
36634
+ inputHydrated.map = {
36635
+ ...inputHydrated.map,
36636
+ __proto__: PreviousMap.prototype
36637
+ };
36433
36638
  }
36434
- }
36435
- if (defaults.nodes) {
36436
- defaults.nodes = json.nodes.map(n => fromJSON(n, inputs));
36437
- }
36639
+ return inputHydrated
36640
+ })
36641
+ }
36642
+
36643
+ function constructNode(json, inputs, children) {
36644
+ let defaults = { ...json };
36645
+ delete defaults.inputs;
36646
+ delete defaults.nodes;
36438
36647
  if (defaults.source) {
36439
36648
  let { inputId, ...source } = defaults.source;
36440
36649
  defaults.source = source;
@@ -36442,19 +36651,74 @@ function requireFromJSON () {
36442
36651
  defaults.source.input = inputs[inputId];
36443
36652
  }
36444
36653
  }
36654
+
36655
+ let node;
36445
36656
  if (defaults.type === 'root') {
36446
- return new Root(defaults)
36657
+ node = new Root(defaults);
36447
36658
  } else if (defaults.type === 'decl') {
36448
- return new Declaration(defaults)
36659
+ node = new Declaration(defaults);
36449
36660
  } else if (defaults.type === 'rule') {
36450
- return new Rule(defaults)
36661
+ node = new Rule(defaults);
36451
36662
  } else if (defaults.type === 'comment') {
36452
- return new Comment(defaults)
36663
+ node = new Comment(defaults);
36453
36664
  } else if (defaults.type === 'atrule') {
36454
- return new AtRule(defaults)
36665
+ node = new AtRule(defaults);
36455
36666
  } else {
36456
36667
  throw new Error('Unknown node type: ' + json.type)
36457
36668
  }
36669
+
36670
+ // Rehydrated children are attached after construction. Passing them
36671
+ // through the container constructor would re-run insertion spacing
36672
+ // normalization and overwrite each child's own `raws.before`.
36673
+ if (children) {
36674
+ node.nodes = children;
36675
+ for (let child of children) child.parent = node;
36676
+ }
36677
+
36678
+ return node
36679
+ }
36680
+
36681
+ function fromJSON(json, inputs) {
36682
+ if (Array.isArray(json)) return json.map(n => fromJSON(n))
36683
+
36684
+ // An explicit stack instead of recursive calls to survive deeply
36685
+ // nested trees. Children are rehydrated before their parent node
36686
+ // is constructed.
36687
+ let result;
36688
+ let stack = [
36689
+ { childIndex: 0, children: [], inputs: hydrateInputs(json, inputs), json }
36690
+ ];
36691
+
36692
+ while (stack.length > 0) {
36693
+ let frame = stack[stack.length - 1];
36694
+ let jsonNodes = frame.json.nodes;
36695
+
36696
+ if (jsonNodes && frame.childIndex < jsonNodes.length) {
36697
+ let childJson = jsonNodes[frame.childIndex];
36698
+ frame.childIndex += 1;
36699
+ stack.push({
36700
+ childIndex: 0,
36701
+ children: [],
36702
+ inputs: hydrateInputs(childJson, frame.inputs),
36703
+ json: childJson
36704
+ });
36705
+ continue
36706
+ }
36707
+
36708
+ stack.pop();
36709
+ let node = constructNode(
36710
+ frame.json,
36711
+ frame.inputs,
36712
+ jsonNodes ? frame.children : undefined
36713
+ );
36714
+ if (stack.length > 0) {
36715
+ stack[stack.length - 1].children.push(node);
36716
+ } else {
36717
+ result = node;
36718
+ }
36719
+ }
36720
+
36721
+ return result
36458
36722
  }
36459
36723
 
36460
36724
  fromJSON_1 = fromJSON;
@@ -37743,8 +38007,14 @@ function requireLazyResult () {
37743
38007
  }
37744
38008
 
37745
38009
  function cleanMarks(node) {
37746
- node[isClean] = false;
37747
- if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
38010
+ let stack = [node];
38011
+ while (stack.length > 0) {
38012
+ let next = stack.pop();
38013
+ next[isClean] = false;
38014
+ if (next.nodes) {
38015
+ for (let i of next.nodes) stack.push(i);
38016
+ }
38017
+ }
37748
38018
  return node
37749
38019
  }
37750
38020
 
@@ -38175,21 +38445,57 @@ function requireLazyResult () {
38175
38445
  }
38176
38446
 
38177
38447
  walkSync(node) {
38448
+ // An explicit stack like in async `visitTick()` to survive deeply
38449
+ // nested trees. Unlike `visitTick()`, nodes are marked clean only
38450
+ // on entering, so a node dirtied by its own visitors is revisited
38451
+ // on the next pass.
38178
38452
  node[isClean] = true;
38179
- let events = getEvents(node);
38180
- for (let event of events) {
38181
- if (event === CHILDREN) {
38182
- if (node.nodes) {
38183
- node.each(child => {
38184
- if (!child[isClean]) this.walkSync(child);
38185
- });
38453
+ let stack = [{ eventIndex: 0, events: getEvents(node), iterator: 0, node }];
38454
+
38455
+ while (stack.length > 0) {
38456
+ let visit = stack[stack.length - 1];
38457
+ let visitNode = visit.node;
38458
+
38459
+ if (visit.iterator !== 0) {
38460
+ let iterator = visit.iterator;
38461
+ let child;
38462
+ let descended = false;
38463
+ while ((child = visitNode.nodes[visitNode.indexes[iterator]])) {
38464
+ visitNode.indexes[iterator] += 1;
38465
+ if (!child[isClean]) {
38466
+ child[isClean] = true;
38467
+ stack.push({
38468
+ eventIndex: 0,
38469
+ events: getEvents(child),
38470
+ iterator: 0,
38471
+ node: child
38472
+ });
38473
+ descended = true;
38474
+ break
38475
+ }
38186
38476
  }
38187
- } else {
38188
- let visitors = this.listeners[event];
38189
- if (visitors) {
38190
- if (this.visitSync(visitors, node.toProxy())) return
38477
+ if (descended) continue
38478
+ visit.iterator = 0;
38479
+ delete visitNode.indexes[iterator];
38480
+ }
38481
+
38482
+ if (visit.eventIndex < visit.events.length) {
38483
+ let event = visit.events[visit.eventIndex];
38484
+ visit.eventIndex += 1;
38485
+ if (event === CHILDREN) {
38486
+ if (visitNode.nodes && visitNode.nodes.length) {
38487
+ visit.iterator = visitNode.getIterator();
38488
+ }
38489
+ } else {
38490
+ let visitors = this.listeners[event];
38491
+ if (visitors) {
38492
+ if (this.visitSync(visitors, visitNode.toProxy())) stack.pop();
38493
+ }
38191
38494
  }
38495
+ continue
38192
38496
  }
38497
+
38498
+ stack.pop();
38193
38499
  }
38194
38500
  }
38195
38501
 
@@ -38369,7 +38675,7 @@ function requireProcessor$1 () {
38369
38675
 
38370
38676
  class Processor {
38371
38677
  constructor(plugins = []) {
38372
- this.version = '8.5.15';
38678
+ this.version = '8.5.19';
38373
38679
  this.plugins = this.normalize(plugins);
38374
38680
  }
38375
38681
 
@@ -51470,7 +51776,7 @@ var __spreadValues = (a, b) => {
51470
51776
  }
51471
51777
  return a;
51472
51778
  };
51473
- const version = "3.5.39";
51779
+ const version = "3.5.40";
51474
51780
  const parseCache = parseCache$1;
51475
51781
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
51476
51782
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.5.39",
3
+ "version": "3.5.40",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -45,12 +45,12 @@
45
45
  "@babel/parser": "^7.29.7",
46
46
  "estree-walker": "^2.0.2",
47
47
  "magic-string": "^0.30.21",
48
- "postcss": "^8.5.15",
48
+ "postcss": "^8.5.19",
49
49
  "source-map-js": "^1.2.1",
50
- "@vue/compiler-core": "3.5.39",
51
- "@vue/compiler-ssr": "3.5.39",
52
- "@vue/shared": "3.5.39",
53
- "@vue/compiler-dom": "3.5.39"
50
+ "@vue/compiler-core": "3.5.40",
51
+ "@vue/compiler-ssr": "3.5.40",
52
+ "@vue/compiler-dom": "3.5.40",
53
+ "@vue/shared": "3.5.40"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.29.7",