@vue/compiler-core 3.3.9 → 3.4.0-alpha.2

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.
@@ -3,86 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var shared = require('@vue/shared');
6
+ var decode_js = require('entities/lib/decode.js');
6
7
  var parser = require('@babel/parser');
7
8
  var sourceMapJs = require('source-map-js');
8
9
  var estreeWalker = require('estree-walker');
9
10
 
10
- function defaultOnError(error) {
11
- throw error;
12
- }
13
- function defaultOnWarn(msg) {
14
- }
15
- function createCompilerError(code, loc, messages, additionalMessage) {
16
- const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
17
- const error = new SyntaxError(String(msg));
18
- error.code = code;
19
- error.loc = loc;
20
- return error;
21
- }
22
- const errorMessages = {
23
- // parse errors
24
- [0]: "Illegal comment.",
25
- [1]: "CDATA section is allowed only in XML context.",
26
- [2]: "Duplicate attribute.",
27
- [3]: "End tag cannot have attributes.",
28
- [4]: "Illegal '/' in tags.",
29
- [5]: "Unexpected EOF in tag.",
30
- [6]: "Unexpected EOF in CDATA section.",
31
- [7]: "Unexpected EOF in comment.",
32
- [8]: "Unexpected EOF in script.",
33
- [9]: "Unexpected EOF in tag.",
34
- [10]: "Incorrectly closed comment.",
35
- [11]: "Incorrectly opened comment.",
36
- [12]: "Illegal tag name. Use '&lt;' to print '<'.",
37
- [13]: "Attribute value was expected.",
38
- [14]: "End tag name was expected.",
39
- [15]: "Whitespace was expected.",
40
- [16]: "Unexpected '<!--' in comment.",
41
- [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
42
- [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
43
- [19]: "Attribute name cannot start with '='.",
44
- [21]: "'<?' is allowed only in XML context.",
45
- [20]: `Unexpected null character.`,
46
- [22]: "Illegal '/' in tags.",
47
- // Vue-specific parse errors
48
- [23]: "Invalid end tag.",
49
- [24]: "Element is missing end tag.",
50
- [25]: "Interpolation end sign was not found.",
51
- [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
52
- [26]: "Legal directive name was expected.",
53
- // transform errors
54
- [28]: `v-if/v-else-if is missing expression.`,
55
- [29]: `v-if/else branches must use unique keys.`,
56
- [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
57
- [31]: `v-for is missing expression.`,
58
- [32]: `v-for has invalid expression.`,
59
- [33]: `<template v-for> key should be placed on the <template> tag.`,
60
- [34]: `v-bind is missing expression.`,
61
- [35]: `v-on is missing expression.`,
62
- [36]: `Unexpected custom directive on <slot> outlet.`,
63
- [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
64
- [38]: `Duplicate slot names found. `,
65
- [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
66
- [40]: `v-slot can only be used on components or <template> tags.`,
67
- [41]: `v-model is missing expression.`,
68
- [42]: `v-model value must be a valid JavaScript member expression.`,
69
- [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
70
- [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
71
- Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
72
- [45]: `Error parsing JavaScript expression: `,
73
- [46]: `<KeepAlive> expects exactly one child component.`,
74
- // generic errors
75
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
76
- [48]: `ES module mode is not supported in this build of compiler.`,
77
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
78
- [50]: `"scopeId" option is only supported in module mode.`,
79
- // deprecations
80
- [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
81
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
82
- // just to fulfill types
83
- [53]: ``
84
- };
85
-
86
11
  const FRAGMENT = Symbol(``);
87
12
  const TELEPORT = Symbol(``);
88
13
  const SUSPENSE = Symbol(``);
@@ -172,13 +97,14 @@ function registerRuntimeHelpers(helpers) {
172
97
  }
173
98
 
174
99
  const locStub = {
175
- source: "",
176
100
  start: { line: 1, column: 1, offset: 0 },
177
- end: { line: 1, column: 1, offset: 0 }
101
+ end: { line: 1, column: 1, offset: 0 },
102
+ source: ""
178
103
  };
179
- function createRoot(children, loc = locStub) {
104
+ function createRoot(children, source = "") {
180
105
  return {
181
106
  type: 0,
107
+ source,
182
108
  children,
183
109
  helpers: /* @__PURE__ */ new Set(),
184
110
  components: [],
@@ -188,7 +114,7 @@ function createRoot(children, loc = locStub) {
188
114
  cached: 0,
189
115
  temps: 0,
190
116
  codegenNode: void 0,
191
- loc
117
+ loc: locStub
192
118
  };
193
119
  }
194
120
  function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
@@ -359,17 +285,1028 @@ function convertToBlock(node, { helper, removeHelper, inSSR }) {
359
285
  }
360
286
  }
361
287
 
288
+ const defaultDelimitersOpen = new Uint8Array([123, 123]);
289
+ const defaultDelimitersClose = new Uint8Array([125, 125]);
290
+ function isTagStartChar(c) {
291
+ return c >= 97 && c <= 122 || c >= 65 && c <= 90;
292
+ }
293
+ function isWhitespace(c) {
294
+ return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
295
+ }
296
+ function isEndOfTagSection(c) {
297
+ return c === 47 || c === 62 || isWhitespace(c);
298
+ }
299
+ function toCharCodes(str) {
300
+ const ret = new Uint8Array(str.length);
301
+ for (let i = 0; i < str.length; i++) {
302
+ ret[i] = str.charCodeAt(i);
303
+ }
304
+ return ret;
305
+ }
306
+ const Sequences = {
307
+ Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
308
+ // CDATA[
309
+ CdataEnd: new Uint8Array([93, 93, 62]),
310
+ // ]]>
311
+ CommentEnd: new Uint8Array([45, 45, 62]),
312
+ // `-->`
313
+ ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
314
+ // `<\/script`
315
+ StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
316
+ // `</style`
317
+ TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
318
+ // `</title`
319
+ TextareaEnd: new Uint8Array([
320
+ 60,
321
+ 47,
322
+ 116,
323
+ 101,
324
+ 120,
325
+ 116,
326
+ 97,
327
+ 114,
328
+ 101,
329
+ 97
330
+ ])
331
+ // `</textarea
332
+ };
333
+ class Tokenizer {
334
+ constructor(stack, cbs) {
335
+ this.stack = stack;
336
+ this.cbs = cbs;
337
+ /** The current state the tokenizer is in. */
338
+ this.state = 1;
339
+ /** The read buffer. */
340
+ this.buffer = "";
341
+ /** The beginning of the section that is currently being read. */
342
+ this.sectionStart = 0;
343
+ /** The index within the buffer that we are currently looking at. */
344
+ this.index = 0;
345
+ /** The start of the last entity. */
346
+ this.entityStart = 0;
347
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
348
+ this.baseState = 1;
349
+ /** For special parsing behavior inside of script and style tags. */
350
+ this.inRCDATA = false;
351
+ /** For disabling RCDATA tags handling */
352
+ this.inXML = false;
353
+ /** Reocrd newline positions for fast line / column calculation */
354
+ this.newlines = [];
355
+ this.mode = 0;
356
+ this.delimiterOpen = defaultDelimitersOpen;
357
+ this.delimiterClose = defaultDelimitersClose;
358
+ this.delimiterIndex = -1;
359
+ this.currentSequence = void 0;
360
+ this.sequenceIndex = 0;
361
+ {
362
+ this.entityDecoder = new decode_js.EntityDecoder(
363
+ decode_js.htmlDecodeTree,
364
+ (cp, consumed) => this.emitCodePoint(cp, consumed)
365
+ );
366
+ }
367
+ }
368
+ get inSFCRoot() {
369
+ return this.mode === 2 && this.stack.length === 0;
370
+ }
371
+ reset() {
372
+ this.state = 1;
373
+ this.mode = 0;
374
+ this.buffer = "";
375
+ this.sectionStart = 0;
376
+ this.index = 0;
377
+ this.baseState = 1;
378
+ this.currentSequence = void 0;
379
+ this.newlines.length = 0;
380
+ this.delimiterOpen = defaultDelimitersOpen;
381
+ this.delimiterClose = defaultDelimitersClose;
382
+ }
383
+ /**
384
+ * Generate Position object with line / column information using recorded
385
+ * newline positions. We know the index is always going to be an already
386
+ * processed index, so all the newlines up to this index should have been
387
+ * recorded.
388
+ */
389
+ getPos(index) {
390
+ let line = 1;
391
+ let column = index + 1;
392
+ for (let i = this.newlines.length - 1; i >= 0; i--) {
393
+ const newlineIndex = this.newlines[i];
394
+ if (index > newlineIndex) {
395
+ line = i + 2;
396
+ column = index - newlineIndex;
397
+ break;
398
+ }
399
+ }
400
+ return {
401
+ column,
402
+ line,
403
+ offset: index
404
+ };
405
+ }
406
+ peek() {
407
+ return this.buffer.charCodeAt(this.index + 1);
408
+ }
409
+ stateText(c) {
410
+ if (c === 60) {
411
+ if (this.index > this.sectionStart) {
412
+ this.cbs.ontext(this.sectionStart, this.index);
413
+ }
414
+ this.state = 5;
415
+ this.sectionStart = this.index;
416
+ } else if (c === 38) {
417
+ this.startEntity();
418
+ } else if (c === this.delimiterOpen[0]) {
419
+ this.state = 2;
420
+ this.delimiterIndex = 0;
421
+ this.stateInterpolationOpen(c);
422
+ }
423
+ }
424
+ stateInterpolationOpen(c) {
425
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
426
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
427
+ const start = this.index + 1 - this.delimiterOpen.length;
428
+ if (start > this.sectionStart) {
429
+ this.cbs.ontext(this.sectionStart, start);
430
+ }
431
+ this.state = 3;
432
+ this.sectionStart = start;
433
+ } else {
434
+ this.delimiterIndex++;
435
+ }
436
+ } else if (this.inRCDATA) {
437
+ this.state = 32;
438
+ this.stateInRCDATA(c);
439
+ } else {
440
+ this.state = 1;
441
+ this.stateText(c);
442
+ }
443
+ }
444
+ stateInterpolation(c) {
445
+ if (c === this.delimiterClose[0]) {
446
+ this.state = 4;
447
+ this.delimiterIndex = 0;
448
+ this.stateInterpolationClose(c);
449
+ }
450
+ }
451
+ stateInterpolationClose(c) {
452
+ if (c === this.delimiterClose[this.delimiterIndex]) {
453
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
454
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
455
+ if (this.inRCDATA) {
456
+ this.state = 32;
457
+ } else {
458
+ this.state = 1;
459
+ }
460
+ this.sectionStart = this.index + 1;
461
+ } else {
462
+ this.delimiterIndex++;
463
+ }
464
+ } else {
465
+ this.state = 3;
466
+ this.stateInterpolation(c);
467
+ }
468
+ }
469
+ stateSpecialStartSequence(c) {
470
+ const isEnd = this.sequenceIndex === this.currentSequence.length;
471
+ const isMatch = isEnd ? (
472
+ // If we are at the end of the sequence, make sure the tag name has ended
473
+ isEndOfTagSection(c)
474
+ ) : (
475
+ // Otherwise, do a case-insensitive comparison
476
+ (c | 32) === this.currentSequence[this.sequenceIndex]
477
+ );
478
+ if (!isMatch) {
479
+ this.inRCDATA = false;
480
+ } else if (!isEnd) {
481
+ this.sequenceIndex++;
482
+ return;
483
+ }
484
+ this.sequenceIndex = 0;
485
+ this.state = 6;
486
+ this.stateInTagName(c);
487
+ }
488
+ /** Look for an end tag. For <title> and <textarea>, also decode entities. */
489
+ stateInRCDATA(c) {
490
+ if (this.sequenceIndex === this.currentSequence.length) {
491
+ if (c === 62 || isWhitespace(c)) {
492
+ const endOfText = this.index - this.currentSequence.length;
493
+ if (this.sectionStart < endOfText) {
494
+ const actualIndex = this.index;
495
+ this.index = endOfText;
496
+ this.cbs.ontext(this.sectionStart, endOfText);
497
+ this.index = actualIndex;
498
+ }
499
+ this.sectionStart = endOfText + 2;
500
+ this.stateInClosingTagName(c);
501
+ this.inRCDATA = false;
502
+ return;
503
+ }
504
+ this.sequenceIndex = 0;
505
+ }
506
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
507
+ this.sequenceIndex += 1;
508
+ } else if (this.sequenceIndex === 0) {
509
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
510
+ if (c === 38) {
511
+ this.startEntity();
512
+ } else if (c === this.delimiterOpen[0]) {
513
+ this.state = 2;
514
+ this.delimiterIndex = 0;
515
+ this.stateInterpolationOpen(c);
516
+ }
517
+ } else if (this.fastForwardTo(60)) {
518
+ this.sequenceIndex = 1;
519
+ }
520
+ } else {
521
+ this.sequenceIndex = Number(c === 60);
522
+ }
523
+ }
524
+ stateCDATASequence(c) {
525
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
526
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
527
+ this.state = 28;
528
+ this.currentSequence = Sequences.CdataEnd;
529
+ this.sequenceIndex = 0;
530
+ this.sectionStart = this.index + 1;
531
+ }
532
+ } else {
533
+ this.sequenceIndex = 0;
534
+ this.state = 23;
535
+ this.stateInDeclaration(c);
536
+ }
537
+ }
538
+ /**
539
+ * When we wait for one specific character, we can speed things up
540
+ * by skipping through the buffer until we find it.
541
+ *
542
+ * @returns Whether the character was found.
543
+ */
544
+ fastForwardTo(c) {
545
+ while (++this.index < this.buffer.length) {
546
+ const cc = this.buffer.charCodeAt(this.index);
547
+ if (cc === 10) {
548
+ this.newlines.push(this.index);
549
+ }
550
+ if (cc === c) {
551
+ return true;
552
+ }
553
+ }
554
+ this.index = this.buffer.length - 1;
555
+ return false;
556
+ }
557
+ /**
558
+ * Comments and CDATA end with `-->` and `]]>`.
559
+ *
560
+ * Their common qualities are:
561
+ * - Their end sequences have a distinct character they start with.
562
+ * - That character is then repeated, so we have to check multiple repeats.
563
+ * - All characters but the start character of the sequence can be skipped.
564
+ */
565
+ stateInCommentLike(c) {
566
+ if (c === this.currentSequence[this.sequenceIndex]) {
567
+ if (++this.sequenceIndex === this.currentSequence.length) {
568
+ if (this.currentSequence === Sequences.CdataEnd) {
569
+ this.cbs.oncdata(this.sectionStart, this.index - 2);
570
+ } else {
571
+ this.cbs.oncomment(this.sectionStart, this.index - 2);
572
+ }
573
+ this.sequenceIndex = 0;
574
+ this.sectionStart = this.index + 1;
575
+ this.state = 1;
576
+ }
577
+ } else if (this.sequenceIndex === 0) {
578
+ if (this.fastForwardTo(this.currentSequence[0])) {
579
+ this.sequenceIndex = 1;
580
+ }
581
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
582
+ this.sequenceIndex = 0;
583
+ }
584
+ }
585
+ startSpecial(sequence, offset) {
586
+ this.enterRCDATA(sequence, offset);
587
+ this.state = 31;
588
+ }
589
+ enterRCDATA(sequence, offset) {
590
+ this.inRCDATA = true;
591
+ this.currentSequence = sequence;
592
+ this.sequenceIndex = offset;
593
+ }
594
+ stateBeforeTagName(c) {
595
+ if (c === 33) {
596
+ this.state = 22;
597
+ this.sectionStart = this.index + 1;
598
+ } else if (c === 63) {
599
+ this.state = 24;
600
+ this.sectionStart = this.index + 1;
601
+ } else if (isTagStartChar(c)) {
602
+ this.sectionStart = this.index;
603
+ if (this.mode === 0) {
604
+ this.state = 6;
605
+ } else if (this.inSFCRoot) {
606
+ this.state = 34;
607
+ } else if (!this.inXML) {
608
+ const lower = c | 32;
609
+ if (lower === 116) {
610
+ this.state = 30;
611
+ } else {
612
+ this.state = lower === 115 ? 29 : 6;
613
+ }
614
+ } else {
615
+ this.state = 6;
616
+ }
617
+ } else if (c === 47) {
618
+ this.state = 8;
619
+ } else {
620
+ this.state = 1;
621
+ this.stateText(c);
622
+ }
623
+ }
624
+ stateInTagName(c) {
625
+ if (isEndOfTagSection(c)) {
626
+ this.handleTagName(c);
627
+ }
628
+ }
629
+ stateInSFCRootTagName(c) {
630
+ if (isEndOfTagSection(c)) {
631
+ const tag = this.buffer.slice(this.sectionStart, this.index);
632
+ if (tag !== "template") {
633
+ this.enterRCDATA(toCharCodes(`</` + tag), 0);
634
+ }
635
+ this.handleTagName(c);
636
+ }
637
+ }
638
+ handleTagName(c) {
639
+ this.cbs.onopentagname(this.sectionStart, this.index);
640
+ this.sectionStart = -1;
641
+ this.state = 11;
642
+ this.stateBeforeAttrName(c);
643
+ }
644
+ stateBeforeClosingTagName(c) {
645
+ if (isWhitespace(c)) ; else if (c === 62) {
646
+ {
647
+ this.cbs.onerr(14, this.index);
648
+ }
649
+ this.state = 1;
650
+ this.sectionStart = this.index + 1;
651
+ } else {
652
+ this.state = isTagStartChar(c) ? 9 : 27;
653
+ this.sectionStart = this.index;
654
+ }
655
+ }
656
+ stateInClosingTagName(c) {
657
+ if (c === 62 || isWhitespace(c)) {
658
+ this.cbs.onclosetag(this.sectionStart, this.index);
659
+ this.sectionStart = -1;
660
+ this.state = 10;
661
+ this.stateAfterClosingTagName(c);
662
+ }
663
+ }
664
+ stateAfterClosingTagName(c) {
665
+ if (c === 62) {
666
+ this.state = 1;
667
+ this.sectionStart = this.index + 1;
668
+ }
669
+ }
670
+ stateBeforeAttrName(c) {
671
+ if (c === 62) {
672
+ this.cbs.onopentagend(this.index);
673
+ if (this.inRCDATA) {
674
+ this.state = 32;
675
+ } else {
676
+ this.state = 1;
677
+ }
678
+ this.sectionStart = this.index + 1;
679
+ } else if (c === 47) {
680
+ this.state = 7;
681
+ if (this.peek() !== 62) {
682
+ this.cbs.onerr(22, this.index);
683
+ }
684
+ } else if (c === 60 && this.peek() === 47) {
685
+ this.cbs.onopentagend(this.index);
686
+ this.state = 5;
687
+ this.sectionStart = this.index;
688
+ } else if (!isWhitespace(c)) {
689
+ if (c === 61) {
690
+ this.cbs.onerr(
691
+ 19,
692
+ this.index
693
+ );
694
+ }
695
+ this.handleAttrStart(c);
696
+ }
697
+ }
698
+ handleAttrStart(c) {
699
+ if (c === 118 && this.peek() === 45) {
700
+ this.state = 13;
701
+ this.sectionStart = this.index;
702
+ } else if (c === 46 || c === 58 || c === 64 || c === 35) {
703
+ this.cbs.ondirname(this.index, this.index + 1);
704
+ this.state = 14;
705
+ this.sectionStart = this.index + 1;
706
+ } else {
707
+ this.state = 12;
708
+ this.sectionStart = this.index;
709
+ }
710
+ }
711
+ stateInSelfClosingTag(c) {
712
+ if (c === 62) {
713
+ this.cbs.onselfclosingtag(this.index);
714
+ this.state = 1;
715
+ this.sectionStart = this.index + 1;
716
+ this.inRCDATA = false;
717
+ } else if (!isWhitespace(c)) {
718
+ this.state = 11;
719
+ this.stateBeforeAttrName(c);
720
+ }
721
+ }
722
+ stateInAttrName(c) {
723
+ if (c === 61 || isEndOfTagSection(c)) {
724
+ this.cbs.onattribname(this.sectionStart, this.index);
725
+ this.handleAttrNameEnd(c);
726
+ } else if (c === 34 || c === 39 || c === 60) {
727
+ this.cbs.onerr(
728
+ 17,
729
+ this.index
730
+ );
731
+ }
732
+ }
733
+ stateInDirName(c) {
734
+ if (c === 61 || isEndOfTagSection(c)) {
735
+ this.cbs.ondirname(this.sectionStart, this.index);
736
+ this.handleAttrNameEnd(c);
737
+ } else if (c === 58) {
738
+ this.cbs.ondirname(this.sectionStart, this.index);
739
+ this.state = 14;
740
+ this.sectionStart = this.index + 1;
741
+ } else if (c === 46) {
742
+ this.cbs.ondirname(this.sectionStart, this.index);
743
+ this.state = 16;
744
+ this.sectionStart = this.index + 1;
745
+ }
746
+ }
747
+ stateInDirArg(c) {
748
+ if (c === 61 || isEndOfTagSection(c)) {
749
+ this.cbs.ondirarg(this.sectionStart, this.index);
750
+ this.handleAttrNameEnd(c);
751
+ } else if (c === 91) {
752
+ this.state = 15;
753
+ } else if (c === 46) {
754
+ this.cbs.ondirarg(this.sectionStart, this.index);
755
+ this.state = 16;
756
+ this.sectionStart = this.index + 1;
757
+ }
758
+ }
759
+ stateInDynamicDirArg(c) {
760
+ if (c === 93) {
761
+ this.state = 14;
762
+ } else if (c === 61 || isEndOfTagSection(c)) {
763
+ this.cbs.ondirarg(this.sectionStart, this.index + 1);
764
+ this.handleAttrNameEnd(c);
765
+ {
766
+ this.cbs.onerr(
767
+ 27,
768
+ this.index
769
+ );
770
+ }
771
+ }
772
+ }
773
+ stateInDirModifier(c) {
774
+ if (c === 61 || isEndOfTagSection(c)) {
775
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
776
+ this.handleAttrNameEnd(c);
777
+ } else if (c === 46) {
778
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
779
+ this.sectionStart = this.index + 1;
780
+ }
781
+ }
782
+ handleAttrNameEnd(c) {
783
+ this.sectionStart = this.index;
784
+ this.state = 17;
785
+ this.cbs.onattribnameend(this.index);
786
+ this.stateAfterAttrName(c);
787
+ }
788
+ stateAfterAttrName(c) {
789
+ if (c === 61) {
790
+ this.state = 18;
791
+ } else if (c === 47 || c === 62) {
792
+ this.cbs.onattribend(0, this.sectionStart);
793
+ this.sectionStart = -1;
794
+ this.state = 11;
795
+ this.stateBeforeAttrName(c);
796
+ } else if (!isWhitespace(c)) {
797
+ this.cbs.onattribend(0, this.sectionStart);
798
+ this.handleAttrStart(c);
799
+ }
800
+ }
801
+ stateBeforeAttrValue(c) {
802
+ if (c === 34) {
803
+ this.state = 19;
804
+ this.sectionStart = this.index + 1;
805
+ } else if (c === 39) {
806
+ this.state = 20;
807
+ this.sectionStart = this.index + 1;
808
+ } else if (!isWhitespace(c)) {
809
+ this.sectionStart = this.index;
810
+ this.state = 21;
811
+ this.stateInAttrValueNoQuotes(c);
812
+ }
813
+ }
814
+ handleInAttrValue(c, quote) {
815
+ if (c === quote || false) {
816
+ this.cbs.onattribdata(this.sectionStart, this.index);
817
+ this.sectionStart = -1;
818
+ this.cbs.onattribend(
819
+ quote === 34 ? 3 : 2,
820
+ this.index + 1
821
+ );
822
+ this.state = 11;
823
+ } else if (c === 38) {
824
+ this.startEntity();
825
+ }
826
+ }
827
+ stateInAttrValueDoubleQuotes(c) {
828
+ this.handleInAttrValue(c, 34);
829
+ }
830
+ stateInAttrValueSingleQuotes(c) {
831
+ this.handleInAttrValue(c, 39);
832
+ }
833
+ stateInAttrValueNoQuotes(c) {
834
+ if (isWhitespace(c) || c === 62) {
835
+ this.cbs.onattribdata(this.sectionStart, this.index);
836
+ this.sectionStart = -1;
837
+ this.cbs.onattribend(1, this.index);
838
+ this.state = 11;
839
+ this.stateBeforeAttrName(c);
840
+ } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
841
+ this.cbs.onerr(
842
+ 18,
843
+ this.index
844
+ );
845
+ } else if (c === 38) {
846
+ this.startEntity();
847
+ }
848
+ }
849
+ stateBeforeDeclaration(c) {
850
+ if (c === 91) {
851
+ this.state = 26;
852
+ this.sequenceIndex = 0;
853
+ } else {
854
+ this.state = c === 45 ? 25 : 23;
855
+ }
856
+ }
857
+ stateInDeclaration(c) {
858
+ if (c === 62 || this.fastForwardTo(62)) {
859
+ this.state = 1;
860
+ this.sectionStart = this.index + 1;
861
+ }
862
+ }
863
+ stateInProcessingInstruction(c) {
864
+ if (c === 62 || this.fastForwardTo(62)) {
865
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index);
866
+ this.state = 1;
867
+ this.sectionStart = this.index + 1;
868
+ }
869
+ }
870
+ stateBeforeComment(c) {
871
+ if (c === 45) {
872
+ this.state = 28;
873
+ this.currentSequence = Sequences.CommentEnd;
874
+ this.sequenceIndex = 2;
875
+ this.sectionStart = this.index + 1;
876
+ } else {
877
+ this.state = 23;
878
+ }
879
+ }
880
+ stateInSpecialComment(c) {
881
+ if (c === 62 || this.fastForwardTo(62)) {
882
+ this.cbs.oncomment(this.sectionStart, this.index);
883
+ this.state = 1;
884
+ this.sectionStart = this.index + 1;
885
+ }
886
+ }
887
+ stateBeforeSpecialS(c) {
888
+ const lower = c | 32;
889
+ if (lower === Sequences.ScriptEnd[3]) {
890
+ this.startSpecial(Sequences.ScriptEnd, 4);
891
+ } else if (lower === Sequences.StyleEnd[3]) {
892
+ this.startSpecial(Sequences.StyleEnd, 4);
893
+ } else {
894
+ this.state = 6;
895
+ this.stateInTagName(c);
896
+ }
897
+ }
898
+ stateBeforeSpecialT(c) {
899
+ const lower = c | 32;
900
+ if (lower === Sequences.TitleEnd[3]) {
901
+ this.startSpecial(Sequences.TitleEnd, 4);
902
+ } else if (lower === Sequences.TextareaEnd[3]) {
903
+ this.startSpecial(Sequences.TextareaEnd, 4);
904
+ } else {
905
+ this.state = 6;
906
+ this.stateInTagName(c);
907
+ }
908
+ }
909
+ startEntity() {
910
+ {
911
+ this.baseState = this.state;
912
+ this.state = 33;
913
+ this.entityStart = this.index;
914
+ this.entityDecoder.startEntity(
915
+ this.baseState === 1 || this.baseState === 32 ? decode_js.DecodingMode.Legacy : decode_js.DecodingMode.Attribute
916
+ );
917
+ }
918
+ }
919
+ stateInEntity() {
920
+ {
921
+ const length = this.entityDecoder.write(this.buffer, this.index);
922
+ if (length >= 0) {
923
+ this.state = this.baseState;
924
+ if (length === 0) {
925
+ this.index = this.entityStart;
926
+ }
927
+ } else {
928
+ this.index = this.buffer.length - 1;
929
+ }
930
+ }
931
+ }
932
+ /**
933
+ * Iterates through the buffer, calling the function corresponding to the current state.
934
+ *
935
+ * States that are more likely to be hit are higher up, as a performance improvement.
936
+ */
937
+ parse(input) {
938
+ this.buffer = input;
939
+ while (this.index < this.buffer.length) {
940
+ const c = this.buffer.charCodeAt(this.index);
941
+ if (c === 10) {
942
+ this.newlines.push(this.index);
943
+ }
944
+ switch (this.state) {
945
+ case 1: {
946
+ this.stateText(c);
947
+ break;
948
+ }
949
+ case 2: {
950
+ this.stateInterpolationOpen(c);
951
+ break;
952
+ }
953
+ case 3: {
954
+ this.stateInterpolation(c);
955
+ break;
956
+ }
957
+ case 4: {
958
+ this.stateInterpolationClose(c);
959
+ break;
960
+ }
961
+ case 31: {
962
+ this.stateSpecialStartSequence(c);
963
+ break;
964
+ }
965
+ case 32: {
966
+ this.stateInRCDATA(c);
967
+ break;
968
+ }
969
+ case 26: {
970
+ this.stateCDATASequence(c);
971
+ break;
972
+ }
973
+ case 19: {
974
+ this.stateInAttrValueDoubleQuotes(c);
975
+ break;
976
+ }
977
+ case 12: {
978
+ this.stateInAttrName(c);
979
+ break;
980
+ }
981
+ case 13: {
982
+ this.stateInDirName(c);
983
+ break;
984
+ }
985
+ case 14: {
986
+ this.stateInDirArg(c);
987
+ break;
988
+ }
989
+ case 15: {
990
+ this.stateInDynamicDirArg(c);
991
+ break;
992
+ }
993
+ case 16: {
994
+ this.stateInDirModifier(c);
995
+ break;
996
+ }
997
+ case 28: {
998
+ this.stateInCommentLike(c);
999
+ break;
1000
+ }
1001
+ case 27: {
1002
+ this.stateInSpecialComment(c);
1003
+ break;
1004
+ }
1005
+ case 11: {
1006
+ this.stateBeforeAttrName(c);
1007
+ break;
1008
+ }
1009
+ case 6: {
1010
+ this.stateInTagName(c);
1011
+ break;
1012
+ }
1013
+ case 34: {
1014
+ this.stateInSFCRootTagName(c);
1015
+ break;
1016
+ }
1017
+ case 9: {
1018
+ this.stateInClosingTagName(c);
1019
+ break;
1020
+ }
1021
+ case 5: {
1022
+ this.stateBeforeTagName(c);
1023
+ break;
1024
+ }
1025
+ case 17: {
1026
+ this.stateAfterAttrName(c);
1027
+ break;
1028
+ }
1029
+ case 20: {
1030
+ this.stateInAttrValueSingleQuotes(c);
1031
+ break;
1032
+ }
1033
+ case 18: {
1034
+ this.stateBeforeAttrValue(c);
1035
+ break;
1036
+ }
1037
+ case 8: {
1038
+ this.stateBeforeClosingTagName(c);
1039
+ break;
1040
+ }
1041
+ case 10: {
1042
+ this.stateAfterClosingTagName(c);
1043
+ break;
1044
+ }
1045
+ case 29: {
1046
+ this.stateBeforeSpecialS(c);
1047
+ break;
1048
+ }
1049
+ case 30: {
1050
+ this.stateBeforeSpecialT(c);
1051
+ break;
1052
+ }
1053
+ case 21: {
1054
+ this.stateInAttrValueNoQuotes(c);
1055
+ break;
1056
+ }
1057
+ case 7: {
1058
+ this.stateInSelfClosingTag(c);
1059
+ break;
1060
+ }
1061
+ case 23: {
1062
+ this.stateInDeclaration(c);
1063
+ break;
1064
+ }
1065
+ case 22: {
1066
+ this.stateBeforeDeclaration(c);
1067
+ break;
1068
+ }
1069
+ case 25: {
1070
+ this.stateBeforeComment(c);
1071
+ break;
1072
+ }
1073
+ case 24: {
1074
+ this.stateInProcessingInstruction(c);
1075
+ break;
1076
+ }
1077
+ case 33: {
1078
+ this.stateInEntity();
1079
+ break;
1080
+ }
1081
+ }
1082
+ this.index++;
1083
+ }
1084
+ this.cleanup();
1085
+ this.finish();
1086
+ }
1087
+ /**
1088
+ * Remove data that has already been consumed from the buffer.
1089
+ */
1090
+ cleanup() {
1091
+ if (this.sectionStart !== this.index) {
1092
+ if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
1093
+ this.cbs.ontext(this.sectionStart, this.index);
1094
+ this.sectionStart = this.index;
1095
+ } else if (this.state === 19 || this.state === 20 || this.state === 21) {
1096
+ this.cbs.onattribdata(this.sectionStart, this.index);
1097
+ this.sectionStart = this.index;
1098
+ }
1099
+ }
1100
+ }
1101
+ finish() {
1102
+ if (this.state === 33) {
1103
+ this.entityDecoder.end();
1104
+ this.state = this.baseState;
1105
+ }
1106
+ this.handleTrailingData();
1107
+ this.cbs.onend();
1108
+ }
1109
+ /** Handle any trailing data. */
1110
+ handleTrailingData() {
1111
+ const endIndex = this.buffer.length;
1112
+ if (this.sectionStart >= endIndex) {
1113
+ return;
1114
+ }
1115
+ if (this.state === 28) {
1116
+ if (this.currentSequence === Sequences.CdataEnd) {
1117
+ this.cbs.oncdata(this.sectionStart, endIndex);
1118
+ } else {
1119
+ this.cbs.oncomment(this.sectionStart, endIndex);
1120
+ }
1121
+ } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
1122
+ this.cbs.ontext(this.sectionStart, endIndex);
1123
+ }
1124
+ }
1125
+ emitCodePoint(cp, consumed) {
1126
+ {
1127
+ if (this.baseState !== 1 && this.baseState !== 32) {
1128
+ if (this.sectionStart < this.entityStart) {
1129
+ this.cbs.onattribdata(this.sectionStart, this.entityStart);
1130
+ }
1131
+ this.sectionStart = this.entityStart + consumed;
1132
+ this.index = this.sectionStart - 1;
1133
+ this.cbs.onattribentity(
1134
+ decode_js.fromCodePoint(cp),
1135
+ this.entityStart,
1136
+ this.sectionStart
1137
+ );
1138
+ } else {
1139
+ if (this.sectionStart < this.entityStart) {
1140
+ this.cbs.ontext(this.sectionStart, this.entityStart);
1141
+ }
1142
+ this.sectionStart = this.entityStart + consumed;
1143
+ this.index = this.sectionStart - 1;
1144
+ this.cbs.ontextentity(
1145
+ decode_js.fromCodePoint(cp),
1146
+ this.entityStart,
1147
+ this.sectionStart
1148
+ );
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+
1154
+ const deprecationData = {
1155
+ ["COMPILER_IS_ON_ELEMENT"]: {
1156
+ message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
1157
+ link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
1158
+ },
1159
+ ["COMPILER_V_BIND_SYNC"]: {
1160
+ message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
1161
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
1162
+ },
1163
+ ["COMPILER_V_BIND_OBJECT_ORDER"]: {
1164
+ message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
1165
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
1166
+ },
1167
+ ["COMPILER_V_ON_NATIVE"]: {
1168
+ message: `.native modifier for v-on has been removed as is no longer necessary.`,
1169
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
1170
+ },
1171
+ ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
1172
+ message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
1173
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
1174
+ },
1175
+ ["COMPILER_NATIVE_TEMPLATE"]: {
1176
+ message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
1177
+ },
1178
+ ["COMPILER_INLINE_TEMPLATE"]: {
1179
+ message: `"inline-template" has been removed in Vue 3.`,
1180
+ link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
1181
+ },
1182
+ ["COMPILER_FILTER"]: {
1183
+ message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
1184
+ link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
1185
+ }
1186
+ };
1187
+ function getCompatValue(key, { compatConfig }) {
1188
+ const value = compatConfig && compatConfig[key];
1189
+ if (key === "MODE") {
1190
+ return value || 3;
1191
+ } else {
1192
+ return value;
1193
+ }
1194
+ }
1195
+ function isCompatEnabled(key, context) {
1196
+ const mode = getCompatValue("MODE", context);
1197
+ const value = getCompatValue(key, context);
1198
+ return mode === 3 ? value === true : value !== false;
1199
+ }
1200
+ function checkCompatEnabled(key, context, loc, ...args) {
1201
+ const enabled = isCompatEnabled(key, context);
1202
+ return enabled;
1203
+ }
1204
+ function warnDeprecation(key, context, loc, ...args) {
1205
+ const val = getCompatValue(key, context);
1206
+ if (val === "suppress-warning") {
1207
+ return;
1208
+ }
1209
+ const { message, link } = deprecationData[key];
1210
+ const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
1211
+ Details: ${link}` : ``}`;
1212
+ const err = new SyntaxError(msg);
1213
+ err.code = key;
1214
+ if (loc)
1215
+ err.loc = loc;
1216
+ context.onWarn(err);
1217
+ }
1218
+
1219
+ function defaultOnError(error) {
1220
+ throw error;
1221
+ }
1222
+ function defaultOnWarn(msg) {
1223
+ }
1224
+ function createCompilerError(code, loc, messages, additionalMessage) {
1225
+ const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
1226
+ const error = new SyntaxError(String(msg));
1227
+ error.code = code;
1228
+ error.loc = loc;
1229
+ return error;
1230
+ }
1231
+ const errorMessages = {
1232
+ // parse errors
1233
+ [0]: "Illegal comment.",
1234
+ [1]: "CDATA section is allowed only in XML context.",
1235
+ [2]: "Duplicate attribute.",
1236
+ [3]: "End tag cannot have attributes.",
1237
+ [4]: "Illegal '/' in tags.",
1238
+ [5]: "Unexpected EOF in tag.",
1239
+ [6]: "Unexpected EOF in CDATA section.",
1240
+ [7]: "Unexpected EOF in comment.",
1241
+ [8]: "Unexpected EOF in script.",
1242
+ [9]: "Unexpected EOF in tag.",
1243
+ [10]: "Incorrectly closed comment.",
1244
+ [11]: "Incorrectly opened comment.",
1245
+ [12]: "Illegal tag name. Use '&lt;' to print '<'.",
1246
+ [13]: "Attribute value was expected.",
1247
+ [14]: "End tag name was expected.",
1248
+ [15]: "Whitespace was expected.",
1249
+ [16]: "Unexpected '<!--' in comment.",
1250
+ [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
1251
+ [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
1252
+ [19]: "Attribute name cannot start with '='.",
1253
+ [21]: "'<?' is allowed only in XML context.",
1254
+ [20]: `Unexpected null character.`,
1255
+ [22]: "Illegal '/' in tags.",
1256
+ // Vue-specific parse errors
1257
+ [23]: "Invalid end tag.",
1258
+ [24]: "Element is missing end tag.",
1259
+ [25]: "Interpolation end sign was not found.",
1260
+ [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
1261
+ [26]: "Legal directive name was expected.",
1262
+ // transform errors
1263
+ [28]: `v-if/v-else-if is missing expression.`,
1264
+ [29]: `v-if/else branches must use unique keys.`,
1265
+ [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
1266
+ [31]: `v-for is missing expression.`,
1267
+ [32]: `v-for has invalid expression.`,
1268
+ [33]: `<template v-for> key should be placed on the <template> tag.`,
1269
+ [34]: `v-bind is missing expression.`,
1270
+ [35]: `v-on is missing expression.`,
1271
+ [36]: `Unexpected custom directive on <slot> outlet.`,
1272
+ [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
1273
+ [38]: `Duplicate slot names found. `,
1274
+ [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
1275
+ [40]: `v-slot can only be used on components or <template> tags.`,
1276
+ [41]: `v-model is missing expression.`,
1277
+ [42]: `v-model value must be a valid JavaScript member expression.`,
1278
+ [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
1279
+ [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
1280
+ Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
1281
+ [45]: `Error parsing JavaScript expression: `,
1282
+ [46]: `<KeepAlive> expects exactly one child component.`,
1283
+ // generic errors
1284
+ [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
1285
+ [48]: `ES module mode is not supported in this build of compiler.`,
1286
+ [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
1287
+ [50]: `"scopeId" option is only supported in module mode.`,
1288
+ // deprecations
1289
+ [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
1290
+ [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
1291
+ // just to fulfill types
1292
+ [53]: ``
1293
+ };
1294
+
362
1295
  const isStaticExp = (p) => p.type === 4 && p.isStatic;
363
- const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
364
1296
  function isCoreComponent(tag) {
365
- if (isBuiltInType(tag, "Teleport")) {
366
- return TELEPORT;
367
- } else if (isBuiltInType(tag, "Suspense")) {
368
- return SUSPENSE;
369
- } else if (isBuiltInType(tag, "KeepAlive")) {
370
- return KEEP_ALIVE;
371
- } else if (isBuiltInType(tag, "BaseTransition")) {
372
- return BASE_TRANSITION;
1297
+ switch (tag) {
1298
+ case "Teleport":
1299
+ case "teleport":
1300
+ return TELEPORT;
1301
+ case "Suspense":
1302
+ case "suspense":
1303
+ return SUSPENSE;
1304
+ case "KeepAlive":
1305
+ case "keep-alive":
1306
+ return KEEP_ALIVE;
1307
+ case "BaseTransition":
1308
+ case "base-transition":
1309
+ return BASE_TRANSITION;
373
1310
  }
374
1311
  }
375
1312
  const nonIdentifierRE = /^\d|[^\$\w]/;
@@ -453,25 +1390,13 @@ const isMemberExpressionNode = (path, context) => {
453
1390
  }
454
1391
  };
455
1392
  const isMemberExpression = isMemberExpressionNode;
456
- function getInnerRange(loc, offset, length) {
457
- const source = loc.source.slice(offset, offset + length);
458
- const newLoc = {
459
- source,
460
- start: advancePositionWithClone(loc.start, loc.source, offset),
461
- end: loc.end
462
- };
463
- if (length != null) {
464
- newLoc.end = advancePositionWithClone(
465
- loc.start,
466
- loc.source,
467
- offset + length
468
- );
469
- }
470
- return newLoc;
471
- }
472
1393
  function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
473
1394
  return advancePositionWithMutation(
474
- shared.extend({}, pos),
1395
+ {
1396
+ offset: pos.offset,
1397
+ line: pos.line,
1398
+ column: pos.column
1399
+ },
475
1400
  source,
476
1401
  numberOfCharacters
477
1402
  );
@@ -674,437 +1599,515 @@ function getMemoedVNodeCall(node) {
674
1599
  }
675
1600
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
676
1601
 
677
- const deprecationData = {
678
- ["COMPILER_IS_ON_ELEMENT"]: {
679
- message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
680
- link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
681
- },
682
- ["COMPILER_V_BIND_SYNC"]: {
683
- message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
684
- link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
685
- },
686
- ["COMPILER_V_BIND_PROP"]: {
687
- message: `.prop modifier for v-bind has been removed and no longer necessary. Vue 3 will automatically set a binding as DOM property when appropriate.`
688
- },
689
- ["COMPILER_V_BIND_OBJECT_ORDER"]: {
690
- message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
691
- link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
692
- },
693
- ["COMPILER_V_ON_NATIVE"]: {
694
- message: `.native modifier for v-on has been removed as is no longer necessary.`,
695
- link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
696
- },
697
- ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
698
- message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
699
- link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
700
- },
701
- ["COMPILER_NATIVE_TEMPLATE"]: {
702
- message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
703
- },
704
- ["COMPILER_INLINE_TEMPLATE"]: {
705
- message: `"inline-template" has been removed in Vue 3.`,
706
- link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
707
- },
708
- ["COMPILER_FILTER"]: {
709
- message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
710
- link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
711
- }
712
- };
713
- function getCompatValue(key, context) {
714
- const config = context.options ? context.options.compatConfig : context.compatConfig;
715
- const value = config && config[key];
716
- if (key === "MODE") {
717
- return value || 3;
718
- } else {
719
- return value;
720
- }
721
- }
722
- function isCompatEnabled(key, context) {
723
- const mode = getCompatValue("MODE", context);
724
- const value = getCompatValue(key, context);
725
- return mode === 3 ? value === true : value !== false;
726
- }
727
- function checkCompatEnabled(key, context, loc, ...args) {
728
- const enabled = isCompatEnabled(key, context);
729
- return enabled;
730
- }
731
- function warnDeprecation(key, context, loc, ...args) {
732
- const val = getCompatValue(key, context);
733
- if (val === "suppress-warning") {
734
- return;
735
- }
736
- const { message, link } = deprecationData[key];
737
- const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
738
- Details: ${link}` : ``}`;
739
- const err = new SyntaxError(msg);
740
- err.code = key;
741
- if (loc)
742
- err.loc = loc;
743
- context.onWarn(err);
744
- }
745
-
746
- const decodeRE = /&(gt|lt|amp|apos|quot);/g;
747
- const decodeMap = {
748
- gt: ">",
749
- lt: "<",
750
- amp: "&",
751
- apos: "'",
752
- quot: '"'
753
- };
754
1602
  const defaultParserOptions = {
1603
+ parseMode: "base",
1604
+ ns: 0,
755
1605
  delimiters: [`{{`, `}}`],
756
1606
  getNamespace: () => 0,
757
- getTextMode: () => 0,
758
1607
  isVoidTag: shared.NO,
759
1608
  isPreTag: shared.NO,
760
1609
  isCustomElement: shared.NO,
761
- decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
762
1610
  onError: defaultOnError,
763
1611
  onWarn: defaultOnWarn,
764
1612
  comments: false
765
1613
  };
766
- function baseParse(content, options = {}) {
767
- const context = createParserContext(content, options);
768
- const start = getCursor(context);
769
- return createRoot(
770
- parseChildren(context, 0, []),
771
- getSelection(context, start)
772
- );
773
- }
774
- function createParserContext(content, rawOptions) {
775
- const options = shared.extend({}, defaultParserOptions);
776
- let key;
777
- for (key in rawOptions) {
778
- options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
779
- }
780
- return {
781
- options,
782
- column: 1,
783
- line: 1,
784
- offset: 0,
785
- originalSource: content,
786
- source: content,
787
- inPre: false,
788
- inVPre: false,
789
- onWarn: options.onWarn
790
- };
791
- }
792
- function parseChildren(context, mode, ancestors) {
793
- const parent = last(ancestors);
794
- const ns = parent ? parent.ns : 0;
795
- const nodes = [];
796
- while (!isEnd(context, mode, ancestors)) {
797
- const s = context.source;
798
- let node = void 0;
799
- if (mode === 0 || mode === 1) {
800
- if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
801
- node = parseInterpolation(context, mode);
802
- } else if (mode === 0 && s[0] === "<") {
803
- if (s.length === 1) {
804
- emitError(context, 5, 1);
805
- } else if (s[1] === "!") {
806
- if (startsWith(s, "<!--")) {
807
- node = parseComment(context);
808
- } else if (startsWith(s, "<!DOCTYPE")) {
809
- node = parseBogusComment(context);
810
- } else if (startsWith(s, "<![CDATA[")) {
811
- if (ns !== 0) {
812
- node = parseCDATA(context, ancestors);
813
- } else {
814
- emitError(context, 1);
815
- node = parseBogusComment(context);
816
- }
817
- } else {
818
- emitError(context, 11);
819
- node = parseBogusComment(context);
1614
+ let currentOptions = defaultParserOptions;
1615
+ let currentRoot = null;
1616
+ let currentInput = "";
1617
+ let currentOpenTag = null;
1618
+ let currentProp = null;
1619
+ let currentAttrValue = "";
1620
+ let currentAttrStartIndex = -1;
1621
+ let currentAttrEndIndex = -1;
1622
+ let inPre = 0;
1623
+ let inVPre = false;
1624
+ let currentVPreBoundary = null;
1625
+ const stack = [];
1626
+ const tokenizer = new Tokenizer(stack, {
1627
+ onerr: emitError,
1628
+ ontext(start, end) {
1629
+ onText(getSlice(start, end), start, end);
1630
+ },
1631
+ ontextentity(char, start, end) {
1632
+ onText(char, start, end);
1633
+ },
1634
+ oninterpolation(start, end) {
1635
+ if (inVPre) {
1636
+ return onText(getSlice(start, end), start, end);
1637
+ }
1638
+ let innerStart = start + tokenizer.delimiterOpen.length;
1639
+ let innerEnd = end - tokenizer.delimiterClose.length;
1640
+ while (isWhitespace(currentInput.charCodeAt(innerStart))) {
1641
+ innerStart++;
1642
+ }
1643
+ while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
1644
+ innerEnd--;
1645
+ }
1646
+ let exp = getSlice(innerStart, innerEnd);
1647
+ if (exp.includes("&")) {
1648
+ {
1649
+ exp = decode_js.decodeHTML(exp);
1650
+ }
1651
+ }
1652
+ addNode({
1653
+ type: 5,
1654
+ content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
1655
+ loc: getLoc(start, end)
1656
+ });
1657
+ },
1658
+ onopentagname(start, end) {
1659
+ const name = getSlice(start, end);
1660
+ currentOpenTag = {
1661
+ type: 1,
1662
+ tag: name,
1663
+ ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
1664
+ tagType: 0,
1665
+ // will be refined on tag close
1666
+ props: [],
1667
+ children: [],
1668
+ loc: getLoc(start - 1, end),
1669
+ codegenNode: void 0
1670
+ };
1671
+ if (tokenizer.inSFCRoot) {
1672
+ currentOpenTag.innerLoc = getLoc(
1673
+ end + fastForward(end) + 1,
1674
+ end
1675
+ );
1676
+ }
1677
+ },
1678
+ onopentagend(end) {
1679
+ endOpenTag(end);
1680
+ },
1681
+ onclosetag(start, end) {
1682
+ const name = getSlice(start, end);
1683
+ if (!currentOptions.isVoidTag(name)) {
1684
+ let found = false;
1685
+ for (let i = 0; i < stack.length; i++) {
1686
+ const e = stack[i];
1687
+ if (e.tag.toLowerCase() === name.toLowerCase()) {
1688
+ found = true;
1689
+ if (i > 0) {
1690
+ emitError(24, stack[0].loc.start.offset);
820
1691
  }
821
- } else if (s[1] === "/") {
822
- if (s.length === 2) {
823
- emitError(context, 5, 2);
824
- } else if (s[2] === ">") {
825
- emitError(context, 14, 2);
826
- advanceBy(context, 3);
827
- continue;
828
- } else if (/[a-z]/i.test(s[2])) {
829
- emitError(context, 23);
830
- parseTag(context, 1 /* End */, parent);
831
- continue;
832
- } else {
833
- emitError(
834
- context,
835
- 12,
836
- 2
837
- );
838
- node = parseBogusComment(context);
1692
+ for (let j = 0; j <= i; j++) {
1693
+ const el = stack.shift();
1694
+ onCloseTag(el, end, j < i);
839
1695
  }
840
- } else if (/[a-z]/i.test(s[1])) {
841
- node = parseElement(context, ancestors);
842
- if (isCompatEnabled(
843
- "COMPILER_NATIVE_TEMPLATE",
844
- context
845
- ) && node && node.tag === "template" && !node.props.some(
846
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
847
- )) {
848
- node = node.children;
1696
+ break;
1697
+ }
1698
+ }
1699
+ if (!found) {
1700
+ emitError(23, backTrack(start, 60));
1701
+ }
1702
+ }
1703
+ },
1704
+ onselfclosingtag(end) {
1705
+ var _a;
1706
+ const name = currentOpenTag.tag;
1707
+ currentOpenTag.isSelfClosing = true;
1708
+ endOpenTag(end);
1709
+ if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
1710
+ onCloseTag(stack.shift(), end);
1711
+ }
1712
+ },
1713
+ onattribname(start, end) {
1714
+ currentProp = {
1715
+ type: 6,
1716
+ name: getSlice(start, end),
1717
+ nameLoc: getLoc(start, end),
1718
+ value: void 0,
1719
+ loc: getLoc(start)
1720
+ };
1721
+ },
1722
+ ondirname(start, end) {
1723
+ const raw = getSlice(start, end);
1724
+ const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
1725
+ if (!inVPre && name === "") {
1726
+ emitError(26, start);
1727
+ }
1728
+ if (inVPre || name === "") {
1729
+ currentProp = {
1730
+ type: 6,
1731
+ name: raw,
1732
+ nameLoc: getLoc(start, end),
1733
+ value: void 0,
1734
+ loc: getLoc(start)
1735
+ };
1736
+ } else {
1737
+ currentProp = {
1738
+ type: 7,
1739
+ name,
1740
+ rawName: raw,
1741
+ exp: void 0,
1742
+ arg: void 0,
1743
+ modifiers: raw === "." ? ["prop"] : [],
1744
+ loc: getLoc(start)
1745
+ };
1746
+ if (name === "pre") {
1747
+ inVPre = true;
1748
+ currentVPreBoundary = currentOpenTag;
1749
+ const props = currentOpenTag.props;
1750
+ for (let i = 0; i < props.length; i++) {
1751
+ if (props[i].type === 7) {
1752
+ props[i] = dirToAttr(props[i]);
849
1753
  }
850
- } else if (s[1] === "?") {
851
- emitError(
852
- context,
853
- 21,
854
- 1
855
- );
856
- node = parseBogusComment(context);
857
- } else {
858
- emitError(context, 12, 1);
859
1754
  }
860
1755
  }
861
1756
  }
862
- if (!node) {
863
- node = parseText(context, mode);
1757
+ },
1758
+ ondirarg(start, end) {
1759
+ const arg = getSlice(start, end);
1760
+ if (inVPre) {
1761
+ currentProp.name += arg;
1762
+ setLocEnd(currentProp.nameLoc, end);
1763
+ } else {
1764
+ const isStatic = arg[0] !== `[`;
1765
+ currentProp.arg = createSimpleExpression(
1766
+ isStatic ? arg : arg.slice(1, -1),
1767
+ isStatic,
1768
+ getLoc(start, end),
1769
+ isStatic ? 3 : 0
1770
+ );
864
1771
  }
865
- if (shared.isArray(node)) {
866
- for (let i = 0; i < node.length; i++) {
867
- pushNode(nodes, node[i]);
1772
+ },
1773
+ ondirmodifier(start, end) {
1774
+ const mod = getSlice(start, end);
1775
+ if (inVPre) {
1776
+ currentProp.name += "." + mod;
1777
+ setLocEnd(currentProp.nameLoc, end);
1778
+ } else if (currentProp.name === "slot") {
1779
+ const arg = currentProp.arg;
1780
+ if (arg) {
1781
+ arg.content += "." + mod;
1782
+ setLocEnd(arg.loc, end);
868
1783
  }
869
1784
  } else {
870
- pushNode(nodes, node);
1785
+ currentProp.modifiers.push(mod);
871
1786
  }
872
- }
873
- let removedWhitespace = false;
874
- if (mode !== 2 && mode !== 1) {
875
- const shouldCondense = context.options.whitespace !== "preserve";
876
- for (let i = 0; i < nodes.length; i++) {
877
- const node = nodes[i];
878
- if (node.type === 2) {
879
- if (!context.inPre) {
880
- if (!/[^\t\r\n\f ]/.test(node.content)) {
881
- const prev = nodes[i - 1];
882
- const next = nodes[i + 1];
883
- if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
884
- removedWhitespace = true;
885
- nodes[i] = null;
886
- } else {
887
- node.content = " ";
888
- }
889
- } else if (shouldCondense) {
890
- node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
1787
+ },
1788
+ onattribdata(start, end) {
1789
+ currentAttrValue += getSlice(start, end);
1790
+ if (currentAttrStartIndex < 0)
1791
+ currentAttrStartIndex = start;
1792
+ currentAttrEndIndex = end;
1793
+ },
1794
+ onattribentity(char, start, end) {
1795
+ currentAttrValue += char;
1796
+ if (currentAttrStartIndex < 0)
1797
+ currentAttrStartIndex = start;
1798
+ currentAttrEndIndex = end;
1799
+ },
1800
+ onattribnameend(end) {
1801
+ const start = currentProp.loc.start.offset;
1802
+ const name = getSlice(start, end);
1803
+ if (currentProp.type === 7) {
1804
+ currentProp.rawName = name;
1805
+ }
1806
+ if (currentOpenTag.props.some(
1807
+ (p) => (p.type === 7 ? p.rawName : p.name) === name
1808
+ )) {
1809
+ emitError(2, start);
1810
+ }
1811
+ },
1812
+ onattribend(quote, end) {
1813
+ if (currentOpenTag && currentProp) {
1814
+ setLocEnd(currentProp.loc, end);
1815
+ if (quote !== 0) {
1816
+ if (currentProp.type === 6) {
1817
+ if (currentProp.name === "class") {
1818
+ currentAttrValue = condense(currentAttrValue).trim();
1819
+ }
1820
+ if (quote === 1 && !currentAttrValue) {
1821
+ emitError(13, end);
1822
+ }
1823
+ currentProp.value = {
1824
+ type: 2,
1825
+ content: currentAttrValue,
1826
+ loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
1827
+ };
1828
+ if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
1829
+ tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
891
1830
  }
892
1831
  } else {
893
- node.content = node.content.replace(/\r\n/g, "\n");
1832
+ currentProp.exp = createSimpleExpression(
1833
+ currentAttrValue,
1834
+ false,
1835
+ getLoc(currentAttrStartIndex, currentAttrEndIndex)
1836
+ );
1837
+ if (currentProp.name === "for") {
1838
+ currentProp.forParseResult = parseForExpression(currentProp.exp);
1839
+ }
1840
+ let syncIndex = -1;
1841
+ if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
1842
+ "COMPILER_V_BIND_SYNC",
1843
+ currentOptions,
1844
+ currentProp.loc,
1845
+ currentProp.rawName
1846
+ )) {
1847
+ currentProp.name = "model";
1848
+ currentProp.modifiers.splice(syncIndex, 1);
1849
+ }
894
1850
  }
895
- } else if (node.type === 3 && !context.options.comments) {
896
- removedWhitespace = true;
897
- nodes[i] = null;
898
1851
  }
1852
+ if (currentProp.type !== 7 || currentProp.name !== "pre") {
1853
+ currentOpenTag.props.push(currentProp);
1854
+ }
1855
+ }
1856
+ currentAttrValue = "";
1857
+ currentAttrStartIndex = currentAttrEndIndex = -1;
1858
+ },
1859
+ oncomment(start, end) {
1860
+ if (currentOptions.comments) {
1861
+ addNode({
1862
+ type: 3,
1863
+ content: getSlice(start, end),
1864
+ loc: getLoc(start - 4, end + 3)
1865
+ });
899
1866
  }
900
- if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
901
- const first = nodes[0];
902
- if (first && first.type === 2) {
903
- first.content = first.content.replace(/^\r?\n/, "");
1867
+ },
1868
+ onend() {
1869
+ const end = currentInput.length;
1870
+ if (tokenizer.state !== 1) {
1871
+ switch (tokenizer.state) {
1872
+ case 5:
1873
+ case 8:
1874
+ emitError(5, end);
1875
+ break;
1876
+ case 3:
1877
+ case 4:
1878
+ emitError(
1879
+ 25,
1880
+ tokenizer.sectionStart
1881
+ );
1882
+ break;
1883
+ case 28:
1884
+ if (tokenizer.currentSequence === Sequences.CdataEnd) {
1885
+ emitError(6, end);
1886
+ } else {
1887
+ emitError(7, end);
1888
+ }
1889
+ break;
1890
+ case 6:
1891
+ case 7:
1892
+ case 9:
1893
+ case 11:
1894
+ case 12:
1895
+ case 13:
1896
+ case 14:
1897
+ case 15:
1898
+ case 16:
1899
+ case 17:
1900
+ case 18:
1901
+ case 19:
1902
+ case 20:
1903
+ case 21:
1904
+ emitError(9, end);
1905
+ break;
904
1906
  }
905
1907
  }
1908
+ for (let index = 0; index < stack.length; index++) {
1909
+ onCloseTag(stack[index], end - 1);
1910
+ emitError(24, stack[index].loc.start.offset);
1911
+ }
1912
+ },
1913
+ oncdata(start, end) {
1914
+ if (stack[0].ns !== 0) {
1915
+ onText(getSlice(start, end), start, end);
1916
+ } else {
1917
+ emitError(1, start - 9);
1918
+ }
1919
+ },
1920
+ onprocessinginstruction(start) {
1921
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
1922
+ emitError(
1923
+ 21,
1924
+ start - 1
1925
+ );
1926
+ }
906
1927
  }
907
- return removedWhitespace ? nodes.filter(Boolean) : nodes;
1928
+ });
1929
+ const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
1930
+ const stripParensRE = /^\(|\)$/g;
1931
+ function parseForExpression(input) {
1932
+ const loc = input.loc;
1933
+ const exp = input.content;
1934
+ const inMatch = exp.match(forAliasRE);
1935
+ if (!inMatch)
1936
+ return;
1937
+ const [, LHS, RHS] = inMatch;
1938
+ const createAliasExpression = (content, offset) => {
1939
+ const start = loc.start.offset + offset;
1940
+ const end = start + content.length;
1941
+ return createSimpleExpression(content, false, getLoc(start, end));
1942
+ };
1943
+ const result = {
1944
+ source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
1945
+ value: void 0,
1946
+ key: void 0,
1947
+ index: void 0,
1948
+ finalized: false
1949
+ };
1950
+ let valueContent = LHS.trim().replace(stripParensRE, "").trim();
1951
+ const trimmedOffset = LHS.indexOf(valueContent);
1952
+ const iteratorMatch = valueContent.match(forIteratorRE);
1953
+ if (iteratorMatch) {
1954
+ valueContent = valueContent.replace(forIteratorRE, "").trim();
1955
+ const keyContent = iteratorMatch[1].trim();
1956
+ let keyOffset;
1957
+ if (keyContent) {
1958
+ keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
1959
+ result.key = createAliasExpression(keyContent, keyOffset);
1960
+ }
1961
+ if (iteratorMatch[2]) {
1962
+ const indexContent = iteratorMatch[2].trim();
1963
+ if (indexContent) {
1964
+ result.index = createAliasExpression(
1965
+ indexContent,
1966
+ exp.indexOf(
1967
+ indexContent,
1968
+ result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
1969
+ )
1970
+ );
1971
+ }
1972
+ }
1973
+ }
1974
+ if (valueContent) {
1975
+ result.value = createAliasExpression(valueContent, trimmedOffset);
1976
+ }
1977
+ return result;
908
1978
  }
909
- function pushNode(nodes, node) {
910
- if (node.type === 2) {
911
- const prev = last(nodes);
912
- if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
913
- prev.content += node.content;
914
- prev.loc.end = node.loc.end;
915
- prev.loc.source += node.loc.source;
916
- return;
1979
+ function getSlice(start, end) {
1980
+ return currentInput.slice(start, end);
1981
+ }
1982
+ function endOpenTag(end) {
1983
+ addNode(currentOpenTag);
1984
+ const { tag, ns } = currentOpenTag;
1985
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
1986
+ inPre++;
1987
+ }
1988
+ if (currentOptions.isVoidTag(tag)) {
1989
+ onCloseTag(currentOpenTag, end);
1990
+ } else {
1991
+ stack.unshift(currentOpenTag);
1992
+ if (ns === 1 || ns === 2) {
1993
+ tokenizer.inXML = true;
917
1994
  }
918
1995
  }
919
- nodes.push(node);
1996
+ currentOpenTag = null;
920
1997
  }
921
- function parseCDATA(context, ancestors) {
922
- advanceBy(context, 9);
923
- const nodes = parseChildren(context, 3, ancestors);
924
- if (context.source.length === 0) {
925
- emitError(context, 6);
1998
+ function onText(content, start, end) {
1999
+ const parent = stack[0] || currentRoot;
2000
+ const lastNode = parent.children[parent.children.length - 1];
2001
+ if ((lastNode == null ? void 0 : lastNode.type) === 2) {
2002
+ lastNode.content += content;
2003
+ setLocEnd(lastNode.loc, end);
926
2004
  } else {
927
- advanceBy(context, 3);
2005
+ parent.children.push({
2006
+ type: 2,
2007
+ content,
2008
+ loc: getLoc(start, end)
2009
+ });
928
2010
  }
929
- return nodes;
930
2011
  }
931
- function parseComment(context) {
932
- const start = getCursor(context);
933
- let content;
934
- const match = /--(\!)?>/.exec(context.source);
935
- if (!match) {
936
- content = context.source.slice(4);
937
- advanceBy(context, context.source.length);
938
- emitError(context, 7);
2012
+ function onCloseTag(el, end, isImplied = false) {
2013
+ if (isImplied) {
2014
+ setLocEnd(el.loc, backTrack(end, 60));
939
2015
  } else {
940
- if (match.index <= 3) {
941
- emitError(context, 0);
942
- }
943
- if (match[1]) {
944
- emitError(context, 10);
2016
+ setLocEnd(el.loc, end + fastForward(end) + 1);
2017
+ }
2018
+ if (tokenizer.inSFCRoot) {
2019
+ if (el.children.length) {
2020
+ el.innerLoc.end = shared.extend({}, el.children[el.children.length - 1].loc.end);
2021
+ } else {
2022
+ el.innerLoc.end = shared.extend({}, el.innerLoc.start);
945
2023
  }
946
- content = context.source.slice(4, match.index);
947
- const s = context.source.slice(0, match.index);
948
- let prevIndex = 1, nestedIndex = 0;
949
- while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
950
- advanceBy(context, nestedIndex - prevIndex + 1);
951
- if (nestedIndex + 4 < s.length) {
952
- emitError(context, 16);
953
- }
954
- prevIndex = nestedIndex + 1;
2024
+ el.innerLoc.source = getSlice(
2025
+ el.innerLoc.start.offset,
2026
+ el.innerLoc.end.offset
2027
+ );
2028
+ }
2029
+ const { tag, ns } = el;
2030
+ if (!inVPre) {
2031
+ if (tag === "slot") {
2032
+ el.tagType = 2;
2033
+ } else if (isFragmentTemplate(el)) {
2034
+ el.tagType = 3;
2035
+ } else if (isComponent(el)) {
2036
+ el.tagType = 1;
955
2037
  }
956
- advanceBy(context, match.index + match[0].length - prevIndex + 1);
957
2038
  }
958
- return {
959
- type: 3,
960
- content,
961
- loc: getSelection(context, start)
962
- };
963
- }
964
- function parseBogusComment(context) {
965
- const start = getCursor(context);
966
- const contentStart = context.source[1] === "?" ? 1 : 2;
967
- let content;
968
- const closeIndex = context.source.indexOf(">");
969
- if (closeIndex === -1) {
970
- content = context.source.slice(contentStart);
971
- advanceBy(context, context.source.length);
972
- } else {
973
- content = context.source.slice(contentStart, closeIndex);
974
- advanceBy(context, closeIndex + 1);
2039
+ if (!tokenizer.inRCDATA) {
2040
+ el.children = condenseWhitespace(el.children, el.tag);
2041
+ }
2042
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
2043
+ inPre--;
2044
+ }
2045
+ if (currentVPreBoundary === el) {
2046
+ inVPre = false;
2047
+ currentVPreBoundary = null;
2048
+ }
2049
+ if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
2050
+ tokenizer.inXML = false;
975
2051
  }
976
- return {
977
- type: 3,
978
- content,
979
- loc: getSelection(context, start)
980
- };
981
- }
982
- function parseElement(context, ancestors) {
983
- const wasInPre = context.inPre;
984
- const wasInVPre = context.inVPre;
985
- const parent = last(ancestors);
986
- const element = parseTag(context, 0 /* Start */, parent);
987
- const isPreBoundary = context.inPre && !wasInPre;
988
- const isVPreBoundary = context.inVPre && !wasInVPre;
989
- if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
990
- if (isPreBoundary) {
991
- context.inPre = false;
992
- }
993
- if (isVPreBoundary) {
994
- context.inVPre = false;
995
- }
996
- return element;
997
- }
998
- ancestors.push(element);
999
- const mode = context.options.getTextMode(element, parent);
1000
- const children = parseChildren(context, mode, ancestors);
1001
- ancestors.pop();
1002
2052
  {
1003
- const inlineTemplateProp = element.props.find(
2053
+ const props = el.props;
2054
+ if (isCompatEnabled(
2055
+ "COMPILER_NATIVE_TEMPLATE",
2056
+ currentOptions
2057
+ ) && el.tag === "template" && !isFragmentTemplate(el)) {
2058
+ const parent = stack[0] || currentRoot;
2059
+ const index = parent.children.indexOf(el);
2060
+ parent.children.splice(index, 1, ...el.children);
2061
+ }
2062
+ const inlineTemplateProp = props.find(
1004
2063
  (p) => p.type === 6 && p.name === "inline-template"
1005
2064
  );
1006
2065
  if (inlineTemplateProp && checkCompatEnabled(
1007
2066
  "COMPILER_INLINE_TEMPLATE",
1008
- context,
2067
+ currentOptions,
1009
2068
  inlineTemplateProp.loc
1010
- )) {
1011
- const loc = getSelection(context, element.loc.end);
2069
+ ) && el.children.length) {
1012
2070
  inlineTemplateProp.value = {
1013
2071
  type: 2,
1014
- content: loc.source,
1015
- loc
2072
+ content: getSlice(
2073
+ el.children[0].loc.start.offset,
2074
+ el.children[el.children.length - 1].loc.end.offset
2075
+ ),
2076
+ loc: inlineTemplateProp.loc
1016
2077
  };
1017
2078
  }
1018
2079
  }
1019
- element.children = children;
1020
- if (startsWithEndTagOpen(context.source, element.tag)) {
1021
- parseTag(context, 1 /* End */, parent);
1022
- } else {
1023
- emitError(context, 24, 0, element.loc.start);
1024
- if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
1025
- const first = children[0];
1026
- if (first && startsWith(first.loc.source, "<!--")) {
1027
- emitError(context, 8);
1028
- }
1029
- }
1030
- }
1031
- element.loc = getSelection(context, element.loc.start);
1032
- if (isPreBoundary) {
1033
- context.inPre = false;
1034
- }
1035
- if (isVPreBoundary) {
1036
- context.inVPre = false;
1037
- }
1038
- return element;
1039
2080
  }
1040
- const isSpecialTemplateDirective = /* @__PURE__ */ shared.makeMap(
1041
- `if,else,else-if,for,slot`
1042
- );
1043
- function parseTag(context, type, parent) {
1044
- const start = getCursor(context);
1045
- const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
1046
- const tag = match[1];
1047
- const ns = context.options.getNamespace(tag, parent);
1048
- advanceBy(context, match[0].length);
1049
- advanceSpaces(context);
1050
- const cursor = getCursor(context);
1051
- const currentSource = context.source;
1052
- if (context.options.isPreTag(tag)) {
1053
- context.inPre = true;
1054
- }
1055
- let props = parseAttributes(context, type);
1056
- if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
1057
- context.inVPre = true;
1058
- shared.extend(context, cursor);
1059
- context.source = currentSource;
1060
- props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
1061
- }
1062
- let isSelfClosing = false;
1063
- if (context.source.length === 0) {
1064
- emitError(context, 9);
1065
- } else {
1066
- isSelfClosing = startsWith(context.source, "/>");
1067
- if (type === 1 /* End */ && isSelfClosing) {
1068
- emitError(context, 4);
1069
- }
1070
- advanceBy(context, isSelfClosing ? 2 : 1);
1071
- }
1072
- if (type === 1 /* End */) {
1073
- return;
2081
+ function fastForward(start, c) {
2082
+ let offset = 0;
2083
+ while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
2084
+ offset++;
1074
2085
  }
1075
- let tagType = 0;
1076
- if (!context.inVPre) {
1077
- if (tag === "slot") {
1078
- tagType = 2;
1079
- } else if (tag === "template") {
1080
- if (props.some(
1081
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
1082
- )) {
1083
- tagType = 3;
2086
+ return offset;
2087
+ }
2088
+ function backTrack(index, c) {
2089
+ let i = index;
2090
+ while (currentInput.charCodeAt(i) !== c && i >= 0)
2091
+ i--;
2092
+ return i;
2093
+ }
2094
+ const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
2095
+ function isFragmentTemplate({ tag, props }) {
2096
+ if (tag === "template") {
2097
+ for (let i = 0; i < props.length; i++) {
2098
+ if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
2099
+ return true;
1084
2100
  }
1085
- } else if (isComponent(tag, props, context)) {
1086
- tagType = 1;
1087
2101
  }
1088
2102
  }
1089
- return {
1090
- type: 1,
1091
- ns,
1092
- tag,
1093
- tagType,
1094
- props,
1095
- isSelfClosing,
1096
- children: [],
1097
- loc: getSelection(context, start),
1098
- codegenNode: void 0
1099
- // to be created during transform phase
1100
- };
2103
+ return false;
1101
2104
  }
1102
- function isComponent(tag, props, context) {
1103
- const options = context.options;
1104
- if (options.isCustomElement(tag)) {
2105
+ function isComponent({ tag, props }) {
2106
+ var _a;
2107
+ if (currentOptions.isCustomElement(tag)) {
1105
2108
  return false;
1106
2109
  }
1107
- if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
2110
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
1108
2111
  return true;
1109
2112
  }
1110
2113
  for (let i = 0; i < props.length; i++) {
@@ -1115,367 +2118,172 @@ function isComponent(tag, props, context) {
1115
2118
  return true;
1116
2119
  } else if (checkCompatEnabled(
1117
2120
  "COMPILER_IS_ON_ELEMENT",
1118
- context,
2121
+ currentOptions,
1119
2122
  p.loc
1120
2123
  )) {
1121
2124
  return true;
1122
2125
  }
1123
2126
  }
1124
- } else {
1125
- if (p.name === "is") {
1126
- return true;
1127
- } else if (
1128
- // :is on plain element - only treat as component in compat mode
1129
- p.name === "bind" && isStaticArgOf(p.arg, "is") && true && checkCompatEnabled(
1130
- "COMPILER_IS_ON_ELEMENT",
1131
- context,
1132
- p.loc
1133
- )
1134
- ) {
1135
- return true;
1136
- }
2127
+ } else if (// :is on plain element - only treat as component in compat mode
2128
+ p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
2129
+ "COMPILER_IS_ON_ELEMENT",
2130
+ currentOptions,
2131
+ p.loc
2132
+ )) {
2133
+ return true;
1137
2134
  }
1138
2135
  }
2136
+ return false;
1139
2137
  }
1140
- function parseAttributes(context, type) {
1141
- const props = [];
1142
- const attributeNames = /* @__PURE__ */ new Set();
1143
- while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
1144
- if (startsWith(context.source, "/")) {
1145
- emitError(context, 22);
1146
- advanceBy(context, 1);
1147
- advanceSpaces(context);
1148
- continue;
1149
- }
1150
- if (type === 1 /* End */) {
1151
- emitError(context, 3);
1152
- }
1153
- const attr = parseAttribute(context, attributeNames);
1154
- if (attr.type === 6 && attr.value && attr.name === "class") {
1155
- attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
1156
- }
1157
- if (type === 0 /* Start */) {
1158
- props.push(attr);
1159
- }
1160
- if (/^[^\t\r\n\f />]/.test(context.source)) {
1161
- emitError(context, 15);
1162
- }
1163
- advanceSpaces(context);
1164
- }
1165
- return props;
2138
+ function isUpperCase(c) {
2139
+ return c > 64 && c < 91;
1166
2140
  }
1167
- function parseAttribute(context, nameSet) {
1168
- var _a;
1169
- const start = getCursor(context);
1170
- const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
1171
- const name = match[0];
1172
- if (nameSet.has(name)) {
1173
- emitError(context, 2);
1174
- }
1175
- nameSet.add(name);
1176
- if (name[0] === "=") {
1177
- emitError(context, 19);
1178
- }
1179
- {
1180
- const pattern = /["'<]/g;
1181
- let m;
1182
- while (m = pattern.exec(name)) {
1183
- emitError(
1184
- context,
1185
- 17,
1186
- m.index
1187
- );
1188
- }
1189
- }
1190
- advanceBy(context, name.length);
1191
- let value = void 0;
1192
- if (/^[\t\r\n\f ]*=/.test(context.source)) {
1193
- advanceSpaces(context);
1194
- advanceBy(context, 1);
1195
- advanceSpaces(context);
1196
- value = parseAttributeValue(context);
1197
- if (!value) {
1198
- emitError(context, 13);
1199
- }
1200
- }
1201
- const loc = getSelection(context, start);
1202
- if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
1203
- const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
1204
- name
1205
- );
1206
- let isPropShorthand = startsWith(name, ".");
1207
- let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
1208
- let arg;
1209
- if (match2[2]) {
1210
- const isSlot = dirName === "slot";
1211
- const startOffset = name.lastIndexOf(
1212
- match2[2],
1213
- name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
1214
- );
1215
- const loc2 = getSelection(
1216
- context,
1217
- getNewPosition(context, start, startOffset),
1218
- getNewPosition(
1219
- context,
1220
- start,
1221
- startOffset + match2[2].length + (isSlot && match2[3] || "").length
1222
- )
1223
- );
1224
- let content = match2[2];
1225
- let isStatic = true;
1226
- if (content.startsWith("[")) {
1227
- isStatic = false;
1228
- if (!content.endsWith("]")) {
1229
- emitError(
1230
- context,
1231
- 27
1232
- );
1233
- content = content.slice(1);
1234
- } else {
1235
- content = content.slice(1, content.length - 1);
2141
+ const windowsNewlineRE = /\r\n/g;
2142
+ function condenseWhitespace(nodes, tag) {
2143
+ var _a, _b;
2144
+ const shouldCondense = currentOptions.whitespace !== "preserve";
2145
+ let removedWhitespace = false;
2146
+ for (let i = 0; i < nodes.length; i++) {
2147
+ const node = nodes[i];
2148
+ if (node.type === 2) {
2149
+ if (!inPre) {
2150
+ if (isAllWhitespace(node.content)) {
2151
+ const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
2152
+ const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
2153
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2154
+ removedWhitespace = true;
2155
+ nodes[i] = null;
2156
+ } else {
2157
+ node.content = " ";
2158
+ }
2159
+ } else if (shouldCondense) {
2160
+ node.content = condense(node.content);
1236
2161
  }
1237
- } else if (isSlot) {
1238
- content += match2[3] || "";
1239
- }
1240
- arg = {
1241
- type: 4,
1242
- content,
1243
- isStatic,
1244
- constType: isStatic ? 3 : 0,
1245
- loc: loc2
1246
- };
1247
- }
1248
- if (value && value.isQuoted) {
1249
- const valueLoc = value.loc;
1250
- valueLoc.start.offset++;
1251
- valueLoc.start.column++;
1252
- valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1253
- valueLoc.source = valueLoc.source.slice(1, -1);
1254
- }
1255
- const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
1256
- if (isPropShorthand)
1257
- modifiers.push("prop");
1258
- if (dirName === "bind" && arg) {
1259
- if (modifiers.includes("sync") && checkCompatEnabled(
1260
- "COMPILER_V_BIND_SYNC",
1261
- context,
1262
- loc,
1263
- arg.loc.source
1264
- )) {
1265
- dirName = "model";
1266
- modifiers.splice(modifiers.indexOf("sync"), 1);
2162
+ } else {
2163
+ node.content = node.content.replace(windowsNewlineRE, "\n");
1267
2164
  }
1268
2165
  }
1269
- return {
1270
- type: 7,
1271
- name: dirName,
1272
- exp: value && {
1273
- type: 4,
1274
- content: value.content,
1275
- isStatic: false,
1276
- // Treat as non-constant by default. This can be potentially set to
1277
- // other values by `transformExpression` to make it eligible for hoisting.
1278
- constType: 0,
1279
- loc: value.loc
1280
- },
1281
- arg,
1282
- modifiers,
1283
- loc
1284
- };
1285
2166
  }
1286
- if (!context.inVPre && startsWith(name, "v-")) {
1287
- emitError(context, 26);
2167
+ if (inPre && tag && currentOptions.isPreTag(tag)) {
2168
+ const first = nodes[0];
2169
+ if (first && first.type === 2) {
2170
+ first.content = first.content.replace(/^\r?\n/, "");
2171
+ }
1288
2172
  }
1289
- return {
1290
- type: 6,
1291
- name,
1292
- value: value && {
1293
- type: 2,
1294
- content: value.content,
1295
- loc: value.loc
1296
- },
1297
- loc
1298
- };
2173
+ return removedWhitespace ? nodes.filter(Boolean) : nodes;
1299
2174
  }
1300
- function parseAttributeValue(context) {
1301
- const start = getCursor(context);
1302
- let content;
1303
- const quote = context.source[0];
1304
- const isQuoted = quote === `"` || quote === `'`;
1305
- if (isQuoted) {
1306
- advanceBy(context, 1);
1307
- const endIndex = context.source.indexOf(quote);
1308
- if (endIndex === -1) {
1309
- content = parseTextData(
1310
- context,
1311
- context.source.length,
1312
- 4
1313
- );
1314
- } else {
1315
- content = parseTextData(context, endIndex, 4);
1316
- advanceBy(context, 1);
1317
- }
1318
- } else {
1319
- const match = /^[^\t\r\n\f >]+/.exec(context.source);
1320
- if (!match) {
1321
- return void 0;
1322
- }
1323
- const unexpectedChars = /["'<=`]/g;
1324
- let m;
1325
- while (m = unexpectedChars.exec(match[0])) {
1326
- emitError(
1327
- context,
1328
- 18,
1329
- m.index
1330
- );
2175
+ function isAllWhitespace(str) {
2176
+ for (let i = 0; i < str.length; i++) {
2177
+ if (!isWhitespace(str.charCodeAt(i))) {
2178
+ return false;
1331
2179
  }
1332
- content = parseTextData(context, match[0].length, 4);
1333
- }
1334
- return { content, isQuoted, loc: getSelection(context, start) };
1335
- }
1336
- function parseInterpolation(context, mode) {
1337
- const [open, close] = context.options.delimiters;
1338
- const closeIndex = context.source.indexOf(close, open.length);
1339
- if (closeIndex === -1) {
1340
- emitError(context, 25);
1341
- return void 0;
1342
- }
1343
- const start = getCursor(context);
1344
- advanceBy(context, open.length);
1345
- const innerStart = getCursor(context);
1346
- const innerEnd = getCursor(context);
1347
- const rawContentLength = closeIndex - open.length;
1348
- const rawContent = context.source.slice(0, rawContentLength);
1349
- const preTrimContent = parseTextData(context, rawContentLength, mode);
1350
- const content = preTrimContent.trim();
1351
- const startOffset = preTrimContent.indexOf(content);
1352
- if (startOffset > 0) {
1353
- advancePositionWithMutation(innerStart, rawContent, startOffset);
1354
- }
1355
- const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
1356
- advancePositionWithMutation(innerEnd, rawContent, endOffset);
1357
- advanceBy(context, close.length);
1358
- return {
1359
- type: 5,
1360
- content: {
1361
- type: 4,
1362
- isStatic: false,
1363
- // Set `isConstant` to false by default and will decide in transformExpression
1364
- constType: 0,
1365
- content,
1366
- loc: getSelection(context, innerStart, innerEnd)
1367
- },
1368
- loc: getSelection(context, start)
1369
- };
2180
+ }
2181
+ return true;
1370
2182
  }
1371
- function parseText(context, mode) {
1372
- const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
1373
- let endIndex = context.source.length;
1374
- for (let i = 0; i < endTokens.length; i++) {
1375
- const index = context.source.indexOf(endTokens[i], 1);
1376
- if (index !== -1 && endIndex > index) {
1377
- endIndex = index;
2183
+ function hasNewlineChar(str) {
2184
+ for (let i = 0; i < str.length; i++) {
2185
+ const c = str.charCodeAt(i);
2186
+ if (c === 10 || c === 13) {
2187
+ return true;
1378
2188
  }
1379
2189
  }
1380
- const start = getCursor(context);
1381
- const content = parseTextData(context, endIndex, mode);
1382
- return {
1383
- type: 2,
1384
- content,
1385
- loc: getSelection(context, start)
1386
- };
2190
+ return false;
1387
2191
  }
1388
- function parseTextData(context, length, mode) {
1389
- const rawText = context.source.slice(0, length);
1390
- advanceBy(context, length);
1391
- if (mode === 2 || mode === 3 || !rawText.includes("&")) {
1392
- return rawText;
1393
- } else {
1394
- return context.options.decodeEntities(
1395
- rawText,
1396
- mode === 4
1397
- );
2192
+ function condense(str) {
2193
+ let ret = "";
2194
+ let prevCharIsWhitespace = false;
2195
+ for (let i = 0; i < str.length; i++) {
2196
+ if (isWhitespace(str.charCodeAt(i))) {
2197
+ if (!prevCharIsWhitespace) {
2198
+ ret += " ";
2199
+ prevCharIsWhitespace = true;
2200
+ }
2201
+ } else {
2202
+ ret += str[i];
2203
+ prevCharIsWhitespace = false;
2204
+ }
1398
2205
  }
2206
+ return ret;
1399
2207
  }
1400
- function getCursor(context) {
1401
- const { column, line, offset } = context;
1402
- return { column, line, offset };
2208
+ function addNode(node) {
2209
+ (stack[0] || currentRoot).children.push(node);
1403
2210
  }
1404
- function getSelection(context, start, end) {
1405
- end = end || getCursor(context);
2211
+ function getLoc(start, end) {
1406
2212
  return {
1407
- start,
1408
- end,
1409
- source: context.originalSource.slice(start.offset, end.offset)
2213
+ start: tokenizer.getPos(start),
2214
+ // @ts-expect-error allow late attachment
2215
+ end: end == null ? end : tokenizer.getPos(end),
2216
+ // @ts-expect-error allow late attachment
2217
+ source: end == null ? end : getSlice(start, end)
1410
2218
  };
1411
2219
  }
1412
- function last(xs) {
1413
- return xs[xs.length - 1];
1414
- }
1415
- function startsWith(source, searchString) {
1416
- return source.startsWith(searchString);
1417
- }
1418
- function advanceBy(context, numberOfCharacters) {
1419
- const { source } = context;
1420
- advancePositionWithMutation(context, source, numberOfCharacters);
1421
- context.source = source.slice(numberOfCharacters);
1422
- }
1423
- function advanceSpaces(context) {
1424
- const match = /^[\t\r\n\f ]+/.exec(context.source);
1425
- if (match) {
1426
- advanceBy(context, match[0].length);
1427
- }
1428
- }
1429
- function getNewPosition(context, start, numberOfCharacters) {
1430
- return advancePositionWithClone(
1431
- start,
1432
- context.originalSource.slice(start.offset, numberOfCharacters),
1433
- numberOfCharacters
1434
- );
1435
- }
1436
- function emitError(context, code, offset, loc = getCursor(context)) {
1437
- if (offset) {
1438
- loc.offset += offset;
1439
- loc.column += offset;
1440
- }
1441
- context.options.onError(
1442
- createCompilerError(code, {
1443
- start: loc,
1444
- end: loc,
1445
- source: ""
1446
- })
1447
- );
2220
+ function setLocEnd(loc, end) {
2221
+ loc.end = tokenizer.getPos(end);
2222
+ loc.source = getSlice(loc.start.offset, end);
1448
2223
  }
1449
- function isEnd(context, mode, ancestors) {
1450
- const s = context.source;
1451
- switch (mode) {
1452
- case 0:
1453
- if (startsWith(s, "</")) {
1454
- for (let i = ancestors.length - 1; i >= 0; --i) {
1455
- if (startsWithEndTagOpen(s, ancestors[i].tag)) {
1456
- return true;
1457
- }
1458
- }
1459
- }
1460
- break;
1461
- case 1:
1462
- case 2: {
1463
- const parent = last(ancestors);
1464
- if (parent && startsWithEndTagOpen(s, parent.tag)) {
1465
- return true;
1466
- }
1467
- break;
1468
- }
1469
- case 3:
1470
- if (startsWith(s, "]]>")) {
1471
- return true;
1472
- }
1473
- break;
2224
+ function dirToAttr(dir) {
2225
+ const attr = {
2226
+ type: 6,
2227
+ name: dir.rawName,
2228
+ nameLoc: getLoc(
2229
+ dir.loc.start.offset,
2230
+ dir.loc.start.offset + dir.rawName.length
2231
+ ),
2232
+ value: void 0,
2233
+ loc: dir.loc
2234
+ };
2235
+ if (dir.exp) {
2236
+ const loc = dir.exp.loc;
2237
+ if (loc.end.offset < dir.loc.end.offset) {
2238
+ loc.start.offset--;
2239
+ loc.start.column--;
2240
+ loc.end.offset++;
2241
+ loc.end.column++;
2242
+ }
2243
+ attr.value = {
2244
+ type: 2,
2245
+ content: dir.exp.content,
2246
+ loc
2247
+ };
1474
2248
  }
1475
- return !s;
1476
- }
1477
- function startsWithEndTagOpen(source, tag) {
1478
- return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
2249
+ return attr;
2250
+ }
2251
+ function emitError(code, index) {
2252
+ currentOptions.onError(createCompilerError(code, getLoc(index, index)));
2253
+ }
2254
+ function reset() {
2255
+ tokenizer.reset();
2256
+ currentOpenTag = null;
2257
+ currentProp = null;
2258
+ currentAttrValue = "";
2259
+ currentAttrStartIndex = -1;
2260
+ currentAttrEndIndex = -1;
2261
+ stack.length = 0;
2262
+ }
2263
+ function baseParse(input, options) {
2264
+ reset();
2265
+ currentInput = input;
2266
+ currentOptions = shared.extend({}, defaultParserOptions);
2267
+ if (options) {
2268
+ let key;
2269
+ for (key in options) {
2270
+ if (options[key] != null) {
2271
+ currentOptions[key] = options[key];
2272
+ }
2273
+ }
2274
+ }
2275
+ tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
2276
+ const delimiters = options == null ? void 0 : options.delimiters;
2277
+ if (delimiters) {
2278
+ tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
2279
+ tokenizer.delimiterClose = toCharCodes(delimiters[1]);
2280
+ }
2281
+ const root = currentRoot = createRoot([], input);
2282
+ tokenizer.parse(currentInput);
2283
+ root.loc = getLoc(0, input.length);
2284
+ root.children = condenseWhitespace(root.children);
2285
+ currentRoot = null;
2286
+ return root;
1479
2287
  }
1480
2288
 
1481
2289
  function hoistStatic(root, context) {
@@ -1901,6 +2709,7 @@ function transform(root, options) {
1901
2709
  root.hoists = context.hoists;
1902
2710
  root.temps = context.temps;
1903
2711
  root.cached = context.cached;
2712
+ root.transformed = true;
1904
2713
  {
1905
2714
  root.filters = [...context.filters];
1906
2715
  }
@@ -2053,7 +2862,7 @@ function createCodegenContext(ast, {
2053
2862
  ssr,
2054
2863
  isTS,
2055
2864
  inSSR,
2056
- source: ast.loc.source,
2865
+ source: ast.source,
2057
2866
  code: ``,
2058
2867
  column: 1,
2059
2868
  line: 1,
@@ -2064,7 +2873,7 @@ function createCodegenContext(ast, {
2064
2873
  helper(key) {
2065
2874
  return `_${helperNameMap[key]}`;
2066
2875
  },
2067
- push(code, node) {
2876
+ push(code, newlineIndex = -2 /* None */, node) {
2068
2877
  context.code += code;
2069
2878
  if (context.map) {
2070
2879
  if (node) {
@@ -2077,7 +2886,20 @@ function createCodegenContext(ast, {
2077
2886
  }
2078
2887
  addMapping(node.loc.start, name);
2079
2888
  }
2080
- advancePositionWithMutation(context, code);
2889
+ if (newlineIndex === -3 /* Unknown */) {
2890
+ advancePositionWithMutation(context, code);
2891
+ } else {
2892
+ context.offset += code.length;
2893
+ if (newlineIndex === -2 /* None */) {
2894
+ context.column += code.length;
2895
+ } else {
2896
+ if (newlineIndex === -1 /* End */) {
2897
+ newlineIndex = code.length - 1;
2898
+ }
2899
+ context.line++;
2900
+ context.column = code.length - newlineIndex;
2901
+ }
2902
+ }
2081
2903
  if (node && node.loc !== locStub) {
2082
2904
  addMapping(node.loc.end);
2083
2905
  }
@@ -2098,26 +2920,27 @@ function createCodegenContext(ast, {
2098
2920
  }
2099
2921
  };
2100
2922
  function newline(n) {
2101
- context.push("\n" + ` `.repeat(n));
2102
- }
2103
- function addMapping(loc, name) {
2104
- context.map.addMapping({
2105
- name,
2106
- source: context.filename,
2107
- original: {
2108
- line: loc.line,
2109
- column: loc.column - 1
2110
- // source-map column is 0 based
2111
- },
2112
- generated: {
2113
- line: context.line,
2114
- column: context.column - 1
2115
- }
2923
+ context.push("\n" + ` `.repeat(n), 0 /* Start */);
2924
+ }
2925
+ function addMapping(loc, name = null) {
2926
+ const { _names, _mappings } = context.map;
2927
+ if (name !== null && !_names.has(name))
2928
+ _names.add(name);
2929
+ _mappings.add({
2930
+ originalLine: loc.line,
2931
+ originalColumn: loc.column - 1,
2932
+ // source-map column is 0 based
2933
+ generatedLine: context.line,
2934
+ generatedColumn: context.column - 1,
2935
+ source: filename,
2936
+ // @ts-ignore it is possible to be null
2937
+ name
2116
2938
  });
2117
2939
  }
2118
2940
  if (sourceMap) {
2119
2941
  context.map = new sourceMapJs.SourceMapGenerator();
2120
2942
  context.map.setSourceContent(filename, context.source);
2943
+ context.map._sources.add(filename);
2121
2944
  }
2122
2945
  return context;
2123
2946
  }
@@ -2162,9 +2985,11 @@ function generate(ast, options = {}) {
2162
2985
  push(`with (_ctx) {`);
2163
2986
  indent();
2164
2987
  if (hasHelpers) {
2165
- push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
2166
- push(`
2167
- `);
2988
+ push(
2989
+ `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
2990
+ `,
2991
+ -1 /* End */
2992
+ );
2168
2993
  newline();
2169
2994
  }
2170
2995
  }
@@ -2193,7 +3018,7 @@ function generate(ast, options = {}) {
2193
3018
  }
2194
3019
  if (ast.components.length || ast.directives.length || ast.temps) {
2195
3020
  push(`
2196
- `);
3021
+ `, 0 /* Start */);
2197
3022
  newline();
2198
3023
  }
2199
3024
  if (!ssr) {
@@ -2214,7 +3039,6 @@ function generate(ast, options = {}) {
2214
3039
  ast,
2215
3040
  code: context.code,
2216
3041
  preamble: isSetupInlined ? preambleContext.code : ``,
2217
- // SourceMapGenerator does have toJSON() method but it's not in the types
2218
3042
  map: context.map ? context.map.toJSON() : void 0
2219
3043
  };
2220
3044
  }
@@ -2232,11 +3056,14 @@ function genFunctionPreamble(ast, context) {
2232
3056
  const helpers = Array.from(ast.helpers);
2233
3057
  if (helpers.length > 0) {
2234
3058
  if (prefixIdentifiers) {
2235
- push(`const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
2236
- `);
3059
+ push(
3060
+ `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
3061
+ `,
3062
+ -1 /* End */
3063
+ );
2237
3064
  } else {
2238
3065
  push(`const _Vue = ${VueBinding}
2239
- `);
3066
+ `, -1 /* End */);
2240
3067
  if (ast.hoists.length) {
2241
3068
  const staticHelpers = [
2242
3069
  CREATE_VNODE,
@@ -2246,14 +3073,15 @@ function genFunctionPreamble(ast, context) {
2246
3073
  CREATE_STATIC
2247
3074
  ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
2248
3075
  push(`const { ${staticHelpers} } = _Vue
2249
- `);
3076
+ `, -1 /* End */);
2250
3077
  }
2251
3078
  }
2252
3079
  }
2253
3080
  if (ast.ssrHelpers && ast.ssrHelpers.length) {
2254
3081
  push(
2255
3082
  `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
2256
- `
3083
+ `,
3084
+ -1 /* End */
2257
3085
  );
2258
3086
  }
2259
3087
  genHoists(ast.hoists, context);
@@ -2277,25 +3105,29 @@ function genModulePreamble(ast, context, genScopeId, inline) {
2277
3105
  if (optimizeImports) {
2278
3106
  push(
2279
3107
  `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
2280
- `
3108
+ `,
3109
+ -1 /* End */
2281
3110
  );
2282
3111
  push(
2283
3112
  `
2284
3113
  // Binding optimization for webpack code-split
2285
3114
  const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
2286
- `
3115
+ `,
3116
+ -1 /* End */
2287
3117
  );
2288
3118
  } else {
2289
3119
  push(
2290
3120
  `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
2291
- `
3121
+ `,
3122
+ -1 /* End */
2292
3123
  );
2293
3124
  }
2294
3125
  }
2295
3126
  if (ast.ssrHelpers && ast.ssrHelpers.length) {
2296
3127
  push(
2297
3128
  `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
2298
- `
3129
+ `,
3130
+ -1 /* End */
2299
3131
  );
2300
3132
  }
2301
3133
  if (ast.imports.length) {
@@ -2385,7 +3217,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
2385
3217
  for (let i = 0; i < nodes.length; i++) {
2386
3218
  const node = nodes[i];
2387
3219
  if (shared.isString(node)) {
2388
- push(node);
3220
+ push(node, -3 /* Unknown */);
2389
3221
  } else if (shared.isArray(node)) {
2390
3222
  genNodeListAsArray(node, context);
2391
3223
  } else {
@@ -2403,7 +3235,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
2403
3235
  }
2404
3236
  function genNode(node, context) {
2405
3237
  if (shared.isString(node)) {
2406
- context.push(node);
3238
+ context.push(node, -3 /* Unknown */);
2407
3239
  return;
2408
3240
  }
2409
3241
  if (shared.isSymbol(node)) {
@@ -2476,11 +3308,15 @@ function genNode(node, context) {
2476
3308
  }
2477
3309
  }
2478
3310
  function genText(node, context) {
2479
- context.push(JSON.stringify(node.content), node);
3311
+ context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
2480
3312
  }
2481
3313
  function genExpression(node, context) {
2482
3314
  const { content, isStatic } = node;
2483
- context.push(isStatic ? JSON.stringify(content) : content, node);
3315
+ context.push(
3316
+ isStatic ? JSON.stringify(content) : content,
3317
+ -3 /* Unknown */,
3318
+ node
3319
+ );
2484
3320
  }
2485
3321
  function genInterpolation(node, context) {
2486
3322
  const { push, helper, pure } = context;
@@ -2494,7 +3330,7 @@ function genCompoundExpression(node, context) {
2494
3330
  for (let i = 0; i < node.children.length; i++) {
2495
3331
  const child = node.children[i];
2496
3332
  if (shared.isString(child)) {
2497
- context.push(child);
3333
+ context.push(child, -3 /* Unknown */);
2498
3334
  } else {
2499
3335
  genNode(child, context);
2500
3336
  }
@@ -2508,9 +3344,9 @@ function genExpressionAsPropertyKey(node, context) {
2508
3344
  push(`]`);
2509
3345
  } else if (node.isStatic) {
2510
3346
  const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
2511
- push(text, node);
3347
+ push(text, -2 /* None */, node);
2512
3348
  } else {
2513
- push(`[${node.content}]`, node);
3349
+ push(`[${node.content}]`, -3 /* Unknown */, node);
2514
3350
  }
2515
3351
  }
2516
3352
  function genComment(node, context) {
@@ -2518,7 +3354,11 @@ function genComment(node, context) {
2518
3354
  if (pure) {
2519
3355
  push(PURE_ANNOTATION);
2520
3356
  }
2521
- push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
3357
+ push(
3358
+ `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
3359
+ -3 /* Unknown */,
3360
+ node
3361
+ );
2522
3362
  }
2523
3363
  function genVNodeCall(node, context) {
2524
3364
  const { push, helper, pure } = context;
@@ -2543,7 +3383,7 @@ function genVNodeCall(node, context) {
2543
3383
  push(PURE_ANNOTATION);
2544
3384
  }
2545
3385
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
2546
- push(helper(callHelper) + `(`, node);
3386
+ push(helper(callHelper) + `(`, -2 /* None */, node);
2547
3387
  genNodeList(
2548
3388
  genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
2549
3389
  context
@@ -2572,7 +3412,7 @@ function genCallExpression(node, context) {
2572
3412
  if (pure) {
2573
3413
  push(PURE_ANNOTATION);
2574
3414
  }
2575
- push(callee + `(`, node);
3415
+ push(callee + `(`, -2 /* None */, node);
2576
3416
  genNodeList(node.arguments, context);
2577
3417
  push(`)`);
2578
3418
  }
@@ -2580,7 +3420,7 @@ function genObjectExpression(node, context) {
2580
3420
  const { push, indent, deindent, newline } = context;
2581
3421
  const { properties } = node;
2582
3422
  if (!properties.length) {
2583
- push(`{}`, node);
3423
+ push(`{}`, -2 /* None */, node);
2584
3424
  return;
2585
3425
  }
2586
3426
  const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
@@ -2608,7 +3448,7 @@ function genFunctionExpression(node, context) {
2608
3448
  if (isSlot) {
2609
3449
  push(`_${helperNameMap[WITH_CTX]}(`);
2610
3450
  }
2611
- push(`(`, node);
3451
+ push(`(`, -2 /* None */, node);
2612
3452
  if (shared.isArray(params)) {
2613
3453
  genNodeList(params, context);
2614
3454
  } else if (params) {
@@ -2705,7 +3545,7 @@ function genTemplateLiteral(node, context) {
2705
3545
  for (let i = 0; i < l; i++) {
2706
3546
  const e = node.elements[i];
2707
3547
  if (shared.isString(e)) {
2708
- push(e.replace(/(`|\$|\\)/g, "\\$1"));
3548
+ push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
2709
3549
  } else {
2710
3550
  push("${");
2711
3551
  if (multilines)
@@ -3192,9 +4032,9 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3192
4032
  id.name,
3193
4033
  false,
3194
4034
  {
3195
- source: source2,
3196
4035
  start: advancePositionWithClone(node.loc.start, source2, start),
3197
- end: advancePositionWithClone(node.loc.start, source2, end)
4036
+ end: advancePositionWithClone(node.loc.start, source2, end),
4037
+ source: source2
3198
4038
  },
3199
4039
  id.isConstant ? 3 : 0
3200
4040
  )
@@ -3599,18 +4439,14 @@ function processFor(node, dir, context, processCodegen) {
3599
4439
  );
3600
4440
  return;
3601
4441
  }
3602
- const parseResult = parseForExpression(
3603
- // can only be simple expression because vFor transform is applied
3604
- // before expression transform.
3605
- dir.exp,
3606
- context
3607
- );
4442
+ const parseResult = dir.forParseResult;
3608
4443
  if (!parseResult) {
3609
4444
  context.onError(
3610
4445
  createCompilerError(32, dir.loc)
3611
4446
  );
3612
4447
  return;
3613
4448
  }
4449
+ finalizeForParseResult(parseResult, context);
3614
4450
  const { addIdentifiers, removeIdentifiers, scopes } = context;
3615
4451
  const { source, value, key, index } = parseResult;
3616
4452
  const forNode = {
@@ -3642,76 +4478,37 @@ function processFor(node, dir, context, processCodegen) {
3642
4478
  onExit();
3643
4479
  };
3644
4480
  }
3645
- const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
3646
- const stripParensRE = /^\(|\)$/g;
3647
- function parseForExpression(input, context) {
3648
- const loc = input.loc;
3649
- const exp = input.content;
3650
- const inMatch = exp.match(forAliasRE);
3651
- if (!inMatch)
4481
+ function finalizeForParseResult(result, context) {
4482
+ if (result.finalized)
3652
4483
  return;
3653
- const [, LHS, RHS] = inMatch;
3654
- const result = {
3655
- source: createAliasExpression(
3656
- loc,
3657
- RHS.trim(),
3658
- exp.indexOf(RHS, LHS.length)
3659
- ),
3660
- value: void 0,
3661
- key: void 0,
3662
- index: void 0
3663
- };
3664
4484
  if (context.prefixIdentifiers) {
3665
4485
  result.source = processExpression(
3666
4486
  result.source,
3667
4487
  context
3668
4488
  );
3669
- }
3670
- let valueContent = LHS.trim().replace(stripParensRE, "").trim();
3671
- const trimmedOffset = LHS.indexOf(valueContent);
3672
- const iteratorMatch = valueContent.match(forIteratorRE);
3673
- if (iteratorMatch) {
3674
- valueContent = valueContent.replace(forIteratorRE, "").trim();
3675
- const keyContent = iteratorMatch[1].trim();
3676
- let keyOffset;
3677
- if (keyContent) {
3678
- keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
3679
- result.key = createAliasExpression(loc, keyContent, keyOffset);
3680
- if (context.prefixIdentifiers) {
3681
- result.key = processExpression(result.key, context, true);
3682
- }
4489
+ if (result.key) {
4490
+ result.key = processExpression(
4491
+ result.key,
4492
+ context,
4493
+ true
4494
+ );
3683
4495
  }
3684
- if (iteratorMatch[2]) {
3685
- const indexContent = iteratorMatch[2].trim();
3686
- if (indexContent) {
3687
- result.index = createAliasExpression(
3688
- loc,
3689
- indexContent,
3690
- exp.indexOf(
3691
- indexContent,
3692
- result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
3693
- )
3694
- );
3695
- if (context.prefixIdentifiers) {
3696
- result.index = processExpression(result.index, context, true);
3697
- }
3698
- }
4496
+ if (result.index) {
4497
+ result.index = processExpression(
4498
+ result.index,
4499
+ context,
4500
+ true
4501
+ );
3699
4502
  }
3700
- }
3701
- if (valueContent) {
3702
- result.value = createAliasExpression(loc, valueContent, trimmedOffset);
3703
- if (context.prefixIdentifiers) {
3704
- result.value = processExpression(result.value, context, true);
4503
+ if (result.value) {
4504
+ result.value = processExpression(
4505
+ result.value,
4506
+ context,
4507
+ true
4508
+ );
3705
4509
  }
3706
4510
  }
3707
- return result;
3708
- }
3709
- function createAliasExpression(range, content, offset) {
3710
- return createSimpleExpression(
3711
- content,
3712
- false,
3713
- getInnerRange(range, offset, content.length)
3714
- );
4511
+ result.finalized = true;
3715
4512
  }
3716
4513
  function createForLoopParams({ value, key, index }, memoArgs = []) {
3717
4514
  return createParamsList([value, key, index, ...memoArgs]);
@@ -3747,11 +4544,9 @@ const trackSlotScopes = (node, context) => {
3747
4544
  const trackVForSlotScopes = (node, context) => {
3748
4545
  let vFor;
3749
4546
  if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
3750
- const result = vFor.parseResult = parseForExpression(
3751
- vFor.exp,
3752
- context
3753
- );
4547
+ const result = vFor.forParseResult;
3754
4548
  if (result) {
4549
+ finalizeForParseResult(result, context);
3755
4550
  const { value, key, index } = result;
3756
4551
  const { addIdentifiers, removeIdentifiers } = context;
3757
4552
  value && addIdentifiers(value);
@@ -3828,12 +4623,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3828
4623
  hasDynamicSlots = true;
3829
4624
  }
3830
4625
  const vFor = findDir(slotElement, "for");
3831
- const slotFunction = buildSlotFn(
3832
- slotProps,
3833
- vFor == null ? void 0 : vFor.exp,
3834
- slotChildren,
3835
- slotLoc
3836
- );
4626
+ const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
3837
4627
  let vIf;
3838
4628
  let vElse;
3839
4629
  if (vIf = findDir(slotElement, "if")) {
@@ -3882,8 +4672,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3882
4672
  }
3883
4673
  } else if (vFor) {
3884
4674
  hasDynamicSlots = true;
3885
- const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
4675
+ const parseResult = vFor.forParseResult;
3886
4676
  if (parseResult) {
4677
+ finalizeForParseResult(parseResult, context);
3887
4678
  dynamicSlots.push(
3888
4679
  createCallExpression(context.helper(RENDER_LIST), [
3889
4680
  parseResult.source,
@@ -4130,12 +4921,6 @@ function resolveComponentType(node, context, ssr = false) {
4130
4921
  tag = isProp.value.content.slice(4);
4131
4922
  }
4132
4923
  }
4133
- const isDir = !isExplicitDynamic && findDir(node, "is");
4134
- if (isDir && isDir.exp) {
4135
- return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
4136
- isDir.exp
4137
- ]);
4138
- }
4139
4924
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
4140
4925
  if (builtIn) {
4141
4926
  if (!ssr)
@@ -4258,7 +5043,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4258
5043
  for (let i = 0; i < props.length; i++) {
4259
5044
  const prop = props[i];
4260
5045
  if (prop.type === 6) {
4261
- const { loc, name, value } = prop;
5046
+ const { loc, name, nameLoc, value } = prop;
4262
5047
  let isStatic = true;
4263
5048
  if (name === "ref") {
4264
5049
  hasRef = true;
@@ -4291,11 +5076,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4291
5076
  }
4292
5077
  properties.push(
4293
5078
  createObjectProperty(
4294
- createSimpleExpression(
4295
- name,
4296
- true,
4297
- getInnerRange(loc, 0, name.length)
4298
- ),
5079
+ createSimpleExpression(name, true, nameLoc),
4299
5080
  createSimpleExpression(
4300
5081
  value ? value.content : "",
4301
5082
  isStatic,
@@ -4776,8 +5557,16 @@ const transformOn = (dir, node, context, augmentor) => {
4776
5557
  };
4777
5558
 
4778
5559
  const transformBind = (dir, _node, context) => {
4779
- const { exp, modifiers, loc } = dir;
5560
+ const { modifiers, loc } = dir;
4780
5561
  const arg = dir.arg;
5562
+ let { exp } = dir;
5563
+ if (!exp && arg.type === 4) {
5564
+ const propName = shared.camelize(arg.content);
5565
+ exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
5566
+ {
5567
+ exp = dir.exp = processExpression(exp, context);
5568
+ }
5569
+ }
4781
5570
  if (arg.type !== 4) {
4782
5571
  arg.children.unshift(`(`);
4783
5572
  arg.children.push(`) || ""`);
@@ -5199,7 +5988,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
5199
5988
  }
5200
5989
  ];
5201
5990
  }
5202
- function baseCompile(template, options = {}) {
5991
+ function baseCompile(source, options = {}) {
5203
5992
  const onError = options.onError || defaultOnError;
5204
5993
  const isModuleMode = options.mode === "module";
5205
5994
  const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
@@ -5209,7 +5998,7 @@ function baseCompile(template, options = {}) {
5209
5998
  if (options.scopeId && !isModuleMode) {
5210
5999
  onError(createCompilerError(50));
5211
6000
  }
5212
- const ast = shared.isString(template) ? baseParse(template, options) : template;
6001
+ const ast = shared.isString(source) ? baseParse(source, options) : source;
5213
6002
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
5214
6003
  if (options.isTS) {
5215
6004
  const { expressionPlugins } = options;
@@ -5317,6 +6106,7 @@ exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform;
5317
6106
  exports.createTemplateLiteral = createTemplateLiteral;
5318
6107
  exports.createTransformContext = createTransformContext;
5319
6108
  exports.createVNodeCall = createVNodeCall;
6109
+ exports.errorMessages = errorMessages;
5320
6110
  exports.extractIdentifiers = extractIdentifiers;
5321
6111
  exports.findDir = findDir;
5322
6112
  exports.findProp = findProp;
@@ -5324,7 +6114,6 @@ exports.forAliasRE = forAliasRE;
5324
6114
  exports.generate = generate;
5325
6115
  exports.getBaseTransformPreset = getBaseTransformPreset;
5326
6116
  exports.getConstantType = getConstantType;
5327
- exports.getInnerRange = getInnerRange;
5328
6117
  exports.getMemoedVNodeCall = getMemoedVNodeCall;
5329
6118
  exports.getVNodeBlockHelper = getVNodeBlockHelper;
5330
6119
  exports.getVNodeHelper = getVNodeHelper;
@@ -5332,7 +6121,6 @@ exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
5332
6121
  exports.hasScopeRef = hasScopeRef;
5333
6122
  exports.helperNameMap = helperNameMap;
5334
6123
  exports.injectProp = injectProp;
5335
- exports.isBuiltInType = isBuiltInType;
5336
6124
  exports.isCoreComponent = isCoreComponent;
5337
6125
  exports.isFunctionType = isFunctionType;
5338
6126
  exports.isInDestructureAssignment = isInDestructureAssignment;