@vue/compat 3.4.0-alpha.1 → 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.
@@ -1,10 +1,6 @@
1
1
  function makeMap(str, expectsLowerCase) {
2
- const map = /* @__PURE__ */ Object.create(null);
3
- const list = str.split(",");
4
- for (let i = 0; i < list.length; i++) {
5
- map[list[i]] = true;
6
- }
7
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
2
+ const set = new Set(str.split(","));
3
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
8
4
  }
9
5
 
10
6
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -104,7 +100,7 @@ const PatchFlagNames = {
104
100
  [4]: `STYLE`,
105
101
  [8]: `PROPS`,
106
102
  [16]: `FULL_PROPS`,
107
- [32]: `HYDRATE_EVENTS`,
103
+ [32]: `NEED_HYDRATION`,
108
104
  [64]: `STABLE_FRAGMENT`,
109
105
  [128]: `KEYED_FRAGMENT`,
110
106
  [256]: `UNKEYED_FRAGMENT`,
@@ -1026,7 +1022,7 @@ function createReadonlyMethod(type) {
1026
1022
  toRaw(this)
1027
1023
  );
1028
1024
  }
1029
- return type === "delete" ? false : this;
1025
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1030
1026
  };
1031
1027
  }
1032
1028
  function createInstrumentations() {
@@ -1282,9 +1278,10 @@ class ComputedRefImpl {
1282
1278
  this.dep = void 0;
1283
1279
  this.__v_isRef = true;
1284
1280
  this["__v_isReadonly"] = false;
1285
- this.effect = new ReactiveEffect(getter, () => {
1286
- triggerRefValue(this, 1);
1287
- });
1281
+ this.effect = new ReactiveEffect(
1282
+ () => getter(this._value),
1283
+ () => triggerRefValue(this, 1)
1284
+ );
1288
1285
  this.effect.computed = this;
1289
1286
  this.effect.active = this._cacheable = !isSSR;
1290
1287
  this["__v_isReadonly"] = isReadonly;
@@ -1501,16 +1498,16 @@ function propertyToRef(source, key, defaultValue) {
1501
1498
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1502
1499
  }
1503
1500
 
1504
- const stack = [];
1501
+ const stack$1 = [];
1505
1502
  function pushWarningContext(vnode) {
1506
- stack.push(vnode);
1503
+ stack$1.push(vnode);
1507
1504
  }
1508
1505
  function popWarningContext() {
1509
- stack.pop();
1506
+ stack$1.pop();
1510
1507
  }
1511
1508
  function warn(msg, ...args) {
1512
1509
  pauseTracking();
1513
- const instance = stack.length ? stack[stack.length - 1].component : null;
1510
+ const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
1514
1511
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
1515
1512
  const trace = getComponentTrace();
1516
1513
  if (appWarnHandler) {
@@ -1539,7 +1536,7 @@ function warn(msg, ...args) {
1539
1536
  resetTracking();
1540
1537
  }
1541
1538
  function getComponentTrace() {
1542
- let currentVNode = stack[stack.length - 1];
1539
+ let currentVNode = stack$1[stack$1.length - 1];
1543
1540
  if (!currentVNode) {
1544
1541
  return [];
1545
1542
  }
@@ -2768,9 +2765,19 @@ function renderComponentRoot(instance) {
2768
2765
  try {
2769
2766
  if (vnode.shapeFlag & 4) {
2770
2767
  const proxyToUse = withProxy || proxy;
2768
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2769
+ get(target, key, receiver) {
2770
+ warn(
2771
+ `Property '${String(
2772
+ key
2773
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2774
+ );
2775
+ return Reflect.get(target, key, receiver);
2776
+ }
2777
+ }) : proxyToUse;
2771
2778
  result = normalizeVNode(
2772
2779
  render.call(
2773
- proxyToUse,
2780
+ thisProxy,
2774
2781
  proxyToUse,
2775
2782
  renderCache,
2776
2783
  props,
@@ -3021,6 +3028,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
3021
3028
  }
3022
3029
  }
3023
3030
 
3031
+ const COMPONENTS = "components";
3032
+ const DIRECTIVES = "directives";
3033
+ const FILTERS = "filters";
3034
+ function resolveComponent(name, maybeSelfReference) {
3035
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
3036
+ }
3037
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
3038
+ function resolveDynamicComponent(component) {
3039
+ if (isString(component)) {
3040
+ return resolveAsset(COMPONENTS, component, false) || component;
3041
+ } else {
3042
+ return component || NULL_DYNAMIC_COMPONENT;
3043
+ }
3044
+ }
3045
+ function resolveDirective(name) {
3046
+ return resolveAsset(DIRECTIVES, name);
3047
+ }
3048
+ function resolveFilter$1(name) {
3049
+ return resolveAsset(FILTERS, name);
3050
+ }
3051
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3052
+ const instance = currentRenderingInstance || currentInstance;
3053
+ if (instance) {
3054
+ const Component = instance.type;
3055
+ if (type === COMPONENTS) {
3056
+ const selfName = getComponentName(
3057
+ Component,
3058
+ false
3059
+ /* do not include inferred name to avoid breaking existing code */
3060
+ );
3061
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3062
+ return Component;
3063
+ }
3064
+ }
3065
+ const res = (
3066
+ // local registration
3067
+ // check instance[type] first which is resolved for options API
3068
+ resolve(instance[type] || Component[type], name) || // global registration
3069
+ resolve(instance.appContext[type], name)
3070
+ );
3071
+ if (!res && maybeSelfReference) {
3072
+ return Component;
3073
+ }
3074
+ if (warnMissing && !res) {
3075
+ const extra = type === COMPONENTS ? `
3076
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3077
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3078
+ }
3079
+ return res;
3080
+ } else {
3081
+ warn(
3082
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3083
+ );
3084
+ }
3085
+ }
3086
+ function resolve(registry, name) {
3087
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3088
+ }
3089
+
3024
3090
  const isSuspense = (type) => type.__isSuspense;
3025
3091
  const SuspenseImpl = {
3026
3092
  name: "Suspense",
@@ -3555,7 +3621,7 @@ function normalizeSuspenseSlot(s) {
3555
3621
  }
3556
3622
  if (isArray(s)) {
3557
3623
  const singleChild = filterSingleRoot(s);
3558
- if (!singleChild) {
3624
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3559
3625
  warn(`<Suspense> slots expect a single root node.`);
3560
3626
  }
3561
3627
  s = singleChild;
@@ -3753,6 +3819,7 @@ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger
3753
3819
  let onCleanup = (fn) => {
3754
3820
  cleanup = effect.onStop = () => {
3755
3821
  callWithErrorHandling(fn, instance, 4);
3822
+ cleanup = effect.onStop = void 0;
3756
3823
  };
3757
3824
  };
3758
3825
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -4230,7 +4297,11 @@ function emptyPlaceholder(vnode) {
4230
4297
  }
4231
4298
  }
4232
4299
  function getKeepAliveChild(vnode) {
4233
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4300
+ return isKeepAlive(vnode) ? (
4301
+ // #7121 ensure get the child component subtree in case
4302
+ // it's been replaced during HMR
4303
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4304
+ ) : vnode;
4234
4305
  }
4235
4306
  function setTransitionHooks(vnode, hooks) {
4236
4307
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4746,65 +4817,6 @@ function getCompatListeners(instance) {
4746
4817
  return listeners;
4747
4818
  }
4748
4819
 
4749
- const COMPONENTS = "components";
4750
- const DIRECTIVES = "directives";
4751
- const FILTERS = "filters";
4752
- function resolveComponent(name, maybeSelfReference) {
4753
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4754
- }
4755
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4756
- function resolveDynamicComponent(component) {
4757
- if (isString(component)) {
4758
- return resolveAsset(COMPONENTS, component, false) || component;
4759
- } else {
4760
- return component || NULL_DYNAMIC_COMPONENT;
4761
- }
4762
- }
4763
- function resolveDirective(name) {
4764
- return resolveAsset(DIRECTIVES, name);
4765
- }
4766
- function resolveFilter$1(name) {
4767
- return resolveAsset(FILTERS, name);
4768
- }
4769
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4770
- const instance = currentRenderingInstance || currentInstance;
4771
- if (instance) {
4772
- const Component = instance.type;
4773
- if (type === COMPONENTS) {
4774
- const selfName = getComponentName(
4775
- Component,
4776
- false
4777
- /* do not include inferred name to avoid breaking existing code */
4778
- );
4779
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4780
- return Component;
4781
- }
4782
- }
4783
- const res = (
4784
- // local registration
4785
- // check instance[type] first which is resolved for options API
4786
- resolve(instance[type] || Component[type], name) || // global registration
4787
- resolve(instance.appContext[type], name)
4788
- );
4789
- if (!res && maybeSelfReference) {
4790
- return Component;
4791
- }
4792
- if (warnMissing && !res) {
4793
- const extra = type === COMPONENTS ? `
4794
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4795
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4796
- }
4797
- return res;
4798
- } else {
4799
- warn(
4800
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4801
- );
4802
- }
4803
- }
4804
- function resolve(registry, name) {
4805
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4806
- }
4807
-
4808
4820
  function convertLegacyRenderFn(instance) {
4809
4821
  const Component2 = instance.type;
4810
4822
  const render = Component2.render;
@@ -6310,7 +6322,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6310
6322
  return vm;
6311
6323
  }
6312
6324
  }
6313
- Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6325
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.2"}`;
6314
6326
  Vue.config = singletonApp.config;
6315
6327
  Vue.use = (p, ...options) => {
6316
6328
  if (p && isFunction(p.install)) {
@@ -7338,6 +7350,9 @@ function assertType(value, type) {
7338
7350
  };
7339
7351
  }
7340
7352
  function getInvalidTypeMessage(name, value, expectedTypes) {
7353
+ if (expectedTypes.length === 0) {
7354
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7355
+ }
7341
7356
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7342
7357
  const expectedType = expectedTypes[0];
7343
7358
  const receivedType = toRawType(value);
@@ -7609,6 +7624,20 @@ function createHydrationFunctions(rendererInternals) {
7609
7624
  const { type, ref, shapeFlag, patchFlag } = vnode;
7610
7625
  let domType = node.nodeType;
7611
7626
  vnode.el = node;
7627
+ {
7628
+ if (!("__vnode" in node)) {
7629
+ Object.defineProperty(node, "__vnode", {
7630
+ value: vnode,
7631
+ enumerable: false
7632
+ });
7633
+ }
7634
+ if (!("__vueParentComponent" in node)) {
7635
+ Object.defineProperty(node, "__vueParentComponent", {
7636
+ value: parentComponent,
7637
+ enumerable: false
7638
+ });
7639
+ }
7640
+ }
7612
7641
  if (patchFlag === -2) {
7613
7642
  optimized = false;
7614
7643
  vnode.dynamicChildren = null;
@@ -7639,15 +7668,15 @@ function createHydrationFunctions(rendererInternals) {
7639
7668
  }
7640
7669
  break;
7641
7670
  case Comment:
7642
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7643
- if (node.tagName.toLowerCase() === "template") {
7644
- const content = vnode.el.content.firstChild;
7645
- replaceNode(content, node, parentComponent);
7646
- vnode.el = node = content;
7647
- nextNode = nextSibling(node);
7648
- } else {
7649
- nextNode = onMismatch();
7650
- }
7671
+ if (isTemplateNode(node)) {
7672
+ nextNode = nextSibling(node);
7673
+ replaceNode(
7674
+ vnode.el = node.content.firstChild,
7675
+ node,
7676
+ parentComponent
7677
+ );
7678
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7679
+ nextNode = onMismatch();
7651
7680
  } else {
7652
7681
  nextNode = nextSibling(node);
7653
7682
  }
@@ -7770,15 +7799,16 @@ function createHydrationFunctions(rendererInternals) {
7770
7799
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7771
7800
  optimized = optimized || !!vnode.dynamicChildren;
7772
7801
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7773
- const forcePatchValue = type === "input" && dirs || type === "option";
7802
+ const forcePatch = type === "input" || type === "option";
7774
7803
  {
7775
7804
  if (dirs) {
7776
7805
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7777
7806
  }
7778
7807
  if (props) {
7779
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7808
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7780
7809
  for (const key in props) {
7781
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7810
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7811
+ key[0] === ".") {
7782
7812
  patchProp(
7783
7813
  el,
7784
7814
  key,
@@ -7991,8 +8021,7 @@ function createHydrationFunctions(rendererInternals) {
7991
8021
  let parent = parentComponent;
7992
8022
  while (parent) {
7993
8023
  if (parent.vnode.el === oldNode) {
7994
- parent.vnode.el = newNode;
7995
- parent.subTree.el = newNode;
8024
+ parent.vnode.el = parent.subTree.el = newNode;
7996
8025
  }
7997
8026
  parent = parent.parent;
7998
8027
  }
@@ -9576,6 +9605,7 @@ const resolveTarget = (props, select) => {
9576
9605
  }
9577
9606
  };
9578
9607
  const TeleportImpl = {
9608
+ name: "Teleport",
9579
9609
  __isTeleport: true,
9580
9610
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9581
9611
  const {
@@ -10055,7 +10085,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
10055
10085
  if (shapeFlag & 4 && isProxy(type)) {
10056
10086
  type = toRaw(type);
10057
10087
  warn(
10058
- `Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
10088
+ `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
10059
10089
  `
10060
10090
  Component that was made reactive: `,
10061
10091
  type
@@ -10891,7 +10921,7 @@ function isMemoSame(cached, memo) {
10891
10921
  return true;
10892
10922
  }
10893
10923
 
10894
- const version = "3.4.0-alpha.1";
10924
+ const version = "3.4.0-alpha.2";
10895
10925
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10896
10926
  const ssrUtils = null;
10897
10927
  const resolveFilter = resolveFilter$1 ;
@@ -12133,21 +12163,20 @@ const vModelText = {
12133
12163
  el[assignKey] = getModelAssigner(vnode);
12134
12164
  if (el.composing)
12135
12165
  return;
12166
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12167
+ const newValue = value == null ? "" : value;
12168
+ if (elValue === newValue) {
12169
+ return;
12170
+ }
12136
12171
  if (document.activeElement === el && el.type !== "range") {
12137
12172
  if (lazy) {
12138
12173
  return;
12139
12174
  }
12140
- if (trim && el.value.trim() === value) {
12141
- return;
12142
- }
12143
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12175
+ if (trim && el.value.trim() === newValue) {
12144
12176
  return;
12145
12177
  }
12146
12178
  }
12147
- const newValue = value == null ? "" : value;
12148
- if (el.value !== newValue) {
12149
- el.value = newValue;
12150
- }
12179
+ el.value = newValue;
12151
12180
  }
12152
12181
  };
12153
12182
  const vModelCheckbox = {
@@ -12712,83 +12741,6 @@ function createCompatVue() {
12712
12741
  return Vue;
12713
12742
  }
12714
12743
 
12715
- function defaultOnError(error) {
12716
- throw error;
12717
- }
12718
- function defaultOnWarn(msg) {
12719
- console.warn(`[Vue warn] ${msg.message}`);
12720
- }
12721
- function createCompilerError(code, loc, messages, additionalMessage) {
12722
- const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
12723
- const error = new SyntaxError(String(msg));
12724
- error.code = code;
12725
- error.loc = loc;
12726
- return error;
12727
- }
12728
- const errorMessages = {
12729
- // parse errors
12730
- [0]: "Illegal comment.",
12731
- [1]: "CDATA section is allowed only in XML context.",
12732
- [2]: "Duplicate attribute.",
12733
- [3]: "End tag cannot have attributes.",
12734
- [4]: "Illegal '/' in tags.",
12735
- [5]: "Unexpected EOF in tag.",
12736
- [6]: "Unexpected EOF in CDATA section.",
12737
- [7]: "Unexpected EOF in comment.",
12738
- [8]: "Unexpected EOF in script.",
12739
- [9]: "Unexpected EOF in tag.",
12740
- [10]: "Incorrectly closed comment.",
12741
- [11]: "Incorrectly opened comment.",
12742
- [12]: "Illegal tag name. Use '&lt;' to print '<'.",
12743
- [13]: "Attribute value was expected.",
12744
- [14]: "End tag name was expected.",
12745
- [15]: "Whitespace was expected.",
12746
- [16]: "Unexpected '<!--' in comment.",
12747
- [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
12748
- [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
12749
- [19]: "Attribute name cannot start with '='.",
12750
- [21]: "'<?' is allowed only in XML context.",
12751
- [20]: `Unexpected null character.`,
12752
- [22]: "Illegal '/' in tags.",
12753
- // Vue-specific parse errors
12754
- [23]: "Invalid end tag.",
12755
- [24]: "Element is missing end tag.",
12756
- [25]: "Interpolation end sign was not found.",
12757
- [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
12758
- [26]: "Legal directive name was expected.",
12759
- // transform errors
12760
- [28]: `v-if/v-else-if is missing expression.`,
12761
- [29]: `v-if/else branches must use unique keys.`,
12762
- [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
12763
- [31]: `v-for is missing expression.`,
12764
- [32]: `v-for has invalid expression.`,
12765
- [33]: `<template v-for> key should be placed on the <template> tag.`,
12766
- [34]: `v-bind is missing expression.`,
12767
- [35]: `v-on is missing expression.`,
12768
- [36]: `Unexpected custom directive on <slot> outlet.`,
12769
- [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.`,
12770
- [38]: `Duplicate slot names found. `,
12771
- [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
12772
- [40]: `v-slot can only be used on components or <template> tags.`,
12773
- [41]: `v-model is missing expression.`,
12774
- [42]: `v-model value must be a valid JavaScript member expression.`,
12775
- [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
12776
- [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
12777
- Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
12778
- [45]: `Error parsing JavaScript expression: `,
12779
- [46]: `<KeepAlive> expects exactly one child component.`,
12780
- // generic errors
12781
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
12782
- [48]: `ES module mode is not supported in this build of compiler.`,
12783
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
12784
- [50]: `"scopeId" option is only supported in module mode.`,
12785
- // deprecations
12786
- [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.`,
12787
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
12788
- // just to fulfill types
12789
- [53]: ``
12790
- };
12791
-
12792
12744
  const FRAGMENT = Symbol(`Fragment` );
12793
12745
  const TELEPORT = Symbol(`Teleport` );
12794
12746
  const SUSPENSE = Symbol(`Suspense` );
@@ -12878,13 +12830,14 @@ function registerRuntimeHelpers(helpers) {
12878
12830
  }
12879
12831
 
12880
12832
  const locStub = {
12881
- source: "",
12882
12833
  start: { line: 1, column: 1, offset: 0 },
12883
- end: { line: 1, column: 1, offset: 0 }
12834
+ end: { line: 1, column: 1, offset: 0 },
12835
+ source: ""
12884
12836
  };
12885
- function createRoot(children, loc = locStub) {
12837
+ function createRoot(children, source = "") {
12886
12838
  return {
12887
12839
  type: 0,
12840
+ source,
12888
12841
  children,
12889
12842
  helpers: /* @__PURE__ */ new Set(),
12890
12843
  components: [],
@@ -12894,7 +12847,7 @@ function createRoot(children, loc = locStub) {
12894
12847
  cached: 0,
12895
12848
  temps: 0,
12896
12849
  codegenNode: void 0,
12897
- loc
12850
+ loc: locStub
12898
12851
  };
12899
12852
  }
12900
12853
  function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
@@ -13020,39 +12973,992 @@ function convertToBlock(node, { helper, removeHelper, inSSR }) {
13020
12973
  }
13021
12974
  }
13022
12975
 
13023
- const isStaticExp = (p) => p.type === 4 && p.isStatic;
13024
- const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
13025
- function isCoreComponent(tag) {
13026
- if (isBuiltInType(tag, "Teleport")) {
13027
- return TELEPORT;
13028
- } else if (isBuiltInType(tag, "Suspense")) {
13029
- return SUSPENSE;
13030
- } else if (isBuiltInType(tag, "KeepAlive")) {
13031
- return KEEP_ALIVE;
13032
- } else if (isBuiltInType(tag, "BaseTransition")) {
13033
- return BASE_TRANSITION;
12976
+ const defaultDelimitersOpen = new Uint8Array([123, 123]);
12977
+ const defaultDelimitersClose = new Uint8Array([125, 125]);
12978
+ function isTagStartChar(c) {
12979
+ return c >= 97 && c <= 122 || c >= 65 && c <= 90;
12980
+ }
12981
+ function isWhitespace(c) {
12982
+ return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
12983
+ }
12984
+ function isEndOfTagSection(c) {
12985
+ return c === 47 || c === 62 || isWhitespace(c);
12986
+ }
12987
+ function toCharCodes(str) {
12988
+ const ret = new Uint8Array(str.length);
12989
+ for (let i = 0; i < str.length; i++) {
12990
+ ret[i] = str.charCodeAt(i);
13034
12991
  }
12992
+ return ret;
13035
12993
  }
13036
- const nonIdentifierRE = /^\d|[^\$\w]/;
13037
- const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13038
- const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
13039
- const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
13040
- const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
13041
- const isMemberExpressionBrowser = (path) => {
13042
- path = path.trim().replace(whitespaceRE, (s) => s.trim());
13043
- let state = 0 /* inMemberExp */;
13044
- let stateStack = [];
13045
- let currentOpenBracketCount = 0;
13046
- let currentOpenParensCount = 0;
13047
- let currentStringType = null;
13048
- for (let i = 0; i < path.length; i++) {
13049
- const char = path.charAt(i);
13050
- switch (state) {
13051
- case 0 /* inMemberExp */:
13052
- if (char === "[") {
13053
- stateStack.push(state);
13054
- state = 1 /* inBrackets */;
13055
- currentOpenBracketCount++;
12994
+ const Sequences = {
12995
+ Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
12996
+ // CDATA[
12997
+ CdataEnd: new Uint8Array([93, 93, 62]),
12998
+ // ]]>
12999
+ CommentEnd: new Uint8Array([45, 45, 62]),
13000
+ // `-->`
13001
+ ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
13002
+ // `<\/script`
13003
+ StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
13004
+ // `</style`
13005
+ TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
13006
+ // `</title`
13007
+ TextareaEnd: new Uint8Array([
13008
+ 60,
13009
+ 47,
13010
+ 116,
13011
+ 101,
13012
+ 120,
13013
+ 116,
13014
+ 97,
13015
+ 114,
13016
+ 101,
13017
+ 97
13018
+ ])
13019
+ // `</textarea
13020
+ };
13021
+ class Tokenizer {
13022
+ constructor(stack, cbs) {
13023
+ this.stack = stack;
13024
+ this.cbs = cbs;
13025
+ /** The current state the tokenizer is in. */
13026
+ this.state = 1;
13027
+ /** The read buffer. */
13028
+ this.buffer = "";
13029
+ /** The beginning of the section that is currently being read. */
13030
+ this.sectionStart = 0;
13031
+ /** The index within the buffer that we are currently looking at. */
13032
+ this.index = 0;
13033
+ /** The start of the last entity. */
13034
+ this.entityStart = 0;
13035
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
13036
+ this.baseState = 1;
13037
+ /** For special parsing behavior inside of script and style tags. */
13038
+ this.inRCDATA = false;
13039
+ /** For disabling RCDATA tags handling */
13040
+ this.inXML = false;
13041
+ /** Reocrd newline positions for fast line / column calculation */
13042
+ this.newlines = [];
13043
+ this.mode = 0;
13044
+ this.delimiterOpen = defaultDelimitersOpen;
13045
+ this.delimiterClose = defaultDelimitersClose;
13046
+ this.delimiterIndex = -1;
13047
+ this.currentSequence = void 0;
13048
+ this.sequenceIndex = 0;
13049
+ }
13050
+ get inSFCRoot() {
13051
+ return this.mode === 2 && this.stack.length === 0;
13052
+ }
13053
+ reset() {
13054
+ this.state = 1;
13055
+ this.mode = 0;
13056
+ this.buffer = "";
13057
+ this.sectionStart = 0;
13058
+ this.index = 0;
13059
+ this.baseState = 1;
13060
+ this.currentSequence = void 0;
13061
+ this.newlines.length = 0;
13062
+ this.delimiterOpen = defaultDelimitersOpen;
13063
+ this.delimiterClose = defaultDelimitersClose;
13064
+ }
13065
+ /**
13066
+ * Generate Position object with line / column information using recorded
13067
+ * newline positions. We know the index is always going to be an already
13068
+ * processed index, so all the newlines up to this index should have been
13069
+ * recorded.
13070
+ */
13071
+ getPos(index) {
13072
+ let line = 1;
13073
+ let column = index + 1;
13074
+ for (let i = this.newlines.length - 1; i >= 0; i--) {
13075
+ const newlineIndex = this.newlines[i];
13076
+ if (index > newlineIndex) {
13077
+ line = i + 2;
13078
+ column = index - newlineIndex;
13079
+ break;
13080
+ }
13081
+ }
13082
+ return {
13083
+ column,
13084
+ line,
13085
+ offset: index
13086
+ };
13087
+ }
13088
+ peek() {
13089
+ return this.buffer.charCodeAt(this.index + 1);
13090
+ }
13091
+ stateText(c) {
13092
+ if (c === 60) {
13093
+ if (this.index > this.sectionStart) {
13094
+ this.cbs.ontext(this.sectionStart, this.index);
13095
+ }
13096
+ this.state = 5;
13097
+ this.sectionStart = this.index;
13098
+ } else if (c === this.delimiterOpen[0]) {
13099
+ this.state = 2;
13100
+ this.delimiterIndex = 0;
13101
+ this.stateInterpolationOpen(c);
13102
+ }
13103
+ }
13104
+ stateInterpolationOpen(c) {
13105
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
13106
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
13107
+ const start = this.index + 1 - this.delimiterOpen.length;
13108
+ if (start > this.sectionStart) {
13109
+ this.cbs.ontext(this.sectionStart, start);
13110
+ }
13111
+ this.state = 3;
13112
+ this.sectionStart = start;
13113
+ } else {
13114
+ this.delimiterIndex++;
13115
+ }
13116
+ } else if (this.inRCDATA) {
13117
+ this.state = 32;
13118
+ this.stateInRCDATA(c);
13119
+ } else {
13120
+ this.state = 1;
13121
+ this.stateText(c);
13122
+ }
13123
+ }
13124
+ stateInterpolation(c) {
13125
+ if (c === this.delimiterClose[0]) {
13126
+ this.state = 4;
13127
+ this.delimiterIndex = 0;
13128
+ this.stateInterpolationClose(c);
13129
+ }
13130
+ }
13131
+ stateInterpolationClose(c) {
13132
+ if (c === this.delimiterClose[this.delimiterIndex]) {
13133
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
13134
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
13135
+ if (this.inRCDATA) {
13136
+ this.state = 32;
13137
+ } else {
13138
+ this.state = 1;
13139
+ }
13140
+ this.sectionStart = this.index + 1;
13141
+ } else {
13142
+ this.delimiterIndex++;
13143
+ }
13144
+ } else {
13145
+ this.state = 3;
13146
+ this.stateInterpolation(c);
13147
+ }
13148
+ }
13149
+ stateSpecialStartSequence(c) {
13150
+ const isEnd = this.sequenceIndex === this.currentSequence.length;
13151
+ const isMatch = isEnd ? (
13152
+ // If we are at the end of the sequence, make sure the tag name has ended
13153
+ isEndOfTagSection(c)
13154
+ ) : (
13155
+ // Otherwise, do a case-insensitive comparison
13156
+ (c | 32) === this.currentSequence[this.sequenceIndex]
13157
+ );
13158
+ if (!isMatch) {
13159
+ this.inRCDATA = false;
13160
+ } else if (!isEnd) {
13161
+ this.sequenceIndex++;
13162
+ return;
13163
+ }
13164
+ this.sequenceIndex = 0;
13165
+ this.state = 6;
13166
+ this.stateInTagName(c);
13167
+ }
13168
+ /** Look for an end tag. For <title> and <textarea>, also decode entities. */
13169
+ stateInRCDATA(c) {
13170
+ if (this.sequenceIndex === this.currentSequence.length) {
13171
+ if (c === 62 || isWhitespace(c)) {
13172
+ const endOfText = this.index - this.currentSequence.length;
13173
+ if (this.sectionStart < endOfText) {
13174
+ const actualIndex = this.index;
13175
+ this.index = endOfText;
13176
+ this.cbs.ontext(this.sectionStart, endOfText);
13177
+ this.index = actualIndex;
13178
+ }
13179
+ this.sectionStart = endOfText + 2;
13180
+ this.stateInClosingTagName(c);
13181
+ this.inRCDATA = false;
13182
+ return;
13183
+ }
13184
+ this.sequenceIndex = 0;
13185
+ }
13186
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
13187
+ this.sequenceIndex += 1;
13188
+ } else if (this.sequenceIndex === 0) {
13189
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
13190
+ if (c === this.delimiterOpen[0]) {
13191
+ this.state = 2;
13192
+ this.delimiterIndex = 0;
13193
+ this.stateInterpolationOpen(c);
13194
+ }
13195
+ } else if (this.fastForwardTo(60)) {
13196
+ this.sequenceIndex = 1;
13197
+ }
13198
+ } else {
13199
+ this.sequenceIndex = Number(c === 60);
13200
+ }
13201
+ }
13202
+ stateCDATASequence(c) {
13203
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
13204
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
13205
+ this.state = 28;
13206
+ this.currentSequence = Sequences.CdataEnd;
13207
+ this.sequenceIndex = 0;
13208
+ this.sectionStart = this.index + 1;
13209
+ }
13210
+ } else {
13211
+ this.sequenceIndex = 0;
13212
+ this.state = 23;
13213
+ this.stateInDeclaration(c);
13214
+ }
13215
+ }
13216
+ /**
13217
+ * When we wait for one specific character, we can speed things up
13218
+ * by skipping through the buffer until we find it.
13219
+ *
13220
+ * @returns Whether the character was found.
13221
+ */
13222
+ fastForwardTo(c) {
13223
+ while (++this.index < this.buffer.length) {
13224
+ const cc = this.buffer.charCodeAt(this.index);
13225
+ if (cc === 10) {
13226
+ this.newlines.push(this.index);
13227
+ }
13228
+ if (cc === c) {
13229
+ return true;
13230
+ }
13231
+ }
13232
+ this.index = this.buffer.length - 1;
13233
+ return false;
13234
+ }
13235
+ /**
13236
+ * Comments and CDATA end with `-->` and `]]>`.
13237
+ *
13238
+ * Their common qualities are:
13239
+ * - Their end sequences have a distinct character they start with.
13240
+ * - That character is then repeated, so we have to check multiple repeats.
13241
+ * - All characters but the start character of the sequence can be skipped.
13242
+ */
13243
+ stateInCommentLike(c) {
13244
+ if (c === this.currentSequence[this.sequenceIndex]) {
13245
+ if (++this.sequenceIndex === this.currentSequence.length) {
13246
+ if (this.currentSequence === Sequences.CdataEnd) {
13247
+ this.cbs.oncdata(this.sectionStart, this.index - 2);
13248
+ } else {
13249
+ this.cbs.oncomment(this.sectionStart, this.index - 2);
13250
+ }
13251
+ this.sequenceIndex = 0;
13252
+ this.sectionStart = this.index + 1;
13253
+ this.state = 1;
13254
+ }
13255
+ } else if (this.sequenceIndex === 0) {
13256
+ if (this.fastForwardTo(this.currentSequence[0])) {
13257
+ this.sequenceIndex = 1;
13258
+ }
13259
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
13260
+ this.sequenceIndex = 0;
13261
+ }
13262
+ }
13263
+ startSpecial(sequence, offset) {
13264
+ this.enterRCDATA(sequence, offset);
13265
+ this.state = 31;
13266
+ }
13267
+ enterRCDATA(sequence, offset) {
13268
+ this.inRCDATA = true;
13269
+ this.currentSequence = sequence;
13270
+ this.sequenceIndex = offset;
13271
+ }
13272
+ stateBeforeTagName(c) {
13273
+ if (c === 33) {
13274
+ this.state = 22;
13275
+ this.sectionStart = this.index + 1;
13276
+ } else if (c === 63) {
13277
+ this.state = 24;
13278
+ this.sectionStart = this.index + 1;
13279
+ } else if (isTagStartChar(c)) {
13280
+ this.sectionStart = this.index;
13281
+ if (this.mode === 0) {
13282
+ this.state = 6;
13283
+ } else if (this.inSFCRoot) {
13284
+ this.state = 34;
13285
+ } else if (!this.inXML) {
13286
+ const lower = c | 32;
13287
+ if (lower === 116) {
13288
+ this.state = 30;
13289
+ } else {
13290
+ this.state = lower === 115 ? 29 : 6;
13291
+ }
13292
+ } else {
13293
+ this.state = 6;
13294
+ }
13295
+ } else if (c === 47) {
13296
+ this.state = 8;
13297
+ } else {
13298
+ this.state = 1;
13299
+ this.stateText(c);
13300
+ }
13301
+ }
13302
+ stateInTagName(c) {
13303
+ if (isEndOfTagSection(c)) {
13304
+ this.handleTagName(c);
13305
+ }
13306
+ }
13307
+ stateInSFCRootTagName(c) {
13308
+ if (isEndOfTagSection(c)) {
13309
+ const tag = this.buffer.slice(this.sectionStart, this.index);
13310
+ if (tag !== "template") {
13311
+ this.enterRCDATA(toCharCodes(`</` + tag), 0);
13312
+ }
13313
+ this.handleTagName(c);
13314
+ }
13315
+ }
13316
+ handleTagName(c) {
13317
+ this.cbs.onopentagname(this.sectionStart, this.index);
13318
+ this.sectionStart = -1;
13319
+ this.state = 11;
13320
+ this.stateBeforeAttrName(c);
13321
+ }
13322
+ stateBeforeClosingTagName(c) {
13323
+ if (isWhitespace(c)) ; else if (c === 62) {
13324
+ {
13325
+ this.cbs.onerr(14, this.index);
13326
+ }
13327
+ this.state = 1;
13328
+ this.sectionStart = this.index + 1;
13329
+ } else {
13330
+ this.state = isTagStartChar(c) ? 9 : 27;
13331
+ this.sectionStart = this.index;
13332
+ }
13333
+ }
13334
+ stateInClosingTagName(c) {
13335
+ if (c === 62 || isWhitespace(c)) {
13336
+ this.cbs.onclosetag(this.sectionStart, this.index);
13337
+ this.sectionStart = -1;
13338
+ this.state = 10;
13339
+ this.stateAfterClosingTagName(c);
13340
+ }
13341
+ }
13342
+ stateAfterClosingTagName(c) {
13343
+ if (c === 62) {
13344
+ this.state = 1;
13345
+ this.sectionStart = this.index + 1;
13346
+ }
13347
+ }
13348
+ stateBeforeAttrName(c) {
13349
+ if (c === 62) {
13350
+ this.cbs.onopentagend(this.index);
13351
+ if (this.inRCDATA) {
13352
+ this.state = 32;
13353
+ } else {
13354
+ this.state = 1;
13355
+ }
13356
+ this.sectionStart = this.index + 1;
13357
+ } else if (c === 47) {
13358
+ this.state = 7;
13359
+ if (this.peek() !== 62) {
13360
+ this.cbs.onerr(22, this.index);
13361
+ }
13362
+ } else if (c === 60 && this.peek() === 47) {
13363
+ this.cbs.onopentagend(this.index);
13364
+ this.state = 5;
13365
+ this.sectionStart = this.index;
13366
+ } else if (!isWhitespace(c)) {
13367
+ if (c === 61) {
13368
+ this.cbs.onerr(
13369
+ 19,
13370
+ this.index
13371
+ );
13372
+ }
13373
+ this.handleAttrStart(c);
13374
+ }
13375
+ }
13376
+ handleAttrStart(c) {
13377
+ if (c === 118 && this.peek() === 45) {
13378
+ this.state = 13;
13379
+ this.sectionStart = this.index;
13380
+ } else if (c === 46 || c === 58 || c === 64 || c === 35) {
13381
+ this.cbs.ondirname(this.index, this.index + 1);
13382
+ this.state = 14;
13383
+ this.sectionStart = this.index + 1;
13384
+ } else {
13385
+ this.state = 12;
13386
+ this.sectionStart = this.index;
13387
+ }
13388
+ }
13389
+ stateInSelfClosingTag(c) {
13390
+ if (c === 62) {
13391
+ this.cbs.onselfclosingtag(this.index);
13392
+ this.state = 1;
13393
+ this.sectionStart = this.index + 1;
13394
+ this.inRCDATA = false;
13395
+ } else if (!isWhitespace(c)) {
13396
+ this.state = 11;
13397
+ this.stateBeforeAttrName(c);
13398
+ }
13399
+ }
13400
+ stateInAttrName(c) {
13401
+ if (c === 61 || isEndOfTagSection(c)) {
13402
+ this.cbs.onattribname(this.sectionStart, this.index);
13403
+ this.handleAttrNameEnd(c);
13404
+ } else if (c === 34 || c === 39 || c === 60) {
13405
+ this.cbs.onerr(
13406
+ 17,
13407
+ this.index
13408
+ );
13409
+ }
13410
+ }
13411
+ stateInDirName(c) {
13412
+ if (c === 61 || isEndOfTagSection(c)) {
13413
+ this.cbs.ondirname(this.sectionStart, this.index);
13414
+ this.handleAttrNameEnd(c);
13415
+ } else if (c === 58) {
13416
+ this.cbs.ondirname(this.sectionStart, this.index);
13417
+ this.state = 14;
13418
+ this.sectionStart = this.index + 1;
13419
+ } else if (c === 46) {
13420
+ this.cbs.ondirname(this.sectionStart, this.index);
13421
+ this.state = 16;
13422
+ this.sectionStart = this.index + 1;
13423
+ }
13424
+ }
13425
+ stateInDirArg(c) {
13426
+ if (c === 61 || isEndOfTagSection(c)) {
13427
+ this.cbs.ondirarg(this.sectionStart, this.index);
13428
+ this.handleAttrNameEnd(c);
13429
+ } else if (c === 91) {
13430
+ this.state = 15;
13431
+ } else if (c === 46) {
13432
+ this.cbs.ondirarg(this.sectionStart, this.index);
13433
+ this.state = 16;
13434
+ this.sectionStart = this.index + 1;
13435
+ }
13436
+ }
13437
+ stateInDynamicDirArg(c) {
13438
+ if (c === 93) {
13439
+ this.state = 14;
13440
+ } else if (c === 61 || isEndOfTagSection(c)) {
13441
+ this.cbs.ondirarg(this.sectionStart, this.index + 1);
13442
+ this.handleAttrNameEnd(c);
13443
+ {
13444
+ this.cbs.onerr(
13445
+ 27,
13446
+ this.index
13447
+ );
13448
+ }
13449
+ }
13450
+ }
13451
+ stateInDirModifier(c) {
13452
+ if (c === 61 || isEndOfTagSection(c)) {
13453
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
13454
+ this.handleAttrNameEnd(c);
13455
+ } else if (c === 46) {
13456
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
13457
+ this.sectionStart = this.index + 1;
13458
+ }
13459
+ }
13460
+ handleAttrNameEnd(c) {
13461
+ this.sectionStart = this.index;
13462
+ this.state = 17;
13463
+ this.cbs.onattribnameend(this.index);
13464
+ this.stateAfterAttrName(c);
13465
+ }
13466
+ stateAfterAttrName(c) {
13467
+ if (c === 61) {
13468
+ this.state = 18;
13469
+ } else if (c === 47 || c === 62) {
13470
+ this.cbs.onattribend(0, this.sectionStart);
13471
+ this.sectionStart = -1;
13472
+ this.state = 11;
13473
+ this.stateBeforeAttrName(c);
13474
+ } else if (!isWhitespace(c)) {
13475
+ this.cbs.onattribend(0, this.sectionStart);
13476
+ this.handleAttrStart(c);
13477
+ }
13478
+ }
13479
+ stateBeforeAttrValue(c) {
13480
+ if (c === 34) {
13481
+ this.state = 19;
13482
+ this.sectionStart = this.index + 1;
13483
+ } else if (c === 39) {
13484
+ this.state = 20;
13485
+ this.sectionStart = this.index + 1;
13486
+ } else if (!isWhitespace(c)) {
13487
+ this.sectionStart = this.index;
13488
+ this.state = 21;
13489
+ this.stateInAttrValueNoQuotes(c);
13490
+ }
13491
+ }
13492
+ handleInAttrValue(c, quote) {
13493
+ if (c === quote || this.fastForwardTo(quote)) {
13494
+ this.cbs.onattribdata(this.sectionStart, this.index);
13495
+ this.sectionStart = -1;
13496
+ this.cbs.onattribend(
13497
+ quote === 34 ? 3 : 2,
13498
+ this.index + 1
13499
+ );
13500
+ this.state = 11;
13501
+ }
13502
+ }
13503
+ stateInAttrValueDoubleQuotes(c) {
13504
+ this.handleInAttrValue(c, 34);
13505
+ }
13506
+ stateInAttrValueSingleQuotes(c) {
13507
+ this.handleInAttrValue(c, 39);
13508
+ }
13509
+ stateInAttrValueNoQuotes(c) {
13510
+ if (isWhitespace(c) || c === 62) {
13511
+ this.cbs.onattribdata(this.sectionStart, this.index);
13512
+ this.sectionStart = -1;
13513
+ this.cbs.onattribend(1, this.index);
13514
+ this.state = 11;
13515
+ this.stateBeforeAttrName(c);
13516
+ } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
13517
+ this.cbs.onerr(
13518
+ 18,
13519
+ this.index
13520
+ );
13521
+ } else ;
13522
+ }
13523
+ stateBeforeDeclaration(c) {
13524
+ if (c === 91) {
13525
+ this.state = 26;
13526
+ this.sequenceIndex = 0;
13527
+ } else {
13528
+ this.state = c === 45 ? 25 : 23;
13529
+ }
13530
+ }
13531
+ stateInDeclaration(c) {
13532
+ if (c === 62 || this.fastForwardTo(62)) {
13533
+ this.state = 1;
13534
+ this.sectionStart = this.index + 1;
13535
+ }
13536
+ }
13537
+ stateInProcessingInstruction(c) {
13538
+ if (c === 62 || this.fastForwardTo(62)) {
13539
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index);
13540
+ this.state = 1;
13541
+ this.sectionStart = this.index + 1;
13542
+ }
13543
+ }
13544
+ stateBeforeComment(c) {
13545
+ if (c === 45) {
13546
+ this.state = 28;
13547
+ this.currentSequence = Sequences.CommentEnd;
13548
+ this.sequenceIndex = 2;
13549
+ this.sectionStart = this.index + 1;
13550
+ } else {
13551
+ this.state = 23;
13552
+ }
13553
+ }
13554
+ stateInSpecialComment(c) {
13555
+ if (c === 62 || this.fastForwardTo(62)) {
13556
+ this.cbs.oncomment(this.sectionStart, this.index);
13557
+ this.state = 1;
13558
+ this.sectionStart = this.index + 1;
13559
+ }
13560
+ }
13561
+ stateBeforeSpecialS(c) {
13562
+ const lower = c | 32;
13563
+ if (lower === Sequences.ScriptEnd[3]) {
13564
+ this.startSpecial(Sequences.ScriptEnd, 4);
13565
+ } else if (lower === Sequences.StyleEnd[3]) {
13566
+ this.startSpecial(Sequences.StyleEnd, 4);
13567
+ } else {
13568
+ this.state = 6;
13569
+ this.stateInTagName(c);
13570
+ }
13571
+ }
13572
+ stateBeforeSpecialT(c) {
13573
+ const lower = c | 32;
13574
+ if (lower === Sequences.TitleEnd[3]) {
13575
+ this.startSpecial(Sequences.TitleEnd, 4);
13576
+ } else if (lower === Sequences.TextareaEnd[3]) {
13577
+ this.startSpecial(Sequences.TextareaEnd, 4);
13578
+ } else {
13579
+ this.state = 6;
13580
+ this.stateInTagName(c);
13581
+ }
13582
+ }
13583
+ startEntity() {
13584
+ }
13585
+ stateInEntity() {
13586
+ }
13587
+ /**
13588
+ * Iterates through the buffer, calling the function corresponding to the current state.
13589
+ *
13590
+ * States that are more likely to be hit are higher up, as a performance improvement.
13591
+ */
13592
+ parse(input) {
13593
+ this.buffer = input;
13594
+ while (this.index < this.buffer.length) {
13595
+ const c = this.buffer.charCodeAt(this.index);
13596
+ if (c === 10) {
13597
+ this.newlines.push(this.index);
13598
+ }
13599
+ switch (this.state) {
13600
+ case 1: {
13601
+ this.stateText(c);
13602
+ break;
13603
+ }
13604
+ case 2: {
13605
+ this.stateInterpolationOpen(c);
13606
+ break;
13607
+ }
13608
+ case 3: {
13609
+ this.stateInterpolation(c);
13610
+ break;
13611
+ }
13612
+ case 4: {
13613
+ this.stateInterpolationClose(c);
13614
+ break;
13615
+ }
13616
+ case 31: {
13617
+ this.stateSpecialStartSequence(c);
13618
+ break;
13619
+ }
13620
+ case 32: {
13621
+ this.stateInRCDATA(c);
13622
+ break;
13623
+ }
13624
+ case 26: {
13625
+ this.stateCDATASequence(c);
13626
+ break;
13627
+ }
13628
+ case 19: {
13629
+ this.stateInAttrValueDoubleQuotes(c);
13630
+ break;
13631
+ }
13632
+ case 12: {
13633
+ this.stateInAttrName(c);
13634
+ break;
13635
+ }
13636
+ case 13: {
13637
+ this.stateInDirName(c);
13638
+ break;
13639
+ }
13640
+ case 14: {
13641
+ this.stateInDirArg(c);
13642
+ break;
13643
+ }
13644
+ case 15: {
13645
+ this.stateInDynamicDirArg(c);
13646
+ break;
13647
+ }
13648
+ case 16: {
13649
+ this.stateInDirModifier(c);
13650
+ break;
13651
+ }
13652
+ case 28: {
13653
+ this.stateInCommentLike(c);
13654
+ break;
13655
+ }
13656
+ case 27: {
13657
+ this.stateInSpecialComment(c);
13658
+ break;
13659
+ }
13660
+ case 11: {
13661
+ this.stateBeforeAttrName(c);
13662
+ break;
13663
+ }
13664
+ case 6: {
13665
+ this.stateInTagName(c);
13666
+ break;
13667
+ }
13668
+ case 34: {
13669
+ this.stateInSFCRootTagName(c);
13670
+ break;
13671
+ }
13672
+ case 9: {
13673
+ this.stateInClosingTagName(c);
13674
+ break;
13675
+ }
13676
+ case 5: {
13677
+ this.stateBeforeTagName(c);
13678
+ break;
13679
+ }
13680
+ case 17: {
13681
+ this.stateAfterAttrName(c);
13682
+ break;
13683
+ }
13684
+ case 20: {
13685
+ this.stateInAttrValueSingleQuotes(c);
13686
+ break;
13687
+ }
13688
+ case 18: {
13689
+ this.stateBeforeAttrValue(c);
13690
+ break;
13691
+ }
13692
+ case 8: {
13693
+ this.stateBeforeClosingTagName(c);
13694
+ break;
13695
+ }
13696
+ case 10: {
13697
+ this.stateAfterClosingTagName(c);
13698
+ break;
13699
+ }
13700
+ case 29: {
13701
+ this.stateBeforeSpecialS(c);
13702
+ break;
13703
+ }
13704
+ case 30: {
13705
+ this.stateBeforeSpecialT(c);
13706
+ break;
13707
+ }
13708
+ case 21: {
13709
+ this.stateInAttrValueNoQuotes(c);
13710
+ break;
13711
+ }
13712
+ case 7: {
13713
+ this.stateInSelfClosingTag(c);
13714
+ break;
13715
+ }
13716
+ case 23: {
13717
+ this.stateInDeclaration(c);
13718
+ break;
13719
+ }
13720
+ case 22: {
13721
+ this.stateBeforeDeclaration(c);
13722
+ break;
13723
+ }
13724
+ case 25: {
13725
+ this.stateBeforeComment(c);
13726
+ break;
13727
+ }
13728
+ case 24: {
13729
+ this.stateInProcessingInstruction(c);
13730
+ break;
13731
+ }
13732
+ case 33: {
13733
+ this.stateInEntity();
13734
+ break;
13735
+ }
13736
+ }
13737
+ this.index++;
13738
+ }
13739
+ this.cleanup();
13740
+ this.finish();
13741
+ }
13742
+ /**
13743
+ * Remove data that has already been consumed from the buffer.
13744
+ */
13745
+ cleanup() {
13746
+ if (this.sectionStart !== this.index) {
13747
+ if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
13748
+ this.cbs.ontext(this.sectionStart, this.index);
13749
+ this.sectionStart = this.index;
13750
+ } else if (this.state === 19 || this.state === 20 || this.state === 21) {
13751
+ this.cbs.onattribdata(this.sectionStart, this.index);
13752
+ this.sectionStart = this.index;
13753
+ }
13754
+ }
13755
+ }
13756
+ finish() {
13757
+ this.handleTrailingData();
13758
+ this.cbs.onend();
13759
+ }
13760
+ /** Handle any trailing data. */
13761
+ handleTrailingData() {
13762
+ const endIndex = this.buffer.length;
13763
+ if (this.sectionStart >= endIndex) {
13764
+ return;
13765
+ }
13766
+ if (this.state === 28) {
13767
+ if (this.currentSequence === Sequences.CdataEnd) {
13768
+ this.cbs.oncdata(this.sectionStart, endIndex);
13769
+ } else {
13770
+ this.cbs.oncomment(this.sectionStart, endIndex);
13771
+ }
13772
+ } 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 {
13773
+ this.cbs.ontext(this.sectionStart, endIndex);
13774
+ }
13775
+ }
13776
+ emitCodePoint(cp, consumed) {
13777
+ }
13778
+ }
13779
+
13780
+ const deprecationData = {
13781
+ ["COMPILER_IS_ON_ELEMENT"]: {
13782
+ message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
13783
+ link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
13784
+ },
13785
+ ["COMPILER_V_BIND_SYNC"]: {
13786
+ 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}\`.`,
13787
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
13788
+ },
13789
+ ["COMPILER_V_BIND_OBJECT_ORDER"]: {
13790
+ 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.`,
13791
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
13792
+ },
13793
+ ["COMPILER_V_ON_NATIVE"]: {
13794
+ message: `.native modifier for v-on has been removed as is no longer necessary.`,
13795
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
13796
+ },
13797
+ ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
13798
+ message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
13799
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
13800
+ },
13801
+ ["COMPILER_NATIVE_TEMPLATE"]: {
13802
+ message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
13803
+ },
13804
+ ["COMPILER_INLINE_TEMPLATE"]: {
13805
+ message: `"inline-template" has been removed in Vue 3.`,
13806
+ link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
13807
+ },
13808
+ ["COMPILER_FILTER"]: {
13809
+ message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
13810
+ link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
13811
+ }
13812
+ };
13813
+ function getCompatValue(key, { compatConfig }) {
13814
+ const value = compatConfig && compatConfig[key];
13815
+ if (key === "MODE") {
13816
+ return value || 3;
13817
+ } else {
13818
+ return value;
13819
+ }
13820
+ }
13821
+ function isCompatEnabled(key, context) {
13822
+ const mode = getCompatValue("MODE", context);
13823
+ const value = getCompatValue(key, context);
13824
+ return mode === 3 ? value === true : value !== false;
13825
+ }
13826
+ function checkCompatEnabled(key, context, loc, ...args) {
13827
+ const enabled = isCompatEnabled(key, context);
13828
+ if (enabled) {
13829
+ warnDeprecation(key, context, loc, ...args);
13830
+ }
13831
+ return enabled;
13832
+ }
13833
+ function warnDeprecation(key, context, loc, ...args) {
13834
+ const val = getCompatValue(key, context);
13835
+ if (val === "suppress-warning") {
13836
+ return;
13837
+ }
13838
+ const { message, link } = deprecationData[key];
13839
+ const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
13840
+ Details: ${link}` : ``}`;
13841
+ const err = new SyntaxError(msg);
13842
+ err.code = key;
13843
+ if (loc)
13844
+ err.loc = loc;
13845
+ context.onWarn(err);
13846
+ }
13847
+
13848
+ function defaultOnError(error) {
13849
+ throw error;
13850
+ }
13851
+ function defaultOnWarn(msg) {
13852
+ console.warn(`[Vue warn] ${msg.message}`);
13853
+ }
13854
+ function createCompilerError(code, loc, messages, additionalMessage) {
13855
+ const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
13856
+ const error = new SyntaxError(String(msg));
13857
+ error.code = code;
13858
+ error.loc = loc;
13859
+ return error;
13860
+ }
13861
+ const errorMessages = {
13862
+ // parse errors
13863
+ [0]: "Illegal comment.",
13864
+ [1]: "CDATA section is allowed only in XML context.",
13865
+ [2]: "Duplicate attribute.",
13866
+ [3]: "End tag cannot have attributes.",
13867
+ [4]: "Illegal '/' in tags.",
13868
+ [5]: "Unexpected EOF in tag.",
13869
+ [6]: "Unexpected EOF in CDATA section.",
13870
+ [7]: "Unexpected EOF in comment.",
13871
+ [8]: "Unexpected EOF in script.",
13872
+ [9]: "Unexpected EOF in tag.",
13873
+ [10]: "Incorrectly closed comment.",
13874
+ [11]: "Incorrectly opened comment.",
13875
+ [12]: "Illegal tag name. Use '&lt;' to print '<'.",
13876
+ [13]: "Attribute value was expected.",
13877
+ [14]: "End tag name was expected.",
13878
+ [15]: "Whitespace was expected.",
13879
+ [16]: "Unexpected '<!--' in comment.",
13880
+ [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
13881
+ [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
13882
+ [19]: "Attribute name cannot start with '='.",
13883
+ [21]: "'<?' is allowed only in XML context.",
13884
+ [20]: `Unexpected null character.`,
13885
+ [22]: "Illegal '/' in tags.",
13886
+ // Vue-specific parse errors
13887
+ [23]: "Invalid end tag.",
13888
+ [24]: "Element is missing end tag.",
13889
+ [25]: "Interpolation end sign was not found.",
13890
+ [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
13891
+ [26]: "Legal directive name was expected.",
13892
+ // transform errors
13893
+ [28]: `v-if/v-else-if is missing expression.`,
13894
+ [29]: `v-if/else branches must use unique keys.`,
13895
+ [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
13896
+ [31]: `v-for is missing expression.`,
13897
+ [32]: `v-for has invalid expression.`,
13898
+ [33]: `<template v-for> key should be placed on the <template> tag.`,
13899
+ [34]: `v-bind is missing expression.`,
13900
+ [35]: `v-on is missing expression.`,
13901
+ [36]: `Unexpected custom directive on <slot> outlet.`,
13902
+ [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.`,
13903
+ [38]: `Duplicate slot names found. `,
13904
+ [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
13905
+ [40]: `v-slot can only be used on components or <template> tags.`,
13906
+ [41]: `v-model is missing expression.`,
13907
+ [42]: `v-model value must be a valid JavaScript member expression.`,
13908
+ [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
13909
+ [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
13910
+ Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
13911
+ [45]: `Error parsing JavaScript expression: `,
13912
+ [46]: `<KeepAlive> expects exactly one child component.`,
13913
+ // generic errors
13914
+ [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
13915
+ [48]: `ES module mode is not supported in this build of compiler.`,
13916
+ [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
13917
+ [50]: `"scopeId" option is only supported in module mode.`,
13918
+ // deprecations
13919
+ [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.`,
13920
+ [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
13921
+ // just to fulfill types
13922
+ [53]: ``
13923
+ };
13924
+
13925
+ const isStaticExp = (p) => p.type === 4 && p.isStatic;
13926
+ function isCoreComponent(tag) {
13927
+ switch (tag) {
13928
+ case "Teleport":
13929
+ case "teleport":
13930
+ return TELEPORT;
13931
+ case "Suspense":
13932
+ case "suspense":
13933
+ return SUSPENSE;
13934
+ case "KeepAlive":
13935
+ case "keep-alive":
13936
+ return KEEP_ALIVE;
13937
+ case "BaseTransition":
13938
+ case "base-transition":
13939
+ return BASE_TRANSITION;
13940
+ }
13941
+ }
13942
+ const nonIdentifierRE = /^\d|[^\$\w]/;
13943
+ const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13944
+ const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
13945
+ const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
13946
+ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
13947
+ const isMemberExpressionBrowser = (path) => {
13948
+ path = path.trim().replace(whitespaceRE, (s) => s.trim());
13949
+ let state = 0 /* inMemberExp */;
13950
+ let stateStack = [];
13951
+ let currentOpenBracketCount = 0;
13952
+ let currentOpenParensCount = 0;
13953
+ let currentStringType = null;
13954
+ for (let i = 0; i < path.length; i++) {
13955
+ const char = path.charAt(i);
13956
+ switch (state) {
13957
+ case 0 /* inMemberExp */:
13958
+ if (char === "[") {
13959
+ stateStack.push(state);
13960
+ state = 1 /* inBrackets */;
13961
+ currentOpenBracketCount++;
13056
13962
  } else if (char === "(") {
13057
13963
  stateStack.push(state);
13058
13964
  state = 2 /* inParens */;
@@ -13101,43 +14007,6 @@ const isMemberExpressionBrowser = (path) => {
13101
14007
  return !currentOpenBracketCount && !currentOpenParensCount;
13102
14008
  };
13103
14009
  const isMemberExpression = isMemberExpressionBrowser ;
13104
- function getInnerRange(loc, offset, length) {
13105
- const source = loc.source.slice(offset, offset + length);
13106
- const newLoc = {
13107
- source,
13108
- start: advancePositionWithClone(loc.start, loc.source, offset),
13109
- end: loc.end
13110
- };
13111
- if (length != null) {
13112
- newLoc.end = advancePositionWithClone(
13113
- loc.start,
13114
- loc.source,
13115
- offset + length
13116
- );
13117
- }
13118
- return newLoc;
13119
- }
13120
- function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
13121
- return advancePositionWithMutation(
13122
- extend({}, pos),
13123
- source,
13124
- numberOfCharacters
13125
- );
13126
- }
13127
- function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
13128
- let linesCount = 0;
13129
- let lastNewLinePos = -1;
13130
- for (let i = 0; i < numberOfCharacters; i++) {
13131
- if (source.charCodeAt(i) === 10) {
13132
- linesCount++;
13133
- lastNewLinePos = i;
13134
- }
13135
- }
13136
- pos.offset += numberOfCharacters;
13137
- pos.line += linesCount;
13138
- pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
13139
- return pos;
13140
- }
13141
14010
  function assert(condition, msg) {
13142
14011
  if (!condition) {
13143
14012
  throw new Error(msg || `unexpected compiler condition`);
@@ -13243,509 +14112,598 @@ function injectProp(node, prop, context) {
13243
14112
  ]);
13244
14113
  if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
13245
14114
  parentCall = callPath[callPath.length - 2];
13246
- }
13247
- }
13248
- if (node.type === 13) {
13249
- if (parentCall) {
13250
- parentCall.arguments[0] = propsWithInjection;
13251
- } else {
13252
- node.props = propsWithInjection;
13253
- }
13254
- } else {
13255
- if (parentCall) {
13256
- parentCall.arguments[0] = propsWithInjection;
13257
- } else {
13258
- node.arguments[2] = propsWithInjection;
13259
- }
13260
- }
13261
- }
13262
- function hasProp(prop, props) {
13263
- let result = false;
13264
- if (prop.key.type === 4) {
13265
- const propKeyName = prop.key.content;
13266
- result = props.properties.some(
13267
- (p) => p.key.type === 4 && p.key.content === propKeyName
13268
- );
13269
- }
13270
- return result;
13271
- }
13272
- function toValidAssetId(name, type) {
13273
- return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
13274
- return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
13275
- })}`;
13276
- }
13277
- function getMemoedVNodeCall(node) {
13278
- if (node.type === 14 && node.callee === WITH_MEMO) {
13279
- return node.arguments[1].returns;
13280
- } else {
13281
- return node;
13282
- }
13283
- }
13284
-
13285
- const deprecationData = {
13286
- ["COMPILER_IS_ON_ELEMENT"]: {
13287
- message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
13288
- link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
13289
- },
13290
- ["COMPILER_V_BIND_SYNC"]: {
13291
- 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}\`.`,
13292
- link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
13293
- },
13294
- ["COMPILER_V_BIND_PROP"]: {
13295
- 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.`
13296
- },
13297
- ["COMPILER_V_BIND_OBJECT_ORDER"]: {
13298
- 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.`,
13299
- link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
13300
- },
13301
- ["COMPILER_V_ON_NATIVE"]: {
13302
- message: `.native modifier for v-on has been removed as is no longer necessary.`,
13303
- link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
13304
- },
13305
- ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
13306
- message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
13307
- link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
13308
- },
13309
- ["COMPILER_NATIVE_TEMPLATE"]: {
13310
- message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
13311
- },
13312
- ["COMPILER_INLINE_TEMPLATE"]: {
13313
- message: `"inline-template" has been removed in Vue 3.`,
13314
- link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
13315
- },
13316
- ["COMPILER_FILTER"]: {
13317
- message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
13318
- link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
13319
- }
13320
- };
13321
- function getCompatValue(key, context) {
13322
- const config = context.options ? context.options.compatConfig : context.compatConfig;
13323
- const value = config && config[key];
13324
- if (key === "MODE") {
13325
- return value || 3;
14115
+ }
14116
+ }
14117
+ if (node.type === 13) {
14118
+ if (parentCall) {
14119
+ parentCall.arguments[0] = propsWithInjection;
14120
+ } else {
14121
+ node.props = propsWithInjection;
14122
+ }
13326
14123
  } else {
13327
- return value;
14124
+ if (parentCall) {
14125
+ parentCall.arguments[0] = propsWithInjection;
14126
+ } else {
14127
+ node.arguments[2] = propsWithInjection;
14128
+ }
13328
14129
  }
13329
14130
  }
13330
- function isCompatEnabled(key, context) {
13331
- const mode = getCompatValue("MODE", context);
13332
- const value = getCompatValue(key, context);
13333
- return mode === 3 ? value === true : value !== false;
13334
- }
13335
- function checkCompatEnabled(key, context, loc, ...args) {
13336
- const enabled = isCompatEnabled(key, context);
13337
- if (enabled) {
13338
- warnDeprecation(key, context, loc, ...args);
14131
+ function hasProp(prop, props) {
14132
+ let result = false;
14133
+ if (prop.key.type === 4) {
14134
+ const propKeyName = prop.key.content;
14135
+ result = props.properties.some(
14136
+ (p) => p.key.type === 4 && p.key.content === propKeyName
14137
+ );
13339
14138
  }
13340
- return enabled;
14139
+ return result;
13341
14140
  }
13342
- function warnDeprecation(key, context, loc, ...args) {
13343
- const val = getCompatValue(key, context);
13344
- if (val === "suppress-warning") {
13345
- return;
14141
+ function toValidAssetId(name, type) {
14142
+ return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
14143
+ return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
14144
+ })}`;
14145
+ }
14146
+ function getMemoedVNodeCall(node) {
14147
+ if (node.type === 14 && node.callee === WITH_MEMO) {
14148
+ return node.arguments[1].returns;
14149
+ } else {
14150
+ return node;
13346
14151
  }
13347
- const { message, link } = deprecationData[key];
13348
- const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
13349
- Details: ${link}` : ``}`;
13350
- const err = new SyntaxError(msg);
13351
- err.code = key;
13352
- if (loc)
13353
- err.loc = loc;
13354
- context.onWarn(err);
13355
14152
  }
14153
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13356
14154
 
13357
- const decodeRE = /&(gt|lt|amp|apos|quot);/g;
13358
- const decodeMap = {
13359
- gt: ">",
13360
- lt: "<",
13361
- amp: "&",
13362
- apos: "'",
13363
- quot: '"'
13364
- };
13365
14155
  const defaultParserOptions = {
14156
+ parseMode: "base",
14157
+ ns: 0,
13366
14158
  delimiters: [`{{`, `}}`],
13367
14159
  getNamespace: () => 0,
13368
- getTextMode: () => 0,
13369
14160
  isVoidTag: NO,
13370
14161
  isPreTag: NO,
13371
14162
  isCustomElement: NO,
13372
- decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
13373
14163
  onError: defaultOnError,
13374
14164
  onWarn: defaultOnWarn,
13375
14165
  comments: true
13376
14166
  };
13377
- function baseParse(content, options = {}) {
13378
- const context = createParserContext(content, options);
13379
- const start = getCursor(context);
13380
- return createRoot(
13381
- parseChildren(context, 0, []),
13382
- getSelection(context, start)
13383
- );
13384
- }
13385
- function createParserContext(content, rawOptions) {
13386
- const options = extend({}, defaultParserOptions);
13387
- let key;
13388
- for (key in rawOptions) {
13389
- options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
13390
- }
13391
- return {
13392
- options,
13393
- column: 1,
13394
- line: 1,
13395
- offset: 0,
13396
- originalSource: content,
13397
- source: content,
13398
- inPre: false,
13399
- inVPre: false,
13400
- onWarn: options.onWarn
13401
- };
13402
- }
13403
- function parseChildren(context, mode, ancestors) {
13404
- const parent = last(ancestors);
13405
- const ns = parent ? parent.ns : 0;
13406
- const nodes = [];
13407
- while (!isEnd(context, mode, ancestors)) {
13408
- const s = context.source;
13409
- let node = void 0;
13410
- if (mode === 0 || mode === 1) {
13411
- if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
13412
- node = parseInterpolation(context, mode);
13413
- } else if (mode === 0 && s[0] === "<") {
13414
- if (s.length === 1) {
13415
- emitError(context, 5, 1);
13416
- } else if (s[1] === "!") {
13417
- if (startsWith(s, "<!--")) {
13418
- node = parseComment(context);
13419
- } else if (startsWith(s, "<!DOCTYPE")) {
13420
- node = parseBogusComment(context);
13421
- } else if (startsWith(s, "<![CDATA[")) {
13422
- if (ns !== 0) {
13423
- node = parseCDATA(context, ancestors);
13424
- } else {
13425
- emitError(context, 1);
13426
- node = parseBogusComment(context);
13427
- }
13428
- } else {
13429
- emitError(context, 11);
13430
- node = parseBogusComment(context);
14167
+ let currentOptions = defaultParserOptions;
14168
+ let currentRoot = null;
14169
+ let currentInput = "";
14170
+ let currentOpenTag = null;
14171
+ let currentProp = null;
14172
+ let currentAttrValue = "";
14173
+ let currentAttrStartIndex = -1;
14174
+ let currentAttrEndIndex = -1;
14175
+ let inPre = 0;
14176
+ let inVPre = false;
14177
+ let currentVPreBoundary = null;
14178
+ const stack = [];
14179
+ const tokenizer = new Tokenizer(stack, {
14180
+ onerr: emitError,
14181
+ ontext(start, end) {
14182
+ onText(getSlice(start, end), start, end);
14183
+ },
14184
+ ontextentity(char, start, end) {
14185
+ onText(char, start, end);
14186
+ },
14187
+ oninterpolation(start, end) {
14188
+ if (inVPre) {
14189
+ return onText(getSlice(start, end), start, end);
14190
+ }
14191
+ let innerStart = start + tokenizer.delimiterOpen.length;
14192
+ let innerEnd = end - tokenizer.delimiterClose.length;
14193
+ while (isWhitespace(currentInput.charCodeAt(innerStart))) {
14194
+ innerStart++;
14195
+ }
14196
+ while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
14197
+ innerEnd--;
14198
+ }
14199
+ let exp = getSlice(innerStart, innerEnd);
14200
+ if (exp.includes("&")) {
14201
+ {
14202
+ exp = currentOptions.decodeEntities(exp, false);
14203
+ }
14204
+ }
14205
+ addNode({
14206
+ type: 5,
14207
+ content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
14208
+ loc: getLoc(start, end)
14209
+ });
14210
+ },
14211
+ onopentagname(start, end) {
14212
+ const name = getSlice(start, end);
14213
+ currentOpenTag = {
14214
+ type: 1,
14215
+ tag: name,
14216
+ ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
14217
+ tagType: 0,
14218
+ // will be refined on tag close
14219
+ props: [],
14220
+ children: [],
14221
+ loc: getLoc(start - 1, end),
14222
+ codegenNode: void 0
14223
+ };
14224
+ if (tokenizer.inSFCRoot) {
14225
+ currentOpenTag.innerLoc = getLoc(
14226
+ end + fastForward(end) + 1,
14227
+ end
14228
+ );
14229
+ }
14230
+ },
14231
+ onopentagend(end) {
14232
+ endOpenTag(end);
14233
+ },
14234
+ onclosetag(start, end) {
14235
+ const name = getSlice(start, end);
14236
+ if (!currentOptions.isVoidTag(name)) {
14237
+ let found = false;
14238
+ for (let i = 0; i < stack.length; i++) {
14239
+ const e = stack[i];
14240
+ if (e.tag.toLowerCase() === name.toLowerCase()) {
14241
+ found = true;
14242
+ if (i > 0) {
14243
+ emitError(24, stack[0].loc.start.offset);
13431
14244
  }
13432
- } else if (s[1] === "/") {
13433
- if (s.length === 2) {
13434
- emitError(context, 5, 2);
13435
- } else if (s[2] === ">") {
13436
- emitError(context, 14, 2);
13437
- advanceBy(context, 3);
13438
- continue;
13439
- } else if (/[a-z]/i.test(s[2])) {
13440
- emitError(context, 23);
13441
- parseTag(context, 1 /* End */, parent);
13442
- continue;
13443
- } else {
13444
- emitError(
13445
- context,
13446
- 12,
13447
- 2
13448
- );
13449
- node = parseBogusComment(context);
14245
+ for (let j = 0; j <= i; j++) {
14246
+ const el = stack.shift();
14247
+ onCloseTag(el, end, j < i);
13450
14248
  }
13451
- } else if (/[a-z]/i.test(s[1])) {
13452
- node = parseElement(context, ancestors);
13453
- if (isCompatEnabled(
13454
- "COMPILER_NATIVE_TEMPLATE",
13455
- context
13456
- ) && node && node.tag === "template" && !node.props.some(
13457
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
13458
- )) {
13459
- warnDeprecation(
13460
- "COMPILER_NATIVE_TEMPLATE",
13461
- context,
13462
- node.loc
13463
- );
13464
- node = node.children;
14249
+ break;
14250
+ }
14251
+ }
14252
+ if (!found) {
14253
+ emitError(23, backTrack(start, 60));
14254
+ }
14255
+ }
14256
+ },
14257
+ onselfclosingtag(end) {
14258
+ var _a;
14259
+ const name = currentOpenTag.tag;
14260
+ currentOpenTag.isSelfClosing = true;
14261
+ endOpenTag(end);
14262
+ if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
14263
+ onCloseTag(stack.shift(), end);
14264
+ }
14265
+ },
14266
+ onattribname(start, end) {
14267
+ currentProp = {
14268
+ type: 6,
14269
+ name: getSlice(start, end),
14270
+ nameLoc: getLoc(start, end),
14271
+ value: void 0,
14272
+ loc: getLoc(start)
14273
+ };
14274
+ },
14275
+ ondirname(start, end) {
14276
+ const raw = getSlice(start, end);
14277
+ const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
14278
+ if (!inVPre && name === "") {
14279
+ emitError(26, start);
14280
+ }
14281
+ if (inVPre || name === "") {
14282
+ currentProp = {
14283
+ type: 6,
14284
+ name: raw,
14285
+ nameLoc: getLoc(start, end),
14286
+ value: void 0,
14287
+ loc: getLoc(start)
14288
+ };
14289
+ } else {
14290
+ currentProp = {
14291
+ type: 7,
14292
+ name,
14293
+ rawName: raw,
14294
+ exp: void 0,
14295
+ arg: void 0,
14296
+ modifiers: raw === "." ? ["prop"] : [],
14297
+ loc: getLoc(start)
14298
+ };
14299
+ if (name === "pre") {
14300
+ inVPre = true;
14301
+ currentVPreBoundary = currentOpenTag;
14302
+ const props = currentOpenTag.props;
14303
+ for (let i = 0; i < props.length; i++) {
14304
+ if (props[i].type === 7) {
14305
+ props[i] = dirToAttr(props[i]);
13465
14306
  }
13466
- } else if (s[1] === "?") {
13467
- emitError(
13468
- context,
13469
- 21,
13470
- 1
13471
- );
13472
- node = parseBogusComment(context);
13473
- } else {
13474
- emitError(context, 12, 1);
13475
14307
  }
13476
14308
  }
13477
14309
  }
13478
- if (!node) {
13479
- node = parseText(context, mode);
14310
+ },
14311
+ ondirarg(start, end) {
14312
+ const arg = getSlice(start, end);
14313
+ if (inVPre) {
14314
+ currentProp.name += arg;
14315
+ setLocEnd(currentProp.nameLoc, end);
14316
+ } else {
14317
+ const isStatic = arg[0] !== `[`;
14318
+ currentProp.arg = createSimpleExpression(
14319
+ isStatic ? arg : arg.slice(1, -1),
14320
+ isStatic,
14321
+ getLoc(start, end),
14322
+ isStatic ? 3 : 0
14323
+ );
13480
14324
  }
13481
- if (isArray(node)) {
13482
- for (let i = 0; i < node.length; i++) {
13483
- pushNode(nodes, node[i]);
14325
+ },
14326
+ ondirmodifier(start, end) {
14327
+ const mod = getSlice(start, end);
14328
+ if (inVPre) {
14329
+ currentProp.name += "." + mod;
14330
+ setLocEnd(currentProp.nameLoc, end);
14331
+ } else if (currentProp.name === "slot") {
14332
+ const arg = currentProp.arg;
14333
+ if (arg) {
14334
+ arg.content += "." + mod;
14335
+ setLocEnd(arg.loc, end);
13484
14336
  }
13485
14337
  } else {
13486
- pushNode(nodes, node);
14338
+ currentProp.modifiers.push(mod);
13487
14339
  }
13488
- }
13489
- let removedWhitespace = false;
13490
- if (mode !== 2 && mode !== 1) {
13491
- const shouldCondense = context.options.whitespace !== "preserve";
13492
- for (let i = 0; i < nodes.length; i++) {
13493
- const node = nodes[i];
13494
- if (node.type === 2) {
13495
- if (!context.inPre) {
13496
- if (!/[^\t\r\n\f ]/.test(node.content)) {
13497
- const prev = nodes[i - 1];
13498
- const next = nodes[i + 1];
13499
- 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))) {
13500
- removedWhitespace = true;
13501
- nodes[i] = null;
13502
- } else {
13503
- node.content = " ";
13504
- }
13505
- } else if (shouldCondense) {
13506
- node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
14340
+ },
14341
+ onattribdata(start, end) {
14342
+ currentAttrValue += getSlice(start, end);
14343
+ if (currentAttrStartIndex < 0)
14344
+ currentAttrStartIndex = start;
14345
+ currentAttrEndIndex = end;
14346
+ },
14347
+ onattribentity(char, start, end) {
14348
+ currentAttrValue += char;
14349
+ if (currentAttrStartIndex < 0)
14350
+ currentAttrStartIndex = start;
14351
+ currentAttrEndIndex = end;
14352
+ },
14353
+ onattribnameend(end) {
14354
+ const start = currentProp.loc.start.offset;
14355
+ const name = getSlice(start, end);
14356
+ if (currentProp.type === 7) {
14357
+ currentProp.rawName = name;
14358
+ }
14359
+ if (currentOpenTag.props.some(
14360
+ (p) => (p.type === 7 ? p.rawName : p.name) === name
14361
+ )) {
14362
+ emitError(2, start);
14363
+ }
14364
+ },
14365
+ onattribend(quote, end) {
14366
+ if (currentOpenTag && currentProp) {
14367
+ setLocEnd(currentProp.loc, end);
14368
+ if (quote !== 0) {
14369
+ if (currentAttrValue.includes("&")) {
14370
+ currentAttrValue = currentOptions.decodeEntities(
14371
+ currentAttrValue,
14372
+ true
14373
+ );
14374
+ }
14375
+ if (currentProp.type === 6) {
14376
+ if (currentProp.name === "class") {
14377
+ currentAttrValue = condense(currentAttrValue).trim();
14378
+ }
14379
+ if (quote === 1 && !currentAttrValue) {
14380
+ emitError(13, end);
14381
+ }
14382
+ currentProp.value = {
14383
+ type: 2,
14384
+ content: currentAttrValue,
14385
+ loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
14386
+ };
14387
+ if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
14388
+ tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
13507
14389
  }
13508
14390
  } else {
13509
- node.content = node.content.replace(/\r\n/g, "\n");
14391
+ currentProp.exp = createSimpleExpression(
14392
+ currentAttrValue,
14393
+ false,
14394
+ getLoc(currentAttrStartIndex, currentAttrEndIndex)
14395
+ );
14396
+ if (currentProp.name === "for") {
14397
+ currentProp.forParseResult = parseForExpression(currentProp.exp);
14398
+ }
14399
+ let syncIndex = -1;
14400
+ if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
14401
+ "COMPILER_V_BIND_SYNC",
14402
+ currentOptions,
14403
+ currentProp.loc,
14404
+ currentProp.rawName
14405
+ )) {
14406
+ currentProp.name = "model";
14407
+ currentProp.modifiers.splice(syncIndex, 1);
14408
+ }
13510
14409
  }
13511
- } else if (node.type === 3 && !context.options.comments) {
13512
- removedWhitespace = true;
13513
- nodes[i] = null;
13514
14410
  }
14411
+ if (currentProp.type !== 7 || currentProp.name !== "pre") {
14412
+ currentOpenTag.props.push(currentProp);
14413
+ }
14414
+ }
14415
+ currentAttrValue = "";
14416
+ currentAttrStartIndex = currentAttrEndIndex = -1;
14417
+ },
14418
+ oncomment(start, end) {
14419
+ if (currentOptions.comments) {
14420
+ addNode({
14421
+ type: 3,
14422
+ content: getSlice(start, end),
14423
+ loc: getLoc(start - 4, end + 3)
14424
+ });
13515
14425
  }
13516
- if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
13517
- const first = nodes[0];
13518
- if (first && first.type === 2) {
13519
- first.content = first.content.replace(/^\r?\n/, "");
14426
+ },
14427
+ onend() {
14428
+ const end = currentInput.length;
14429
+ if (tokenizer.state !== 1) {
14430
+ switch (tokenizer.state) {
14431
+ case 5:
14432
+ case 8:
14433
+ emitError(5, end);
14434
+ break;
14435
+ case 3:
14436
+ case 4:
14437
+ emitError(
14438
+ 25,
14439
+ tokenizer.sectionStart
14440
+ );
14441
+ break;
14442
+ case 28:
14443
+ if (tokenizer.currentSequence === Sequences.CdataEnd) {
14444
+ emitError(6, end);
14445
+ } else {
14446
+ emitError(7, end);
14447
+ }
14448
+ break;
14449
+ case 6:
14450
+ case 7:
14451
+ case 9:
14452
+ case 11:
14453
+ case 12:
14454
+ case 13:
14455
+ case 14:
14456
+ case 15:
14457
+ case 16:
14458
+ case 17:
14459
+ case 18:
14460
+ case 19:
14461
+ case 20:
14462
+ case 21:
14463
+ emitError(9, end);
14464
+ break;
13520
14465
  }
13521
14466
  }
13522
- }
13523
- return removedWhitespace ? nodes.filter(Boolean) : nodes;
13524
- }
13525
- function pushNode(nodes, node) {
13526
- if (node.type === 2) {
13527
- const prev = last(nodes);
13528
- if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
13529
- prev.content += node.content;
13530
- prev.loc.end = node.loc.end;
13531
- prev.loc.source += node.loc.source;
13532
- return;
14467
+ for (let index = 0; index < stack.length; index++) {
14468
+ onCloseTag(stack[index], end - 1);
14469
+ emitError(24, stack[index].loc.start.offset);
13533
14470
  }
13534
- }
13535
- nodes.push(node);
13536
- }
13537
- function parseCDATA(context, ancestors) {
13538
- advanceBy(context, 9);
13539
- const nodes = parseChildren(context, 3, ancestors);
13540
- if (context.source.length === 0) {
13541
- emitError(context, 6);
13542
- } else {
13543
- advanceBy(context, 3);
13544
- }
13545
- return nodes;
13546
- }
13547
- function parseComment(context) {
13548
- const start = getCursor(context);
13549
- let content;
13550
- const match = /--(\!)?>/.exec(context.source);
13551
- if (!match) {
13552
- content = context.source.slice(4);
13553
- advanceBy(context, context.source.length);
13554
- emitError(context, 7);
13555
- } else {
13556
- if (match.index <= 3) {
13557
- emitError(context, 0);
14471
+ },
14472
+ oncdata(start, end) {
14473
+ if (stack[0].ns !== 0) {
14474
+ onText(getSlice(start, end), start, end);
14475
+ } else {
14476
+ emitError(1, start - 9);
14477
+ }
14478
+ },
14479
+ onprocessinginstruction(start) {
14480
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
14481
+ emitError(
14482
+ 21,
14483
+ start - 1
14484
+ );
13558
14485
  }
13559
- if (match[1]) {
13560
- emitError(context, 10);
14486
+ }
14487
+ });
14488
+ const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
14489
+ const stripParensRE = /^\(|\)$/g;
14490
+ function parseForExpression(input) {
14491
+ const loc = input.loc;
14492
+ const exp = input.content;
14493
+ const inMatch = exp.match(forAliasRE);
14494
+ if (!inMatch)
14495
+ return;
14496
+ const [, LHS, RHS] = inMatch;
14497
+ const createAliasExpression = (content, offset) => {
14498
+ const start = loc.start.offset + offset;
14499
+ const end = start + content.length;
14500
+ return createSimpleExpression(content, false, getLoc(start, end));
14501
+ };
14502
+ const result = {
14503
+ source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
14504
+ value: void 0,
14505
+ key: void 0,
14506
+ index: void 0,
14507
+ finalized: false
14508
+ };
14509
+ let valueContent = LHS.trim().replace(stripParensRE, "").trim();
14510
+ const trimmedOffset = LHS.indexOf(valueContent);
14511
+ const iteratorMatch = valueContent.match(forIteratorRE);
14512
+ if (iteratorMatch) {
14513
+ valueContent = valueContent.replace(forIteratorRE, "").trim();
14514
+ const keyContent = iteratorMatch[1].trim();
14515
+ let keyOffset;
14516
+ if (keyContent) {
14517
+ keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
14518
+ result.key = createAliasExpression(keyContent, keyOffset);
13561
14519
  }
13562
- content = context.source.slice(4, match.index);
13563
- const s = context.source.slice(0, match.index);
13564
- let prevIndex = 1, nestedIndex = 0;
13565
- while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
13566
- advanceBy(context, nestedIndex - prevIndex + 1);
13567
- if (nestedIndex + 4 < s.length) {
13568
- emitError(context, 16);
14520
+ if (iteratorMatch[2]) {
14521
+ const indexContent = iteratorMatch[2].trim();
14522
+ if (indexContent) {
14523
+ result.index = createAliasExpression(
14524
+ indexContent,
14525
+ exp.indexOf(
14526
+ indexContent,
14527
+ result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
14528
+ )
14529
+ );
13569
14530
  }
13570
- prevIndex = nestedIndex + 1;
13571
14531
  }
13572
- advanceBy(context, match.index + match[0].length - prevIndex + 1);
13573
14532
  }
13574
- return {
13575
- type: 3,
13576
- content,
13577
- loc: getSelection(context, start)
13578
- };
14533
+ if (valueContent) {
14534
+ result.value = createAliasExpression(valueContent, trimmedOffset);
14535
+ }
14536
+ return result;
14537
+ }
14538
+ function getSlice(start, end) {
14539
+ return currentInput.slice(start, end);
13579
14540
  }
13580
- function parseBogusComment(context) {
13581
- const start = getCursor(context);
13582
- const contentStart = context.source[1] === "?" ? 1 : 2;
13583
- let content;
13584
- const closeIndex = context.source.indexOf(">");
13585
- if (closeIndex === -1) {
13586
- content = context.source.slice(contentStart);
13587
- advanceBy(context, context.source.length);
14541
+ function endOpenTag(end) {
14542
+ addNode(currentOpenTag);
14543
+ const { tag, ns } = currentOpenTag;
14544
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
14545
+ inPre++;
14546
+ }
14547
+ if (currentOptions.isVoidTag(tag)) {
14548
+ onCloseTag(currentOpenTag, end);
13588
14549
  } else {
13589
- content = context.source.slice(contentStart, closeIndex);
13590
- advanceBy(context, closeIndex + 1);
14550
+ stack.unshift(currentOpenTag);
14551
+ if (ns === 1 || ns === 2) {
14552
+ tokenizer.inXML = true;
14553
+ }
13591
14554
  }
13592
- return {
13593
- type: 3,
13594
- content,
13595
- loc: getSelection(context, start)
13596
- };
14555
+ currentOpenTag = null;
13597
14556
  }
13598
- function parseElement(context, ancestors) {
13599
- const wasInPre = context.inPre;
13600
- const wasInVPre = context.inVPre;
13601
- const parent = last(ancestors);
13602
- const element = parseTag(context, 0 /* Start */, parent);
13603
- const isPreBoundary = context.inPre && !wasInPre;
13604
- const isVPreBoundary = context.inVPre && !wasInVPre;
13605
- if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
13606
- if (isPreBoundary) {
13607
- context.inPre = false;
13608
- }
13609
- if (isVPreBoundary) {
13610
- context.inVPre = false;
13611
- }
13612
- return element;
13613
- }
13614
- ancestors.push(element);
13615
- const mode = context.options.getTextMode(element, parent);
13616
- const children = parseChildren(context, mode, ancestors);
13617
- ancestors.pop();
14557
+ function onText(content, start, end) {
14558
+ var _a;
13618
14559
  {
13619
- const inlineTemplateProp = element.props.find(
13620
- (p) => p.type === 6 && p.name === "inline-template"
13621
- );
13622
- if (inlineTemplateProp && checkCompatEnabled(
13623
- "COMPILER_INLINE_TEMPLATE",
13624
- context,
13625
- inlineTemplateProp.loc
13626
- )) {
13627
- const loc = getSelection(context, element.loc.end);
13628
- inlineTemplateProp.value = {
13629
- type: 2,
13630
- content: loc.source,
13631
- loc
13632
- };
14560
+ const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
14561
+ if (tag !== "script" && tag !== "style" && content.includes("&")) {
14562
+ content = currentOptions.decodeEntities(content, false);
13633
14563
  }
13634
14564
  }
13635
- element.children = children;
13636
- if (startsWithEndTagOpen(context.source, element.tag)) {
13637
- parseTag(context, 1 /* End */, parent);
14565
+ const parent = stack[0] || currentRoot;
14566
+ const lastNode = parent.children[parent.children.length - 1];
14567
+ if ((lastNode == null ? void 0 : lastNode.type) === 2) {
14568
+ lastNode.content += content;
14569
+ setLocEnd(lastNode.loc, end);
13638
14570
  } else {
13639
- emitError(context, 24, 0, element.loc.start);
13640
- if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
13641
- const first = children[0];
13642
- if (first && startsWith(first.loc.source, "<!--")) {
13643
- emitError(context, 8);
13644
- }
14571
+ parent.children.push({
14572
+ type: 2,
14573
+ content,
14574
+ loc: getLoc(start, end)
14575
+ });
14576
+ }
14577
+ }
14578
+ function onCloseTag(el, end, isImplied = false) {
14579
+ if (isImplied) {
14580
+ setLocEnd(el.loc, backTrack(end, 60));
14581
+ } else {
14582
+ setLocEnd(el.loc, end + fastForward(end) + 1);
14583
+ }
14584
+ if (tokenizer.inSFCRoot) {
14585
+ if (el.children.length) {
14586
+ el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
14587
+ } else {
14588
+ el.innerLoc.end = extend({}, el.innerLoc.start);
14589
+ }
14590
+ el.innerLoc.source = getSlice(
14591
+ el.innerLoc.start.offset,
14592
+ el.innerLoc.end.offset
14593
+ );
14594
+ }
14595
+ const { tag, ns } = el;
14596
+ if (!inVPre) {
14597
+ if (tag === "slot") {
14598
+ el.tagType = 2;
14599
+ } else if (isFragmentTemplate(el)) {
14600
+ el.tagType = 3;
14601
+ } else if (isComponent(el)) {
14602
+ el.tagType = 1;
13645
14603
  }
13646
14604
  }
13647
- element.loc = getSelection(context, element.loc.start);
13648
- if (isPreBoundary) {
13649
- context.inPre = false;
14605
+ if (!tokenizer.inRCDATA) {
14606
+ el.children = condenseWhitespace(el.children, el.tag);
13650
14607
  }
13651
- if (isVPreBoundary) {
13652
- context.inVPre = false;
14608
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
14609
+ inPre--;
13653
14610
  }
13654
- return element;
13655
- }
13656
- const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
13657
- `if,else,else-if,for,slot`
13658
- );
13659
- function parseTag(context, type, parent) {
13660
- const start = getCursor(context);
13661
- const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
13662
- const tag = match[1];
13663
- const ns = context.options.getNamespace(tag, parent);
13664
- advanceBy(context, match[0].length);
13665
- advanceSpaces(context);
13666
- const cursor = getCursor(context);
13667
- const currentSource = context.source;
13668
- if (context.options.isPreTag(tag)) {
13669
- context.inPre = true;
13670
- }
13671
- let props = parseAttributes(context, type);
13672
- if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
13673
- context.inVPre = true;
13674
- extend(context, cursor);
13675
- context.source = currentSource;
13676
- props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
13677
- }
13678
- let isSelfClosing = false;
13679
- if (context.source.length === 0) {
13680
- emitError(context, 9);
13681
- } else {
13682
- isSelfClosing = startsWith(context.source, "/>");
13683
- if (type === 1 /* End */ && isSelfClosing) {
13684
- emitError(context, 4);
14611
+ if (currentVPreBoundary === el) {
14612
+ inVPre = false;
14613
+ currentVPreBoundary = null;
14614
+ }
14615
+ if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
14616
+ tokenizer.inXML = false;
14617
+ }
14618
+ {
14619
+ const props = el.props;
14620
+ if (isCompatEnabled(
14621
+ "COMPILER_V_IF_V_FOR_PRECEDENCE",
14622
+ currentOptions
14623
+ )) {
14624
+ let hasIf = false;
14625
+ let hasFor = false;
14626
+ for (let i = 0; i < props.length; i++) {
14627
+ const p = props[i];
14628
+ if (p.type === 7) {
14629
+ if (p.name === "if") {
14630
+ hasIf = true;
14631
+ } else if (p.name === "for") {
14632
+ hasFor = true;
14633
+ }
14634
+ }
14635
+ if (hasIf && hasFor) {
14636
+ warnDeprecation(
14637
+ "COMPILER_V_IF_V_FOR_PRECEDENCE",
14638
+ currentOptions,
14639
+ el.loc
14640
+ );
14641
+ break;
14642
+ }
14643
+ }
14644
+ }
14645
+ if (isCompatEnabled(
14646
+ "COMPILER_NATIVE_TEMPLATE",
14647
+ currentOptions
14648
+ ) && el.tag === "template" && !isFragmentTemplate(el)) {
14649
+ warnDeprecation(
14650
+ "COMPILER_NATIVE_TEMPLATE",
14651
+ currentOptions,
14652
+ el.loc
14653
+ );
14654
+ const parent = stack[0] || currentRoot;
14655
+ const index = parent.children.indexOf(el);
14656
+ parent.children.splice(index, 1, ...el.children);
14657
+ }
14658
+ const inlineTemplateProp = props.find(
14659
+ (p) => p.type === 6 && p.name === "inline-template"
14660
+ );
14661
+ if (inlineTemplateProp && checkCompatEnabled(
14662
+ "COMPILER_INLINE_TEMPLATE",
14663
+ currentOptions,
14664
+ inlineTemplateProp.loc
14665
+ ) && el.children.length) {
14666
+ inlineTemplateProp.value = {
14667
+ type: 2,
14668
+ content: getSlice(
14669
+ el.children[0].loc.start.offset,
14670
+ el.children[el.children.length - 1].loc.end.offset
14671
+ ),
14672
+ loc: inlineTemplateProp.loc
14673
+ };
13685
14674
  }
13686
- advanceBy(context, isSelfClosing ? 2 : 1);
13687
14675
  }
13688
- if (type === 1 /* End */) {
13689
- return;
14676
+ }
14677
+ function fastForward(start, c) {
14678
+ let offset = 0;
14679
+ while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
14680
+ offset++;
13690
14681
  }
13691
- if (isCompatEnabled(
13692
- "COMPILER_V_IF_V_FOR_PRECEDENCE",
13693
- context
13694
- )) {
13695
- let hasIf = false;
13696
- let hasFor = false;
14682
+ return offset;
14683
+ }
14684
+ function backTrack(index, c) {
14685
+ let i = index;
14686
+ while (currentInput.charCodeAt(i) !== c && i >= 0)
14687
+ i--;
14688
+ return i;
14689
+ }
14690
+ const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
14691
+ function isFragmentTemplate({ tag, props }) {
14692
+ if (tag === "template") {
13697
14693
  for (let i = 0; i < props.length; i++) {
13698
- const p = props[i];
13699
- if (p.type === 7) {
13700
- if (p.name === "if") {
13701
- hasIf = true;
13702
- } else if (p.name === "for") {
13703
- hasFor = true;
13704
- }
13705
- }
13706
- if (hasIf && hasFor) {
13707
- warnDeprecation(
13708
- "COMPILER_V_IF_V_FOR_PRECEDENCE",
13709
- context,
13710
- getSelection(context, start)
13711
- );
13712
- break;
13713
- }
13714
- }
13715
- }
13716
- let tagType = 0;
13717
- if (!context.inVPre) {
13718
- if (tag === "slot") {
13719
- tagType = 2;
13720
- } else if (tag === "template") {
13721
- if (props.some(
13722
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
13723
- )) {
13724
- tagType = 3;
14694
+ if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
14695
+ return true;
13725
14696
  }
13726
- } else if (isComponent(tag, props, context)) {
13727
- tagType = 1;
13728
14697
  }
13729
14698
  }
13730
- return {
13731
- type: 1,
13732
- ns,
13733
- tag,
13734
- tagType,
13735
- props,
13736
- isSelfClosing,
13737
- children: [],
13738
- loc: getSelection(context, start),
13739
- codegenNode: void 0
13740
- // to be created during transform phase
13741
- };
14699
+ return false;
13742
14700
  }
13743
- function isComponent(tag, props, context) {
13744
- const options = context.options;
13745
- if (options.isCustomElement(tag)) {
14701
+ function isComponent({ tag, props }) {
14702
+ var _a;
14703
+ if (currentOptions.isCustomElement(tag)) {
13746
14704
  return false;
13747
14705
  }
13748
- if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
14706
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
13749
14707
  return true;
13750
14708
  }
13751
14709
  for (let i = 0; i < props.length; i++) {
@@ -13756,374 +14714,179 @@ function isComponent(tag, props, context) {
13756
14714
  return true;
13757
14715
  } else if (checkCompatEnabled(
13758
14716
  "COMPILER_IS_ON_ELEMENT",
13759
- context,
14717
+ currentOptions,
13760
14718
  p.loc
13761
14719
  )) {
13762
14720
  return true;
13763
14721
  }
13764
14722
  }
13765
- } else {
13766
- if (p.name === "is") {
13767
- return true;
13768
- } else if (
13769
- // :is on plain element - only treat as component in compat mode
13770
- p.name === "bind" && isStaticArgOf(p.arg, "is") && true && checkCompatEnabled(
13771
- "COMPILER_IS_ON_ELEMENT",
13772
- context,
13773
- p.loc
13774
- )
13775
- ) {
13776
- return true;
13777
- }
14723
+ } else if (// :is on plain element - only treat as component in compat mode
14724
+ p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
14725
+ "COMPILER_IS_ON_ELEMENT",
14726
+ currentOptions,
14727
+ p.loc
14728
+ )) {
14729
+ return true;
13778
14730
  }
13779
14731
  }
14732
+ return false;
13780
14733
  }
13781
- function parseAttributes(context, type) {
13782
- const props = [];
13783
- const attributeNames = /* @__PURE__ */ new Set();
13784
- while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
13785
- if (startsWith(context.source, "/")) {
13786
- emitError(context, 22);
13787
- advanceBy(context, 1);
13788
- advanceSpaces(context);
13789
- continue;
13790
- }
13791
- if (type === 1 /* End */) {
13792
- emitError(context, 3);
13793
- }
13794
- const attr = parseAttribute(context, attributeNames);
13795
- if (attr.type === 6 && attr.value && attr.name === "class") {
13796
- attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
13797
- }
13798
- if (type === 0 /* Start */) {
13799
- props.push(attr);
13800
- }
13801
- if (/^[^\t\r\n\f />]/.test(context.source)) {
13802
- emitError(context, 15);
13803
- }
13804
- advanceSpaces(context);
13805
- }
13806
- return props;
14734
+ function isUpperCase(c) {
14735
+ return c > 64 && c < 91;
13807
14736
  }
13808
- function parseAttribute(context, nameSet) {
13809
- var _a;
13810
- const start = getCursor(context);
13811
- const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
13812
- const name = match[0];
13813
- if (nameSet.has(name)) {
13814
- emitError(context, 2);
13815
- }
13816
- nameSet.add(name);
13817
- if (name[0] === "=") {
13818
- emitError(context, 19);
13819
- }
13820
- {
13821
- const pattern = /["'<]/g;
13822
- let m;
13823
- while (m = pattern.exec(name)) {
13824
- emitError(
13825
- context,
13826
- 17,
13827
- m.index
13828
- );
13829
- }
13830
- }
13831
- advanceBy(context, name.length);
13832
- let value = void 0;
13833
- if (/^[\t\r\n\f ]*=/.test(context.source)) {
13834
- advanceSpaces(context);
13835
- advanceBy(context, 1);
13836
- advanceSpaces(context);
13837
- value = parseAttributeValue(context);
13838
- if (!value) {
13839
- emitError(context, 13);
13840
- }
13841
- }
13842
- const loc = getSelection(context, start);
13843
- if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
13844
- const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
13845
- name
13846
- );
13847
- let isPropShorthand = startsWith(name, ".");
13848
- let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
13849
- let arg;
13850
- if (match2[2]) {
13851
- const isSlot = dirName === "slot";
13852
- const startOffset = name.lastIndexOf(
13853
- match2[2],
13854
- name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
13855
- );
13856
- const loc2 = getSelection(
13857
- context,
13858
- getNewPosition(context, start, startOffset),
13859
- getNewPosition(
13860
- context,
13861
- start,
13862
- startOffset + match2[2].length + (isSlot && match2[3] || "").length
13863
- )
13864
- );
13865
- let content = match2[2];
13866
- let isStatic = true;
13867
- if (content.startsWith("[")) {
13868
- isStatic = false;
13869
- if (!content.endsWith("]")) {
13870
- emitError(
13871
- context,
13872
- 27
13873
- );
13874
- content = content.slice(1);
13875
- } else {
13876
- content = content.slice(1, content.length - 1);
14737
+ const windowsNewlineRE = /\r\n/g;
14738
+ function condenseWhitespace(nodes, tag) {
14739
+ var _a, _b;
14740
+ const shouldCondense = currentOptions.whitespace !== "preserve";
14741
+ let removedWhitespace = false;
14742
+ for (let i = 0; i < nodes.length; i++) {
14743
+ const node = nodes[i];
14744
+ if (node.type === 2) {
14745
+ if (!inPre) {
14746
+ if (isAllWhitespace(node.content)) {
14747
+ const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
14748
+ const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
14749
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
14750
+ removedWhitespace = true;
14751
+ nodes[i] = null;
14752
+ } else {
14753
+ node.content = " ";
14754
+ }
14755
+ } else if (shouldCondense) {
14756
+ node.content = condense(node.content);
13877
14757
  }
13878
- } else if (isSlot) {
13879
- content += match2[3] || "";
13880
- }
13881
- arg = {
13882
- type: 4,
13883
- content,
13884
- isStatic,
13885
- constType: isStatic ? 3 : 0,
13886
- loc: loc2
13887
- };
13888
- }
13889
- if (value && value.isQuoted) {
13890
- const valueLoc = value.loc;
13891
- valueLoc.start.offset++;
13892
- valueLoc.start.column++;
13893
- valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
13894
- valueLoc.source = valueLoc.source.slice(1, -1);
13895
- }
13896
- const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
13897
- if (isPropShorthand)
13898
- modifiers.push("prop");
13899
- if (dirName === "bind" && arg) {
13900
- if (modifiers.includes("sync") && checkCompatEnabled(
13901
- "COMPILER_V_BIND_SYNC",
13902
- context,
13903
- loc,
13904
- arg.loc.source
13905
- )) {
13906
- dirName = "model";
13907
- modifiers.splice(modifiers.indexOf("sync"), 1);
13908
- }
13909
- if (modifiers.includes("prop")) {
13910
- checkCompatEnabled(
13911
- "COMPILER_V_BIND_PROP",
13912
- context,
13913
- loc
13914
- );
14758
+ } else {
14759
+ node.content = node.content.replace(windowsNewlineRE, "\n");
13915
14760
  }
13916
14761
  }
13917
- return {
13918
- type: 7,
13919
- name: dirName,
13920
- exp: value && {
13921
- type: 4,
13922
- content: value.content,
13923
- isStatic: false,
13924
- // Treat as non-constant by default. This can be potentially set to
13925
- // other values by `transformExpression` to make it eligible for hoisting.
13926
- constType: 0,
13927
- loc: value.loc
13928
- },
13929
- arg,
13930
- modifiers,
13931
- loc
13932
- };
13933
14762
  }
13934
- if (!context.inVPre && startsWith(name, "v-")) {
13935
- emitError(context, 26);
14763
+ if (inPre && tag && currentOptions.isPreTag(tag)) {
14764
+ const first = nodes[0];
14765
+ if (first && first.type === 2) {
14766
+ first.content = first.content.replace(/^\r?\n/, "");
14767
+ }
13936
14768
  }
13937
- return {
13938
- type: 6,
13939
- name,
13940
- value: value && {
13941
- type: 2,
13942
- content: value.content,
13943
- loc: value.loc
13944
- },
13945
- loc
13946
- };
14769
+ return removedWhitespace ? nodes.filter(Boolean) : nodes;
13947
14770
  }
13948
- function parseAttributeValue(context) {
13949
- const start = getCursor(context);
13950
- let content;
13951
- const quote = context.source[0];
13952
- const isQuoted = quote === `"` || quote === `'`;
13953
- if (isQuoted) {
13954
- advanceBy(context, 1);
13955
- const endIndex = context.source.indexOf(quote);
13956
- if (endIndex === -1) {
13957
- content = parseTextData(
13958
- context,
13959
- context.source.length,
13960
- 4
13961
- );
13962
- } else {
13963
- content = parseTextData(context, endIndex, 4);
13964
- advanceBy(context, 1);
13965
- }
13966
- } else {
13967
- const match = /^[^\t\r\n\f >]+/.exec(context.source);
13968
- if (!match) {
13969
- return void 0;
13970
- }
13971
- const unexpectedChars = /["'<=`]/g;
13972
- let m;
13973
- while (m = unexpectedChars.exec(match[0])) {
13974
- emitError(
13975
- context,
13976
- 18,
13977
- m.index
13978
- );
14771
+ function isAllWhitespace(str) {
14772
+ for (let i = 0; i < str.length; i++) {
14773
+ if (!isWhitespace(str.charCodeAt(i))) {
14774
+ return false;
13979
14775
  }
13980
- content = parseTextData(context, match[0].length, 4);
13981
- }
13982
- return { content, isQuoted, loc: getSelection(context, start) };
13983
- }
13984
- function parseInterpolation(context, mode) {
13985
- const [open, close] = context.options.delimiters;
13986
- const closeIndex = context.source.indexOf(close, open.length);
13987
- if (closeIndex === -1) {
13988
- emitError(context, 25);
13989
- return void 0;
13990
- }
13991
- const start = getCursor(context);
13992
- advanceBy(context, open.length);
13993
- const innerStart = getCursor(context);
13994
- const innerEnd = getCursor(context);
13995
- const rawContentLength = closeIndex - open.length;
13996
- const rawContent = context.source.slice(0, rawContentLength);
13997
- const preTrimContent = parseTextData(context, rawContentLength, mode);
13998
- const content = preTrimContent.trim();
13999
- const startOffset = preTrimContent.indexOf(content);
14000
- if (startOffset > 0) {
14001
- advancePositionWithMutation(innerStart, rawContent, startOffset);
14002
- }
14003
- const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
14004
- advancePositionWithMutation(innerEnd, rawContent, endOffset);
14005
- advanceBy(context, close.length);
14006
- return {
14007
- type: 5,
14008
- content: {
14009
- type: 4,
14010
- isStatic: false,
14011
- // Set `isConstant` to false by default and will decide in transformExpression
14012
- constType: 0,
14013
- content,
14014
- loc: getSelection(context, innerStart, innerEnd)
14015
- },
14016
- loc: getSelection(context, start)
14017
- };
14776
+ }
14777
+ return true;
14018
14778
  }
14019
- function parseText(context, mode) {
14020
- const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
14021
- let endIndex = context.source.length;
14022
- for (let i = 0; i < endTokens.length; i++) {
14023
- const index = context.source.indexOf(endTokens[i], 1);
14024
- if (index !== -1 && endIndex > index) {
14025
- endIndex = index;
14779
+ function hasNewlineChar(str) {
14780
+ for (let i = 0; i < str.length; i++) {
14781
+ const c = str.charCodeAt(i);
14782
+ if (c === 10 || c === 13) {
14783
+ return true;
14026
14784
  }
14027
14785
  }
14028
- const start = getCursor(context);
14029
- const content = parseTextData(context, endIndex, mode);
14030
- return {
14031
- type: 2,
14032
- content,
14033
- loc: getSelection(context, start)
14034
- };
14786
+ return false;
14035
14787
  }
14036
- function parseTextData(context, length, mode) {
14037
- const rawText = context.source.slice(0, length);
14038
- advanceBy(context, length);
14039
- if (mode === 2 || mode === 3 || !rawText.includes("&")) {
14040
- return rawText;
14041
- } else {
14042
- return context.options.decodeEntities(
14043
- rawText,
14044
- mode === 4
14045
- );
14788
+ function condense(str) {
14789
+ let ret = "";
14790
+ let prevCharIsWhitespace = false;
14791
+ for (let i = 0; i < str.length; i++) {
14792
+ if (isWhitespace(str.charCodeAt(i))) {
14793
+ if (!prevCharIsWhitespace) {
14794
+ ret += " ";
14795
+ prevCharIsWhitespace = true;
14796
+ }
14797
+ } else {
14798
+ ret += str[i];
14799
+ prevCharIsWhitespace = false;
14800
+ }
14046
14801
  }
14802
+ return ret;
14047
14803
  }
14048
- function getCursor(context) {
14049
- const { column, line, offset } = context;
14050
- return { column, line, offset };
14804
+ function addNode(node) {
14805
+ (stack[0] || currentRoot).children.push(node);
14051
14806
  }
14052
- function getSelection(context, start, end) {
14053
- end = end || getCursor(context);
14807
+ function getLoc(start, end) {
14054
14808
  return {
14055
- start,
14056
- end,
14057
- source: context.originalSource.slice(start.offset, end.offset)
14809
+ start: tokenizer.getPos(start),
14810
+ // @ts-expect-error allow late attachment
14811
+ end: end == null ? end : tokenizer.getPos(end),
14812
+ // @ts-expect-error allow late attachment
14813
+ source: end == null ? end : getSlice(start, end)
14058
14814
  };
14059
14815
  }
14060
- function last(xs) {
14061
- return xs[xs.length - 1];
14062
- }
14063
- function startsWith(source, searchString) {
14064
- return source.startsWith(searchString);
14816
+ function setLocEnd(loc, end) {
14817
+ loc.end = tokenizer.getPos(end);
14818
+ loc.source = getSlice(loc.start.offset, end);
14065
14819
  }
14066
- function advanceBy(context, numberOfCharacters) {
14067
- const { source } = context;
14068
- advancePositionWithMutation(context, source, numberOfCharacters);
14069
- context.source = source.slice(numberOfCharacters);
14070
- }
14071
- function advanceSpaces(context) {
14072
- const match = /^[\t\r\n\f ]+/.exec(context.source);
14073
- if (match) {
14074
- advanceBy(context, match[0].length);
14820
+ function dirToAttr(dir) {
14821
+ const attr = {
14822
+ type: 6,
14823
+ name: dir.rawName,
14824
+ nameLoc: getLoc(
14825
+ dir.loc.start.offset,
14826
+ dir.loc.start.offset + dir.rawName.length
14827
+ ),
14828
+ value: void 0,
14829
+ loc: dir.loc
14830
+ };
14831
+ if (dir.exp) {
14832
+ const loc = dir.exp.loc;
14833
+ if (loc.end.offset < dir.loc.end.offset) {
14834
+ loc.start.offset--;
14835
+ loc.start.column--;
14836
+ loc.end.offset++;
14837
+ loc.end.column++;
14838
+ }
14839
+ attr.value = {
14840
+ type: 2,
14841
+ content: dir.exp.content,
14842
+ loc
14843
+ };
14075
14844
  }
14845
+ return attr;
14076
14846
  }
14077
- function getNewPosition(context, start, numberOfCharacters) {
14078
- return advancePositionWithClone(
14079
- start,
14080
- context.originalSource.slice(start.offset, numberOfCharacters),
14081
- numberOfCharacters
14082
- );
14847
+ function emitError(code, index) {
14848
+ currentOptions.onError(createCompilerError(code, getLoc(index, index)));
14083
14849
  }
14084
- function emitError(context, code, offset, loc = getCursor(context)) {
14085
- if (offset) {
14086
- loc.offset += offset;
14087
- loc.column += offset;
14088
- }
14089
- context.options.onError(
14090
- createCompilerError(code, {
14091
- start: loc,
14092
- end: loc,
14093
- source: ""
14094
- })
14095
- );
14850
+ function reset() {
14851
+ tokenizer.reset();
14852
+ currentOpenTag = null;
14853
+ currentProp = null;
14854
+ currentAttrValue = "";
14855
+ currentAttrStartIndex = -1;
14856
+ currentAttrEndIndex = -1;
14857
+ stack.length = 0;
14096
14858
  }
14097
- function isEnd(context, mode, ancestors) {
14098
- const s = context.source;
14099
- switch (mode) {
14100
- case 0:
14101
- if (startsWith(s, "</")) {
14102
- for (let i = ancestors.length - 1; i >= 0; --i) {
14103
- if (startsWithEndTagOpen(s, ancestors[i].tag)) {
14104
- return true;
14105
- }
14106
- }
14107
- }
14108
- break;
14109
- case 1:
14110
- case 2: {
14111
- const parent = last(ancestors);
14112
- if (parent && startsWithEndTagOpen(s, parent.tag)) {
14113
- return true;
14859
+ function baseParse(input, options) {
14860
+ reset();
14861
+ currentInput = input;
14862
+ currentOptions = extend({}, defaultParserOptions);
14863
+ if (options) {
14864
+ let key;
14865
+ for (key in options) {
14866
+ if (options[key] != null) {
14867
+ currentOptions[key] = options[key];
14114
14868
  }
14115
- break;
14116
14869
  }
14117
- case 3:
14118
- if (startsWith(s, "]]>")) {
14119
- return true;
14120
- }
14121
- break;
14122
14870
  }
14123
- return !s;
14124
- }
14125
- function startsWithEndTagOpen(source, tag) {
14126
- return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
14871
+ {
14872
+ if (!currentOptions.decodeEntities) {
14873
+ throw new Error(
14874
+ `[@vue/compiler-core] decodeEntities option is required in browser builds.`
14875
+ );
14876
+ }
14877
+ }
14878
+ tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
14879
+ const delimiters = options == null ? void 0 : options.delimiters;
14880
+ if (delimiters) {
14881
+ tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
14882
+ tokenizer.delimiterClose = toCharCodes(delimiters[1]);
14883
+ }
14884
+ const root = currentRoot = createRoot([], input);
14885
+ tokenizer.parse(currentInput);
14886
+ root.loc = getLoc(0, input.length);
14887
+ root.children = condenseWhitespace(root.children);
14888
+ currentRoot = null;
14889
+ return root;
14127
14890
  }
14128
14891
 
14129
14892
  function hoistStatic(root, context) {
@@ -14535,6 +15298,7 @@ function transform(root, options) {
14535
15298
  root.hoists = context.hoists;
14536
15299
  root.temps = context.temps;
14537
15300
  root.cached = context.cached;
15301
+ root.transformed = true;
14538
15302
  {
14539
15303
  root.filters = [...context.filters];
14540
15304
  }
@@ -14691,7 +15455,7 @@ function createCodegenContext(ast, {
14691
15455
  ssr,
14692
15456
  isTS,
14693
15457
  inSSR,
14694
- source: ast.loc.source,
15458
+ source: ast.source,
14695
15459
  code: ``,
14696
15460
  column: 1,
14697
15461
  line: 1,
@@ -14702,7 +15466,7 @@ function createCodegenContext(ast, {
14702
15466
  helper(key) {
14703
15467
  return `_${helperNameMap[key]}`;
14704
15468
  },
14705
- push(code, node) {
15469
+ push(code, newlineIndex = -2 /* None */, node) {
14706
15470
  context.code += code;
14707
15471
  },
14708
15472
  indent() {
@@ -14720,7 +15484,7 @@ function createCodegenContext(ast, {
14720
15484
  }
14721
15485
  };
14722
15486
  function newline(n) {
14723
- context.push("\n" + ` `.repeat(n));
15487
+ context.push("\n" + ` `.repeat(n), 0 /* Start */);
14724
15488
  }
14725
15489
  return context;
14726
15490
  }
@@ -14757,9 +15521,11 @@ function generate(ast, options = {}) {
14757
15521
  push(`with (_ctx) {`);
14758
15522
  indent();
14759
15523
  if (hasHelpers) {
14760
- push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
14761
- push(`
14762
- `);
15524
+ push(
15525
+ `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
15526
+ `,
15527
+ -1 /* End */
15528
+ );
14763
15529
  newline();
14764
15530
  }
14765
15531
  }
@@ -14788,7 +15554,7 @@ function generate(ast, options = {}) {
14788
15554
  }
14789
15555
  if (ast.components.length || ast.directives.length || ast.temps) {
14790
15556
  push(`
14791
- `);
15557
+ `, 0 /* Start */);
14792
15558
  newline();
14793
15559
  }
14794
15560
  if (!ssr) {
@@ -14809,7 +15575,6 @@ function generate(ast, options = {}) {
14809
15575
  ast,
14810
15576
  code: context.code,
14811
15577
  preamble: isSetupInlined ? preambleContext.code : ``,
14812
- // SourceMapGenerator does have toJSON() method but it's not in the types
14813
15578
  map: context.map ? context.map.toJSON() : void 0
14814
15579
  };
14815
15580
  }
@@ -14828,7 +15593,7 @@ function genFunctionPreamble(ast, context) {
14828
15593
  if (helpers.length > 0) {
14829
15594
  {
14830
15595
  push(`const _Vue = ${VueBinding}
14831
- `);
15596
+ `, -1 /* End */);
14832
15597
  if (ast.hoists.length) {
14833
15598
  const staticHelpers = [
14834
15599
  CREATE_VNODE,
@@ -14838,7 +15603,7 @@ function genFunctionPreamble(ast, context) {
14838
15603
  CREATE_STATIC
14839
15604
  ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
14840
15605
  push(`const { ${staticHelpers} } = _Vue
14841
- `);
15606
+ `, -1 /* End */);
14842
15607
  }
14843
15608
  }
14844
15609
  }
@@ -14899,7 +15664,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
14899
15664
  for (let i = 0; i < nodes.length; i++) {
14900
15665
  const node = nodes[i];
14901
15666
  if (isString(node)) {
14902
- push(node);
15667
+ push(node, -3 /* Unknown */);
14903
15668
  } else if (isArray(node)) {
14904
15669
  genNodeListAsArray(node, context);
14905
15670
  } else {
@@ -14917,7 +15682,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
14917
15682
  }
14918
15683
  function genNode(node, context) {
14919
15684
  if (isString(node)) {
14920
- context.push(node);
15685
+ context.push(node, -3 /* Unknown */);
14921
15686
  return;
14922
15687
  }
14923
15688
  if (isSymbol(node)) {
@@ -14997,11 +15762,15 @@ function genNode(node, context) {
14997
15762
  }
14998
15763
  }
14999
15764
  function genText(node, context) {
15000
- context.push(JSON.stringify(node.content), node);
15765
+ context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
15001
15766
  }
15002
15767
  function genExpression(node, context) {
15003
15768
  const { content, isStatic } = node;
15004
- context.push(isStatic ? JSON.stringify(content) : content, node);
15769
+ context.push(
15770
+ isStatic ? JSON.stringify(content) : content,
15771
+ -3 /* Unknown */,
15772
+ node
15773
+ );
15005
15774
  }
15006
15775
  function genInterpolation(node, context) {
15007
15776
  const { push, helper, pure } = context;
@@ -15015,7 +15784,7 @@ function genCompoundExpression(node, context) {
15015
15784
  for (let i = 0; i < node.children.length; i++) {
15016
15785
  const child = node.children[i];
15017
15786
  if (isString(child)) {
15018
- context.push(child);
15787
+ context.push(child, -3 /* Unknown */);
15019
15788
  } else {
15020
15789
  genNode(child, context);
15021
15790
  }
@@ -15029,9 +15798,9 @@ function genExpressionAsPropertyKey(node, context) {
15029
15798
  push(`]`);
15030
15799
  } else if (node.isStatic) {
15031
15800
  const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
15032
- push(text, node);
15801
+ push(text, -2 /* None */, node);
15033
15802
  } else {
15034
- push(`[${node.content}]`, node);
15803
+ push(`[${node.content}]`, -3 /* Unknown */, node);
15035
15804
  }
15036
15805
  }
15037
15806
  function genComment(node, context) {
@@ -15039,7 +15808,11 @@ function genComment(node, context) {
15039
15808
  if (pure) {
15040
15809
  push(PURE_ANNOTATION);
15041
15810
  }
15042
- push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
15811
+ push(
15812
+ `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
15813
+ -3 /* Unknown */,
15814
+ node
15815
+ );
15043
15816
  }
15044
15817
  function genVNodeCall(node, context) {
15045
15818
  const { push, helper, pure } = context;
@@ -15064,7 +15837,7 @@ function genVNodeCall(node, context) {
15064
15837
  push(PURE_ANNOTATION);
15065
15838
  }
15066
15839
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
15067
- push(helper(callHelper) + `(`, node);
15840
+ push(helper(callHelper) + `(`, -2 /* None */, node);
15068
15841
  genNodeList(
15069
15842
  genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
15070
15843
  context
@@ -15093,7 +15866,7 @@ function genCallExpression(node, context) {
15093
15866
  if (pure) {
15094
15867
  push(PURE_ANNOTATION);
15095
15868
  }
15096
- push(callee + `(`, node);
15869
+ push(callee + `(`, -2 /* None */, node);
15097
15870
  genNodeList(node.arguments, context);
15098
15871
  push(`)`);
15099
15872
  }
@@ -15101,7 +15874,7 @@ function genObjectExpression(node, context) {
15101
15874
  const { push, indent, deindent, newline } = context;
15102
15875
  const { properties } = node;
15103
15876
  if (!properties.length) {
15104
- push(`{}`, node);
15877
+ push(`{}`, -2 /* None */, node);
15105
15878
  return;
15106
15879
  }
15107
15880
  const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
@@ -15129,7 +15902,7 @@ function genFunctionExpression(node, context) {
15129
15902
  if (isSlot) {
15130
15903
  push(`_${helperNameMap[WITH_CTX]}(`);
15131
15904
  }
15132
- push(`(`, node);
15905
+ push(`(`, -2 /* None */, node);
15133
15906
  if (isArray(params)) {
15134
15907
  genNodeList(params, context);
15135
15908
  } else if (params) {
@@ -15363,7 +16136,7 @@ function processIf(node, dir, context, processCodegen) {
15363
16136
  context.removeNode();
15364
16137
  const branch = createIfBranch(node, dir);
15365
16138
  if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
15366
- !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
16139
+ !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
15367
16140
  branch.children = [...comments, ...branch.children];
15368
16141
  }
15369
16142
  {
@@ -15645,18 +16418,14 @@ function processFor(node, dir, context, processCodegen) {
15645
16418
  );
15646
16419
  return;
15647
16420
  }
15648
- const parseResult = parseForExpression(
15649
- // can only be simple expression because vFor transform is applied
15650
- // before expression transform.
15651
- dir.exp,
15652
- context
15653
- );
16421
+ const parseResult = dir.forParseResult;
15654
16422
  if (!parseResult) {
15655
16423
  context.onError(
15656
16424
  createCompilerError(32, dir.loc)
15657
16425
  );
15658
16426
  return;
15659
16427
  }
16428
+ finalizeForParseResult(parseResult, context);
15660
16429
  const { addIdentifiers, removeIdentifiers, scopes } = context;
15661
16430
  const { source, value, key, index } = parseResult;
15662
16431
  const forNode = {
@@ -15678,71 +16447,26 @@ function processFor(node, dir, context, processCodegen) {
15678
16447
  onExit();
15679
16448
  };
15680
16449
  }
15681
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
15682
- const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
15683
- const stripParensRE = /^\(|\)$/g;
15684
- function parseForExpression(input, context) {
15685
- const loc = input.loc;
15686
- const exp = input.content;
15687
- const inMatch = exp.match(forAliasRE);
15688
- if (!inMatch)
16450
+ function finalizeForParseResult(result, context) {
16451
+ if (result.finalized)
15689
16452
  return;
15690
- const [, LHS, RHS] = inMatch;
15691
- const result = {
15692
- source: createAliasExpression(
15693
- loc,
15694
- RHS.trim(),
15695
- exp.indexOf(RHS, LHS.length)
15696
- ),
15697
- value: void 0,
15698
- key: void 0,
15699
- index: void 0
15700
- };
15701
16453
  {
15702
16454
  validateBrowserExpression(result.source, context);
15703
- }
15704
- let valueContent = LHS.trim().replace(stripParensRE, "").trim();
15705
- const trimmedOffset = LHS.indexOf(valueContent);
15706
- const iteratorMatch = valueContent.match(forIteratorRE);
15707
- if (iteratorMatch) {
15708
- valueContent = valueContent.replace(forIteratorRE, "").trim();
15709
- const keyContent = iteratorMatch[1].trim();
15710
- let keyOffset;
15711
- if (keyContent) {
15712
- keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
15713
- result.key = createAliasExpression(loc, keyContent, keyOffset);
15714
- {
15715
- validateBrowserExpression(
15716
- result.key,
15717
- context,
15718
- true
15719
- );
15720
- }
16455
+ if (result.key) {
16456
+ validateBrowserExpression(
16457
+ result.key,
16458
+ context,
16459
+ true
16460
+ );
15721
16461
  }
15722
- if (iteratorMatch[2]) {
15723
- const indexContent = iteratorMatch[2].trim();
15724
- if (indexContent) {
15725
- result.index = createAliasExpression(
15726
- loc,
15727
- indexContent,
15728
- exp.indexOf(
15729
- indexContent,
15730
- result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
15731
- )
15732
- );
15733
- {
15734
- validateBrowserExpression(
15735
- result.index,
15736
- context,
15737
- true
15738
- );
15739
- }
15740
- }
16462
+ if (result.index) {
16463
+ validateBrowserExpression(
16464
+ result.index,
16465
+ context,
16466
+ true
16467
+ );
15741
16468
  }
15742
- }
15743
- if (valueContent) {
15744
- result.value = createAliasExpression(loc, valueContent, trimmedOffset);
15745
- {
16469
+ if (result.value) {
15746
16470
  validateBrowserExpression(
15747
16471
  result.value,
15748
16472
  context,
@@ -15750,14 +16474,7 @@ function parseForExpression(input, context) {
15750
16474
  );
15751
16475
  }
15752
16476
  }
15753
- return result;
15754
- }
15755
- function createAliasExpression(range, content, offset) {
15756
- return createSimpleExpression(
15757
- content,
15758
- false,
15759
- getInnerRange(range, offset, content.length)
15760
- );
16477
+ result.finalized = true;
15761
16478
  }
15762
16479
  function createForLoopParams({ value, key, index }, memoArgs = []) {
15763
16480
  return createParamsList([value, key, index, ...memoArgs]);
@@ -15844,12 +16561,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15844
16561
  hasDynamicSlots = true;
15845
16562
  }
15846
16563
  const vFor = findDir(slotElement, "for");
15847
- const slotFunction = buildSlotFn(
15848
- slotProps,
15849
- vFor == null ? void 0 : vFor.exp,
15850
- slotChildren,
15851
- slotLoc
15852
- );
16564
+ const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
15853
16565
  let vIf;
15854
16566
  let vElse;
15855
16567
  if (vIf = findDir(slotElement, "if")) {
@@ -15898,8 +16610,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15898
16610
  }
15899
16611
  } else if (vFor) {
15900
16612
  hasDynamicSlots = true;
15901
- const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
16613
+ const parseResult = vFor.forParseResult;
15902
16614
  if (parseResult) {
16615
+ finalizeForParseResult(parseResult, context);
15903
16616
  dynamicSlots.push(
15904
16617
  createCallExpression(context.helper(RENDER_LIST), [
15905
16618
  parseResult.source,
@@ -16160,17 +16873,6 @@ function resolveComponentType(node, context, ssr = false) {
16160
16873
  tag = isProp.value.content.slice(4);
16161
16874
  }
16162
16875
  }
16163
- const isDir = !isExplicitDynamic && findDir(node, "is");
16164
- if (isDir && isDir.exp) {
16165
- {
16166
- context.onWarn(
16167
- createCompilerError(52, isDir.loc)
16168
- );
16169
- }
16170
- return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
16171
- isDir.exp
16172
- ]);
16173
- }
16174
16876
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
16175
16877
  if (builtIn) {
16176
16878
  if (!ssr)
@@ -16242,7 +16944,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16242
16944
  for (let i = 0; i < props.length; i++) {
16243
16945
  const prop = props[i];
16244
16946
  if (prop.type === 6) {
16245
- const { loc, name, value } = prop;
16947
+ const { loc, name, nameLoc, value } = prop;
16246
16948
  let isStatic = true;
16247
16949
  if (name === "ref") {
16248
16950
  hasRef = true;
@@ -16263,11 +16965,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16263
16965
  }
16264
16966
  properties.push(
16265
16967
  createObjectProperty(
16266
- createSimpleExpression(
16267
- name,
16268
- true,
16269
- getInnerRange(loc, 0, name.length)
16270
- ),
16968
+ createSimpleExpression(name, true, nameLoc),
16271
16969
  createSimpleExpression(
16272
16970
  value ? value.content : "",
16273
16971
  isStatic,
@@ -16276,7 +16974,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16276
16974
  )
16277
16975
  );
16278
16976
  } else {
16279
- const { name, arg, exp, loc } = prop;
16977
+ const { name, arg, exp, loc, modifiers } = prop;
16280
16978
  const isVBind = name === "bind";
16281
16979
  const isVOn = name === "on";
16282
16980
  if (name === "slot") {
@@ -16369,6 +17067,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16369
17067
  }
16370
17068
  continue;
16371
17069
  }
17070
+ if (isVBind && modifiers.includes("prop")) {
17071
+ patchFlag |= 32;
17072
+ }
16372
17073
  const directiveTransform = context.directiveTransforms[name];
16373
17074
  if (directiveTransform) {
16374
17075
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -16746,8 +17447,13 @@ const transformOn$1 = (dir, node, context, augmentor) => {
16746
17447
  };
16747
17448
 
16748
17449
  const transformBind = (dir, _node, context) => {
16749
- const { exp, modifiers, loc } = dir;
17450
+ const { modifiers, loc } = dir;
16750
17451
  const arg = dir.arg;
17452
+ let { exp } = dir;
17453
+ if (!exp && arg.type === 4) {
17454
+ const propName = camelize(arg.content);
17455
+ exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
17456
+ }
16751
17457
  if (arg.type !== 4) {
16752
17458
  arg.children.unshift(`(`);
16753
17459
  arg.children.push(`) || ""`);
@@ -17146,7 +17852,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
17146
17852
  }
17147
17853
  ];
17148
17854
  }
17149
- function baseCompile(template, options = {}) {
17855
+ function baseCompile(source, options = {}) {
17150
17856
  const onError = options.onError || defaultOnError;
17151
17857
  const isModuleMode = options.mode === "module";
17152
17858
  {
@@ -17163,7 +17869,7 @@ function baseCompile(template, options = {}) {
17163
17869
  if (options.scopeId && !isModuleMode) {
17164
17870
  onError(createCompilerError(50));
17165
17871
  }
17166
- const ast = isString(template) ? baseParse(template, options) : template;
17872
+ const ast = isString(source) ? baseParse(source, options) : source;
17167
17873
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
17168
17874
  transform(
17169
17875
  ast,
@@ -17229,25 +17935,22 @@ function decodeHtmlBrowser(raw, asAttr = false) {
17229
17935
  }
17230
17936
  }
17231
17937
 
17232
- const isRawTextContainer = /* @__PURE__ */ makeMap(
17233
- "style,iframe,script,noscript",
17234
- true
17235
- );
17236
17938
  const parserOptions = {
17939
+ parseMode: "html",
17237
17940
  isVoidTag,
17238
17941
  isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
17239
17942
  isPreTag: (tag) => tag === "pre",
17240
17943
  decodeEntities: decodeHtmlBrowser ,
17241
17944
  isBuiltInComponent: (tag) => {
17242
- if (isBuiltInType(tag, `Transition`)) {
17945
+ if (tag === "Transition" || tag === "transition") {
17243
17946
  return TRANSITION;
17244
- } else if (isBuiltInType(tag, `TransitionGroup`)) {
17947
+ } else if (tag === "TransitionGroup" || tag === "transition-group") {
17245
17948
  return TRANSITION_GROUP;
17246
17949
  }
17247
17950
  },
17248
17951
  // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
17249
- getNamespace(tag, parent) {
17250
- let ns = parent ? parent.ns : 0;
17952
+ getNamespace(tag, parent, rootNamespace) {
17953
+ let ns = parent ? parent.ns : rootNamespace;
17251
17954
  if (parent && ns === 2) {
17252
17955
  if (parent.tag === "annotation-xml") {
17253
17956
  if (tag === "svg") {
@@ -17275,18 +17978,6 @@ const parserOptions = {
17275
17978
  }
17276
17979
  }
17277
17980
  return ns;
17278
- },
17279
- // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
17280
- getTextMode({ tag, ns }) {
17281
- if (ns === 0) {
17282
- if (tag === "textarea" || tag === "title") {
17283
- return 1;
17284
- }
17285
- if (isRawTextContainer(tag)) {
17286
- return 2;
17287
- }
17288
- }
17289
- return 0;
17290
17981
  }
17291
17982
  };
17292
17983
 
@@ -17401,8 +18092,8 @@ const transformModel = (dir, node, context) => {
17401
18092
  );
17402
18093
  }
17403
18094
  function checkDuplicatedValue() {
17404
- const value = findProp(node, "value");
17405
- if (value) {
18095
+ const value = findDir(node, "bind");
18096
+ if (value && isStaticArgOf(value.arg, "value")) {
17406
18097
  context.onError(
17407
18098
  createDOMCompilerError(
17408
18099
  60,
@@ -17607,6 +18298,7 @@ const transformTransition = (node, context) => {
17607
18298
  node.props.push({
17608
18299
  type: 6,
17609
18300
  name: "persisted",
18301
+ nameLoc: node.loc,
17610
18302
  value: void 0,
17611
18303
  loc: node.loc
17612
18304
  });
@@ -17651,9 +18343,9 @@ const DOMDirectiveTransforms = {
17651
18343
  // override compiler-core
17652
18344
  show: transformShow
17653
18345
  };
17654
- function compile(template, options = {}) {
18346
+ function compile(src, options = {}) {
17655
18347
  return baseCompile(
17656
- template,
18348
+ src,
17657
18349
  extend({}, parserOptions, options, {
17658
18350
  nodeTransforms: [
17659
18351
  // ignore <script> and <tag>