@vue/compat 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.
@@ -2,12 +2,8 @@ var Vue = (function () {
2
2
  'use strict';
3
3
 
4
4
  function makeMap(str, expectsLowerCase) {
5
- const map = /* @__PURE__ */ Object.create(null);
6
- const list = str.split(",");
7
- for (let i = 0; i < list.length; i++) {
8
- map[list[i]] = true;
9
- }
10
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
5
+ const set = new Set(str.split(","));
6
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
11
7
  }
12
8
 
13
9
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -422,117 +418,120 @@ var Vue = (function () {
422
418
  }
423
419
  }
424
420
 
425
- const createDep = (effects) => {
426
- const dep = new Set(effects);
427
- dep.w = 0;
428
- dep.n = 0;
429
- return dep;
430
- };
431
- const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
432
- const newTracked = (dep) => (dep.n & trackOpBit) > 0;
433
- const initDepMarkers = ({ deps }) => {
434
- if (deps.length) {
435
- for (let i = 0; i < deps.length; i++) {
436
- deps[i].w |= trackOpBit;
437
- }
438
- }
439
- };
440
- const finalizeDepMarkers = (effect) => {
441
- const { deps } = effect;
442
- if (deps.length) {
443
- let ptr = 0;
444
- for (let i = 0; i < deps.length; i++) {
445
- const dep = deps[i];
446
- if (wasTracked(dep) && !newTracked(dep)) {
447
- dep.delete(effect);
448
- } else {
449
- deps[ptr++] = dep;
450
- }
451
- dep.w &= ~trackOpBit;
452
- dep.n &= ~trackOpBit;
453
- }
454
- deps.length = ptr;
455
- }
456
- };
457
-
458
- const targetMap = /* @__PURE__ */ new WeakMap();
459
- let effectTrackDepth = 0;
460
- let trackOpBit = 1;
461
- const maxMarkerBits = 30;
462
421
  let activeEffect;
463
- const ITERATE_KEY = Symbol("iterate" );
464
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
465
422
  class ReactiveEffect {
466
- constructor(fn, scheduler = null, scope) {
423
+ constructor(fn, trigger, scheduler, scope) {
467
424
  this.fn = fn;
425
+ this.trigger = trigger;
468
426
  this.scheduler = scheduler;
469
427
  this.active = true;
470
428
  this.deps = [];
471
- this.parent = void 0;
429
+ /**
430
+ * @internal
431
+ */
432
+ this._dirtyLevel = 3;
433
+ /**
434
+ * @internal
435
+ */
436
+ this._trackId = 0;
437
+ /**
438
+ * @internal
439
+ */
440
+ this._runnings = 0;
441
+ /**
442
+ * @internal
443
+ */
444
+ this._queryings = 0;
445
+ /**
446
+ * @internal
447
+ */
448
+ this._depsLength = 0;
472
449
  recordEffectScope(this, scope);
473
450
  }
451
+ get dirty() {
452
+ if (this._dirtyLevel === 1) {
453
+ this._dirtyLevel = 0;
454
+ this._queryings++;
455
+ pauseTracking();
456
+ for (const dep of this.deps) {
457
+ if (dep.computed) {
458
+ triggerComputed(dep.computed);
459
+ if (this._dirtyLevel >= 2) {
460
+ break;
461
+ }
462
+ }
463
+ }
464
+ resetTracking();
465
+ this._queryings--;
466
+ }
467
+ return this._dirtyLevel >= 2;
468
+ }
469
+ set dirty(v) {
470
+ this._dirtyLevel = v ? 3 : 0;
471
+ }
474
472
  run() {
473
+ this._dirtyLevel = 0;
475
474
  if (!this.active) {
476
475
  return this.fn();
477
476
  }
478
- let parent = activeEffect;
479
477
  let lastShouldTrack = shouldTrack;
480
- while (parent) {
481
- if (parent === this) {
482
- return;
483
- }
484
- parent = parent.parent;
485
- }
478
+ let lastEffect = activeEffect;
486
479
  try {
487
- this.parent = activeEffect;
488
- activeEffect = this;
489
480
  shouldTrack = true;
490
- trackOpBit = 1 << ++effectTrackDepth;
491
- if (effectTrackDepth <= maxMarkerBits) {
492
- initDepMarkers(this);
493
- } else {
494
- cleanupEffect(this);
495
- }
481
+ activeEffect = this;
482
+ this._runnings++;
483
+ preCleanupEffect(this);
496
484
  return this.fn();
497
485
  } finally {
498
- if (effectTrackDepth <= maxMarkerBits) {
499
- finalizeDepMarkers(this);
500
- }
501
- trackOpBit = 1 << --effectTrackDepth;
502
- activeEffect = this.parent;
486
+ postCleanupEffect(this);
487
+ this._runnings--;
488
+ activeEffect = lastEffect;
503
489
  shouldTrack = lastShouldTrack;
504
- this.parent = void 0;
505
- if (this.deferStop) {
506
- this.stop();
507
- }
508
490
  }
509
491
  }
510
492
  stop() {
511
- if (activeEffect === this) {
512
- this.deferStop = true;
513
- } else if (this.active) {
514
- cleanupEffect(this);
515
- if (this.onStop) {
516
- this.onStop();
517
- }
493
+ var _a;
494
+ if (this.active) {
495
+ preCleanupEffect(this);
496
+ postCleanupEffect(this);
497
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
518
498
  this.active = false;
519
499
  }
520
500
  }
521
501
  }
522
- function cleanupEffect(effect2) {
523
- const { deps } = effect2;
524
- if (deps.length) {
525
- for (let i = 0; i < deps.length; i++) {
526
- deps[i].delete(effect2);
502
+ function triggerComputed(computed) {
503
+ return computed.value;
504
+ }
505
+ function preCleanupEffect(effect2) {
506
+ effect2._trackId++;
507
+ effect2._depsLength = 0;
508
+ }
509
+ function postCleanupEffect(effect2) {
510
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
511
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
512
+ cleanupDepEffect(effect2.deps[i], effect2);
513
+ }
514
+ effect2.deps.length = effect2._depsLength;
515
+ }
516
+ }
517
+ function cleanupDepEffect(dep, effect2) {
518
+ const trackId = dep.get(effect2);
519
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
520
+ dep.delete(effect2);
521
+ if (dep.size === 0) {
522
+ dep.cleanup();
527
523
  }
528
- deps.length = 0;
529
524
  }
530
525
  }
531
526
  function effect(fn, options) {
532
527
  if (fn.effect instanceof ReactiveEffect) {
533
528
  fn = fn.effect.fn;
534
529
  }
535
- const _effect = new ReactiveEffect(fn);
530
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
531
+ if (_effect.dirty) {
532
+ _effect.run();
533
+ }
534
+ });
536
535
  if (options) {
537
536
  extend(_effect, options);
538
537
  if (options.scope)
@@ -549,6 +548,7 @@ var Vue = (function () {
549
548
  runner.effect.stop();
550
549
  }
551
550
  let shouldTrack = true;
551
+ let pauseScheduleStack = 0;
552
552
  const trackStack = [];
553
553
  function pauseTracking() {
554
554
  trackStack.push(shouldTrack);
@@ -558,6 +558,68 @@ var Vue = (function () {
558
558
  const last = trackStack.pop();
559
559
  shouldTrack = last === void 0 ? true : last;
560
560
  }
561
+ function pauseScheduling() {
562
+ pauseScheduleStack++;
563
+ }
564
+ function resetScheduling() {
565
+ pauseScheduleStack--;
566
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
567
+ queueEffectSchedulers.shift()();
568
+ }
569
+ }
570
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
571
+ var _a;
572
+ if (dep.get(effect2) !== effect2._trackId) {
573
+ dep.set(effect2, effect2._trackId);
574
+ const oldDep = effect2.deps[effect2._depsLength];
575
+ if (oldDep !== dep) {
576
+ if (oldDep) {
577
+ cleanupDepEffect(oldDep, effect2);
578
+ }
579
+ effect2.deps[effect2._depsLength++] = dep;
580
+ } else {
581
+ effect2._depsLength++;
582
+ }
583
+ {
584
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
585
+ }
586
+ }
587
+ }
588
+ const queueEffectSchedulers = [];
589
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
590
+ var _a;
591
+ pauseScheduling();
592
+ for (const effect2 of dep.keys()) {
593
+ if (!effect2.allowRecurse && effect2._runnings) {
594
+ continue;
595
+ }
596
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
597
+ const lastDirtyLevel = effect2._dirtyLevel;
598
+ effect2._dirtyLevel = dirtyLevel;
599
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
600
+ {
601
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
602
+ }
603
+ effect2.trigger();
604
+ if (effect2.scheduler) {
605
+ queueEffectSchedulers.push(effect2.scheduler);
606
+ }
607
+ }
608
+ }
609
+ }
610
+ resetScheduling();
611
+ }
612
+
613
+ const createDep = (cleanup, computed) => {
614
+ const dep = /* @__PURE__ */ new Map();
615
+ dep.cleanup = cleanup;
616
+ dep.computed = computed;
617
+ return dep;
618
+ };
619
+
620
+ const targetMap = /* @__PURE__ */ new WeakMap();
621
+ const ITERATE_KEY = Symbol("iterate" );
622
+ const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
561
623
  function track(target, type, key) {
562
624
  if (shouldTrack && activeEffect) {
563
625
  let depsMap = targetMap.get(target);
@@ -566,35 +628,17 @@ var Vue = (function () {
566
628
  }
567
629
  let dep = depsMap.get(key);
568
630
  if (!dep) {
569
- depsMap.set(key, dep = createDep());
570
- }
571
- const eventInfo = { effect: activeEffect, target, type, key } ;
572
- trackEffects(dep, eventInfo);
573
- }
574
- }
575
- function trackEffects(dep, debuggerEventExtraInfo) {
576
- let shouldTrack2 = false;
577
- if (effectTrackDepth <= maxMarkerBits) {
578
- if (!newTracked(dep)) {
579
- dep.n |= trackOpBit;
580
- shouldTrack2 = !wasTracked(dep);
581
- }
582
- } else {
583
- shouldTrack2 = !dep.has(activeEffect);
584
- }
585
- if (shouldTrack2) {
586
- dep.add(activeEffect);
587
- activeEffect.deps.push(dep);
588
- if (activeEffect.onTrack) {
589
- activeEffect.onTrack(
590
- extend(
591
- {
592
- effect: activeEffect
593
- },
594
- debuggerEventExtraInfo
595
- )
596
- );
631
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
597
632
  }
633
+ trackEffect(
634
+ activeEffect,
635
+ dep,
636
+ {
637
+ target,
638
+ type,
639
+ key
640
+ }
641
+ );
598
642
  }
599
643
  }
600
644
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -642,49 +686,24 @@ var Vue = (function () {
642
686
  break;
643
687
  }
644
688
  }
645
- const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
646
- if (deps.length === 1) {
647
- if (deps[0]) {
648
- {
649
- triggerEffects(deps[0], eventInfo);
650
- }
651
- }
652
- } else {
653
- const effects = [];
654
- for (const dep of deps) {
655
- if (dep) {
656
- effects.push(...dep);
657
- }
658
- }
659
- {
660
- triggerEffects(createDep(effects), eventInfo);
661
- }
662
- }
663
- }
664
- function triggerEffects(dep, debuggerEventExtraInfo) {
665
- const effects = isArray(dep) ? dep : [...dep];
666
- for (const effect2 of effects) {
667
- if (effect2.computed) {
668
- triggerEffect(effect2, debuggerEventExtraInfo);
669
- }
670
- }
671
- for (const effect2 of effects) {
672
- if (!effect2.computed) {
673
- triggerEffect(effect2, debuggerEventExtraInfo);
674
- }
675
- }
676
- }
677
- function triggerEffect(effect2, debuggerEventExtraInfo) {
678
- if (effect2 !== activeEffect || effect2.allowRecurse) {
679
- if (effect2.onTrigger) {
680
- effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
681
- }
682
- if (effect2.scheduler) {
683
- effect2.scheduler();
684
- } else {
685
- effect2.run();
689
+ pauseScheduling();
690
+ for (const dep of deps) {
691
+ if (dep) {
692
+ triggerEffects(
693
+ dep,
694
+ 3,
695
+ {
696
+ target,
697
+ type,
698
+ key,
699
+ newValue,
700
+ oldValue,
701
+ oldTarget
702
+ }
703
+ );
686
704
  }
687
705
  }
706
+ resetScheduling();
688
707
  }
689
708
  function getDepFromReactive(object, key) {
690
709
  var _a;
@@ -715,7 +734,9 @@ var Vue = (function () {
715
734
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
716
735
  instrumentations[key] = function(...args) {
717
736
  pauseTracking();
737
+ pauseScheduling();
718
738
  const res = toRaw(this)[key].apply(this, args);
739
+ resetScheduling();
719
740
  resetTracking();
720
741
  return res;
721
742
  };
@@ -1254,30 +1275,94 @@ var Vue = (function () {
1254
1275
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1255
1276
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1256
1277
 
1278
+ class ComputedRefImpl {
1279
+ constructor(getter, _setter, isReadonly, isSSR) {
1280
+ this._setter = _setter;
1281
+ this.dep = void 0;
1282
+ this.__v_isRef = true;
1283
+ this["__v_isReadonly"] = false;
1284
+ this.effect = new ReactiveEffect(
1285
+ () => getter(this._value),
1286
+ () => triggerRefValue(this, 1)
1287
+ );
1288
+ this.effect.computed = this;
1289
+ this.effect.active = this._cacheable = !isSSR;
1290
+ this["__v_isReadonly"] = isReadonly;
1291
+ }
1292
+ get value() {
1293
+ const self = toRaw(this);
1294
+ trackRefValue(self);
1295
+ if (!self._cacheable || self.effect.dirty) {
1296
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1297
+ triggerRefValue(self, 2);
1298
+ }
1299
+ }
1300
+ return self._value;
1301
+ }
1302
+ set value(newValue) {
1303
+ this._setter(newValue);
1304
+ }
1305
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1306
+ get _dirty() {
1307
+ return this.effect.dirty;
1308
+ }
1309
+ set _dirty(v) {
1310
+ this.effect.dirty = v;
1311
+ }
1312
+ // #endregion
1313
+ }
1314
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1315
+ let getter;
1316
+ let setter;
1317
+ const onlyGetter = isFunction(getterOrOptions);
1318
+ if (onlyGetter) {
1319
+ getter = getterOrOptions;
1320
+ setter = () => {
1321
+ console.warn("Write operation failed: computed value is readonly");
1322
+ } ;
1323
+ } else {
1324
+ getter = getterOrOptions.get;
1325
+ setter = getterOrOptions.set;
1326
+ }
1327
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1328
+ if (debugOptions && !isSSR) {
1329
+ cRef.effect.onTrack = debugOptions.onTrack;
1330
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1331
+ }
1332
+ return cRef;
1333
+ }
1334
+
1257
1335
  function trackRefValue(ref2) {
1258
1336
  if (shouldTrack && activeEffect) {
1259
1337
  ref2 = toRaw(ref2);
1260
- {
1261
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1338
+ trackEffect(
1339
+ activeEffect,
1340
+ ref2.dep || (ref2.dep = createDep(
1341
+ () => ref2.dep = void 0,
1342
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1343
+ )),
1344
+ {
1262
1345
  target: ref2,
1263
1346
  type: "get",
1264
1347
  key: "value"
1265
- });
1266
- }
1348
+ }
1349
+ );
1267
1350
  }
1268
1351
  }
1269
- function triggerRefValue(ref2, newVal) {
1352
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1270
1353
  ref2 = toRaw(ref2);
1271
1354
  const dep = ref2.dep;
1272
1355
  if (dep) {
1273
- {
1274
- triggerEffects(dep, {
1356
+ triggerEffects(
1357
+ dep,
1358
+ dirtyLevel,
1359
+ {
1275
1360
  target: ref2,
1276
1361
  type: "set",
1277
1362
  key: "value",
1278
1363
  newValue: newVal
1279
- });
1280
- }
1364
+ }
1365
+ );
1281
1366
  }
1282
1367
  }
1283
1368
  function isRef(r) {
@@ -1313,12 +1398,12 @@ var Vue = (function () {
1313
1398
  if (hasChanged(newVal, this._rawValue)) {
1314
1399
  this._rawValue = newVal;
1315
1400
  this._value = useDirectValue ? newVal : toReactive(newVal);
1316
- triggerRefValue(this, newVal);
1401
+ triggerRefValue(this, 3, newVal);
1317
1402
  }
1318
1403
  }
1319
1404
  }
1320
1405
  function triggerRef(ref2) {
1321
- triggerRefValue(ref2, ref2.value );
1406
+ triggerRefValue(ref2, 3, ref2.value );
1322
1407
  }
1323
1408
  function unref(ref2) {
1324
1409
  return isRef(ref2) ? ref2.value : ref2;
@@ -1416,67 +1501,16 @@ var Vue = (function () {
1416
1501
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1417
1502
  }
1418
1503
 
1419
- class ComputedRefImpl {
1420
- constructor(getter, _setter, isReadonly, isSSR) {
1421
- this._setter = _setter;
1422
- this.dep = void 0;
1423
- this.__v_isRef = true;
1424
- this["__v_isReadonly"] = false;
1425
- this._dirty = true;
1426
- this.effect = new ReactiveEffect(getter, () => {
1427
- if (!this._dirty) {
1428
- this._dirty = true;
1429
- triggerRefValue(this);
1430
- }
1431
- });
1432
- this.effect.computed = this;
1433
- this.effect.active = this._cacheable = !isSSR;
1434
- this["__v_isReadonly"] = isReadonly;
1435
- }
1436
- get value() {
1437
- const self = toRaw(this);
1438
- trackRefValue(self);
1439
- if (self._dirty || !self._cacheable) {
1440
- self._dirty = false;
1441
- self._value = self.effect.run();
1442
- }
1443
- return self._value;
1444
- }
1445
- set value(newValue) {
1446
- this._setter(newValue);
1447
- }
1448
- }
1449
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1450
- let getter;
1451
- let setter;
1452
- const onlyGetter = isFunction(getterOrOptions);
1453
- if (onlyGetter) {
1454
- getter = getterOrOptions;
1455
- setter = () => {
1456
- console.warn("Write operation failed: computed value is readonly");
1457
- } ;
1458
- } else {
1459
- getter = getterOrOptions.get;
1460
- setter = getterOrOptions.set;
1461
- }
1462
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1463
- if (debugOptions && !isSSR) {
1464
- cRef.effect.onTrack = debugOptions.onTrack;
1465
- cRef.effect.onTrigger = debugOptions.onTrigger;
1466
- }
1467
- return cRef;
1468
- }
1469
-
1470
- const stack = [];
1504
+ const stack$1 = [];
1471
1505
  function pushWarningContext(vnode) {
1472
- stack.push(vnode);
1506
+ stack$1.push(vnode);
1473
1507
  }
1474
1508
  function popWarningContext() {
1475
- stack.pop();
1509
+ stack$1.pop();
1476
1510
  }
1477
1511
  function warn(msg, ...args) {
1478
1512
  pauseTracking();
1479
- const instance = stack.length ? stack[stack.length - 1].component : null;
1513
+ const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
1480
1514
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
1481
1515
  const trace = getComponentTrace();
1482
1516
  if (appWarnHandler) {
@@ -1505,7 +1539,7 @@ var Vue = (function () {
1505
1539
  resetTracking();
1506
1540
  }
1507
1541
  function getComponentTrace() {
1508
- let currentVNode = stack[stack.length - 1];
1542
+ let currentVNode = stack$1[stack$1.length - 1];
1509
1543
  if (!currentVNode) {
1510
1544
  return [];
1511
1545
  }
@@ -1581,7 +1615,7 @@ var Vue = (function () {
1581
1615
  }
1582
1616
  }
1583
1617
 
1584
- const ErrorTypeStrings = {
1618
+ const ErrorTypeStrings$1 = {
1585
1619
  ["sp"]: "serverPrefetch hook",
1586
1620
  ["bc"]: "beforeCreate hook",
1587
1621
  ["c"]: "created hook",
@@ -1642,7 +1676,7 @@ var Vue = (function () {
1642
1676
  if (instance) {
1643
1677
  let cur = instance.parent;
1644
1678
  const exposedInstance = instance.proxy;
1645
- const errorInfo = ErrorTypeStrings[type] ;
1679
+ const errorInfo = ErrorTypeStrings$1[type] ;
1646
1680
  while (cur) {
1647
1681
  const errorCapturedHooks = cur.ec;
1648
1682
  if (errorCapturedHooks) {
@@ -1669,7 +1703,7 @@ var Vue = (function () {
1669
1703
  }
1670
1704
  function logError(err, type, contextVNode, throwInDev = true) {
1671
1705
  {
1672
- const info = ErrorTypeStrings[type];
1706
+ const info = ErrorTypeStrings$1[type];
1673
1707
  if (contextVNode) {
1674
1708
  pushWarningContext(contextVNode);
1675
1709
  }
@@ -1897,6 +1931,7 @@ var Vue = (function () {
1897
1931
  }
1898
1932
  instance.renderCache = [];
1899
1933
  isHmrUpdating = true;
1934
+ instance.effect.dirty = true;
1900
1935
  instance.update();
1901
1936
  isHmrUpdating = false;
1902
1937
  });
@@ -1924,6 +1959,7 @@ var Vue = (function () {
1924
1959
  instance.ceReload(newComp.styles);
1925
1960
  hmrDirtyComponents.delete(oldComp);
1926
1961
  } else if (instance.parent) {
1962
+ instance.parent.effect.dirty = true;
1927
1963
  queueJob(instance.parent.update);
1928
1964
  } else if (instance.appContext.reload) {
1929
1965
  instance.appContext.reload();
@@ -3688,8 +3724,15 @@ If this is a native custom element, make sure to exclude it from component resol
3688
3724
  }
3689
3725
  return doWatch(source, cb, options);
3690
3726
  }
3691
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3727
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3692
3728
  var _a;
3729
+ if (cb && once) {
3730
+ const _cb = cb;
3731
+ cb = (...args) => {
3732
+ _cb(...args);
3733
+ unwatch();
3734
+ };
3735
+ }
3693
3736
  if (!cb) {
3694
3737
  if (immediate !== void 0) {
3695
3738
  warn(
@@ -3701,6 +3744,11 @@ If this is a native custom element, make sure to exclude it from component resol
3701
3744
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3702
3745
  );
3703
3746
  }
3747
+ if (once !== void 0) {
3748
+ warn(
3749
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3750
+ );
3751
+ }
3704
3752
  }
3705
3753
  const warnInvalidSource = (s) => {
3706
3754
  warn(
@@ -3779,7 +3827,7 @@ If this is a native custom element, make sure to exclude it from component resol
3779
3827
  };
3780
3828
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3781
3829
  const job = () => {
3782
- if (!effect.active) {
3830
+ if (!effect.active || !effect.dirty) {
3783
3831
  return;
3784
3832
  }
3785
3833
  if (cb) {
@@ -3812,7 +3860,13 @@ If this is a native custom element, make sure to exclude it from component resol
3812
3860
  job.id = instance.uid;
3813
3861
  scheduler = () => queueJob(job);
3814
3862
  }
3815
- const effect = new ReactiveEffect(getter, scheduler);
3863
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3864
+ const unwatch = () => {
3865
+ effect.stop();
3866
+ if (instance && instance.scope) {
3867
+ remove(instance.scope.effects, effect);
3868
+ }
3869
+ };
3816
3870
  {
3817
3871
  effect.onTrack = onTrack;
3818
3872
  effect.onTrigger = onTrigger;
@@ -3831,12 +3885,6 @@ If this is a native custom element, make sure to exclude it from component resol
3831
3885
  } else {
3832
3886
  effect.run();
3833
3887
  }
3834
- const unwatch = () => {
3835
- effect.stop();
3836
- if (instance && instance.scope) {
3837
- remove(instance.scope.effects, effect);
3838
- }
3839
- };
3840
3888
  return unwatch;
3841
3889
  }
3842
3890
  function instanceWatch(source, value, options) {
@@ -4069,6 +4117,7 @@ If this is a native custom element, make sure to exclude it from component resol
4069
4117
  leavingHooks.afterLeave = () => {
4070
4118
  state.isLeaving = false;
4071
4119
  if (instance.update.active !== false) {
4120
+ instance.effect.dirty = true;
4072
4121
  instance.update();
4073
4122
  }
4074
4123
  };
@@ -4411,6 +4460,7 @@ If this is a native custom element, make sure to exclude it from component resol
4411
4460
  load().then(() => {
4412
4461
  loaded.value = true;
4413
4462
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4463
+ instance.parent.effect.dirty = true;
4414
4464
  queueJob(instance.parent.update);
4415
4465
  }
4416
4466
  }).catch((err) => {
@@ -4708,7 +4758,7 @@ If this is a native custom element, make sure to exclude it from component resol
4708
4758
  }
4709
4759
  return wrappedHook;
4710
4760
  } else {
4711
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4761
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4712
4762
  warn(
4713
4763
  `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
4714
4764
  );
@@ -5371,7 +5421,10 @@ If this is a native custom element, make sure to exclude it from component resol
5371
5421
  $root: (i) => getPublicInstance(i.root),
5372
5422
  $emit: (i) => i.emit,
5373
5423
  $options: (i) => resolveMergedOptions(i) ,
5374
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5424
+ $forceUpdate: (i) => i.f || (i.f = () => {
5425
+ i.effect.dirty = true;
5426
+ queueJob(i.update);
5427
+ }),
5375
5428
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5376
5429
  $watch: (i) => instanceWatch.bind(i)
5377
5430
  })
@@ -6272,7 +6325,7 @@ If this is a native custom element, make sure to exclude it from component resol
6272
6325
  return vm;
6273
6326
  }
6274
6327
  }
6275
- Vue.version = `2.6.14-compat:${"3.3.9"}`;
6328
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.2"}`;
6276
6329
  Vue.config = singletonApp.config;
6277
6330
  Vue.use = (p, ...options) => {
6278
6331
  if (p && isFunction(p.install)) {
@@ -8695,6 +8748,7 @@ If you want to remount the same app, move your app creation logic into a factory
8695
8748
  } else {
8696
8749
  instance.next = n2;
8697
8750
  invalidateJob(instance.update);
8751
+ instance.effect.dirty = true;
8698
8752
  instance.update();
8699
8753
  }
8700
8754
  } else {
@@ -8888,11 +8942,16 @@ If you want to remount the same app, move your app creation logic into a factory
8888
8942
  };
8889
8943
  const effect = instance.effect = new ReactiveEffect(
8890
8944
  componentUpdateFn,
8945
+ NOOP,
8891
8946
  () => queueJob(update),
8892
8947
  instance.scope
8893
8948
  // track it in component's effect scope
8894
8949
  );
8895
- const update = instance.update = () => effect.run();
8950
+ const update = instance.update = () => {
8951
+ if (effect.dirty) {
8952
+ effect.run();
8953
+ }
8954
+ };
8896
8955
  update.id = instance.uid;
8897
8956
  toggleRecurse(instance, true);
8898
8957
  {
@@ -10859,7 +10918,8 @@ Component that was made reactive: `,
10859
10918
  return true;
10860
10919
  }
10861
10920
 
10862
- const version = "3.3.9";
10921
+ const version = "3.4.0-alpha.2";
10922
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10863
10923
  const ssrUtils = null;
10864
10924
  const resolveFilter = resolveFilter$1 ;
10865
10925
  const _compatUtils = {
@@ -12482,6 +12542,7 @@ Component that was made reactive: `,
12482
12542
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12483
12543
  Comment: Comment,
12484
12544
  EffectScope: EffectScope,
12545
+ ErrorTypeStrings: ErrorTypeStrings,
12485
12546
  Fragment: Fragment,
12486
12547
  KeepAlive: KeepAlive,
12487
12548
  ReactiveEffect: ReactiveEffect,
@@ -12665,83 +12726,6 @@ Make sure to use the production build (*.prod.js) when deploying for production.
12665
12726
  return Vue;
12666
12727
  }
12667
12728
 
12668
- function defaultOnError(error) {
12669
- throw error;
12670
- }
12671
- function defaultOnWarn(msg) {
12672
- console.warn(`[Vue warn] ${msg.message}`);
12673
- }
12674
- function createCompilerError(code, loc, messages, additionalMessage) {
12675
- const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
12676
- const error = new SyntaxError(String(msg));
12677
- error.code = code;
12678
- error.loc = loc;
12679
- return error;
12680
- }
12681
- const errorMessages = {
12682
- // parse errors
12683
- [0]: "Illegal comment.",
12684
- [1]: "CDATA section is allowed only in XML context.",
12685
- [2]: "Duplicate attribute.",
12686
- [3]: "End tag cannot have attributes.",
12687
- [4]: "Illegal '/' in tags.",
12688
- [5]: "Unexpected EOF in tag.",
12689
- [6]: "Unexpected EOF in CDATA section.",
12690
- [7]: "Unexpected EOF in comment.",
12691
- [8]: "Unexpected EOF in script.",
12692
- [9]: "Unexpected EOF in tag.",
12693
- [10]: "Incorrectly closed comment.",
12694
- [11]: "Incorrectly opened comment.",
12695
- [12]: "Illegal tag name. Use '&lt;' to print '<'.",
12696
- [13]: "Attribute value was expected.",
12697
- [14]: "End tag name was expected.",
12698
- [15]: "Whitespace was expected.",
12699
- [16]: "Unexpected '<!--' in comment.",
12700
- [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
12701
- [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
12702
- [19]: "Attribute name cannot start with '='.",
12703
- [21]: "'<?' is allowed only in XML context.",
12704
- [20]: `Unexpected null character.`,
12705
- [22]: "Illegal '/' in tags.",
12706
- // Vue-specific parse errors
12707
- [23]: "Invalid end tag.",
12708
- [24]: "Element is missing end tag.",
12709
- [25]: "Interpolation end sign was not found.",
12710
- [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
12711
- [26]: "Legal directive name was expected.",
12712
- // transform errors
12713
- [28]: `v-if/v-else-if is missing expression.`,
12714
- [29]: `v-if/else branches must use unique keys.`,
12715
- [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
12716
- [31]: `v-for is missing expression.`,
12717
- [32]: `v-for has invalid expression.`,
12718
- [33]: `<template v-for> key should be placed on the <template> tag.`,
12719
- [34]: `v-bind is missing expression.`,
12720
- [35]: `v-on is missing expression.`,
12721
- [36]: `Unexpected custom directive on <slot> outlet.`,
12722
- [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.`,
12723
- [38]: `Duplicate slot names found. `,
12724
- [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
12725
- [40]: `v-slot can only be used on components or <template> tags.`,
12726
- [41]: `v-model is missing expression.`,
12727
- [42]: `v-model value must be a valid JavaScript member expression.`,
12728
- [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
12729
- [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
12730
- Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
12731
- [45]: `Error parsing JavaScript expression: `,
12732
- [46]: `<KeepAlive> expects exactly one child component.`,
12733
- // generic errors
12734
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
12735
- [48]: `ES module mode is not supported in this build of compiler.`,
12736
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
12737
- [50]: `"scopeId" option is only supported in module mode.`,
12738
- // deprecations
12739
- [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.`,
12740
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
12741
- // just to fulfill types
12742
- [53]: ``
12743
- };
12744
-
12745
12729
  const FRAGMENT = Symbol(`Fragment` );
12746
12730
  const TELEPORT = Symbol(`Teleport` );
12747
12731
  const SUSPENSE = Symbol(`Suspense` );
@@ -12831,13 +12815,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
12831
12815
  }
12832
12816
 
12833
12817
  const locStub = {
12834
- source: "",
12835
12818
  start: { line: 1, column: 1, offset: 0 },
12836
- end: { line: 1, column: 1, offset: 0 }
12819
+ end: { line: 1, column: 1, offset: 0 },
12820
+ source: ""
12837
12821
  };
12838
- function createRoot(children, loc = locStub) {
12822
+ function createRoot(children, source = "") {
12839
12823
  return {
12840
12824
  type: 0,
12825
+ source,
12841
12826
  children,
12842
12827
  helpers: /* @__PURE__ */ new Set(),
12843
12828
  components: [],
@@ -12847,7 +12832,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
12847
12832
  cached: 0,
12848
12833
  temps: 0,
12849
12834
  codegenNode: void 0,
12850
- loc
12835
+ loc: locStub
12851
12836
  };
12852
12837
  }
12853
12838
  function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
@@ -12973,268 +12958,809 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
12973
12958
  }
12974
12959
  }
12975
12960
 
12976
- const isStaticExp = (p) => p.type === 4 && p.isStatic;
12977
- const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
12978
- function isCoreComponent(tag) {
12979
- if (isBuiltInType(tag, "Teleport")) {
12980
- return TELEPORT;
12981
- } else if (isBuiltInType(tag, "Suspense")) {
12982
- return SUSPENSE;
12983
- } else if (isBuiltInType(tag, "KeepAlive")) {
12984
- return KEEP_ALIVE;
12985
- } else if (isBuiltInType(tag, "BaseTransition")) {
12986
- return BASE_TRANSITION;
12987
- }
12961
+ const defaultDelimitersOpen = new Uint8Array([123, 123]);
12962
+ const defaultDelimitersClose = new Uint8Array([125, 125]);
12963
+ function isTagStartChar(c) {
12964
+ return c >= 97 && c <= 122 || c >= 65 && c <= 90;
12988
12965
  }
12989
- const nonIdentifierRE = /^\d|[^\$\w]/;
12990
- const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
12991
- const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
12992
- const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
12993
- const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
12994
- const isMemberExpressionBrowser = (path) => {
12995
- path = path.trim().replace(whitespaceRE, (s) => s.trim());
12996
- let state = 0 /* inMemberExp */;
12997
- let stateStack = [];
12998
- let currentOpenBracketCount = 0;
12999
- let currentOpenParensCount = 0;
13000
- let currentStringType = null;
13001
- for (let i = 0; i < path.length; i++) {
13002
- const char = path.charAt(i);
13003
- switch (state) {
13004
- case 0 /* inMemberExp */:
13005
- if (char === "[") {
13006
- stateStack.push(state);
13007
- state = 1 /* inBrackets */;
13008
- currentOpenBracketCount++;
13009
- } else if (char === "(") {
13010
- stateStack.push(state);
13011
- state = 2 /* inParens */;
13012
- currentOpenParensCount++;
13013
- } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
13014
- return false;
13015
- }
13016
- break;
13017
- case 1 /* inBrackets */:
13018
- if (char === `'` || char === `"` || char === "`") {
13019
- stateStack.push(state);
13020
- state = 3 /* inString */;
13021
- currentStringType = char;
13022
- } else if (char === `[`) {
13023
- currentOpenBracketCount++;
13024
- } else if (char === `]`) {
13025
- if (!--currentOpenBracketCount) {
13026
- state = stateStack.pop();
13027
- }
13028
- }
13029
- break;
13030
- case 2 /* inParens */:
13031
- if (char === `'` || char === `"` || char === "`") {
13032
- stateStack.push(state);
13033
- state = 3 /* inString */;
13034
- currentStringType = char;
13035
- } else if (char === `(`) {
13036
- currentOpenParensCount++;
13037
- } else if (char === `)`) {
13038
- if (i === path.length - 1) {
13039
- return false;
13040
- }
13041
- if (!--currentOpenParensCount) {
13042
- state = stateStack.pop();
13043
- }
13044
- }
13045
- break;
13046
- case 3 /* inString */:
13047
- if (char === currentStringType) {
13048
- state = stateStack.pop();
13049
- currentStringType = null;
13050
- }
13051
- break;
13052
- }
13053
- }
13054
- return !currentOpenBracketCount && !currentOpenParensCount;
13055
- };
13056
- const isMemberExpression = isMemberExpressionBrowser ;
13057
- function getInnerRange(loc, offset, length) {
13058
- const source = loc.source.slice(offset, offset + length);
13059
- const newLoc = {
13060
- source,
13061
- start: advancePositionWithClone(loc.start, loc.source, offset),
13062
- end: loc.end
13063
- };
13064
- if (length != null) {
13065
- newLoc.end = advancePositionWithClone(
13066
- loc.start,
13067
- loc.source,
13068
- offset + length
13069
- );
13070
- }
13071
- return newLoc;
12966
+ function isWhitespace(c) {
12967
+ return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
13072
12968
  }
13073
- function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
13074
- return advancePositionWithMutation(
13075
- extend({}, pos),
13076
- source,
13077
- numberOfCharacters
13078
- );
12969
+ function isEndOfTagSection(c) {
12970
+ return c === 47 || c === 62 || isWhitespace(c);
13079
12971
  }
13080
- function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
13081
- let linesCount = 0;
13082
- let lastNewLinePos = -1;
13083
- for (let i = 0; i < numberOfCharacters; i++) {
13084
- if (source.charCodeAt(i) === 10) {
13085
- linesCount++;
13086
- lastNewLinePos = i;
13087
- }
12972
+ function toCharCodes(str) {
12973
+ const ret = new Uint8Array(str.length);
12974
+ for (let i = 0; i < str.length; i++) {
12975
+ ret[i] = str.charCodeAt(i);
13088
12976
  }
13089
- pos.offset += numberOfCharacters;
13090
- pos.line += linesCount;
13091
- pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
13092
- return pos;
12977
+ return ret;
13093
12978
  }
13094
- function assert(condition, msg) {
13095
- if (!condition) {
13096
- throw new Error(msg || `unexpected compiler condition`);
12979
+ const Sequences = {
12980
+ Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
12981
+ // CDATA[
12982
+ CdataEnd: new Uint8Array([93, 93, 62]),
12983
+ // ]]>
12984
+ CommentEnd: new Uint8Array([45, 45, 62]),
12985
+ // `-->`
12986
+ ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
12987
+ // `<\/script`
12988
+ StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
12989
+ // `</style`
12990
+ TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
12991
+ // `</title`
12992
+ TextareaEnd: new Uint8Array([
12993
+ 60,
12994
+ 47,
12995
+ 116,
12996
+ 101,
12997
+ 120,
12998
+ 116,
12999
+ 97,
13000
+ 114,
13001
+ 101,
13002
+ 97
13003
+ ])
13004
+ // `</textarea
13005
+ };
13006
+ class Tokenizer {
13007
+ constructor(stack, cbs) {
13008
+ this.stack = stack;
13009
+ this.cbs = cbs;
13010
+ /** The current state the tokenizer is in. */
13011
+ this.state = 1;
13012
+ /** The read buffer. */
13013
+ this.buffer = "";
13014
+ /** The beginning of the section that is currently being read. */
13015
+ this.sectionStart = 0;
13016
+ /** The index within the buffer that we are currently looking at. */
13017
+ this.index = 0;
13018
+ /** The start of the last entity. */
13019
+ this.entityStart = 0;
13020
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
13021
+ this.baseState = 1;
13022
+ /** For special parsing behavior inside of script and style tags. */
13023
+ this.inRCDATA = false;
13024
+ /** For disabling RCDATA tags handling */
13025
+ this.inXML = false;
13026
+ /** Reocrd newline positions for fast line / column calculation */
13027
+ this.newlines = [];
13028
+ this.mode = 0;
13029
+ this.delimiterOpen = defaultDelimitersOpen;
13030
+ this.delimiterClose = defaultDelimitersClose;
13031
+ this.delimiterIndex = -1;
13032
+ this.currentSequence = void 0;
13033
+ this.sequenceIndex = 0;
13034
+ }
13035
+ get inSFCRoot() {
13036
+ return this.mode === 2 && this.stack.length === 0;
13037
+ }
13038
+ reset() {
13039
+ this.state = 1;
13040
+ this.mode = 0;
13041
+ this.buffer = "";
13042
+ this.sectionStart = 0;
13043
+ this.index = 0;
13044
+ this.baseState = 1;
13045
+ this.currentSequence = void 0;
13046
+ this.newlines.length = 0;
13047
+ this.delimiterOpen = defaultDelimitersOpen;
13048
+ this.delimiterClose = defaultDelimitersClose;
13097
13049
  }
13098
- }
13099
- function findDir(node, name, allowEmpty = false) {
13100
- for (let i = 0; i < node.props.length; i++) {
13101
- const p = node.props[i];
13102
- if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
13103
- return p;
13050
+ /**
13051
+ * Generate Position object with line / column information using recorded
13052
+ * newline positions. We know the index is always going to be an already
13053
+ * processed index, so all the newlines up to this index should have been
13054
+ * recorded.
13055
+ */
13056
+ getPos(index) {
13057
+ let line = 1;
13058
+ let column = index + 1;
13059
+ for (let i = this.newlines.length - 1; i >= 0; i--) {
13060
+ const newlineIndex = this.newlines[i];
13061
+ if (index > newlineIndex) {
13062
+ line = i + 2;
13063
+ column = index - newlineIndex;
13064
+ break;
13065
+ }
13104
13066
  }
13067
+ return {
13068
+ column,
13069
+ line,
13070
+ offset: index
13071
+ };
13105
13072
  }
13106
- }
13107
- function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
13108
- for (let i = 0; i < node.props.length; i++) {
13109
- const p = node.props[i];
13110
- if (p.type === 6) {
13111
- if (dynamicOnly)
13112
- continue;
13113
- if (p.name === name && (p.value || allowEmpty)) {
13114
- return p;
13073
+ peek() {
13074
+ return this.buffer.charCodeAt(this.index + 1);
13075
+ }
13076
+ stateText(c) {
13077
+ if (c === 60) {
13078
+ if (this.index > this.sectionStart) {
13079
+ this.cbs.ontext(this.sectionStart, this.index);
13115
13080
  }
13116
- } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
13117
- return p;
13081
+ this.state = 5;
13082
+ this.sectionStart = this.index;
13083
+ } else if (c === this.delimiterOpen[0]) {
13084
+ this.state = 2;
13085
+ this.delimiterIndex = 0;
13086
+ this.stateInterpolationOpen(c);
13118
13087
  }
13119
13088
  }
13120
- }
13121
- function isStaticArgOf(arg, name) {
13122
- return !!(arg && isStaticExp(arg) && arg.content === name);
13123
- }
13124
- function hasDynamicKeyVBind(node) {
13125
- return node.props.some(
13126
- (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
13127
- p.arg.type !== 4 || // v-bind:[_ctx.foo]
13128
- !p.arg.isStatic)
13129
- // v-bind:[foo]
13130
- );
13131
- }
13132
- function isText$1(node) {
13133
- return node.type === 5 || node.type === 2;
13134
- }
13135
- function isVSlot(p) {
13136
- return p.type === 7 && p.name === "slot";
13137
- }
13138
- function isTemplateNode(node) {
13139
- return node.type === 1 && node.tagType === 3;
13140
- }
13141
- function isSlotOutlet(node) {
13142
- return node.type === 1 && node.tagType === 2;
13143
- }
13144
- const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
13145
- function getUnnormalizedProps(props, callPath = []) {
13146
- if (props && !isString(props) && props.type === 14) {
13147
- const callee = props.callee;
13148
- if (!isString(callee) && propsHelperSet.has(callee)) {
13149
- return getUnnormalizedProps(
13150
- props.arguments[0],
13151
- callPath.concat(props)
13152
- );
13089
+ stateInterpolationOpen(c) {
13090
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
13091
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
13092
+ const start = this.index + 1 - this.delimiterOpen.length;
13093
+ if (start > this.sectionStart) {
13094
+ this.cbs.ontext(this.sectionStart, start);
13095
+ }
13096
+ this.state = 3;
13097
+ this.sectionStart = start;
13098
+ } else {
13099
+ this.delimiterIndex++;
13100
+ }
13101
+ } else if (this.inRCDATA) {
13102
+ this.state = 32;
13103
+ this.stateInRCDATA(c);
13104
+ } else {
13105
+ this.state = 1;
13106
+ this.stateText(c);
13153
13107
  }
13154
13108
  }
13155
- return [props, callPath];
13156
- }
13157
- function injectProp(node, prop, context) {
13158
- let propsWithInjection;
13159
- let props = node.type === 13 ? node.props : node.arguments[2];
13160
- let callPath = [];
13161
- let parentCall;
13162
- if (props && !isString(props) && props.type === 14) {
13163
- const ret = getUnnormalizedProps(props);
13164
- props = ret[0];
13165
- callPath = ret[1];
13166
- parentCall = callPath[callPath.length - 1];
13109
+ stateInterpolation(c) {
13110
+ if (c === this.delimiterClose[0]) {
13111
+ this.state = 4;
13112
+ this.delimiterIndex = 0;
13113
+ this.stateInterpolationClose(c);
13114
+ }
13167
13115
  }
13168
- if (props == null || isString(props)) {
13169
- propsWithInjection = createObjectExpression([prop]);
13170
- } else if (props.type === 14) {
13171
- const first = props.arguments[0];
13172
- if (!isString(first) && first.type === 15) {
13173
- if (!hasProp(prop, first)) {
13174
- first.properties.unshift(prop);
13116
+ stateInterpolationClose(c) {
13117
+ if (c === this.delimiterClose[this.delimiterIndex]) {
13118
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
13119
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
13120
+ if (this.inRCDATA) {
13121
+ this.state = 32;
13122
+ } else {
13123
+ this.state = 1;
13124
+ }
13125
+ this.sectionStart = this.index + 1;
13126
+ } else {
13127
+ this.delimiterIndex++;
13175
13128
  }
13176
13129
  } else {
13177
- if (props.callee === TO_HANDLERS) {
13178
- propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
13179
- createObjectExpression([prop]),
13180
- props
13181
- ]);
13182
- } else {
13183
- props.arguments.unshift(createObjectExpression([prop]));
13130
+ this.state = 3;
13131
+ this.stateInterpolation(c);
13132
+ }
13133
+ }
13134
+ stateSpecialStartSequence(c) {
13135
+ const isEnd = this.sequenceIndex === this.currentSequence.length;
13136
+ const isMatch = isEnd ? (
13137
+ // If we are at the end of the sequence, make sure the tag name has ended
13138
+ isEndOfTagSection(c)
13139
+ ) : (
13140
+ // Otherwise, do a case-insensitive comparison
13141
+ (c | 32) === this.currentSequence[this.sequenceIndex]
13142
+ );
13143
+ if (!isMatch) {
13144
+ this.inRCDATA = false;
13145
+ } else if (!isEnd) {
13146
+ this.sequenceIndex++;
13147
+ return;
13148
+ }
13149
+ this.sequenceIndex = 0;
13150
+ this.state = 6;
13151
+ this.stateInTagName(c);
13152
+ }
13153
+ /** Look for an end tag. For <title> and <textarea>, also decode entities. */
13154
+ stateInRCDATA(c) {
13155
+ if (this.sequenceIndex === this.currentSequence.length) {
13156
+ if (c === 62 || isWhitespace(c)) {
13157
+ const endOfText = this.index - this.currentSequence.length;
13158
+ if (this.sectionStart < endOfText) {
13159
+ const actualIndex = this.index;
13160
+ this.index = endOfText;
13161
+ this.cbs.ontext(this.sectionStart, endOfText);
13162
+ this.index = actualIndex;
13163
+ }
13164
+ this.sectionStart = endOfText + 2;
13165
+ this.stateInClosingTagName(c);
13166
+ this.inRCDATA = false;
13167
+ return;
13184
13168
  }
13169
+ this.sequenceIndex = 0;
13185
13170
  }
13186
- !propsWithInjection && (propsWithInjection = props);
13187
- } else if (props.type === 15) {
13188
- if (!hasProp(prop, props)) {
13189
- props.properties.unshift(prop);
13171
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
13172
+ this.sequenceIndex += 1;
13173
+ } else if (this.sequenceIndex === 0) {
13174
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
13175
+ if (c === this.delimiterOpen[0]) {
13176
+ this.state = 2;
13177
+ this.delimiterIndex = 0;
13178
+ this.stateInterpolationOpen(c);
13179
+ }
13180
+ } else if (this.fastForwardTo(60)) {
13181
+ this.sequenceIndex = 1;
13182
+ }
13183
+ } else {
13184
+ this.sequenceIndex = Number(c === 60);
13190
13185
  }
13191
- propsWithInjection = props;
13192
- } else {
13193
- propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
13194
- createObjectExpression([prop]),
13195
- props
13196
- ]);
13197
- if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
13198
- parentCall = callPath[callPath.length - 2];
13186
+ }
13187
+ stateCDATASequence(c) {
13188
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
13189
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
13190
+ this.state = 28;
13191
+ this.currentSequence = Sequences.CdataEnd;
13192
+ this.sequenceIndex = 0;
13193
+ this.sectionStart = this.index + 1;
13194
+ }
13195
+ } else {
13196
+ this.sequenceIndex = 0;
13197
+ this.state = 23;
13198
+ this.stateInDeclaration(c);
13199
13199
  }
13200
13200
  }
13201
- if (node.type === 13) {
13202
- if (parentCall) {
13203
- parentCall.arguments[0] = propsWithInjection;
13201
+ /**
13202
+ * When we wait for one specific character, we can speed things up
13203
+ * by skipping through the buffer until we find it.
13204
+ *
13205
+ * @returns Whether the character was found.
13206
+ */
13207
+ fastForwardTo(c) {
13208
+ while (++this.index < this.buffer.length) {
13209
+ const cc = this.buffer.charCodeAt(this.index);
13210
+ if (cc === 10) {
13211
+ this.newlines.push(this.index);
13212
+ }
13213
+ if (cc === c) {
13214
+ return true;
13215
+ }
13216
+ }
13217
+ this.index = this.buffer.length - 1;
13218
+ return false;
13219
+ }
13220
+ /**
13221
+ * Comments and CDATA end with `-->` and `]]>`.
13222
+ *
13223
+ * Their common qualities are:
13224
+ * - Their end sequences have a distinct character they start with.
13225
+ * - That character is then repeated, so we have to check multiple repeats.
13226
+ * - All characters but the start character of the sequence can be skipped.
13227
+ */
13228
+ stateInCommentLike(c) {
13229
+ if (c === this.currentSequence[this.sequenceIndex]) {
13230
+ if (++this.sequenceIndex === this.currentSequence.length) {
13231
+ if (this.currentSequence === Sequences.CdataEnd) {
13232
+ this.cbs.oncdata(this.sectionStart, this.index - 2);
13233
+ } else {
13234
+ this.cbs.oncomment(this.sectionStart, this.index - 2);
13235
+ }
13236
+ this.sequenceIndex = 0;
13237
+ this.sectionStart = this.index + 1;
13238
+ this.state = 1;
13239
+ }
13240
+ } else if (this.sequenceIndex === 0) {
13241
+ if (this.fastForwardTo(this.currentSequence[0])) {
13242
+ this.sequenceIndex = 1;
13243
+ }
13244
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
13245
+ this.sequenceIndex = 0;
13246
+ }
13247
+ }
13248
+ startSpecial(sequence, offset) {
13249
+ this.enterRCDATA(sequence, offset);
13250
+ this.state = 31;
13251
+ }
13252
+ enterRCDATA(sequence, offset) {
13253
+ this.inRCDATA = true;
13254
+ this.currentSequence = sequence;
13255
+ this.sequenceIndex = offset;
13256
+ }
13257
+ stateBeforeTagName(c) {
13258
+ if (c === 33) {
13259
+ this.state = 22;
13260
+ this.sectionStart = this.index + 1;
13261
+ } else if (c === 63) {
13262
+ this.state = 24;
13263
+ this.sectionStart = this.index + 1;
13264
+ } else if (isTagStartChar(c)) {
13265
+ this.sectionStart = this.index;
13266
+ if (this.mode === 0) {
13267
+ this.state = 6;
13268
+ } else if (this.inSFCRoot) {
13269
+ this.state = 34;
13270
+ } else if (!this.inXML) {
13271
+ const lower = c | 32;
13272
+ if (lower === 116) {
13273
+ this.state = 30;
13274
+ } else {
13275
+ this.state = lower === 115 ? 29 : 6;
13276
+ }
13277
+ } else {
13278
+ this.state = 6;
13279
+ }
13280
+ } else if (c === 47) {
13281
+ this.state = 8;
13204
13282
  } else {
13205
- node.props = propsWithInjection;
13283
+ this.state = 1;
13284
+ this.stateText(c);
13206
13285
  }
13207
- } else {
13208
- if (parentCall) {
13209
- parentCall.arguments[0] = propsWithInjection;
13286
+ }
13287
+ stateInTagName(c) {
13288
+ if (isEndOfTagSection(c)) {
13289
+ this.handleTagName(c);
13290
+ }
13291
+ }
13292
+ stateInSFCRootTagName(c) {
13293
+ if (isEndOfTagSection(c)) {
13294
+ const tag = this.buffer.slice(this.sectionStart, this.index);
13295
+ if (tag !== "template") {
13296
+ this.enterRCDATA(toCharCodes(`</` + tag), 0);
13297
+ }
13298
+ this.handleTagName(c);
13299
+ }
13300
+ }
13301
+ handleTagName(c) {
13302
+ this.cbs.onopentagname(this.sectionStart, this.index);
13303
+ this.sectionStart = -1;
13304
+ this.state = 11;
13305
+ this.stateBeforeAttrName(c);
13306
+ }
13307
+ stateBeforeClosingTagName(c) {
13308
+ if (isWhitespace(c)) ; else if (c === 62) {
13309
+ {
13310
+ this.cbs.onerr(14, this.index);
13311
+ }
13312
+ this.state = 1;
13313
+ this.sectionStart = this.index + 1;
13210
13314
  } else {
13211
- node.arguments[2] = propsWithInjection;
13315
+ this.state = isTagStartChar(c) ? 9 : 27;
13316
+ this.sectionStart = this.index;
13212
13317
  }
13213
13318
  }
13214
- }
13215
- function hasProp(prop, props) {
13216
- let result = false;
13217
- if (prop.key.type === 4) {
13218
- const propKeyName = prop.key.content;
13219
- result = props.properties.some(
13220
- (p) => p.key.type === 4 && p.key.content === propKeyName
13221
- );
13319
+ stateInClosingTagName(c) {
13320
+ if (c === 62 || isWhitespace(c)) {
13321
+ this.cbs.onclosetag(this.sectionStart, this.index);
13322
+ this.sectionStart = -1;
13323
+ this.state = 10;
13324
+ this.stateAfterClosingTagName(c);
13325
+ }
13222
13326
  }
13223
- return result;
13224
- }
13225
- function toValidAssetId(name, type) {
13226
- return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
13227
- return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
13228
- })}`;
13229
- }
13230
- function getMemoedVNodeCall(node) {
13231
- if (node.type === 14 && node.callee === WITH_MEMO) {
13232
- return node.arguments[1].returns;
13233
- } else {
13234
- return node;
13327
+ stateAfterClosingTagName(c) {
13328
+ if (c === 62) {
13329
+ this.state = 1;
13330
+ this.sectionStart = this.index + 1;
13331
+ }
13332
+ }
13333
+ stateBeforeAttrName(c) {
13334
+ if (c === 62) {
13335
+ this.cbs.onopentagend(this.index);
13336
+ if (this.inRCDATA) {
13337
+ this.state = 32;
13338
+ } else {
13339
+ this.state = 1;
13340
+ }
13341
+ this.sectionStart = this.index + 1;
13342
+ } else if (c === 47) {
13343
+ this.state = 7;
13344
+ if (this.peek() !== 62) {
13345
+ this.cbs.onerr(22, this.index);
13346
+ }
13347
+ } else if (c === 60 && this.peek() === 47) {
13348
+ this.cbs.onopentagend(this.index);
13349
+ this.state = 5;
13350
+ this.sectionStart = this.index;
13351
+ } else if (!isWhitespace(c)) {
13352
+ if (c === 61) {
13353
+ this.cbs.onerr(
13354
+ 19,
13355
+ this.index
13356
+ );
13357
+ }
13358
+ this.handleAttrStart(c);
13359
+ }
13360
+ }
13361
+ handleAttrStart(c) {
13362
+ if (c === 118 && this.peek() === 45) {
13363
+ this.state = 13;
13364
+ this.sectionStart = this.index;
13365
+ } else if (c === 46 || c === 58 || c === 64 || c === 35) {
13366
+ this.cbs.ondirname(this.index, this.index + 1);
13367
+ this.state = 14;
13368
+ this.sectionStart = this.index + 1;
13369
+ } else {
13370
+ this.state = 12;
13371
+ this.sectionStart = this.index;
13372
+ }
13373
+ }
13374
+ stateInSelfClosingTag(c) {
13375
+ if (c === 62) {
13376
+ this.cbs.onselfclosingtag(this.index);
13377
+ this.state = 1;
13378
+ this.sectionStart = this.index + 1;
13379
+ this.inRCDATA = false;
13380
+ } else if (!isWhitespace(c)) {
13381
+ this.state = 11;
13382
+ this.stateBeforeAttrName(c);
13383
+ }
13384
+ }
13385
+ stateInAttrName(c) {
13386
+ if (c === 61 || isEndOfTagSection(c)) {
13387
+ this.cbs.onattribname(this.sectionStart, this.index);
13388
+ this.handleAttrNameEnd(c);
13389
+ } else if (c === 34 || c === 39 || c === 60) {
13390
+ this.cbs.onerr(
13391
+ 17,
13392
+ this.index
13393
+ );
13394
+ }
13395
+ }
13396
+ stateInDirName(c) {
13397
+ if (c === 61 || isEndOfTagSection(c)) {
13398
+ this.cbs.ondirname(this.sectionStart, this.index);
13399
+ this.handleAttrNameEnd(c);
13400
+ } else if (c === 58) {
13401
+ this.cbs.ondirname(this.sectionStart, this.index);
13402
+ this.state = 14;
13403
+ this.sectionStart = this.index + 1;
13404
+ } else if (c === 46) {
13405
+ this.cbs.ondirname(this.sectionStart, this.index);
13406
+ this.state = 16;
13407
+ this.sectionStart = this.index + 1;
13408
+ }
13409
+ }
13410
+ stateInDirArg(c) {
13411
+ if (c === 61 || isEndOfTagSection(c)) {
13412
+ this.cbs.ondirarg(this.sectionStart, this.index);
13413
+ this.handleAttrNameEnd(c);
13414
+ } else if (c === 91) {
13415
+ this.state = 15;
13416
+ } else if (c === 46) {
13417
+ this.cbs.ondirarg(this.sectionStart, this.index);
13418
+ this.state = 16;
13419
+ this.sectionStart = this.index + 1;
13420
+ }
13421
+ }
13422
+ stateInDynamicDirArg(c) {
13423
+ if (c === 93) {
13424
+ this.state = 14;
13425
+ } else if (c === 61 || isEndOfTagSection(c)) {
13426
+ this.cbs.ondirarg(this.sectionStart, this.index + 1);
13427
+ this.handleAttrNameEnd(c);
13428
+ {
13429
+ this.cbs.onerr(
13430
+ 27,
13431
+ this.index
13432
+ );
13433
+ }
13434
+ }
13435
+ }
13436
+ stateInDirModifier(c) {
13437
+ if (c === 61 || isEndOfTagSection(c)) {
13438
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
13439
+ this.handleAttrNameEnd(c);
13440
+ } else if (c === 46) {
13441
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
13442
+ this.sectionStart = this.index + 1;
13443
+ }
13444
+ }
13445
+ handleAttrNameEnd(c) {
13446
+ this.sectionStart = this.index;
13447
+ this.state = 17;
13448
+ this.cbs.onattribnameend(this.index);
13449
+ this.stateAfterAttrName(c);
13450
+ }
13451
+ stateAfterAttrName(c) {
13452
+ if (c === 61) {
13453
+ this.state = 18;
13454
+ } else if (c === 47 || c === 62) {
13455
+ this.cbs.onattribend(0, this.sectionStart);
13456
+ this.sectionStart = -1;
13457
+ this.state = 11;
13458
+ this.stateBeforeAttrName(c);
13459
+ } else if (!isWhitespace(c)) {
13460
+ this.cbs.onattribend(0, this.sectionStart);
13461
+ this.handleAttrStart(c);
13462
+ }
13463
+ }
13464
+ stateBeforeAttrValue(c) {
13465
+ if (c === 34) {
13466
+ this.state = 19;
13467
+ this.sectionStart = this.index + 1;
13468
+ } else if (c === 39) {
13469
+ this.state = 20;
13470
+ this.sectionStart = this.index + 1;
13471
+ } else if (!isWhitespace(c)) {
13472
+ this.sectionStart = this.index;
13473
+ this.state = 21;
13474
+ this.stateInAttrValueNoQuotes(c);
13475
+ }
13476
+ }
13477
+ handleInAttrValue(c, quote) {
13478
+ if (c === quote || this.fastForwardTo(quote)) {
13479
+ this.cbs.onattribdata(this.sectionStart, this.index);
13480
+ this.sectionStart = -1;
13481
+ this.cbs.onattribend(
13482
+ quote === 34 ? 3 : 2,
13483
+ this.index + 1
13484
+ );
13485
+ this.state = 11;
13486
+ }
13487
+ }
13488
+ stateInAttrValueDoubleQuotes(c) {
13489
+ this.handleInAttrValue(c, 34);
13490
+ }
13491
+ stateInAttrValueSingleQuotes(c) {
13492
+ this.handleInAttrValue(c, 39);
13493
+ }
13494
+ stateInAttrValueNoQuotes(c) {
13495
+ if (isWhitespace(c) || c === 62) {
13496
+ this.cbs.onattribdata(this.sectionStart, this.index);
13497
+ this.sectionStart = -1;
13498
+ this.cbs.onattribend(1, this.index);
13499
+ this.state = 11;
13500
+ this.stateBeforeAttrName(c);
13501
+ } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
13502
+ this.cbs.onerr(
13503
+ 18,
13504
+ this.index
13505
+ );
13506
+ } else ;
13507
+ }
13508
+ stateBeforeDeclaration(c) {
13509
+ if (c === 91) {
13510
+ this.state = 26;
13511
+ this.sequenceIndex = 0;
13512
+ } else {
13513
+ this.state = c === 45 ? 25 : 23;
13514
+ }
13515
+ }
13516
+ stateInDeclaration(c) {
13517
+ if (c === 62 || this.fastForwardTo(62)) {
13518
+ this.state = 1;
13519
+ this.sectionStart = this.index + 1;
13520
+ }
13521
+ }
13522
+ stateInProcessingInstruction(c) {
13523
+ if (c === 62 || this.fastForwardTo(62)) {
13524
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index);
13525
+ this.state = 1;
13526
+ this.sectionStart = this.index + 1;
13527
+ }
13528
+ }
13529
+ stateBeforeComment(c) {
13530
+ if (c === 45) {
13531
+ this.state = 28;
13532
+ this.currentSequence = Sequences.CommentEnd;
13533
+ this.sequenceIndex = 2;
13534
+ this.sectionStart = this.index + 1;
13535
+ } else {
13536
+ this.state = 23;
13537
+ }
13538
+ }
13539
+ stateInSpecialComment(c) {
13540
+ if (c === 62 || this.fastForwardTo(62)) {
13541
+ this.cbs.oncomment(this.sectionStart, this.index);
13542
+ this.state = 1;
13543
+ this.sectionStart = this.index + 1;
13544
+ }
13545
+ }
13546
+ stateBeforeSpecialS(c) {
13547
+ const lower = c | 32;
13548
+ if (lower === Sequences.ScriptEnd[3]) {
13549
+ this.startSpecial(Sequences.ScriptEnd, 4);
13550
+ } else if (lower === Sequences.StyleEnd[3]) {
13551
+ this.startSpecial(Sequences.StyleEnd, 4);
13552
+ } else {
13553
+ this.state = 6;
13554
+ this.stateInTagName(c);
13555
+ }
13556
+ }
13557
+ stateBeforeSpecialT(c) {
13558
+ const lower = c | 32;
13559
+ if (lower === Sequences.TitleEnd[3]) {
13560
+ this.startSpecial(Sequences.TitleEnd, 4);
13561
+ } else if (lower === Sequences.TextareaEnd[3]) {
13562
+ this.startSpecial(Sequences.TextareaEnd, 4);
13563
+ } else {
13564
+ this.state = 6;
13565
+ this.stateInTagName(c);
13566
+ }
13567
+ }
13568
+ startEntity() {
13569
+ }
13570
+ stateInEntity() {
13571
+ }
13572
+ /**
13573
+ * Iterates through the buffer, calling the function corresponding to the current state.
13574
+ *
13575
+ * States that are more likely to be hit are higher up, as a performance improvement.
13576
+ */
13577
+ parse(input) {
13578
+ this.buffer = input;
13579
+ while (this.index < this.buffer.length) {
13580
+ const c = this.buffer.charCodeAt(this.index);
13581
+ if (c === 10) {
13582
+ this.newlines.push(this.index);
13583
+ }
13584
+ switch (this.state) {
13585
+ case 1: {
13586
+ this.stateText(c);
13587
+ break;
13588
+ }
13589
+ case 2: {
13590
+ this.stateInterpolationOpen(c);
13591
+ break;
13592
+ }
13593
+ case 3: {
13594
+ this.stateInterpolation(c);
13595
+ break;
13596
+ }
13597
+ case 4: {
13598
+ this.stateInterpolationClose(c);
13599
+ break;
13600
+ }
13601
+ case 31: {
13602
+ this.stateSpecialStartSequence(c);
13603
+ break;
13604
+ }
13605
+ case 32: {
13606
+ this.stateInRCDATA(c);
13607
+ break;
13608
+ }
13609
+ case 26: {
13610
+ this.stateCDATASequence(c);
13611
+ break;
13612
+ }
13613
+ case 19: {
13614
+ this.stateInAttrValueDoubleQuotes(c);
13615
+ break;
13616
+ }
13617
+ case 12: {
13618
+ this.stateInAttrName(c);
13619
+ break;
13620
+ }
13621
+ case 13: {
13622
+ this.stateInDirName(c);
13623
+ break;
13624
+ }
13625
+ case 14: {
13626
+ this.stateInDirArg(c);
13627
+ break;
13628
+ }
13629
+ case 15: {
13630
+ this.stateInDynamicDirArg(c);
13631
+ break;
13632
+ }
13633
+ case 16: {
13634
+ this.stateInDirModifier(c);
13635
+ break;
13636
+ }
13637
+ case 28: {
13638
+ this.stateInCommentLike(c);
13639
+ break;
13640
+ }
13641
+ case 27: {
13642
+ this.stateInSpecialComment(c);
13643
+ break;
13644
+ }
13645
+ case 11: {
13646
+ this.stateBeforeAttrName(c);
13647
+ break;
13648
+ }
13649
+ case 6: {
13650
+ this.stateInTagName(c);
13651
+ break;
13652
+ }
13653
+ case 34: {
13654
+ this.stateInSFCRootTagName(c);
13655
+ break;
13656
+ }
13657
+ case 9: {
13658
+ this.stateInClosingTagName(c);
13659
+ break;
13660
+ }
13661
+ case 5: {
13662
+ this.stateBeforeTagName(c);
13663
+ break;
13664
+ }
13665
+ case 17: {
13666
+ this.stateAfterAttrName(c);
13667
+ break;
13668
+ }
13669
+ case 20: {
13670
+ this.stateInAttrValueSingleQuotes(c);
13671
+ break;
13672
+ }
13673
+ case 18: {
13674
+ this.stateBeforeAttrValue(c);
13675
+ break;
13676
+ }
13677
+ case 8: {
13678
+ this.stateBeforeClosingTagName(c);
13679
+ break;
13680
+ }
13681
+ case 10: {
13682
+ this.stateAfterClosingTagName(c);
13683
+ break;
13684
+ }
13685
+ case 29: {
13686
+ this.stateBeforeSpecialS(c);
13687
+ break;
13688
+ }
13689
+ case 30: {
13690
+ this.stateBeforeSpecialT(c);
13691
+ break;
13692
+ }
13693
+ case 21: {
13694
+ this.stateInAttrValueNoQuotes(c);
13695
+ break;
13696
+ }
13697
+ case 7: {
13698
+ this.stateInSelfClosingTag(c);
13699
+ break;
13700
+ }
13701
+ case 23: {
13702
+ this.stateInDeclaration(c);
13703
+ break;
13704
+ }
13705
+ case 22: {
13706
+ this.stateBeforeDeclaration(c);
13707
+ break;
13708
+ }
13709
+ case 25: {
13710
+ this.stateBeforeComment(c);
13711
+ break;
13712
+ }
13713
+ case 24: {
13714
+ this.stateInProcessingInstruction(c);
13715
+ break;
13716
+ }
13717
+ case 33: {
13718
+ this.stateInEntity();
13719
+ break;
13720
+ }
13721
+ }
13722
+ this.index++;
13723
+ }
13724
+ this.cleanup();
13725
+ this.finish();
13726
+ }
13727
+ /**
13728
+ * Remove data that has already been consumed from the buffer.
13729
+ */
13730
+ cleanup() {
13731
+ if (this.sectionStart !== this.index) {
13732
+ if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
13733
+ this.cbs.ontext(this.sectionStart, this.index);
13734
+ this.sectionStart = this.index;
13735
+ } else if (this.state === 19 || this.state === 20 || this.state === 21) {
13736
+ this.cbs.onattribdata(this.sectionStart, this.index);
13737
+ this.sectionStart = this.index;
13738
+ }
13739
+ }
13740
+ }
13741
+ finish() {
13742
+ this.handleTrailingData();
13743
+ this.cbs.onend();
13744
+ }
13745
+ /** Handle any trailing data. */
13746
+ handleTrailingData() {
13747
+ const endIndex = this.buffer.length;
13748
+ if (this.sectionStart >= endIndex) {
13749
+ return;
13750
+ }
13751
+ if (this.state === 28) {
13752
+ if (this.currentSequence === Sequences.CdataEnd) {
13753
+ this.cbs.oncdata(this.sectionStart, endIndex);
13754
+ } else {
13755
+ this.cbs.oncomment(this.sectionStart, endIndex);
13756
+ }
13757
+ } 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 {
13758
+ this.cbs.ontext(this.sectionStart, endIndex);
13759
+ }
13760
+ }
13761
+ emitCodePoint(cp, consumed) {
13235
13762
  }
13236
13763
  }
13237
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13238
13764
 
13239
13765
  const deprecationData = {
13240
13766
  ["COMPILER_IS_ON_ELEMENT"]: {
@@ -13245,9 +13771,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
13245
13771
  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}\`.`,
13246
13772
  link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
13247
13773
  },
13248
- ["COMPILER_V_BIND_PROP"]: {
13249
- 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.`
13250
- },
13251
13774
  ["COMPILER_V_BIND_OBJECT_ORDER"]: {
13252
13775
  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.`,
13253
13776
  link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
@@ -13272,9 +13795,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
13272
13795
  link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
13273
13796
  }
13274
13797
  };
13275
- function getCompatValue(key, context) {
13276
- const config = context.options ? context.options.compatConfig : context.compatConfig;
13277
- const value = config && config[key];
13798
+ function getCompatValue(key, { compatConfig }) {
13799
+ const value = compatConfig && compatConfig[key];
13278
13800
  if (key === "MODE") {
13279
13801
  return value || 3;
13280
13802
  } else {
@@ -13308,398 +13830,865 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
13308
13830
  context.onWarn(err);
13309
13831
  }
13310
13832
 
13311
- const decodeRE = /&(gt|lt|amp|apos|quot);/g;
13312
- const decodeMap = {
13313
- gt: ">",
13314
- lt: "<",
13315
- amp: "&",
13316
- apos: "'",
13317
- quot: '"'
13318
- };
13319
- const defaultParserOptions = {
13320
- delimiters: [`{{`, `}}`],
13321
- getNamespace: () => 0,
13322
- getTextMode: () => 0,
13323
- isVoidTag: NO,
13324
- isPreTag: NO,
13325
- isCustomElement: NO,
13326
- decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
13327
- onError: defaultOnError,
13328
- onWarn: defaultOnWarn,
13329
- comments: true
13330
- };
13331
- function baseParse(content, options = {}) {
13332
- const context = createParserContext(content, options);
13333
- const start = getCursor(context);
13334
- return createRoot(
13335
- parseChildren(context, 0, []),
13336
- getSelection(context, start)
13337
- );
13338
- }
13339
- function createParserContext(content, rawOptions) {
13340
- const options = extend({}, defaultParserOptions);
13341
- let key;
13342
- for (key in rawOptions) {
13343
- options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
13344
- }
13345
- return {
13346
- options,
13347
- column: 1,
13348
- line: 1,
13349
- offset: 0,
13350
- originalSource: content,
13351
- source: content,
13352
- inPre: false,
13353
- inVPre: false,
13354
- onWarn: options.onWarn
13355
- };
13833
+ function defaultOnError(error) {
13834
+ throw error;
13356
13835
  }
13357
- function parseChildren(context, mode, ancestors) {
13358
- const parent = last(ancestors);
13359
- const ns = parent ? parent.ns : 0;
13360
- const nodes = [];
13361
- while (!isEnd(context, mode, ancestors)) {
13362
- const s = context.source;
13363
- let node = void 0;
13364
- if (mode === 0 || mode === 1) {
13365
- if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
13366
- node = parseInterpolation(context, mode);
13367
- } else if (mode === 0 && s[0] === "<") {
13368
- if (s.length === 1) {
13369
- emitError(context, 5, 1);
13370
- } else if (s[1] === "!") {
13371
- if (startsWith(s, "<!--")) {
13372
- node = parseComment(context);
13373
- } else if (startsWith(s, "<!DOCTYPE")) {
13374
- node = parseBogusComment(context);
13375
- } else if (startsWith(s, "<![CDATA[")) {
13376
- if (ns !== 0) {
13377
- node = parseCDATA(context, ancestors);
13378
- } else {
13379
- emitError(context, 1);
13380
- node = parseBogusComment(context);
13381
- }
13382
- } else {
13383
- emitError(context, 11);
13384
- node = parseBogusComment(context);
13385
- }
13386
- } else if (s[1] === "/") {
13387
- if (s.length === 2) {
13388
- emitError(context, 5, 2);
13389
- } else if (s[2] === ">") {
13390
- emitError(context, 14, 2);
13391
- advanceBy(context, 3);
13392
- continue;
13393
- } else if (/[a-z]/i.test(s[2])) {
13394
- emitError(context, 23);
13395
- parseTag(context, 1 /* End */, parent);
13396
- continue;
13397
- } else {
13398
- emitError(
13399
- context,
13400
- 12,
13401
- 2
13402
- );
13403
- node = parseBogusComment(context);
13404
- }
13405
- } else if (/[a-z]/i.test(s[1])) {
13406
- node = parseElement(context, ancestors);
13407
- if (isCompatEnabled(
13408
- "COMPILER_NATIVE_TEMPLATE",
13409
- context
13410
- ) && node && node.tag === "template" && !node.props.some(
13411
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
13412
- )) {
13413
- warnDeprecation(
13414
- "COMPILER_NATIVE_TEMPLATE",
13415
- context,
13416
- node.loc
13417
- );
13418
- node = node.children;
13419
- }
13420
- } else if (s[1] === "?") {
13421
- emitError(
13422
- context,
13423
- 21,
13424
- 1
13425
- );
13426
- node = parseBogusComment(context);
13427
- } else {
13428
- emitError(context, 12, 1);
13429
- }
13430
- }
13431
- }
13432
- if (!node) {
13433
- node = parseText(context, mode);
13434
- }
13435
- if (isArray(node)) {
13436
- for (let i = 0; i < node.length; i++) {
13437
- pushNode(nodes, node[i]);
13438
- }
13439
- } else {
13440
- pushNode(nodes, node);
13441
- }
13442
- }
13443
- let removedWhitespace = false;
13444
- if (mode !== 2 && mode !== 1) {
13445
- const shouldCondense = context.options.whitespace !== "preserve";
13446
- for (let i = 0; i < nodes.length; i++) {
13447
- const node = nodes[i];
13448
- if (node.type === 2) {
13449
- if (!context.inPre) {
13450
- if (!/[^\t\r\n\f ]/.test(node.content)) {
13451
- const prev = nodes[i - 1];
13452
- const next = nodes[i + 1];
13453
- 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))) {
13454
- removedWhitespace = true;
13455
- nodes[i] = null;
13456
- } else {
13457
- node.content = " ";
13458
- }
13459
- } else if (shouldCondense) {
13460
- node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
13461
- }
13462
- } else {
13463
- node.content = node.content.replace(/\r\n/g, "\n");
13464
- }
13465
- } else if (node.type === 3 && !context.options.comments) {
13466
- removedWhitespace = true;
13467
- nodes[i] = null;
13468
- }
13469
- }
13470
- if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
13471
- const first = nodes[0];
13472
- if (first && first.type === 2) {
13473
- first.content = first.content.replace(/^\r?\n/, "");
13474
- }
13475
- }
13476
- }
13477
- return removedWhitespace ? nodes.filter(Boolean) : nodes;
13836
+ function defaultOnWarn(msg) {
13837
+ console.warn(`[Vue warn] ${msg.message}`);
13478
13838
  }
13479
- function pushNode(nodes, node) {
13480
- if (node.type === 2) {
13481
- const prev = last(nodes);
13482
- if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
13483
- prev.content += node.content;
13484
- prev.loc.end = node.loc.end;
13485
- prev.loc.source += node.loc.source;
13486
- return;
13487
- }
13488
- }
13489
- nodes.push(node);
13839
+ function createCompilerError(code, loc, messages, additionalMessage) {
13840
+ const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
13841
+ const error = new SyntaxError(String(msg));
13842
+ error.code = code;
13843
+ error.loc = loc;
13844
+ return error;
13490
13845
  }
13491
- function parseCDATA(context, ancestors) {
13492
- advanceBy(context, 9);
13493
- const nodes = parseChildren(context, 3, ancestors);
13494
- if (context.source.length === 0) {
13495
- emitError(context, 6);
13496
- } else {
13497
- advanceBy(context, 3);
13498
- }
13499
- return nodes;
13500
- }
13501
- function parseComment(context) {
13502
- const start = getCursor(context);
13503
- let content;
13504
- const match = /--(\!)?>/.exec(context.source);
13505
- if (!match) {
13506
- content = context.source.slice(4);
13507
- advanceBy(context, context.source.length);
13508
- emitError(context, 7);
13846
+ const errorMessages = {
13847
+ // parse errors
13848
+ [0]: "Illegal comment.",
13849
+ [1]: "CDATA section is allowed only in XML context.",
13850
+ [2]: "Duplicate attribute.",
13851
+ [3]: "End tag cannot have attributes.",
13852
+ [4]: "Illegal '/' in tags.",
13853
+ [5]: "Unexpected EOF in tag.",
13854
+ [6]: "Unexpected EOF in CDATA section.",
13855
+ [7]: "Unexpected EOF in comment.",
13856
+ [8]: "Unexpected EOF in script.",
13857
+ [9]: "Unexpected EOF in tag.",
13858
+ [10]: "Incorrectly closed comment.",
13859
+ [11]: "Incorrectly opened comment.",
13860
+ [12]: "Illegal tag name. Use '&lt;' to print '<'.",
13861
+ [13]: "Attribute value was expected.",
13862
+ [14]: "End tag name was expected.",
13863
+ [15]: "Whitespace was expected.",
13864
+ [16]: "Unexpected '<!--' in comment.",
13865
+ [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
13866
+ [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
13867
+ [19]: "Attribute name cannot start with '='.",
13868
+ [21]: "'<?' is allowed only in XML context.",
13869
+ [20]: `Unexpected null character.`,
13870
+ [22]: "Illegal '/' in tags.",
13871
+ // Vue-specific parse errors
13872
+ [23]: "Invalid end tag.",
13873
+ [24]: "Element is missing end tag.",
13874
+ [25]: "Interpolation end sign was not found.",
13875
+ [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
13876
+ [26]: "Legal directive name was expected.",
13877
+ // transform errors
13878
+ [28]: `v-if/v-else-if is missing expression.`,
13879
+ [29]: `v-if/else branches must use unique keys.`,
13880
+ [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
13881
+ [31]: `v-for is missing expression.`,
13882
+ [32]: `v-for has invalid expression.`,
13883
+ [33]: `<template v-for> key should be placed on the <template> tag.`,
13884
+ [34]: `v-bind is missing expression.`,
13885
+ [35]: `v-on is missing expression.`,
13886
+ [36]: `Unexpected custom directive on <slot> outlet.`,
13887
+ [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.`,
13888
+ [38]: `Duplicate slot names found. `,
13889
+ [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
13890
+ [40]: `v-slot can only be used on components or <template> tags.`,
13891
+ [41]: `v-model is missing expression.`,
13892
+ [42]: `v-model value must be a valid JavaScript member expression.`,
13893
+ [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
13894
+ [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
13895
+ Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
13896
+ [45]: `Error parsing JavaScript expression: `,
13897
+ [46]: `<KeepAlive> expects exactly one child component.`,
13898
+ // generic errors
13899
+ [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
13900
+ [48]: `ES module mode is not supported in this build of compiler.`,
13901
+ [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
13902
+ [50]: `"scopeId" option is only supported in module mode.`,
13903
+ // deprecations
13904
+ [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.`,
13905
+ [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
13906
+ // just to fulfill types
13907
+ [53]: ``
13908
+ };
13909
+
13910
+ const isStaticExp = (p) => p.type === 4 && p.isStatic;
13911
+ function isCoreComponent(tag) {
13912
+ switch (tag) {
13913
+ case "Teleport":
13914
+ case "teleport":
13915
+ return TELEPORT;
13916
+ case "Suspense":
13917
+ case "suspense":
13918
+ return SUSPENSE;
13919
+ case "KeepAlive":
13920
+ case "keep-alive":
13921
+ return KEEP_ALIVE;
13922
+ case "BaseTransition":
13923
+ case "base-transition":
13924
+ return BASE_TRANSITION;
13925
+ }
13926
+ }
13927
+ const nonIdentifierRE = /^\d|[^\$\w]/;
13928
+ const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13929
+ const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
13930
+ const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
13931
+ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
13932
+ const isMemberExpressionBrowser = (path) => {
13933
+ path = path.trim().replace(whitespaceRE, (s) => s.trim());
13934
+ let state = 0 /* inMemberExp */;
13935
+ let stateStack = [];
13936
+ let currentOpenBracketCount = 0;
13937
+ let currentOpenParensCount = 0;
13938
+ let currentStringType = null;
13939
+ for (let i = 0; i < path.length; i++) {
13940
+ const char = path.charAt(i);
13941
+ switch (state) {
13942
+ case 0 /* inMemberExp */:
13943
+ if (char === "[") {
13944
+ stateStack.push(state);
13945
+ state = 1 /* inBrackets */;
13946
+ currentOpenBracketCount++;
13947
+ } else if (char === "(") {
13948
+ stateStack.push(state);
13949
+ state = 2 /* inParens */;
13950
+ currentOpenParensCount++;
13951
+ } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
13952
+ return false;
13953
+ }
13954
+ break;
13955
+ case 1 /* inBrackets */:
13956
+ if (char === `'` || char === `"` || char === "`") {
13957
+ stateStack.push(state);
13958
+ state = 3 /* inString */;
13959
+ currentStringType = char;
13960
+ } else if (char === `[`) {
13961
+ currentOpenBracketCount++;
13962
+ } else if (char === `]`) {
13963
+ if (!--currentOpenBracketCount) {
13964
+ state = stateStack.pop();
13965
+ }
13966
+ }
13967
+ break;
13968
+ case 2 /* inParens */:
13969
+ if (char === `'` || char === `"` || char === "`") {
13970
+ stateStack.push(state);
13971
+ state = 3 /* inString */;
13972
+ currentStringType = char;
13973
+ } else if (char === `(`) {
13974
+ currentOpenParensCount++;
13975
+ } else if (char === `)`) {
13976
+ if (i === path.length - 1) {
13977
+ return false;
13978
+ }
13979
+ if (!--currentOpenParensCount) {
13980
+ state = stateStack.pop();
13981
+ }
13982
+ }
13983
+ break;
13984
+ case 3 /* inString */:
13985
+ if (char === currentStringType) {
13986
+ state = stateStack.pop();
13987
+ currentStringType = null;
13988
+ }
13989
+ break;
13990
+ }
13991
+ }
13992
+ return !currentOpenBracketCount && !currentOpenParensCount;
13993
+ };
13994
+ const isMemberExpression = isMemberExpressionBrowser ;
13995
+ function assert(condition, msg) {
13996
+ if (!condition) {
13997
+ throw new Error(msg || `unexpected compiler condition`);
13998
+ }
13999
+ }
14000
+ function findDir(node, name, allowEmpty = false) {
14001
+ for (let i = 0; i < node.props.length; i++) {
14002
+ const p = node.props[i];
14003
+ if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
14004
+ return p;
14005
+ }
14006
+ }
14007
+ }
14008
+ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
14009
+ for (let i = 0; i < node.props.length; i++) {
14010
+ const p = node.props[i];
14011
+ if (p.type === 6) {
14012
+ if (dynamicOnly)
14013
+ continue;
14014
+ if (p.name === name && (p.value || allowEmpty)) {
14015
+ return p;
14016
+ }
14017
+ } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
14018
+ return p;
14019
+ }
14020
+ }
14021
+ }
14022
+ function isStaticArgOf(arg, name) {
14023
+ return !!(arg && isStaticExp(arg) && arg.content === name);
14024
+ }
14025
+ function hasDynamicKeyVBind(node) {
14026
+ return node.props.some(
14027
+ (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
14028
+ p.arg.type !== 4 || // v-bind:[_ctx.foo]
14029
+ !p.arg.isStatic)
14030
+ // v-bind:[foo]
14031
+ );
14032
+ }
14033
+ function isText$1(node) {
14034
+ return node.type === 5 || node.type === 2;
14035
+ }
14036
+ function isVSlot(p) {
14037
+ return p.type === 7 && p.name === "slot";
14038
+ }
14039
+ function isTemplateNode(node) {
14040
+ return node.type === 1 && node.tagType === 3;
14041
+ }
14042
+ function isSlotOutlet(node) {
14043
+ return node.type === 1 && node.tagType === 2;
14044
+ }
14045
+ const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
14046
+ function getUnnormalizedProps(props, callPath = []) {
14047
+ if (props && !isString(props) && props.type === 14) {
14048
+ const callee = props.callee;
14049
+ if (!isString(callee) && propsHelperSet.has(callee)) {
14050
+ return getUnnormalizedProps(
14051
+ props.arguments[0],
14052
+ callPath.concat(props)
14053
+ );
14054
+ }
14055
+ }
14056
+ return [props, callPath];
14057
+ }
14058
+ function injectProp(node, prop, context) {
14059
+ let propsWithInjection;
14060
+ let props = node.type === 13 ? node.props : node.arguments[2];
14061
+ let callPath = [];
14062
+ let parentCall;
14063
+ if (props && !isString(props) && props.type === 14) {
14064
+ const ret = getUnnormalizedProps(props);
14065
+ props = ret[0];
14066
+ callPath = ret[1];
14067
+ parentCall = callPath[callPath.length - 1];
14068
+ }
14069
+ if (props == null || isString(props)) {
14070
+ propsWithInjection = createObjectExpression([prop]);
14071
+ } else if (props.type === 14) {
14072
+ const first = props.arguments[0];
14073
+ if (!isString(first) && first.type === 15) {
14074
+ if (!hasProp(prop, first)) {
14075
+ first.properties.unshift(prop);
14076
+ }
14077
+ } else {
14078
+ if (props.callee === TO_HANDLERS) {
14079
+ propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
14080
+ createObjectExpression([prop]),
14081
+ props
14082
+ ]);
14083
+ } else {
14084
+ props.arguments.unshift(createObjectExpression([prop]));
14085
+ }
14086
+ }
14087
+ !propsWithInjection && (propsWithInjection = props);
14088
+ } else if (props.type === 15) {
14089
+ if (!hasProp(prop, props)) {
14090
+ props.properties.unshift(prop);
14091
+ }
14092
+ propsWithInjection = props;
14093
+ } else {
14094
+ propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
14095
+ createObjectExpression([prop]),
14096
+ props
14097
+ ]);
14098
+ if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
14099
+ parentCall = callPath[callPath.length - 2];
14100
+ }
14101
+ }
14102
+ if (node.type === 13) {
14103
+ if (parentCall) {
14104
+ parentCall.arguments[0] = propsWithInjection;
14105
+ } else {
14106
+ node.props = propsWithInjection;
14107
+ }
14108
+ } else {
14109
+ if (parentCall) {
14110
+ parentCall.arguments[0] = propsWithInjection;
14111
+ } else {
14112
+ node.arguments[2] = propsWithInjection;
14113
+ }
14114
+ }
14115
+ }
14116
+ function hasProp(prop, props) {
14117
+ let result = false;
14118
+ if (prop.key.type === 4) {
14119
+ const propKeyName = prop.key.content;
14120
+ result = props.properties.some(
14121
+ (p) => p.key.type === 4 && p.key.content === propKeyName
14122
+ );
14123
+ }
14124
+ return result;
14125
+ }
14126
+ function toValidAssetId(name, type) {
14127
+ return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
14128
+ return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
14129
+ })}`;
14130
+ }
14131
+ function getMemoedVNodeCall(node) {
14132
+ if (node.type === 14 && node.callee === WITH_MEMO) {
14133
+ return node.arguments[1].returns;
13509
14134
  } else {
13510
- if (match.index <= 3) {
13511
- emitError(context, 0);
14135
+ return node;
14136
+ }
14137
+ }
14138
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
14139
+
14140
+ const defaultParserOptions = {
14141
+ parseMode: "base",
14142
+ ns: 0,
14143
+ delimiters: [`{{`, `}}`],
14144
+ getNamespace: () => 0,
14145
+ isVoidTag: NO,
14146
+ isPreTag: NO,
14147
+ isCustomElement: NO,
14148
+ onError: defaultOnError,
14149
+ onWarn: defaultOnWarn,
14150
+ comments: true
14151
+ };
14152
+ let currentOptions = defaultParserOptions;
14153
+ let currentRoot = null;
14154
+ let currentInput = "";
14155
+ let currentOpenTag = null;
14156
+ let currentProp = null;
14157
+ let currentAttrValue = "";
14158
+ let currentAttrStartIndex = -1;
14159
+ let currentAttrEndIndex = -1;
14160
+ let inPre = 0;
14161
+ let inVPre = false;
14162
+ let currentVPreBoundary = null;
14163
+ const stack = [];
14164
+ const tokenizer = new Tokenizer(stack, {
14165
+ onerr: emitError,
14166
+ ontext(start, end) {
14167
+ onText(getSlice(start, end), start, end);
14168
+ },
14169
+ ontextentity(char, start, end) {
14170
+ onText(char, start, end);
14171
+ },
14172
+ oninterpolation(start, end) {
14173
+ if (inVPre) {
14174
+ return onText(getSlice(start, end), start, end);
14175
+ }
14176
+ let innerStart = start + tokenizer.delimiterOpen.length;
14177
+ let innerEnd = end - tokenizer.delimiterClose.length;
14178
+ while (isWhitespace(currentInput.charCodeAt(innerStart))) {
14179
+ innerStart++;
14180
+ }
14181
+ while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
14182
+ innerEnd--;
14183
+ }
14184
+ let exp = getSlice(innerStart, innerEnd);
14185
+ if (exp.includes("&")) {
14186
+ {
14187
+ exp = currentOptions.decodeEntities(exp, false);
14188
+ }
14189
+ }
14190
+ addNode({
14191
+ type: 5,
14192
+ content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
14193
+ loc: getLoc(start, end)
14194
+ });
14195
+ },
14196
+ onopentagname(start, end) {
14197
+ const name = getSlice(start, end);
14198
+ currentOpenTag = {
14199
+ type: 1,
14200
+ tag: name,
14201
+ ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
14202
+ tagType: 0,
14203
+ // will be refined on tag close
14204
+ props: [],
14205
+ children: [],
14206
+ loc: getLoc(start - 1, end),
14207
+ codegenNode: void 0
14208
+ };
14209
+ if (tokenizer.inSFCRoot) {
14210
+ currentOpenTag.innerLoc = getLoc(
14211
+ end + fastForward(end) + 1,
14212
+ end
14213
+ );
14214
+ }
14215
+ },
14216
+ onopentagend(end) {
14217
+ endOpenTag(end);
14218
+ },
14219
+ onclosetag(start, end) {
14220
+ const name = getSlice(start, end);
14221
+ if (!currentOptions.isVoidTag(name)) {
14222
+ let found = false;
14223
+ for (let i = 0; i < stack.length; i++) {
14224
+ const e = stack[i];
14225
+ if (e.tag.toLowerCase() === name.toLowerCase()) {
14226
+ found = true;
14227
+ if (i > 0) {
14228
+ emitError(24, stack[0].loc.start.offset);
14229
+ }
14230
+ for (let j = 0; j <= i; j++) {
14231
+ const el = stack.shift();
14232
+ onCloseTag(el, end, j < i);
14233
+ }
14234
+ break;
14235
+ }
14236
+ }
14237
+ if (!found) {
14238
+ emitError(23, backTrack(start, 60));
14239
+ }
14240
+ }
14241
+ },
14242
+ onselfclosingtag(end) {
14243
+ var _a;
14244
+ const name = currentOpenTag.tag;
14245
+ currentOpenTag.isSelfClosing = true;
14246
+ endOpenTag(end);
14247
+ if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
14248
+ onCloseTag(stack.shift(), end);
14249
+ }
14250
+ },
14251
+ onattribname(start, end) {
14252
+ currentProp = {
14253
+ type: 6,
14254
+ name: getSlice(start, end),
14255
+ nameLoc: getLoc(start, end),
14256
+ value: void 0,
14257
+ loc: getLoc(start)
14258
+ };
14259
+ },
14260
+ ondirname(start, end) {
14261
+ const raw = getSlice(start, end);
14262
+ const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
14263
+ if (!inVPre && name === "") {
14264
+ emitError(26, start);
14265
+ }
14266
+ if (inVPre || name === "") {
14267
+ currentProp = {
14268
+ type: 6,
14269
+ name: raw,
14270
+ nameLoc: getLoc(start, end),
14271
+ value: void 0,
14272
+ loc: getLoc(start)
14273
+ };
14274
+ } else {
14275
+ currentProp = {
14276
+ type: 7,
14277
+ name,
14278
+ rawName: raw,
14279
+ exp: void 0,
14280
+ arg: void 0,
14281
+ modifiers: raw === "." ? ["prop"] : [],
14282
+ loc: getLoc(start)
14283
+ };
14284
+ if (name === "pre") {
14285
+ inVPre = true;
14286
+ currentVPreBoundary = currentOpenTag;
14287
+ const props = currentOpenTag.props;
14288
+ for (let i = 0; i < props.length; i++) {
14289
+ if (props[i].type === 7) {
14290
+ props[i] = dirToAttr(props[i]);
14291
+ }
14292
+ }
14293
+ }
14294
+ }
14295
+ },
14296
+ ondirarg(start, end) {
14297
+ const arg = getSlice(start, end);
14298
+ if (inVPre) {
14299
+ currentProp.name += arg;
14300
+ setLocEnd(currentProp.nameLoc, end);
14301
+ } else {
14302
+ const isStatic = arg[0] !== `[`;
14303
+ currentProp.arg = createSimpleExpression(
14304
+ isStatic ? arg : arg.slice(1, -1),
14305
+ isStatic,
14306
+ getLoc(start, end),
14307
+ isStatic ? 3 : 0
14308
+ );
14309
+ }
14310
+ },
14311
+ ondirmodifier(start, end) {
14312
+ const mod = getSlice(start, end);
14313
+ if (inVPre) {
14314
+ currentProp.name += "." + mod;
14315
+ setLocEnd(currentProp.nameLoc, end);
14316
+ } else if (currentProp.name === "slot") {
14317
+ const arg = currentProp.arg;
14318
+ if (arg) {
14319
+ arg.content += "." + mod;
14320
+ setLocEnd(arg.loc, end);
14321
+ }
14322
+ } else {
14323
+ currentProp.modifiers.push(mod);
14324
+ }
14325
+ },
14326
+ onattribdata(start, end) {
14327
+ currentAttrValue += getSlice(start, end);
14328
+ if (currentAttrStartIndex < 0)
14329
+ currentAttrStartIndex = start;
14330
+ currentAttrEndIndex = end;
14331
+ },
14332
+ onattribentity(char, start, end) {
14333
+ currentAttrValue += char;
14334
+ if (currentAttrStartIndex < 0)
14335
+ currentAttrStartIndex = start;
14336
+ currentAttrEndIndex = end;
14337
+ },
14338
+ onattribnameend(end) {
14339
+ const start = currentProp.loc.start.offset;
14340
+ const name = getSlice(start, end);
14341
+ if (currentProp.type === 7) {
14342
+ currentProp.rawName = name;
14343
+ }
14344
+ if (currentOpenTag.props.some(
14345
+ (p) => (p.type === 7 ? p.rawName : p.name) === name
14346
+ )) {
14347
+ emitError(2, start);
14348
+ }
14349
+ },
14350
+ onattribend(quote, end) {
14351
+ if (currentOpenTag && currentProp) {
14352
+ setLocEnd(currentProp.loc, end);
14353
+ if (quote !== 0) {
14354
+ if (currentAttrValue.includes("&")) {
14355
+ currentAttrValue = currentOptions.decodeEntities(
14356
+ currentAttrValue,
14357
+ true
14358
+ );
14359
+ }
14360
+ if (currentProp.type === 6) {
14361
+ if (currentProp.name === "class") {
14362
+ currentAttrValue = condense(currentAttrValue).trim();
14363
+ }
14364
+ if (quote === 1 && !currentAttrValue) {
14365
+ emitError(13, end);
14366
+ }
14367
+ currentProp.value = {
14368
+ type: 2,
14369
+ content: currentAttrValue,
14370
+ loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
14371
+ };
14372
+ if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
14373
+ tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
14374
+ }
14375
+ } else {
14376
+ currentProp.exp = createSimpleExpression(
14377
+ currentAttrValue,
14378
+ false,
14379
+ getLoc(currentAttrStartIndex, currentAttrEndIndex)
14380
+ );
14381
+ if (currentProp.name === "for") {
14382
+ currentProp.forParseResult = parseForExpression(currentProp.exp);
14383
+ }
14384
+ let syncIndex = -1;
14385
+ if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
14386
+ "COMPILER_V_BIND_SYNC",
14387
+ currentOptions,
14388
+ currentProp.loc,
14389
+ currentProp.rawName
14390
+ )) {
14391
+ currentProp.name = "model";
14392
+ currentProp.modifiers.splice(syncIndex, 1);
14393
+ }
14394
+ }
14395
+ }
14396
+ if (currentProp.type !== 7 || currentProp.name !== "pre") {
14397
+ currentOpenTag.props.push(currentProp);
14398
+ }
13512
14399
  }
13513
- if (match[1]) {
13514
- emitError(context, 10);
14400
+ currentAttrValue = "";
14401
+ currentAttrStartIndex = currentAttrEndIndex = -1;
14402
+ },
14403
+ oncomment(start, end) {
14404
+ if (currentOptions.comments) {
14405
+ addNode({
14406
+ type: 3,
14407
+ content: getSlice(start, end),
14408
+ loc: getLoc(start - 4, end + 3)
14409
+ });
13515
14410
  }
13516
- content = context.source.slice(4, match.index);
13517
- const s = context.source.slice(0, match.index);
13518
- let prevIndex = 1, nestedIndex = 0;
13519
- while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
13520
- advanceBy(context, nestedIndex - prevIndex + 1);
13521
- if (nestedIndex + 4 < s.length) {
13522
- emitError(context, 16);
14411
+ },
14412
+ onend() {
14413
+ const end = currentInput.length;
14414
+ if (tokenizer.state !== 1) {
14415
+ switch (tokenizer.state) {
14416
+ case 5:
14417
+ case 8:
14418
+ emitError(5, end);
14419
+ break;
14420
+ case 3:
14421
+ case 4:
14422
+ emitError(
14423
+ 25,
14424
+ tokenizer.sectionStart
14425
+ );
14426
+ break;
14427
+ case 28:
14428
+ if (tokenizer.currentSequence === Sequences.CdataEnd) {
14429
+ emitError(6, end);
14430
+ } else {
14431
+ emitError(7, end);
14432
+ }
14433
+ break;
14434
+ case 6:
14435
+ case 7:
14436
+ case 9:
14437
+ case 11:
14438
+ case 12:
14439
+ case 13:
14440
+ case 14:
14441
+ case 15:
14442
+ case 16:
14443
+ case 17:
14444
+ case 18:
14445
+ case 19:
14446
+ case 20:
14447
+ case 21:
14448
+ emitError(9, end);
14449
+ break;
13523
14450
  }
13524
- prevIndex = nestedIndex + 1;
13525
14451
  }
13526
- advanceBy(context, match.index + match[0].length - prevIndex + 1);
14452
+ for (let index = 0; index < stack.length; index++) {
14453
+ onCloseTag(stack[index], end - 1);
14454
+ emitError(24, stack[index].loc.start.offset);
14455
+ }
14456
+ },
14457
+ oncdata(start, end) {
14458
+ if (stack[0].ns !== 0) {
14459
+ onText(getSlice(start, end), start, end);
14460
+ } else {
14461
+ emitError(1, start - 9);
14462
+ }
14463
+ },
14464
+ onprocessinginstruction(start) {
14465
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
14466
+ emitError(
14467
+ 21,
14468
+ start - 1
14469
+ );
14470
+ }
13527
14471
  }
13528
- return {
13529
- type: 3,
13530
- content,
13531
- loc: getSelection(context, start)
14472
+ });
14473
+ const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
14474
+ const stripParensRE = /^\(|\)$/g;
14475
+ function parseForExpression(input) {
14476
+ const loc = input.loc;
14477
+ const exp = input.content;
14478
+ const inMatch = exp.match(forAliasRE);
14479
+ if (!inMatch)
14480
+ return;
14481
+ const [, LHS, RHS] = inMatch;
14482
+ const createAliasExpression = (content, offset) => {
14483
+ const start = loc.start.offset + offset;
14484
+ const end = start + content.length;
14485
+ return createSimpleExpression(content, false, getLoc(start, end));
13532
14486
  };
14487
+ const result = {
14488
+ source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
14489
+ value: void 0,
14490
+ key: void 0,
14491
+ index: void 0,
14492
+ finalized: false
14493
+ };
14494
+ let valueContent = LHS.trim().replace(stripParensRE, "").trim();
14495
+ const trimmedOffset = LHS.indexOf(valueContent);
14496
+ const iteratorMatch = valueContent.match(forIteratorRE);
14497
+ if (iteratorMatch) {
14498
+ valueContent = valueContent.replace(forIteratorRE, "").trim();
14499
+ const keyContent = iteratorMatch[1].trim();
14500
+ let keyOffset;
14501
+ if (keyContent) {
14502
+ keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
14503
+ result.key = createAliasExpression(keyContent, keyOffset);
14504
+ }
14505
+ if (iteratorMatch[2]) {
14506
+ const indexContent = iteratorMatch[2].trim();
14507
+ if (indexContent) {
14508
+ result.index = createAliasExpression(
14509
+ indexContent,
14510
+ exp.indexOf(
14511
+ indexContent,
14512
+ result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
14513
+ )
14514
+ );
14515
+ }
14516
+ }
14517
+ }
14518
+ if (valueContent) {
14519
+ result.value = createAliasExpression(valueContent, trimmedOffset);
14520
+ }
14521
+ return result;
14522
+ }
14523
+ function getSlice(start, end) {
14524
+ return currentInput.slice(start, end);
13533
14525
  }
13534
- function parseBogusComment(context) {
13535
- const start = getCursor(context);
13536
- const contentStart = context.source[1] === "?" ? 1 : 2;
13537
- let content;
13538
- const closeIndex = context.source.indexOf(">");
13539
- if (closeIndex === -1) {
13540
- content = context.source.slice(contentStart);
13541
- advanceBy(context, context.source.length);
14526
+ function endOpenTag(end) {
14527
+ addNode(currentOpenTag);
14528
+ const { tag, ns } = currentOpenTag;
14529
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
14530
+ inPre++;
14531
+ }
14532
+ if (currentOptions.isVoidTag(tag)) {
14533
+ onCloseTag(currentOpenTag, end);
13542
14534
  } else {
13543
- content = context.source.slice(contentStart, closeIndex);
13544
- advanceBy(context, closeIndex + 1);
14535
+ stack.unshift(currentOpenTag);
14536
+ if (ns === 1 || ns === 2) {
14537
+ tokenizer.inXML = true;
14538
+ }
13545
14539
  }
13546
- return {
13547
- type: 3,
13548
- content,
13549
- loc: getSelection(context, start)
13550
- };
14540
+ currentOpenTag = null;
13551
14541
  }
13552
- function parseElement(context, ancestors) {
13553
- const wasInPre = context.inPre;
13554
- const wasInVPre = context.inVPre;
13555
- const parent = last(ancestors);
13556
- const element = parseTag(context, 0 /* Start */, parent);
13557
- const isPreBoundary = context.inPre && !wasInPre;
13558
- const isVPreBoundary = context.inVPre && !wasInVPre;
13559
- if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
13560
- if (isPreBoundary) {
13561
- context.inPre = false;
13562
- }
13563
- if (isVPreBoundary) {
13564
- context.inVPre = false;
13565
- }
13566
- return element;
13567
- }
13568
- ancestors.push(element);
13569
- const mode = context.options.getTextMode(element, parent);
13570
- const children = parseChildren(context, mode, ancestors);
13571
- ancestors.pop();
14542
+ function onText(content, start, end) {
14543
+ var _a;
14544
+ {
14545
+ const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
14546
+ if (tag !== "script" && tag !== "style" && content.includes("&")) {
14547
+ content = currentOptions.decodeEntities(content, false);
14548
+ }
14549
+ }
14550
+ const parent = stack[0] || currentRoot;
14551
+ const lastNode = parent.children[parent.children.length - 1];
14552
+ if ((lastNode == null ? void 0 : lastNode.type) === 2) {
14553
+ lastNode.content += content;
14554
+ setLocEnd(lastNode.loc, end);
14555
+ } else {
14556
+ parent.children.push({
14557
+ type: 2,
14558
+ content,
14559
+ loc: getLoc(start, end)
14560
+ });
14561
+ }
14562
+ }
14563
+ function onCloseTag(el, end, isImplied = false) {
14564
+ if (isImplied) {
14565
+ setLocEnd(el.loc, backTrack(end, 60));
14566
+ } else {
14567
+ setLocEnd(el.loc, end + fastForward(end) + 1);
14568
+ }
14569
+ if (tokenizer.inSFCRoot) {
14570
+ if (el.children.length) {
14571
+ el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
14572
+ } else {
14573
+ el.innerLoc.end = extend({}, el.innerLoc.start);
14574
+ }
14575
+ el.innerLoc.source = getSlice(
14576
+ el.innerLoc.start.offset,
14577
+ el.innerLoc.end.offset
14578
+ );
14579
+ }
14580
+ const { tag, ns } = el;
14581
+ if (!inVPre) {
14582
+ if (tag === "slot") {
14583
+ el.tagType = 2;
14584
+ } else if (isFragmentTemplate(el)) {
14585
+ el.tagType = 3;
14586
+ } else if (isComponent(el)) {
14587
+ el.tagType = 1;
14588
+ }
14589
+ }
14590
+ if (!tokenizer.inRCDATA) {
14591
+ el.children = condenseWhitespace(el.children, el.tag);
14592
+ }
14593
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
14594
+ inPre--;
14595
+ }
14596
+ if (currentVPreBoundary === el) {
14597
+ inVPre = false;
14598
+ currentVPreBoundary = null;
14599
+ }
14600
+ if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
14601
+ tokenizer.inXML = false;
14602
+ }
13572
14603
  {
13573
- const inlineTemplateProp = element.props.find(
14604
+ const props = el.props;
14605
+ if (isCompatEnabled(
14606
+ "COMPILER_V_IF_V_FOR_PRECEDENCE",
14607
+ currentOptions
14608
+ )) {
14609
+ let hasIf = false;
14610
+ let hasFor = false;
14611
+ for (let i = 0; i < props.length; i++) {
14612
+ const p = props[i];
14613
+ if (p.type === 7) {
14614
+ if (p.name === "if") {
14615
+ hasIf = true;
14616
+ } else if (p.name === "for") {
14617
+ hasFor = true;
14618
+ }
14619
+ }
14620
+ if (hasIf && hasFor) {
14621
+ warnDeprecation(
14622
+ "COMPILER_V_IF_V_FOR_PRECEDENCE",
14623
+ currentOptions,
14624
+ el.loc
14625
+ );
14626
+ break;
14627
+ }
14628
+ }
14629
+ }
14630
+ if (isCompatEnabled(
14631
+ "COMPILER_NATIVE_TEMPLATE",
14632
+ currentOptions
14633
+ ) && el.tag === "template" && !isFragmentTemplate(el)) {
14634
+ warnDeprecation(
14635
+ "COMPILER_NATIVE_TEMPLATE",
14636
+ currentOptions,
14637
+ el.loc
14638
+ );
14639
+ const parent = stack[0] || currentRoot;
14640
+ const index = parent.children.indexOf(el);
14641
+ parent.children.splice(index, 1, ...el.children);
14642
+ }
14643
+ const inlineTemplateProp = props.find(
13574
14644
  (p) => p.type === 6 && p.name === "inline-template"
13575
14645
  );
13576
14646
  if (inlineTemplateProp && checkCompatEnabled(
13577
14647
  "COMPILER_INLINE_TEMPLATE",
13578
- context,
14648
+ currentOptions,
13579
14649
  inlineTemplateProp.loc
13580
- )) {
13581
- const loc = getSelection(context, element.loc.end);
14650
+ ) && el.children.length) {
13582
14651
  inlineTemplateProp.value = {
13583
14652
  type: 2,
13584
- content: loc.source,
13585
- loc
13586
- };
13587
- }
13588
- }
13589
- element.children = children;
13590
- if (startsWithEndTagOpen(context.source, element.tag)) {
13591
- parseTag(context, 1 /* End */, parent);
13592
- } else {
13593
- emitError(context, 24, 0, element.loc.start);
13594
- if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
13595
- const first = children[0];
13596
- if (first && startsWith(first.loc.source, "<!--")) {
13597
- emitError(context, 8);
13598
- }
14653
+ content: getSlice(
14654
+ el.children[0].loc.start.offset,
14655
+ el.children[el.children.length - 1].loc.end.offset
14656
+ ),
14657
+ loc: inlineTemplateProp.loc
14658
+ };
13599
14659
  }
13600
14660
  }
13601
- element.loc = getSelection(context, element.loc.start);
13602
- if (isPreBoundary) {
13603
- context.inPre = false;
13604
- }
13605
- if (isVPreBoundary) {
13606
- context.inVPre = false;
13607
- }
13608
- return element;
13609
14661
  }
13610
- const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
13611
- `if,else,else-if,for,slot`
13612
- );
13613
- function parseTag(context, type, parent) {
13614
- const start = getCursor(context);
13615
- const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
13616
- const tag = match[1];
13617
- const ns = context.options.getNamespace(tag, parent);
13618
- advanceBy(context, match[0].length);
13619
- advanceSpaces(context);
13620
- const cursor = getCursor(context);
13621
- const currentSource = context.source;
13622
- if (context.options.isPreTag(tag)) {
13623
- context.inPre = true;
13624
- }
13625
- let props = parseAttributes(context, type);
13626
- if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
13627
- context.inVPre = true;
13628
- extend(context, cursor);
13629
- context.source = currentSource;
13630
- props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
13631
- }
13632
- let isSelfClosing = false;
13633
- if (context.source.length === 0) {
13634
- emitError(context, 9);
13635
- } else {
13636
- isSelfClosing = startsWith(context.source, "/>");
13637
- if (type === 1 /* End */ && isSelfClosing) {
13638
- emitError(context, 4);
13639
- }
13640
- advanceBy(context, isSelfClosing ? 2 : 1);
13641
- }
13642
- if (type === 1 /* End */) {
13643
- return;
14662
+ function fastForward(start, c) {
14663
+ let offset = 0;
14664
+ while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
14665
+ offset++;
13644
14666
  }
13645
- if (isCompatEnabled(
13646
- "COMPILER_V_IF_V_FOR_PRECEDENCE",
13647
- context
13648
- )) {
13649
- let hasIf = false;
13650
- let hasFor = false;
14667
+ return offset;
14668
+ }
14669
+ function backTrack(index, c) {
14670
+ let i = index;
14671
+ while (currentInput.charCodeAt(i) !== c && i >= 0)
14672
+ i--;
14673
+ return i;
14674
+ }
14675
+ const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
14676
+ function isFragmentTemplate({ tag, props }) {
14677
+ if (tag === "template") {
13651
14678
  for (let i = 0; i < props.length; i++) {
13652
- const p = props[i];
13653
- if (p.type === 7) {
13654
- if (p.name === "if") {
13655
- hasIf = true;
13656
- } else if (p.name === "for") {
13657
- hasFor = true;
13658
- }
13659
- }
13660
- if (hasIf && hasFor) {
13661
- warnDeprecation(
13662
- "COMPILER_V_IF_V_FOR_PRECEDENCE",
13663
- context,
13664
- getSelection(context, start)
13665
- );
13666
- break;
13667
- }
13668
- }
13669
- }
13670
- let tagType = 0;
13671
- if (!context.inVPre) {
13672
- if (tag === "slot") {
13673
- tagType = 2;
13674
- } else if (tag === "template") {
13675
- if (props.some(
13676
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
13677
- )) {
13678
- tagType = 3;
14679
+ if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
14680
+ return true;
13679
14681
  }
13680
- } else if (isComponent(tag, props, context)) {
13681
- tagType = 1;
13682
14682
  }
13683
14683
  }
13684
- return {
13685
- type: 1,
13686
- ns,
13687
- tag,
13688
- tagType,
13689
- props,
13690
- isSelfClosing,
13691
- children: [],
13692
- loc: getSelection(context, start),
13693
- codegenNode: void 0
13694
- // to be created during transform phase
13695
- };
14684
+ return false;
13696
14685
  }
13697
- function isComponent(tag, props, context) {
13698
- const options = context.options;
13699
- if (options.isCustomElement(tag)) {
14686
+ function isComponent({ tag, props }) {
14687
+ var _a;
14688
+ if (currentOptions.isCustomElement(tag)) {
13700
14689
  return false;
13701
14690
  }
13702
- if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
14691
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
13703
14692
  return true;
13704
14693
  }
13705
14694
  for (let i = 0; i < props.length; i++) {
@@ -13710,374 +14699,179 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
13710
14699
  return true;
13711
14700
  } else if (checkCompatEnabled(
13712
14701
  "COMPILER_IS_ON_ELEMENT",
13713
- context,
14702
+ currentOptions,
13714
14703
  p.loc
13715
14704
  )) {
13716
14705
  return true;
13717
14706
  }
13718
14707
  }
13719
- } else {
13720
- if (p.name === "is") {
13721
- return true;
13722
- } else if (
13723
- // :is on plain element - only treat as component in compat mode
13724
- p.name === "bind" && isStaticArgOf(p.arg, "is") && true && checkCompatEnabled(
13725
- "COMPILER_IS_ON_ELEMENT",
13726
- context,
13727
- p.loc
13728
- )
13729
- ) {
13730
- return true;
13731
- }
14708
+ } else if (// :is on plain element - only treat as component in compat mode
14709
+ p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
14710
+ "COMPILER_IS_ON_ELEMENT",
14711
+ currentOptions,
14712
+ p.loc
14713
+ )) {
14714
+ return true;
13732
14715
  }
13733
14716
  }
14717
+ return false;
13734
14718
  }
13735
- function parseAttributes(context, type) {
13736
- const props = [];
13737
- const attributeNames = /* @__PURE__ */ new Set();
13738
- while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
13739
- if (startsWith(context.source, "/")) {
13740
- emitError(context, 22);
13741
- advanceBy(context, 1);
13742
- advanceSpaces(context);
13743
- continue;
13744
- }
13745
- if (type === 1 /* End */) {
13746
- emitError(context, 3);
13747
- }
13748
- const attr = parseAttribute(context, attributeNames);
13749
- if (attr.type === 6 && attr.value && attr.name === "class") {
13750
- attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
13751
- }
13752
- if (type === 0 /* Start */) {
13753
- props.push(attr);
13754
- }
13755
- if (/^[^\t\r\n\f />]/.test(context.source)) {
13756
- emitError(context, 15);
13757
- }
13758
- advanceSpaces(context);
13759
- }
13760
- return props;
14719
+ function isUpperCase(c) {
14720
+ return c > 64 && c < 91;
13761
14721
  }
13762
- function parseAttribute(context, nameSet) {
13763
- var _a;
13764
- const start = getCursor(context);
13765
- const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
13766
- const name = match[0];
13767
- if (nameSet.has(name)) {
13768
- emitError(context, 2);
13769
- }
13770
- nameSet.add(name);
13771
- if (name[0] === "=") {
13772
- emitError(context, 19);
13773
- }
13774
- {
13775
- const pattern = /["'<]/g;
13776
- let m;
13777
- while (m = pattern.exec(name)) {
13778
- emitError(
13779
- context,
13780
- 17,
13781
- m.index
13782
- );
13783
- }
13784
- }
13785
- advanceBy(context, name.length);
13786
- let value = void 0;
13787
- if (/^[\t\r\n\f ]*=/.test(context.source)) {
13788
- advanceSpaces(context);
13789
- advanceBy(context, 1);
13790
- advanceSpaces(context);
13791
- value = parseAttributeValue(context);
13792
- if (!value) {
13793
- emitError(context, 13);
13794
- }
13795
- }
13796
- const loc = getSelection(context, start);
13797
- if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
13798
- const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
13799
- name
13800
- );
13801
- let isPropShorthand = startsWith(name, ".");
13802
- let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
13803
- let arg;
13804
- if (match2[2]) {
13805
- const isSlot = dirName === "slot";
13806
- const startOffset = name.lastIndexOf(
13807
- match2[2],
13808
- name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
13809
- );
13810
- const loc2 = getSelection(
13811
- context,
13812
- getNewPosition(context, start, startOffset),
13813
- getNewPosition(
13814
- context,
13815
- start,
13816
- startOffset + match2[2].length + (isSlot && match2[3] || "").length
13817
- )
13818
- );
13819
- let content = match2[2];
13820
- let isStatic = true;
13821
- if (content.startsWith("[")) {
13822
- isStatic = false;
13823
- if (!content.endsWith("]")) {
13824
- emitError(
13825
- context,
13826
- 27
13827
- );
13828
- content = content.slice(1);
13829
- } else {
13830
- content = content.slice(1, content.length - 1);
14722
+ const windowsNewlineRE = /\r\n/g;
14723
+ function condenseWhitespace(nodes, tag) {
14724
+ var _a, _b;
14725
+ const shouldCondense = currentOptions.whitespace !== "preserve";
14726
+ let removedWhitespace = false;
14727
+ for (let i = 0; i < nodes.length; i++) {
14728
+ const node = nodes[i];
14729
+ if (node.type === 2) {
14730
+ if (!inPre) {
14731
+ if (isAllWhitespace(node.content)) {
14732
+ const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
14733
+ const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
14734
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
14735
+ removedWhitespace = true;
14736
+ nodes[i] = null;
14737
+ } else {
14738
+ node.content = " ";
14739
+ }
14740
+ } else if (shouldCondense) {
14741
+ node.content = condense(node.content);
13831
14742
  }
13832
- } else if (isSlot) {
13833
- content += match2[3] || "";
13834
- }
13835
- arg = {
13836
- type: 4,
13837
- content,
13838
- isStatic,
13839
- constType: isStatic ? 3 : 0,
13840
- loc: loc2
13841
- };
13842
- }
13843
- if (value && value.isQuoted) {
13844
- const valueLoc = value.loc;
13845
- valueLoc.start.offset++;
13846
- valueLoc.start.column++;
13847
- valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
13848
- valueLoc.source = valueLoc.source.slice(1, -1);
13849
- }
13850
- const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
13851
- if (isPropShorthand)
13852
- modifiers.push("prop");
13853
- if (dirName === "bind" && arg) {
13854
- if (modifiers.includes("sync") && checkCompatEnabled(
13855
- "COMPILER_V_BIND_SYNC",
13856
- context,
13857
- loc,
13858
- arg.loc.source
13859
- )) {
13860
- dirName = "model";
13861
- modifiers.splice(modifiers.indexOf("sync"), 1);
13862
- }
13863
- if (modifiers.includes("prop")) {
13864
- checkCompatEnabled(
13865
- "COMPILER_V_BIND_PROP",
13866
- context,
13867
- loc
13868
- );
14743
+ } else {
14744
+ node.content = node.content.replace(windowsNewlineRE, "\n");
13869
14745
  }
13870
14746
  }
13871
- return {
13872
- type: 7,
13873
- name: dirName,
13874
- exp: value && {
13875
- type: 4,
13876
- content: value.content,
13877
- isStatic: false,
13878
- // Treat as non-constant by default. This can be potentially set to
13879
- // other values by `transformExpression` to make it eligible for hoisting.
13880
- constType: 0,
13881
- loc: value.loc
13882
- },
13883
- arg,
13884
- modifiers,
13885
- loc
13886
- };
13887
14747
  }
13888
- if (!context.inVPre && startsWith(name, "v-")) {
13889
- emitError(context, 26);
14748
+ if (inPre && tag && currentOptions.isPreTag(tag)) {
14749
+ const first = nodes[0];
14750
+ if (first && first.type === 2) {
14751
+ first.content = first.content.replace(/^\r?\n/, "");
14752
+ }
13890
14753
  }
13891
- return {
13892
- type: 6,
13893
- name,
13894
- value: value && {
13895
- type: 2,
13896
- content: value.content,
13897
- loc: value.loc
13898
- },
13899
- loc
13900
- };
14754
+ return removedWhitespace ? nodes.filter(Boolean) : nodes;
13901
14755
  }
13902
- function parseAttributeValue(context) {
13903
- const start = getCursor(context);
13904
- let content;
13905
- const quote = context.source[0];
13906
- const isQuoted = quote === `"` || quote === `'`;
13907
- if (isQuoted) {
13908
- advanceBy(context, 1);
13909
- const endIndex = context.source.indexOf(quote);
13910
- if (endIndex === -1) {
13911
- content = parseTextData(
13912
- context,
13913
- context.source.length,
13914
- 4
13915
- );
13916
- } else {
13917
- content = parseTextData(context, endIndex, 4);
13918
- advanceBy(context, 1);
13919
- }
13920
- } else {
13921
- const match = /^[^\t\r\n\f >]+/.exec(context.source);
13922
- if (!match) {
13923
- return void 0;
13924
- }
13925
- const unexpectedChars = /["'<=`]/g;
13926
- let m;
13927
- while (m = unexpectedChars.exec(match[0])) {
13928
- emitError(
13929
- context,
13930
- 18,
13931
- m.index
13932
- );
14756
+ function isAllWhitespace(str) {
14757
+ for (let i = 0; i < str.length; i++) {
14758
+ if (!isWhitespace(str.charCodeAt(i))) {
14759
+ return false;
13933
14760
  }
13934
- content = parseTextData(context, match[0].length, 4);
13935
- }
13936
- return { content, isQuoted, loc: getSelection(context, start) };
13937
- }
13938
- function parseInterpolation(context, mode) {
13939
- const [open, close] = context.options.delimiters;
13940
- const closeIndex = context.source.indexOf(close, open.length);
13941
- if (closeIndex === -1) {
13942
- emitError(context, 25);
13943
- return void 0;
13944
- }
13945
- const start = getCursor(context);
13946
- advanceBy(context, open.length);
13947
- const innerStart = getCursor(context);
13948
- const innerEnd = getCursor(context);
13949
- const rawContentLength = closeIndex - open.length;
13950
- const rawContent = context.source.slice(0, rawContentLength);
13951
- const preTrimContent = parseTextData(context, rawContentLength, mode);
13952
- const content = preTrimContent.trim();
13953
- const startOffset = preTrimContent.indexOf(content);
13954
- if (startOffset > 0) {
13955
- advancePositionWithMutation(innerStart, rawContent, startOffset);
13956
- }
13957
- const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
13958
- advancePositionWithMutation(innerEnd, rawContent, endOffset);
13959
- advanceBy(context, close.length);
13960
- return {
13961
- type: 5,
13962
- content: {
13963
- type: 4,
13964
- isStatic: false,
13965
- // Set `isConstant` to false by default and will decide in transformExpression
13966
- constType: 0,
13967
- content,
13968
- loc: getSelection(context, innerStart, innerEnd)
13969
- },
13970
- loc: getSelection(context, start)
13971
- };
14761
+ }
14762
+ return true;
13972
14763
  }
13973
- function parseText(context, mode) {
13974
- const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
13975
- let endIndex = context.source.length;
13976
- for (let i = 0; i < endTokens.length; i++) {
13977
- const index = context.source.indexOf(endTokens[i], 1);
13978
- if (index !== -1 && endIndex > index) {
13979
- endIndex = index;
14764
+ function hasNewlineChar(str) {
14765
+ for (let i = 0; i < str.length; i++) {
14766
+ const c = str.charCodeAt(i);
14767
+ if (c === 10 || c === 13) {
14768
+ return true;
13980
14769
  }
13981
14770
  }
13982
- const start = getCursor(context);
13983
- const content = parseTextData(context, endIndex, mode);
13984
- return {
13985
- type: 2,
13986
- content,
13987
- loc: getSelection(context, start)
13988
- };
14771
+ return false;
13989
14772
  }
13990
- function parseTextData(context, length, mode) {
13991
- const rawText = context.source.slice(0, length);
13992
- advanceBy(context, length);
13993
- if (mode === 2 || mode === 3 || !rawText.includes("&")) {
13994
- return rawText;
13995
- } else {
13996
- return context.options.decodeEntities(
13997
- rawText,
13998
- mode === 4
13999
- );
14773
+ function condense(str) {
14774
+ let ret = "";
14775
+ let prevCharIsWhitespace = false;
14776
+ for (let i = 0; i < str.length; i++) {
14777
+ if (isWhitespace(str.charCodeAt(i))) {
14778
+ if (!prevCharIsWhitespace) {
14779
+ ret += " ";
14780
+ prevCharIsWhitespace = true;
14781
+ }
14782
+ } else {
14783
+ ret += str[i];
14784
+ prevCharIsWhitespace = false;
14785
+ }
14000
14786
  }
14787
+ return ret;
14001
14788
  }
14002
- function getCursor(context) {
14003
- const { column, line, offset } = context;
14004
- return { column, line, offset };
14789
+ function addNode(node) {
14790
+ (stack[0] || currentRoot).children.push(node);
14005
14791
  }
14006
- function getSelection(context, start, end) {
14007
- end = end || getCursor(context);
14792
+ function getLoc(start, end) {
14008
14793
  return {
14009
- start,
14010
- end,
14011
- source: context.originalSource.slice(start.offset, end.offset)
14794
+ start: tokenizer.getPos(start),
14795
+ // @ts-expect-error allow late attachment
14796
+ end: end == null ? end : tokenizer.getPos(end),
14797
+ // @ts-expect-error allow late attachment
14798
+ source: end == null ? end : getSlice(start, end)
14012
14799
  };
14013
14800
  }
14014
- function last(xs) {
14015
- return xs[xs.length - 1];
14016
- }
14017
- function startsWith(source, searchString) {
14018
- return source.startsWith(searchString);
14801
+ function setLocEnd(loc, end) {
14802
+ loc.end = tokenizer.getPos(end);
14803
+ loc.source = getSlice(loc.start.offset, end);
14019
14804
  }
14020
- function advanceBy(context, numberOfCharacters) {
14021
- const { source } = context;
14022
- advancePositionWithMutation(context, source, numberOfCharacters);
14023
- context.source = source.slice(numberOfCharacters);
14024
- }
14025
- function advanceSpaces(context) {
14026
- const match = /^[\t\r\n\f ]+/.exec(context.source);
14027
- if (match) {
14028
- advanceBy(context, match[0].length);
14805
+ function dirToAttr(dir) {
14806
+ const attr = {
14807
+ type: 6,
14808
+ name: dir.rawName,
14809
+ nameLoc: getLoc(
14810
+ dir.loc.start.offset,
14811
+ dir.loc.start.offset + dir.rawName.length
14812
+ ),
14813
+ value: void 0,
14814
+ loc: dir.loc
14815
+ };
14816
+ if (dir.exp) {
14817
+ const loc = dir.exp.loc;
14818
+ if (loc.end.offset < dir.loc.end.offset) {
14819
+ loc.start.offset--;
14820
+ loc.start.column--;
14821
+ loc.end.offset++;
14822
+ loc.end.column++;
14823
+ }
14824
+ attr.value = {
14825
+ type: 2,
14826
+ content: dir.exp.content,
14827
+ loc
14828
+ };
14029
14829
  }
14830
+ return attr;
14030
14831
  }
14031
- function getNewPosition(context, start, numberOfCharacters) {
14032
- return advancePositionWithClone(
14033
- start,
14034
- context.originalSource.slice(start.offset, numberOfCharacters),
14035
- numberOfCharacters
14036
- );
14832
+ function emitError(code, index) {
14833
+ currentOptions.onError(createCompilerError(code, getLoc(index, index)));
14037
14834
  }
14038
- function emitError(context, code, offset, loc = getCursor(context)) {
14039
- if (offset) {
14040
- loc.offset += offset;
14041
- loc.column += offset;
14042
- }
14043
- context.options.onError(
14044
- createCompilerError(code, {
14045
- start: loc,
14046
- end: loc,
14047
- source: ""
14048
- })
14049
- );
14835
+ function reset() {
14836
+ tokenizer.reset();
14837
+ currentOpenTag = null;
14838
+ currentProp = null;
14839
+ currentAttrValue = "";
14840
+ currentAttrStartIndex = -1;
14841
+ currentAttrEndIndex = -1;
14842
+ stack.length = 0;
14050
14843
  }
14051
- function isEnd(context, mode, ancestors) {
14052
- const s = context.source;
14053
- switch (mode) {
14054
- case 0:
14055
- if (startsWith(s, "</")) {
14056
- for (let i = ancestors.length - 1; i >= 0; --i) {
14057
- if (startsWithEndTagOpen(s, ancestors[i].tag)) {
14058
- return true;
14059
- }
14060
- }
14061
- }
14062
- break;
14063
- case 1:
14064
- case 2: {
14065
- const parent = last(ancestors);
14066
- if (parent && startsWithEndTagOpen(s, parent.tag)) {
14067
- return true;
14844
+ function baseParse(input, options) {
14845
+ reset();
14846
+ currentInput = input;
14847
+ currentOptions = extend({}, defaultParserOptions);
14848
+ if (options) {
14849
+ let key;
14850
+ for (key in options) {
14851
+ if (options[key] != null) {
14852
+ currentOptions[key] = options[key];
14068
14853
  }
14069
- break;
14070
14854
  }
14071
- case 3:
14072
- if (startsWith(s, "]]>")) {
14073
- return true;
14074
- }
14075
- break;
14076
14855
  }
14077
- return !s;
14078
- }
14079
- function startsWithEndTagOpen(source, tag) {
14080
- return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
14856
+ {
14857
+ if (!currentOptions.decodeEntities) {
14858
+ throw new Error(
14859
+ `[@vue/compiler-core] decodeEntities option is required in browser builds.`
14860
+ );
14861
+ }
14862
+ }
14863
+ tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
14864
+ const delimiters = options == null ? void 0 : options.delimiters;
14865
+ if (delimiters) {
14866
+ tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
14867
+ tokenizer.delimiterClose = toCharCodes(delimiters[1]);
14868
+ }
14869
+ const root = currentRoot = createRoot([], input);
14870
+ tokenizer.parse(currentInput);
14871
+ root.loc = getLoc(0, input.length);
14872
+ root.children = condenseWhitespace(root.children);
14873
+ currentRoot = null;
14874
+ return root;
14081
14875
  }
14082
14876
 
14083
14877
  function hoistStatic(root, context) {
@@ -14489,6 +15283,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14489
15283
  root.hoists = context.hoists;
14490
15284
  root.temps = context.temps;
14491
15285
  root.cached = context.cached;
15286
+ root.transformed = true;
14492
15287
  {
14493
15288
  root.filters = [...context.filters];
14494
15289
  }
@@ -14645,7 +15440,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14645
15440
  ssr,
14646
15441
  isTS,
14647
15442
  inSSR,
14648
- source: ast.loc.source,
15443
+ source: ast.source,
14649
15444
  code: ``,
14650
15445
  column: 1,
14651
15446
  line: 1,
@@ -14656,7 +15451,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14656
15451
  helper(key) {
14657
15452
  return `_${helperNameMap[key]}`;
14658
15453
  },
14659
- push(code, node) {
15454
+ push(code, newlineIndex = -2 /* None */, node) {
14660
15455
  context.code += code;
14661
15456
  },
14662
15457
  indent() {
@@ -14674,7 +15469,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14674
15469
  }
14675
15470
  };
14676
15471
  function newline(n) {
14677
- context.push("\n" + ` `.repeat(n));
15472
+ context.push("\n" + ` `.repeat(n), 0 /* Start */);
14678
15473
  }
14679
15474
  return context;
14680
15475
  }
@@ -14711,9 +15506,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14711
15506
  push(`with (_ctx) {`);
14712
15507
  indent();
14713
15508
  if (hasHelpers) {
14714
- push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
14715
- push(`
14716
- `);
15509
+ push(
15510
+ `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
15511
+ `,
15512
+ -1 /* End */
15513
+ );
14717
15514
  newline();
14718
15515
  }
14719
15516
  }
@@ -14742,7 +15539,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14742
15539
  }
14743
15540
  if (ast.components.length || ast.directives.length || ast.temps) {
14744
15541
  push(`
14745
- `);
15542
+ `, 0 /* Start */);
14746
15543
  newline();
14747
15544
  }
14748
15545
  if (!ssr) {
@@ -14763,7 +15560,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14763
15560
  ast,
14764
15561
  code: context.code,
14765
15562
  preamble: isSetupInlined ? preambleContext.code : ``,
14766
- // SourceMapGenerator does have toJSON() method but it's not in the types
14767
15563
  map: context.map ? context.map.toJSON() : void 0
14768
15564
  };
14769
15565
  }
@@ -14782,7 +15578,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14782
15578
  if (helpers.length > 0) {
14783
15579
  {
14784
15580
  push(`const _Vue = ${VueBinding}
14785
- `);
15581
+ `, -1 /* End */);
14786
15582
  if (ast.hoists.length) {
14787
15583
  const staticHelpers = [
14788
15584
  CREATE_VNODE,
@@ -14792,7 +15588,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14792
15588
  CREATE_STATIC
14793
15589
  ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
14794
15590
  push(`const { ${staticHelpers} } = _Vue
14795
- `);
15591
+ `, -1 /* End */);
14796
15592
  }
14797
15593
  }
14798
15594
  }
@@ -14853,7 +15649,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14853
15649
  for (let i = 0; i < nodes.length; i++) {
14854
15650
  const node = nodes[i];
14855
15651
  if (isString(node)) {
14856
- push(node);
15652
+ push(node, -3 /* Unknown */);
14857
15653
  } else if (isArray(node)) {
14858
15654
  genNodeListAsArray(node, context);
14859
15655
  } else {
@@ -14871,7 +15667,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14871
15667
  }
14872
15668
  function genNode(node, context) {
14873
15669
  if (isString(node)) {
14874
- context.push(node);
15670
+ context.push(node, -3 /* Unknown */);
14875
15671
  return;
14876
15672
  }
14877
15673
  if (isSymbol(node)) {
@@ -14951,11 +15747,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14951
15747
  }
14952
15748
  }
14953
15749
  function genText(node, context) {
14954
- context.push(JSON.stringify(node.content), node);
15750
+ context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
14955
15751
  }
14956
15752
  function genExpression(node, context) {
14957
15753
  const { content, isStatic } = node;
14958
- context.push(isStatic ? JSON.stringify(content) : content, node);
15754
+ context.push(
15755
+ isStatic ? JSON.stringify(content) : content,
15756
+ -3 /* Unknown */,
15757
+ node
15758
+ );
14959
15759
  }
14960
15760
  function genInterpolation(node, context) {
14961
15761
  const { push, helper, pure } = context;
@@ -14969,7 +15769,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14969
15769
  for (let i = 0; i < node.children.length; i++) {
14970
15770
  const child = node.children[i];
14971
15771
  if (isString(child)) {
14972
- context.push(child);
15772
+ context.push(child, -3 /* Unknown */);
14973
15773
  } else {
14974
15774
  genNode(child, context);
14975
15775
  }
@@ -14983,9 +15783,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14983
15783
  push(`]`);
14984
15784
  } else if (node.isStatic) {
14985
15785
  const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
14986
- push(text, node);
15786
+ push(text, -2 /* None */, node);
14987
15787
  } else {
14988
- push(`[${node.content}]`, node);
15788
+ push(`[${node.content}]`, -3 /* Unknown */, node);
14989
15789
  }
14990
15790
  }
14991
15791
  function genComment(node, context) {
@@ -14993,7 +15793,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14993
15793
  if (pure) {
14994
15794
  push(PURE_ANNOTATION);
14995
15795
  }
14996
- push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
15796
+ push(
15797
+ `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
15798
+ -3 /* Unknown */,
15799
+ node
15800
+ );
14997
15801
  }
14998
15802
  function genVNodeCall(node, context) {
14999
15803
  const { push, helper, pure } = context;
@@ -15018,7 +15822,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15018
15822
  push(PURE_ANNOTATION);
15019
15823
  }
15020
15824
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
15021
- push(helper(callHelper) + `(`, node);
15825
+ push(helper(callHelper) + `(`, -2 /* None */, node);
15022
15826
  genNodeList(
15023
15827
  genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
15024
15828
  context
@@ -15047,7 +15851,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15047
15851
  if (pure) {
15048
15852
  push(PURE_ANNOTATION);
15049
15853
  }
15050
- push(callee + `(`, node);
15854
+ push(callee + `(`, -2 /* None */, node);
15051
15855
  genNodeList(node.arguments, context);
15052
15856
  push(`)`);
15053
15857
  }
@@ -15055,7 +15859,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15055
15859
  const { push, indent, deindent, newline } = context;
15056
15860
  const { properties } = node;
15057
15861
  if (!properties.length) {
15058
- push(`{}`, node);
15862
+ push(`{}`, -2 /* None */, node);
15059
15863
  return;
15060
15864
  }
15061
15865
  const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
@@ -15083,7 +15887,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15083
15887
  if (isSlot) {
15084
15888
  push(`_${helperNameMap[WITH_CTX]}(`);
15085
15889
  }
15086
- push(`(`, node);
15890
+ push(`(`, -2 /* None */, node);
15087
15891
  if (isArray(params)) {
15088
15892
  genNodeList(params, context);
15089
15893
  } else if (params) {
@@ -15317,7 +16121,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15317
16121
  context.removeNode();
15318
16122
  const branch = createIfBranch(node, dir);
15319
16123
  if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
15320
- !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
16124
+ !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
15321
16125
  branch.children = [...comments, ...branch.children];
15322
16126
  }
15323
16127
  {
@@ -15599,18 +16403,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15599
16403
  );
15600
16404
  return;
15601
16405
  }
15602
- const parseResult = parseForExpression(
15603
- // can only be simple expression because vFor transform is applied
15604
- // before expression transform.
15605
- dir.exp,
15606
- context
15607
- );
16406
+ const parseResult = dir.forParseResult;
15608
16407
  if (!parseResult) {
15609
16408
  context.onError(
15610
16409
  createCompilerError(32, dir.loc)
15611
16410
  );
15612
16411
  return;
15613
16412
  }
16413
+ finalizeForParseResult(parseResult, context);
15614
16414
  const { addIdentifiers, removeIdentifiers, scopes } = context;
15615
16415
  const { source, value, key, index } = parseResult;
15616
16416
  const forNode = {
@@ -15632,70 +16432,26 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15632
16432
  onExit();
15633
16433
  };
15634
16434
  }
15635
- const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
15636
- const stripParensRE = /^\(|\)$/g;
15637
- function parseForExpression(input, context) {
15638
- const loc = input.loc;
15639
- const exp = input.content;
15640
- const inMatch = exp.match(forAliasRE);
15641
- if (!inMatch)
16435
+ function finalizeForParseResult(result, context) {
16436
+ if (result.finalized)
15642
16437
  return;
15643
- const [, LHS, RHS] = inMatch;
15644
- const result = {
15645
- source: createAliasExpression(
15646
- loc,
15647
- RHS.trim(),
15648
- exp.indexOf(RHS, LHS.length)
15649
- ),
15650
- value: void 0,
15651
- key: void 0,
15652
- index: void 0
15653
- };
15654
16438
  {
15655
16439
  validateBrowserExpression(result.source, context);
15656
- }
15657
- let valueContent = LHS.trim().replace(stripParensRE, "").trim();
15658
- const trimmedOffset = LHS.indexOf(valueContent);
15659
- const iteratorMatch = valueContent.match(forIteratorRE);
15660
- if (iteratorMatch) {
15661
- valueContent = valueContent.replace(forIteratorRE, "").trim();
15662
- const keyContent = iteratorMatch[1].trim();
15663
- let keyOffset;
15664
- if (keyContent) {
15665
- keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
15666
- result.key = createAliasExpression(loc, keyContent, keyOffset);
15667
- {
15668
- validateBrowserExpression(
15669
- result.key,
15670
- context,
15671
- true
15672
- );
15673
- }
16440
+ if (result.key) {
16441
+ validateBrowserExpression(
16442
+ result.key,
16443
+ context,
16444
+ true
16445
+ );
15674
16446
  }
15675
- if (iteratorMatch[2]) {
15676
- const indexContent = iteratorMatch[2].trim();
15677
- if (indexContent) {
15678
- result.index = createAliasExpression(
15679
- loc,
15680
- indexContent,
15681
- exp.indexOf(
15682
- indexContent,
15683
- result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
15684
- )
15685
- );
15686
- {
15687
- validateBrowserExpression(
15688
- result.index,
15689
- context,
15690
- true
15691
- );
15692
- }
15693
- }
16447
+ if (result.index) {
16448
+ validateBrowserExpression(
16449
+ result.index,
16450
+ context,
16451
+ true
16452
+ );
15694
16453
  }
15695
- }
15696
- if (valueContent) {
15697
- result.value = createAliasExpression(loc, valueContent, trimmedOffset);
15698
- {
16454
+ if (result.value) {
15699
16455
  validateBrowserExpression(
15700
16456
  result.value,
15701
16457
  context,
@@ -15703,14 +16459,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15703
16459
  );
15704
16460
  }
15705
16461
  }
15706
- return result;
15707
- }
15708
- function createAliasExpression(range, content, offset) {
15709
- return createSimpleExpression(
15710
- content,
15711
- false,
15712
- getInnerRange(range, offset, content.length)
15713
- );
16462
+ result.finalized = true;
15714
16463
  }
15715
16464
  function createForLoopParams({ value, key, index }, memoArgs = []) {
15716
16465
  return createParamsList([value, key, index, ...memoArgs]);
@@ -15797,12 +16546,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15797
16546
  hasDynamicSlots = true;
15798
16547
  }
15799
16548
  const vFor = findDir(slotElement, "for");
15800
- const slotFunction = buildSlotFn(
15801
- slotProps,
15802
- vFor == null ? void 0 : vFor.exp,
15803
- slotChildren,
15804
- slotLoc
15805
- );
16549
+ const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
15806
16550
  let vIf;
15807
16551
  let vElse;
15808
16552
  if (vIf = findDir(slotElement, "if")) {
@@ -15851,8 +16595,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15851
16595
  }
15852
16596
  } else if (vFor) {
15853
16597
  hasDynamicSlots = true;
15854
- const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
16598
+ const parseResult = vFor.forParseResult;
15855
16599
  if (parseResult) {
16600
+ finalizeForParseResult(parseResult, context);
15856
16601
  dynamicSlots.push(
15857
16602
  createCallExpression(context.helper(RENDER_LIST), [
15858
16603
  parseResult.source,
@@ -16113,17 +16858,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
16113
16858
  tag = isProp.value.content.slice(4);
16114
16859
  }
16115
16860
  }
16116
- const isDir = !isExplicitDynamic && findDir(node, "is");
16117
- if (isDir && isDir.exp) {
16118
- {
16119
- context.onWarn(
16120
- createCompilerError(52, isDir.loc)
16121
- );
16122
- }
16123
- return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
16124
- isDir.exp
16125
- ]);
16126
- }
16127
16861
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
16128
16862
  if (builtIn) {
16129
16863
  if (!ssr)
@@ -16195,7 +16929,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
16195
16929
  for (let i = 0; i < props.length; i++) {
16196
16930
  const prop = props[i];
16197
16931
  if (prop.type === 6) {
16198
- const { loc, name, value } = prop;
16932
+ const { loc, name, nameLoc, value } = prop;
16199
16933
  let isStatic = true;
16200
16934
  if (name === "ref") {
16201
16935
  hasRef = true;
@@ -16216,11 +16950,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
16216
16950
  }
16217
16951
  properties.push(
16218
16952
  createObjectProperty(
16219
- createSimpleExpression(
16220
- name,
16221
- true,
16222
- getInnerRange(loc, 0, name.length)
16223
- ),
16953
+ createSimpleExpression(name, true, nameLoc),
16224
16954
  createSimpleExpression(
16225
16955
  value ? value.content : "",
16226
16956
  isStatic,
@@ -16702,8 +17432,13 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
16702
17432
  };
16703
17433
 
16704
17434
  const transformBind = (dir, _node, context) => {
16705
- const { exp, modifiers, loc } = dir;
17435
+ const { modifiers, loc } = dir;
16706
17436
  const arg = dir.arg;
17437
+ let { exp } = dir;
17438
+ if (!exp && arg.type === 4) {
17439
+ const propName = camelize(arg.content);
17440
+ exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
17441
+ }
16707
17442
  if (arg.type !== 4) {
16708
17443
  arg.children.unshift(`(`);
16709
17444
  arg.children.push(`) || ""`);
@@ -17102,7 +17837,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
17102
17837
  }
17103
17838
  ];
17104
17839
  }
17105
- function baseCompile(template, options = {}) {
17840
+ function baseCompile(source, options = {}) {
17106
17841
  const onError = options.onError || defaultOnError;
17107
17842
  const isModuleMode = options.mode === "module";
17108
17843
  {
@@ -17119,7 +17854,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
17119
17854
  if (options.scopeId && !isModuleMode) {
17120
17855
  onError(createCompilerError(50));
17121
17856
  }
17122
- const ast = isString(template) ? baseParse(template, options) : template;
17857
+ const ast = isString(source) ? baseParse(source, options) : source;
17123
17858
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
17124
17859
  transform(
17125
17860
  ast,
@@ -17185,25 +17920,22 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
17185
17920
  }
17186
17921
  }
17187
17922
 
17188
- const isRawTextContainer = /* @__PURE__ */ makeMap(
17189
- "style,iframe,script,noscript",
17190
- true
17191
- );
17192
17923
  const parserOptions = {
17924
+ parseMode: "html",
17193
17925
  isVoidTag,
17194
17926
  isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
17195
17927
  isPreTag: (tag) => tag === "pre",
17196
17928
  decodeEntities: decodeHtmlBrowser ,
17197
17929
  isBuiltInComponent: (tag) => {
17198
- if (isBuiltInType(tag, `Transition`)) {
17930
+ if (tag === "Transition" || tag === "transition") {
17199
17931
  return TRANSITION;
17200
- } else if (isBuiltInType(tag, `TransitionGroup`)) {
17932
+ } else if (tag === "TransitionGroup" || tag === "transition-group") {
17201
17933
  return TRANSITION_GROUP;
17202
17934
  }
17203
17935
  },
17204
17936
  // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
17205
- getNamespace(tag, parent) {
17206
- let ns = parent ? parent.ns : 0;
17937
+ getNamespace(tag, parent, rootNamespace) {
17938
+ let ns = parent ? parent.ns : rootNamespace;
17207
17939
  if (parent && ns === 2) {
17208
17940
  if (parent.tag === "annotation-xml") {
17209
17941
  if (tag === "svg") {
@@ -17231,18 +17963,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
17231
17963
  }
17232
17964
  }
17233
17965
  return ns;
17234
- },
17235
- // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
17236
- getTextMode({ tag, ns }) {
17237
- if (ns === 0) {
17238
- if (tag === "textarea" || tag === "title") {
17239
- return 1;
17240
- }
17241
- if (isRawTextContainer(tag)) {
17242
- return 2;
17243
- }
17244
- }
17245
- return 0;
17246
17966
  }
17247
17967
  };
17248
17968
 
@@ -17563,6 +18283,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
17563
18283
  node.props.push({
17564
18284
  type: 6,
17565
18285
  name: "persisted",
18286
+ nameLoc: node.loc,
17566
18287
  value: void 0,
17567
18288
  loc: node.loc
17568
18289
  });
@@ -17607,9 +18328,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
17607
18328
  // override compiler-core
17608
18329
  show: transformShow
17609
18330
  };
17610
- function compile(template, options = {}) {
18331
+ function compile(src, options = {}) {
17611
18332
  return baseCompile(
17612
- template,
18333
+ src,
17613
18334
  extend({}, parserOptions, options, {
17614
18335
  nodeTransforms: [
17615
18336
  // ignore <script> and <tag>