@vue/runtime-core 3.4.31 → 3.4.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.4.31
2
+ * @vue/runtime-core v3.4.32
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -17,7 +17,10 @@ function pushWarningContext(vnode) {
17
17
  function popWarningContext() {
18
18
  stack.pop();
19
19
  }
20
+ let isWarning = false;
20
21
  function warn$1(msg, ...args) {
22
+ if (isWarning) return;
23
+ isWarning = true;
21
24
  reactivity.pauseTracking();
22
25
  const instance = stack.length ? stack[stack.length - 1].component : null;
23
26
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
@@ -50,6 +53,7 @@ function warn$1(msg, ...args) {
50
53
  console.warn(...warnArgs);
51
54
  }
52
55
  reactivity.resetTracking();
56
+ isWarning = false;
53
57
  }
54
58
  function getComponentTrace() {
55
59
  let currentVNode = stack[stack.length - 1];
@@ -158,7 +162,9 @@ const ErrorCodes = {
158
162
  "ASYNC_COMPONENT_LOADER": 13,
159
163
  "13": "ASYNC_COMPONENT_LOADER",
160
164
  "SCHEDULER": 14,
161
- "14": "SCHEDULER"
165
+ "14": "SCHEDULER",
166
+ "COMPONENT_UPDATE": 15,
167
+ "15": "COMPONENT_UPDATE"
162
168
  };
163
169
  const ErrorTypeStrings$1 = {
164
170
  ["sp"]: "serverPrefetch hook",
@@ -189,7 +195,8 @@ const ErrorTypeStrings$1 = {
189
195
  [11]: "app warnHandler",
190
196
  [12]: "ref function",
191
197
  [13]: "async component loader",
192
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
198
+ [14]: "scheduler flush",
199
+ [15]: "component update"
193
200
  };
194
201
  function callWithErrorHandling(fn, instance, type, args) {
195
202
  try {
@@ -405,7 +412,11 @@ function flushJobs(seen) {
405
412
  if (check(job)) {
406
413
  continue;
407
414
  }
408
- callWithErrorHandling(job, null, 14);
415
+ callWithErrorHandling(
416
+ job,
417
+ job.i,
418
+ job.i ? 15 : 14
419
+ );
409
420
  }
410
421
  }
411
422
  } finally {
@@ -425,7 +436,7 @@ function checkRecursiveUpdates(seen, fn) {
425
436
  } else {
426
437
  const count = seen.get(fn);
427
438
  if (count > RECURSION_LIMIT) {
428
- const instance = fn.ownerInstance;
439
+ const instance = fn.i;
429
440
  const componentName = instance && getComponentName(instance.type);
430
441
  handleError(
431
442
  `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
@@ -440,7 +451,7 @@ function checkRecursiveUpdates(seen, fn) {
440
451
  }
441
452
 
442
453
  let isHmrUpdating = false;
443
- const hmrDirtyComponents = /* @__PURE__ */ new Set();
454
+ const hmrDirtyComponents = /* @__PURE__ */ new Map();
444
455
  {
445
456
  shared.getGlobalThis().__VUE_HMR_RUNTIME__ = {
446
457
  createRecord: tryWrap(createRecord),
@@ -498,26 +509,29 @@ function reload(id, newComp) {
498
509
  newComp = normalizeClassComponent(newComp);
499
510
  updateComponentDef(record.initialDef, newComp);
500
511
  const instances = [...record.instances];
501
- for (const instance of instances) {
512
+ for (let i = 0; i < instances.length; i++) {
513
+ const instance = instances[i];
502
514
  const oldComp = normalizeClassComponent(instance.type);
503
- if (!hmrDirtyComponents.has(oldComp)) {
515
+ let dirtyInstances = hmrDirtyComponents.get(oldComp);
516
+ if (!dirtyInstances) {
504
517
  if (oldComp !== record.initialDef) {
505
518
  updateComponentDef(oldComp, newComp);
506
519
  }
507
- hmrDirtyComponents.add(oldComp);
520
+ hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
508
521
  }
522
+ dirtyInstances.add(instance);
509
523
  instance.appContext.propsCache.delete(instance.type);
510
524
  instance.appContext.emitsCache.delete(instance.type);
511
525
  instance.appContext.optionsCache.delete(instance.type);
512
526
  if (instance.ceReload) {
513
- hmrDirtyComponents.add(oldComp);
527
+ dirtyInstances.add(instance);
514
528
  instance.ceReload(newComp.styles);
515
- hmrDirtyComponents.delete(oldComp);
529
+ dirtyInstances.delete(instance);
516
530
  } else if (instance.parent) {
517
531
  instance.parent.effect.dirty = true;
518
532
  queueJob(() => {
519
533
  instance.parent.update();
520
- hmrDirtyComponents.delete(oldComp);
534
+ dirtyInstances.delete(instance);
521
535
  });
522
536
  } else if (instance.appContext.reload) {
523
537
  instance.appContext.reload();
@@ -530,11 +544,7 @@ function reload(id, newComp) {
530
544
  }
531
545
  }
532
546
  queuePostFlushCb(() => {
533
- for (const instance of instances) {
534
- hmrDirtyComponents.delete(
535
- normalizeClassComponent(instance.type)
536
- );
537
- }
547
+ hmrDirtyComponents.clear();
538
548
  });
539
549
  }
540
550
  function updateComponentDef(oldComp, newComp) {
@@ -658,144 +668,6 @@ function devtoolsComponentEmit(component, event, params) {
658
668
  );
659
669
  }
660
670
 
661
- function emit(instance, event, ...rawArgs) {
662
- if (instance.isUnmounted) return;
663
- const props = instance.vnode.props || shared.EMPTY_OBJ;
664
- {
665
- const {
666
- emitsOptions,
667
- propsOptions: [propsOptions]
668
- } = instance;
669
- if (emitsOptions) {
670
- if (!(event in emitsOptions) && true) {
671
- if (!propsOptions || !(shared.toHandlerKey(event) in propsOptions)) {
672
- warn$1(
673
- `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(event)}" prop.`
674
- );
675
- }
676
- } else {
677
- const validator = emitsOptions[event];
678
- if (shared.isFunction(validator)) {
679
- const isValid = validator(...rawArgs);
680
- if (!isValid) {
681
- warn$1(
682
- `Invalid event arguments: event validation failed for event "${event}".`
683
- );
684
- }
685
- }
686
- }
687
- }
688
- }
689
- let args = rawArgs;
690
- const isModelListener = event.startsWith("update:");
691
- const modelArg = isModelListener && event.slice(7);
692
- if (modelArg && modelArg in props) {
693
- const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
694
- const { number, trim } = props[modifiersKey] || shared.EMPTY_OBJ;
695
- if (trim) {
696
- args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
697
- }
698
- if (number) {
699
- args = rawArgs.map(shared.looseToNumber);
700
- }
701
- }
702
- {
703
- devtoolsComponentEmit(instance, event, args);
704
- }
705
- {
706
- const lowerCaseEvent = event.toLowerCase();
707
- if (lowerCaseEvent !== event && props[shared.toHandlerKey(lowerCaseEvent)]) {
708
- warn$1(
709
- `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
710
- instance,
711
- instance.type
712
- )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${shared.hyphenate(
713
- event
714
- )}" instead of "${event}".`
715
- );
716
- }
717
- }
718
- let handlerName;
719
- let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
720
- props[handlerName = shared.toHandlerKey(shared.camelize(event))];
721
- if (!handler && isModelListener) {
722
- handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
723
- }
724
- if (handler) {
725
- callWithAsyncErrorHandling(
726
- handler,
727
- instance,
728
- 6,
729
- args
730
- );
731
- }
732
- const onceHandler = props[handlerName + `Once`];
733
- if (onceHandler) {
734
- if (!instance.emitted) {
735
- instance.emitted = {};
736
- } else if (instance.emitted[handlerName]) {
737
- return;
738
- }
739
- instance.emitted[handlerName] = true;
740
- callWithAsyncErrorHandling(
741
- onceHandler,
742
- instance,
743
- 6,
744
- args
745
- );
746
- }
747
- }
748
- function normalizeEmitsOptions(comp, appContext, asMixin = false) {
749
- const cache = appContext.emitsCache;
750
- const cached = cache.get(comp);
751
- if (cached !== void 0) {
752
- return cached;
753
- }
754
- const raw = comp.emits;
755
- let normalized = {};
756
- let hasExtends = false;
757
- if (!shared.isFunction(comp)) {
758
- const extendEmits = (raw2) => {
759
- const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
760
- if (normalizedFromExtend) {
761
- hasExtends = true;
762
- shared.extend(normalized, normalizedFromExtend);
763
- }
764
- };
765
- if (!asMixin && appContext.mixins.length) {
766
- appContext.mixins.forEach(extendEmits);
767
- }
768
- if (comp.extends) {
769
- extendEmits(comp.extends);
770
- }
771
- if (comp.mixins) {
772
- comp.mixins.forEach(extendEmits);
773
- }
774
- }
775
- if (!raw && !hasExtends) {
776
- if (shared.isObject(comp)) {
777
- cache.set(comp, null);
778
- }
779
- return null;
780
- }
781
- if (shared.isArray(raw)) {
782
- raw.forEach((key) => normalized[key] = null);
783
- } else {
784
- shared.extend(normalized, raw);
785
- }
786
- if (shared.isObject(comp)) {
787
- cache.set(comp, normalized);
788
- }
789
- return normalized;
790
- }
791
- function isEmitListener(options, key) {
792
- if (!options || !shared.isOn(key)) {
793
- return false;
794
- }
795
- key = key.slice(2).replace(/Once$/, "");
796
- return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
797
- }
798
-
799
671
  let currentRenderingInstance = null;
800
672
  let currentScopeId = null;
801
673
  function setCurrentRenderingInstance(instance) {
@@ -841,941 +713,808 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
841
713
  return renderFnWithContext;
842
714
  }
843
715
 
844
- let accessedAttrs = false;
845
- function markAttrsAccessed() {
846
- accessedAttrs = true;
716
+ function validateDirectiveName(name) {
717
+ if (shared.isBuiltInDirective(name)) {
718
+ warn$1("Do not use built-in directive ids as custom directive id: " + name);
719
+ }
847
720
  }
848
- function renderComponentRoot(instance) {
849
- const {
850
- type: Component,
851
- vnode,
852
- proxy,
853
- withProxy,
854
- propsOptions: [propsOptions],
855
- slots,
856
- attrs,
857
- emit,
858
- render,
859
- renderCache,
860
- props,
861
- data,
862
- setupState,
863
- ctx,
864
- inheritAttrs
865
- } = instance;
866
- const prev = setCurrentRenderingInstance(instance);
867
- let result;
868
- let fallthroughAttrs;
869
- {
870
- accessedAttrs = false;
721
+ function withDirectives(vnode, directives) {
722
+ if (currentRenderingInstance === null) {
723
+ warn$1(`withDirectives can only be used inside render functions.`);
724
+ return vnode;
871
725
  }
872
- try {
873
- if (vnode.shapeFlag & 4) {
874
- const proxyToUse = withProxy || proxy;
875
- const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
876
- get(target, key, receiver) {
877
- warn$1(
878
- `Property '${String(
879
- key
880
- )}' was accessed via 'this'. Avoid using 'this' in templates.`
881
- );
882
- return Reflect.get(target, key, receiver);
883
- }
884
- }) : proxyToUse;
885
- result = normalizeVNode(
886
- render.call(
887
- thisProxy,
888
- proxyToUse,
889
- renderCache,
890
- true ? reactivity.shallowReadonly(props) : props,
891
- setupState,
892
- data,
893
- ctx
894
- )
895
- );
896
- fallthroughAttrs = attrs;
897
- } else {
898
- const render2 = Component;
899
- if (attrs === props) {
900
- markAttrsAccessed();
726
+ const instance = getComponentPublicInstance(currentRenderingInstance);
727
+ const bindings = vnode.dirs || (vnode.dirs = []);
728
+ for (let i = 0; i < directives.length; i++) {
729
+ let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
730
+ if (dir) {
731
+ if (shared.isFunction(dir)) {
732
+ dir = {
733
+ mounted: dir,
734
+ updated: dir
735
+ };
901
736
  }
902
- result = normalizeVNode(
903
- render2.length > 1 ? render2(
904
- true ? reactivity.shallowReadonly(props) : props,
905
- true ? {
906
- get attrs() {
907
- markAttrsAccessed();
908
- return reactivity.shallowReadonly(attrs);
909
- },
910
- slots,
911
- emit
912
- } : { attrs, slots, emit }
913
- ) : render2(
914
- true ? reactivity.shallowReadonly(props) : props,
915
- null
916
- )
917
- );
918
- fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
737
+ if (dir.deep) {
738
+ traverse(value);
739
+ }
740
+ bindings.push({
741
+ dir,
742
+ instance,
743
+ value,
744
+ oldValue: void 0,
745
+ arg,
746
+ modifiers
747
+ });
919
748
  }
920
- } catch (err) {
921
- blockStack.length = 0;
922
- handleError(err, instance, 1);
923
- result = createVNode(Comment);
924
749
  }
925
- let root = result;
926
- let setRoot = void 0;
927
- if (result.patchFlag > 0 && result.patchFlag & 2048) {
928
- [root, setRoot] = getChildRoot(result);
929
- }
930
- if (fallthroughAttrs && inheritAttrs !== false) {
931
- const keys = Object.keys(fallthroughAttrs);
932
- const { shapeFlag } = root;
933
- if (keys.length) {
934
- if (shapeFlag & (1 | 6)) {
935
- if (propsOptions && keys.some(shared.isModelListener)) {
936
- fallthroughAttrs = filterModelListeners(
937
- fallthroughAttrs,
938
- propsOptions
939
- );
940
- }
941
- root = cloneVNode(root, fallthroughAttrs, false, true);
942
- } else if (!accessedAttrs && root.type !== Comment) {
943
- const allAttrs = Object.keys(attrs);
944
- const eventAttrs = [];
945
- const extraAttrs = [];
946
- for (let i = 0, l = allAttrs.length; i < l; i++) {
947
- const key = allAttrs[i];
948
- if (shared.isOn(key)) {
949
- if (!shared.isModelListener(key)) {
950
- eventAttrs.push(key[2].toLowerCase() + key.slice(3));
951
- }
952
- } else {
953
- extraAttrs.push(key);
954
- }
955
- }
956
- if (extraAttrs.length) {
957
- warn$1(
958
- `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
959
- );
960
- }
961
- if (eventAttrs.length) {
962
- warn$1(
963
- `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
964
- );
965
- }
966
- }
967
- }
968
- }
969
- if (vnode.dirs) {
970
- if (!isElementRoot(root)) {
971
- warn$1(
972
- `Runtime directive used on component with non-element root node. The directives will not function as intended.`
973
- );
750
+ return vnode;
751
+ }
752
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
753
+ const bindings = vnode.dirs;
754
+ const oldBindings = prevVNode && prevVNode.dirs;
755
+ for (let i = 0; i < bindings.length; i++) {
756
+ const binding = bindings[i];
757
+ if (oldBindings) {
758
+ binding.oldValue = oldBindings[i].value;
974
759
  }
975
- root = cloneVNode(root, null, false, true);
976
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
977
- }
978
- if (vnode.transition) {
979
- if (!isElementRoot(root)) {
980
- warn$1(
981
- `Component inside <Transition> renders non-element root node that cannot be animated.`
982
- );
760
+ let hook = binding.dir[name];
761
+ if (hook) {
762
+ reactivity.pauseTracking();
763
+ callWithAsyncErrorHandling(hook, instance, 8, [
764
+ vnode.el,
765
+ binding,
766
+ vnode,
767
+ prevVNode
768
+ ]);
769
+ reactivity.resetTracking();
983
770
  }
984
- root.transition = vnode.transition;
985
- }
986
- if (setRoot) {
987
- setRoot(root);
988
- } else {
989
- result = root;
990
771
  }
991
- setCurrentRenderingInstance(prev);
992
- return result;
993
772
  }
994
- const getChildRoot = (vnode) => {
995
- const rawChildren = vnode.children;
996
- const dynamicChildren = vnode.dynamicChildren;
997
- const childRoot = filterSingleRoot(rawChildren, false);
998
- if (!childRoot) {
999
- return [vnode, void 0];
1000
- } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
1001
- return getChildRoot(childRoot);
1002
- }
1003
- const index = rawChildren.indexOf(childRoot);
1004
- const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
1005
- const setRoot = (updatedRoot) => {
1006
- rawChildren[index] = updatedRoot;
1007
- if (dynamicChildren) {
1008
- if (dynamicIndex > -1) {
1009
- dynamicChildren[dynamicIndex] = updatedRoot;
1010
- } else if (updatedRoot.patchFlag > 0) {
1011
- vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
1012
- }
1013
- }
773
+
774
+ const leaveCbKey = Symbol("_leaveCb");
775
+ const enterCbKey = Symbol("_enterCb");
776
+ function useTransitionState() {
777
+ const state = {
778
+ isMounted: false,
779
+ isLeaving: false,
780
+ isUnmounting: false,
781
+ leavingVNodes: /* @__PURE__ */ new Map()
1014
782
  };
1015
- return [normalizeVNode(childRoot), setRoot];
1016
- };
1017
- function filterSingleRoot(children, recurse = true) {
1018
- let singleRoot;
1019
- for (let i = 0; i < children.length; i++) {
1020
- const child = children[i];
1021
- if (isVNode(child)) {
1022
- if (child.type !== Comment || child.children === "v-if") {
1023
- if (singleRoot) {
1024
- return;
1025
- } else {
1026
- singleRoot = child;
1027
- if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
1028
- return filterSingleRoot(singleRoot.children);
1029
- }
1030
- }
1031
- }
1032
- } else {
1033
- return;
1034
- }
1035
- }
1036
- return singleRoot;
783
+ onMounted(() => {
784
+ state.isMounted = true;
785
+ });
786
+ onBeforeUnmount(() => {
787
+ state.isUnmounting = true;
788
+ });
789
+ return state;
1037
790
  }
1038
- const getFunctionalFallthrough = (attrs) => {
1039
- let res;
1040
- for (const key in attrs) {
1041
- if (key === "class" || key === "style" || shared.isOn(key)) {
1042
- (res || (res = {}))[key] = attrs[key];
1043
- }
1044
- }
1045
- return res;
1046
- };
1047
- const filterModelListeners = (attrs, props) => {
1048
- const res = {};
1049
- for (const key in attrs) {
1050
- if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
1051
- res[key] = attrs[key];
1052
- }
1053
- }
1054
- return res;
791
+ const TransitionHookValidator = [Function, Array];
792
+ const BaseTransitionPropsValidators = {
793
+ mode: String,
794
+ appear: Boolean,
795
+ persisted: Boolean,
796
+ // enter
797
+ onBeforeEnter: TransitionHookValidator,
798
+ onEnter: TransitionHookValidator,
799
+ onAfterEnter: TransitionHookValidator,
800
+ onEnterCancelled: TransitionHookValidator,
801
+ // leave
802
+ onBeforeLeave: TransitionHookValidator,
803
+ onLeave: TransitionHookValidator,
804
+ onAfterLeave: TransitionHookValidator,
805
+ onLeaveCancelled: TransitionHookValidator,
806
+ // appear
807
+ onBeforeAppear: TransitionHookValidator,
808
+ onAppear: TransitionHookValidator,
809
+ onAfterAppear: TransitionHookValidator,
810
+ onAppearCancelled: TransitionHookValidator
1055
811
  };
1056
- const isElementRoot = (vnode) => {
1057
- return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
812
+ const recursiveGetSubtree = (instance) => {
813
+ const subTree = instance.subTree;
814
+ return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
1058
815
  };
1059
- function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
1060
- const { props: prevProps, children: prevChildren, component } = prevVNode;
1061
- const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
1062
- const emits = component.emitsOptions;
1063
- if ((prevChildren || nextChildren) && isHmrUpdating) {
1064
- return true;
1065
- }
1066
- if (nextVNode.dirs || nextVNode.transition) {
1067
- return true;
1068
- }
1069
- if (optimized && patchFlag >= 0) {
1070
- if (patchFlag & 1024) {
1071
- return true;
1072
- }
1073
- if (patchFlag & 16) {
1074
- if (!prevProps) {
1075
- return !!nextProps;
816
+ const BaseTransitionImpl = {
817
+ name: `BaseTransition`,
818
+ props: BaseTransitionPropsValidators,
819
+ setup(props, { slots }) {
820
+ const instance = getCurrentInstance();
821
+ const state = useTransitionState();
822
+ return () => {
823
+ const children = slots.default && getTransitionRawChildren(slots.default(), true);
824
+ if (!children || !children.length) {
825
+ return;
1076
826
  }
1077
- return hasPropsChanged(prevProps, nextProps, emits);
1078
- } else if (patchFlag & 8) {
1079
- const dynamicProps = nextVNode.dynamicProps;
1080
- for (let i = 0; i < dynamicProps.length; i++) {
1081
- const key = dynamicProps[i];
1082
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
1083
- return true;
827
+ let child = children[0];
828
+ if (children.length > 1) {
829
+ let hasFound = false;
830
+ for (const c of children) {
831
+ if (c.type !== Comment) {
832
+ if (hasFound) {
833
+ warn$1(
834
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
835
+ );
836
+ break;
837
+ }
838
+ child = c;
839
+ hasFound = true;
840
+ }
1084
841
  }
1085
842
  }
1086
- }
1087
- } else {
1088
- if (prevChildren || nextChildren) {
1089
- if (!nextChildren || !nextChildren.$stable) {
1090
- return true;
843
+ const rawProps = reactivity.toRaw(props);
844
+ const { mode } = rawProps;
845
+ if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
846
+ warn$1(`invalid <transition> mode: ${mode}`);
1091
847
  }
1092
- }
1093
- if (prevProps === nextProps) {
1094
- return false;
1095
- }
1096
- if (!prevProps) {
1097
- return !!nextProps;
1098
- }
1099
- if (!nextProps) {
1100
- return true;
1101
- }
1102
- return hasPropsChanged(prevProps, nextProps, emits);
1103
- }
1104
- return false;
1105
- }
1106
- function hasPropsChanged(prevProps, nextProps, emitsOptions) {
1107
- const nextKeys = Object.keys(nextProps);
1108
- if (nextKeys.length !== Object.keys(prevProps).length) {
1109
- return true;
1110
- }
1111
- for (let i = 0; i < nextKeys.length; i++) {
1112
- const key = nextKeys[i];
1113
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
1114
- return true;
1115
- }
1116
- }
1117
- return false;
1118
- }
1119
- function updateHOCHostEl({ vnode, parent }, el) {
1120
- while (parent) {
1121
- const root = parent.subTree;
1122
- if (root.suspense && root.suspense.activeBranch === vnode) {
1123
- root.el = vnode.el;
1124
- }
1125
- if (root === vnode) {
1126
- (vnode = parent.vnode).el = el;
1127
- parent = parent.parent;
1128
- } else {
1129
- break;
1130
- }
1131
- }
1132
- }
1133
-
1134
- const COMPONENTS = "components";
1135
- const DIRECTIVES = "directives";
1136
- function resolveComponent(name, maybeSelfReference) {
1137
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
1138
- }
1139
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
1140
- function resolveDynamicComponent(component) {
1141
- if (shared.isString(component)) {
1142
- return resolveAsset(COMPONENTS, component, false) || component;
1143
- } else {
1144
- return component || NULL_DYNAMIC_COMPONENT;
1145
- }
1146
- }
1147
- function resolveDirective(name) {
1148
- return resolveAsset(DIRECTIVES, name);
1149
- }
1150
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
1151
- const instance = currentRenderingInstance || currentInstance;
1152
- if (instance) {
1153
- const Component = instance.type;
1154
- if (type === COMPONENTS) {
1155
- const selfName = getComponentName(
1156
- Component,
1157
- false
1158
- );
1159
- if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
1160
- return Component;
848
+ if (state.isLeaving) {
849
+ return emptyPlaceholder(child);
1161
850
  }
1162
- }
1163
- const res = (
1164
- // local registration
1165
- // check instance[type] first which is resolved for options API
1166
- resolve(instance[type] || Component[type], name) || // global registration
1167
- resolve(instance.appContext[type], name)
1168
- );
1169
- if (!res && maybeSelfReference) {
1170
- return Component;
1171
- }
1172
- if (warnMissing && !res) {
1173
- const extra = type === COMPONENTS ? `
1174
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
1175
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
1176
- }
1177
- return res;
1178
- } else {
1179
- warn$1(
1180
- `resolve${shared.capitalize(type.slice(0, -1))} can only be used in render() or setup().`
1181
- );
1182
- }
1183
- }
1184
- function resolve(registry, name) {
1185
- return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
1186
- }
1187
-
1188
- const isSuspense = (type) => type.__isSuspense;
1189
- let suspenseId = 0;
1190
- const SuspenseImpl = {
1191
- name: "Suspense",
1192
- // In order to make Suspense tree-shakable, we need to avoid importing it
1193
- // directly in the renderer. The renderer checks for the __isSuspense flag
1194
- // on a vnode's type and calls the `process` method, passing in renderer
1195
- // internals.
1196
- __isSuspense: true,
1197
- process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
1198
- if (n1 == null) {
1199
- mountSuspense(
1200
- n2,
1201
- container,
1202
- anchor,
1203
- parentComponent,
1204
- parentSuspense,
1205
- namespace,
1206
- slotScopeIds,
1207
- optimized,
1208
- rendererInternals
1209
- );
1210
- } else {
1211
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
1212
- n2.suspense = n1.suspense;
1213
- n2.suspense.vnode = n2;
1214
- n2.el = n1.el;
1215
- return;
851
+ const innerChild = getKeepAliveChild(child);
852
+ if (!innerChild) {
853
+ return emptyPlaceholder(child);
1216
854
  }
1217
- patchSuspense(
1218
- n1,
1219
- n2,
1220
- container,
1221
- anchor,
1222
- parentComponent,
1223
- namespace,
1224
- slotScopeIds,
1225
- optimized,
1226
- rendererInternals
855
+ let enterHooks = resolveTransitionHooks(
856
+ innerChild,
857
+ rawProps,
858
+ state,
859
+ instance,
860
+ // #11061, ensure enterHooks is fresh after clone
861
+ (hooks) => enterHooks = hooks
1227
862
  );
1228
- }
1229
- },
1230
- hydrate: hydrateSuspense,
1231
- normalize: normalizeSuspenseChildren
863
+ setTransitionHooks(innerChild, enterHooks);
864
+ const oldChild = instance.subTree;
865
+ const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
866
+ if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
867
+ const leavingHooks = resolveTransitionHooks(
868
+ oldInnerChild,
869
+ rawProps,
870
+ state,
871
+ instance
872
+ );
873
+ setTransitionHooks(oldInnerChild, leavingHooks);
874
+ if (mode === "out-in" && innerChild.type !== Comment) {
875
+ state.isLeaving = true;
876
+ leavingHooks.afterLeave = () => {
877
+ state.isLeaving = false;
878
+ if (instance.update.active !== false) {
879
+ instance.effect.dirty = true;
880
+ instance.update();
881
+ }
882
+ };
883
+ return emptyPlaceholder(child);
884
+ } else if (mode === "in-out" && innerChild.type !== Comment) {
885
+ leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
886
+ const leavingVNodesCache = getLeavingNodesForType(
887
+ state,
888
+ oldInnerChild
889
+ );
890
+ leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
891
+ el[leaveCbKey] = () => {
892
+ earlyRemove();
893
+ el[leaveCbKey] = void 0;
894
+ delete enterHooks.delayedLeave;
895
+ };
896
+ enterHooks.delayedLeave = delayedLeave;
897
+ };
898
+ }
899
+ }
900
+ return child;
901
+ };
902
+ }
1232
903
  };
1233
- const Suspense = SuspenseImpl ;
1234
- function triggerEvent(vnode, name) {
1235
- const eventListener = vnode.props && vnode.props[name];
1236
- if (shared.isFunction(eventListener)) {
1237
- eventListener();
904
+ const BaseTransition = BaseTransitionImpl;
905
+ function getLeavingNodesForType(state, vnode) {
906
+ const { leavingVNodes } = state;
907
+ let leavingVNodesCache = leavingVNodes.get(vnode.type);
908
+ if (!leavingVNodesCache) {
909
+ leavingVNodesCache = /* @__PURE__ */ Object.create(null);
910
+ leavingVNodes.set(vnode.type, leavingVNodesCache);
1238
911
  }
912
+ return leavingVNodesCache;
1239
913
  }
1240
- function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
914
+ function resolveTransitionHooks(vnode, props, state, instance, postClone) {
1241
915
  const {
1242
- p: patch,
1243
- o: { createElement }
1244
- } = rendererInternals;
1245
- const hiddenContainer = createElement("div");
1246
- const suspense = vnode.suspense = createSuspenseBoundary(
1247
- vnode,
1248
- parentSuspense,
1249
- parentComponent,
1250
- container,
1251
- hiddenContainer,
1252
- anchor,
1253
- namespace,
1254
- slotScopeIds,
1255
- optimized,
1256
- rendererInternals
1257
- );
1258
- patch(
1259
- null,
1260
- suspense.pendingBranch = vnode.ssContent,
1261
- hiddenContainer,
1262
- null,
1263
- parentComponent,
1264
- suspense,
1265
- namespace,
1266
- slotScopeIds
1267
- );
1268
- if (suspense.deps > 0) {
1269
- triggerEvent(vnode, "onPending");
1270
- triggerEvent(vnode, "onFallback");
1271
- patch(
1272
- null,
1273
- vnode.ssFallback,
1274
- container,
1275
- anchor,
1276
- parentComponent,
1277
- null,
1278
- // fallback tree will not have suspense context
1279
- namespace,
1280
- slotScopeIds
916
+ appear,
917
+ mode,
918
+ persisted = false,
919
+ onBeforeEnter,
920
+ onEnter,
921
+ onAfterEnter,
922
+ onEnterCancelled,
923
+ onBeforeLeave,
924
+ onLeave,
925
+ onAfterLeave,
926
+ onLeaveCancelled,
927
+ onBeforeAppear,
928
+ onAppear,
929
+ onAfterAppear,
930
+ onAppearCancelled
931
+ } = props;
932
+ const key = String(vnode.key);
933
+ const leavingVNodesCache = getLeavingNodesForType(state, vnode);
934
+ const callHook = (hook, args) => {
935
+ hook && callWithAsyncErrorHandling(
936
+ hook,
937
+ instance,
938
+ 9,
939
+ args
1281
940
  );
1282
- setActiveBranch(suspense, vnode.ssFallback);
1283
- } else {
1284
- suspense.resolve(false, true);
1285
- }
1286
- }
1287
- function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
1288
- const suspense = n2.suspense = n1.suspense;
1289
- suspense.vnode = n2;
1290
- n2.el = n1.el;
1291
- const newBranch = n2.ssContent;
1292
- const newFallback = n2.ssFallback;
1293
- const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
1294
- if (pendingBranch) {
1295
- suspense.pendingBranch = newBranch;
1296
- if (isSameVNodeType(newBranch, pendingBranch)) {
1297
- patch(
1298
- pendingBranch,
1299
- newBranch,
1300
- suspense.hiddenContainer,
1301
- null,
1302
- parentComponent,
1303
- suspense,
1304
- namespace,
1305
- slotScopeIds,
1306
- optimized
1307
- );
1308
- if (suspense.deps <= 0) {
1309
- suspense.resolve();
1310
- } else if (isInFallback) {
1311
- if (!isHydrating) {
1312
- patch(
1313
- activeBranch,
1314
- newFallback,
1315
- container,
1316
- anchor,
1317
- parentComponent,
1318
- null,
1319
- // fallback tree will not have suspense context
1320
- namespace,
1321
- slotScopeIds,
1322
- optimized
1323
- );
1324
- setActiveBranch(suspense, newFallback);
941
+ };
942
+ const callAsyncHook = (hook, args) => {
943
+ const done = args[1];
944
+ callHook(hook, args);
945
+ if (shared.isArray(hook)) {
946
+ if (hook.every((hook2) => hook2.length <= 1)) done();
947
+ } else if (hook.length <= 1) {
948
+ done();
949
+ }
950
+ };
951
+ const hooks = {
952
+ mode,
953
+ persisted,
954
+ beforeEnter(el) {
955
+ let hook = onBeforeEnter;
956
+ if (!state.isMounted) {
957
+ if (appear) {
958
+ hook = onBeforeAppear || onBeforeEnter;
959
+ } else {
960
+ return;
1325
961
  }
1326
962
  }
1327
- } else {
1328
- suspense.pendingId = suspenseId++;
1329
- if (isHydrating) {
1330
- suspense.isHydrating = false;
1331
- suspense.activeBranch = pendingBranch;
1332
- } else {
1333
- unmount(pendingBranch, parentComponent, suspense);
1334
- }
1335
- suspense.deps = 0;
1336
- suspense.effects.length = 0;
1337
- suspense.hiddenContainer = createElement("div");
1338
- if (isInFallback) {
1339
- patch(
1340
- null,
1341
- newBranch,
1342
- suspense.hiddenContainer,
1343
- null,
1344
- parentComponent,
1345
- suspense,
1346
- namespace,
1347
- slotScopeIds,
1348
- optimized
963
+ if (el[leaveCbKey]) {
964
+ el[leaveCbKey](
965
+ true
966
+ /* cancelled */
1349
967
  );
1350
- if (suspense.deps <= 0) {
1351
- suspense.resolve();
968
+ }
969
+ const leavingVNode = leavingVNodesCache[key];
970
+ if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
971
+ leavingVNode.el[leaveCbKey]();
972
+ }
973
+ callHook(hook, [el]);
974
+ },
975
+ enter(el) {
976
+ let hook = onEnter;
977
+ let afterHook = onAfterEnter;
978
+ let cancelHook = onEnterCancelled;
979
+ if (!state.isMounted) {
980
+ if (appear) {
981
+ hook = onAppear || onEnter;
982
+ afterHook = onAfterAppear || onAfterEnter;
983
+ cancelHook = onAppearCancelled || onEnterCancelled;
1352
984
  } else {
1353
- patch(
1354
- activeBranch,
1355
- newFallback,
1356
- container,
1357
- anchor,
1358
- parentComponent,
1359
- null,
1360
- // fallback tree will not have suspense context
1361
- namespace,
1362
- slotScopeIds,
1363
- optimized
1364
- );
1365
- setActiveBranch(suspense, newFallback);
985
+ return;
1366
986
  }
1367
- } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
1368
- patch(
1369
- activeBranch,
1370
- newBranch,
1371
- container,
1372
- anchor,
1373
- parentComponent,
1374
- suspense,
1375
- namespace,
1376
- slotScopeIds,
1377
- optimized
1378
- );
1379
- suspense.resolve(true);
987
+ }
988
+ let called = false;
989
+ const done = el[enterCbKey] = (cancelled) => {
990
+ if (called) return;
991
+ called = true;
992
+ if (cancelled) {
993
+ callHook(cancelHook, [el]);
994
+ } else {
995
+ callHook(afterHook, [el]);
996
+ }
997
+ if (hooks.delayedLeave) {
998
+ hooks.delayedLeave();
999
+ }
1000
+ el[enterCbKey] = void 0;
1001
+ };
1002
+ if (hook) {
1003
+ callAsyncHook(hook, [el, done]);
1380
1004
  } else {
1381
- patch(
1382
- null,
1383
- newBranch,
1384
- suspense.hiddenContainer,
1385
- null,
1386
- parentComponent,
1387
- suspense,
1388
- namespace,
1389
- slotScopeIds,
1390
- optimized
1005
+ done();
1006
+ }
1007
+ },
1008
+ leave(el, remove) {
1009
+ const key2 = String(vnode.key);
1010
+ if (el[enterCbKey]) {
1011
+ el[enterCbKey](
1012
+ true
1013
+ /* cancelled */
1391
1014
  );
1392
- if (suspense.deps <= 0) {
1393
- suspense.resolve();
1015
+ }
1016
+ if (state.isUnmounting) {
1017
+ return remove();
1018
+ }
1019
+ callHook(onBeforeLeave, [el]);
1020
+ let called = false;
1021
+ const done = el[leaveCbKey] = (cancelled) => {
1022
+ if (called) return;
1023
+ called = true;
1024
+ remove();
1025
+ if (cancelled) {
1026
+ callHook(onLeaveCancelled, [el]);
1027
+ } else {
1028
+ callHook(onAfterLeave, [el]);
1394
1029
  }
1030
+ el[leaveCbKey] = void 0;
1031
+ if (leavingVNodesCache[key2] === vnode) {
1032
+ delete leavingVNodesCache[key2];
1033
+ }
1034
+ };
1035
+ leavingVNodesCache[key2] = vnode;
1036
+ if (onLeave) {
1037
+ callAsyncHook(onLeave, [el, done]);
1038
+ } else {
1039
+ done();
1395
1040
  }
1041
+ },
1042
+ clone(vnode2) {
1043
+ const hooks2 = resolveTransitionHooks(
1044
+ vnode2,
1045
+ props,
1046
+ state,
1047
+ instance,
1048
+ postClone
1049
+ );
1050
+ if (postClone) postClone(hooks2);
1051
+ return hooks2;
1396
1052
  }
1053
+ };
1054
+ return hooks;
1055
+ }
1056
+ function emptyPlaceholder(vnode) {
1057
+ if (isKeepAlive(vnode)) {
1058
+ vnode = cloneVNode(vnode);
1059
+ vnode.children = null;
1060
+ return vnode;
1061
+ }
1062
+ }
1063
+ function getKeepAliveChild(vnode) {
1064
+ if (!isKeepAlive(vnode)) {
1065
+ return vnode;
1066
+ }
1067
+ if (vnode.component) {
1068
+ return vnode.component.subTree;
1069
+ }
1070
+ const { shapeFlag, children } = vnode;
1071
+ if (children) {
1072
+ if (shapeFlag & 16) {
1073
+ return children[0];
1074
+ }
1075
+ if (shapeFlag & 32 && shared.isFunction(children.default)) {
1076
+ return children.default();
1077
+ }
1078
+ }
1079
+ }
1080
+ function setTransitionHooks(vnode, hooks) {
1081
+ if (vnode.shapeFlag & 6 && vnode.component) {
1082
+ setTransitionHooks(vnode.component.subTree, hooks);
1083
+ } else if (vnode.shapeFlag & 128) {
1084
+ vnode.ssContent.transition = hooks.clone(vnode.ssContent);
1085
+ vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
1397
1086
  } else {
1398
- if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
1399
- patch(
1400
- activeBranch,
1401
- newBranch,
1402
- container,
1403
- anchor,
1404
- parentComponent,
1405
- suspense,
1406
- namespace,
1407
- slotScopeIds,
1408
- optimized
1087
+ vnode.transition = hooks;
1088
+ }
1089
+ }
1090
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
1091
+ let ret = [];
1092
+ let keyedFragmentCount = 0;
1093
+ for (let i = 0; i < children.length; i++) {
1094
+ let child = children[i];
1095
+ const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
1096
+ if (child.type === Fragment) {
1097
+ if (child.patchFlag & 128) keyedFragmentCount++;
1098
+ ret = ret.concat(
1099
+ getTransitionRawChildren(child.children, keepComment, key)
1409
1100
  );
1410
- setActiveBranch(suspense, newBranch);
1411
- } else {
1412
- triggerEvent(n2, "onPending");
1413
- suspense.pendingBranch = newBranch;
1414
- if (newBranch.shapeFlag & 512) {
1415
- suspense.pendingId = newBranch.component.suspenseId;
1101
+ } else if (keepComment || child.type !== Comment) {
1102
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
1103
+ }
1104
+ }
1105
+ if (keyedFragmentCount > 1) {
1106
+ for (let i = 0; i < ret.length; i++) {
1107
+ ret[i].patchFlag = -2;
1108
+ }
1109
+ }
1110
+ return ret;
1111
+ }
1112
+
1113
+ /*! #__NO_SIDE_EFFECTS__ */
1114
+ // @__NO_SIDE_EFFECTS__
1115
+ function defineComponent(options, extraOptions) {
1116
+ return shared.isFunction(options) ? (
1117
+ // #8326: extend call and options.name access are considered side-effects
1118
+ // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1119
+ /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
1120
+ ) : options;
1121
+ }
1122
+
1123
+ const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
1124
+ /*! #__NO_SIDE_EFFECTS__ */
1125
+ // @__NO_SIDE_EFFECTS__
1126
+ function defineAsyncComponent(source) {
1127
+ if (shared.isFunction(source)) {
1128
+ source = { loader: source };
1129
+ }
1130
+ const {
1131
+ loader,
1132
+ loadingComponent,
1133
+ errorComponent,
1134
+ delay = 200,
1135
+ timeout,
1136
+ // undefined = never times out
1137
+ suspensible = true,
1138
+ onError: userOnError
1139
+ } = source;
1140
+ let pendingRequest = null;
1141
+ let resolvedComp;
1142
+ let retries = 0;
1143
+ const retry = () => {
1144
+ retries++;
1145
+ pendingRequest = null;
1146
+ return load();
1147
+ };
1148
+ const load = () => {
1149
+ let thisRequest;
1150
+ return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
1151
+ err = err instanceof Error ? err : new Error(String(err));
1152
+ if (userOnError) {
1153
+ return new Promise((resolve, reject) => {
1154
+ const userRetry = () => resolve(retry());
1155
+ const userFail = () => reject(err);
1156
+ userOnError(err, userRetry, userFail, retries + 1);
1157
+ });
1416
1158
  } else {
1417
- suspense.pendingId = suspenseId++;
1159
+ throw err;
1160
+ }
1161
+ }).then((comp) => {
1162
+ if (thisRequest !== pendingRequest && pendingRequest) {
1163
+ return pendingRequest;
1164
+ }
1165
+ if (!comp) {
1166
+ warn$1(
1167
+ `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
1168
+ );
1169
+ }
1170
+ if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
1171
+ comp = comp.default;
1172
+ }
1173
+ if (comp && !shared.isObject(comp) && !shared.isFunction(comp)) {
1174
+ throw new Error(`Invalid async component load result: ${comp}`);
1175
+ }
1176
+ resolvedComp = comp;
1177
+ return comp;
1178
+ }));
1179
+ };
1180
+ return defineComponent({
1181
+ name: "AsyncComponentWrapper",
1182
+ __asyncLoader: load,
1183
+ get __asyncResolved() {
1184
+ return resolvedComp;
1185
+ },
1186
+ setup() {
1187
+ const instance = currentInstance;
1188
+ if (resolvedComp) {
1189
+ return () => createInnerComp(resolvedComp, instance);
1190
+ }
1191
+ const onError = (err) => {
1192
+ pendingRequest = null;
1193
+ handleError(
1194
+ err,
1195
+ instance,
1196
+ 13,
1197
+ !errorComponent
1198
+ );
1199
+ };
1200
+ if (suspensible && instance.suspense || isInSSRComponentSetup) {
1201
+ return load().then((comp) => {
1202
+ return () => createInnerComp(comp, instance);
1203
+ }).catch((err) => {
1204
+ onError(err);
1205
+ return () => errorComponent ? createVNode(errorComponent, {
1206
+ error: err
1207
+ }) : null;
1208
+ });
1209
+ }
1210
+ const loaded = reactivity.ref(false);
1211
+ const error = reactivity.ref();
1212
+ const delayed = reactivity.ref(!!delay);
1213
+ if (delay) {
1214
+ setTimeout(() => {
1215
+ delayed.value = false;
1216
+ }, delay);
1217
+ }
1218
+ if (timeout != null) {
1219
+ setTimeout(() => {
1220
+ if (!loaded.value && !error.value) {
1221
+ const err = new Error(
1222
+ `Async component timed out after ${timeout}ms.`
1223
+ );
1224
+ onError(err);
1225
+ error.value = err;
1226
+ }
1227
+ }, timeout);
1228
+ }
1229
+ load().then(() => {
1230
+ loaded.value = true;
1231
+ if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1232
+ instance.parent.effect.dirty = true;
1233
+ queueJob(instance.parent.update);
1234
+ }
1235
+ }).catch((err) => {
1236
+ onError(err);
1237
+ error.value = err;
1238
+ });
1239
+ return () => {
1240
+ if (loaded.value && resolvedComp) {
1241
+ return createInnerComp(resolvedComp, instance);
1242
+ } else if (error.value && errorComponent) {
1243
+ return createVNode(errorComponent, {
1244
+ error: error.value
1245
+ });
1246
+ } else if (loadingComponent && !delayed.value) {
1247
+ return createVNode(loadingComponent);
1248
+ }
1249
+ };
1250
+ }
1251
+ });
1252
+ }
1253
+ function createInnerComp(comp, parent) {
1254
+ const { ref: ref2, props, children, ce } = parent.vnode;
1255
+ const vnode = createVNode(comp, props, children);
1256
+ vnode.ref = ref2;
1257
+ vnode.ce = ce;
1258
+ delete parent.vnode.ce;
1259
+ return vnode;
1260
+ }
1261
+
1262
+ const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
1263
+ const KeepAliveImpl = {
1264
+ name: `KeepAlive`,
1265
+ // Marker for special handling inside the renderer. We are not using a ===
1266
+ // check directly on KeepAlive in the renderer, because importing it directly
1267
+ // would prevent it from being tree-shaken.
1268
+ __isKeepAlive: true,
1269
+ props: {
1270
+ include: [String, RegExp, Array],
1271
+ exclude: [String, RegExp, Array],
1272
+ max: [String, Number]
1273
+ },
1274
+ setup(props, { slots }) {
1275
+ const instance = getCurrentInstance();
1276
+ const sharedContext = instance.ctx;
1277
+ if (!sharedContext.renderer) {
1278
+ return () => {
1279
+ const children = slots.default && slots.default();
1280
+ return children && children.length === 1 ? children[0] : children;
1281
+ };
1282
+ }
1283
+ const cache = /* @__PURE__ */ new Map();
1284
+ const keys = /* @__PURE__ */ new Set();
1285
+ let current = null;
1286
+ {
1287
+ instance.__v_cache = cache;
1288
+ }
1289
+ const parentSuspense = instance.suspense;
1290
+ const {
1291
+ renderer: {
1292
+ p: patch,
1293
+ m: move,
1294
+ um: _unmount,
1295
+ o: { createElement }
1418
1296
  }
1297
+ } = sharedContext;
1298
+ const storageContainer = createElement("div");
1299
+ sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
1300
+ const instance2 = vnode.component;
1301
+ move(vnode, container, anchor, 0, parentSuspense);
1419
1302
  patch(
1420
- null,
1421
- newBranch,
1422
- suspense.hiddenContainer,
1423
- null,
1424
- parentComponent,
1425
- suspense,
1303
+ instance2.vnode,
1304
+ vnode,
1305
+ container,
1306
+ anchor,
1307
+ instance2,
1308
+ parentSuspense,
1426
1309
  namespace,
1427
- slotScopeIds,
1310
+ vnode.slotScopeIds,
1428
1311
  optimized
1429
1312
  );
1430
- if (suspense.deps <= 0) {
1431
- suspense.resolve();
1432
- } else {
1433
- const { timeout, pendingId } = suspense;
1434
- if (timeout > 0) {
1435
- setTimeout(() => {
1436
- if (suspense.pendingId === pendingId) {
1437
- suspense.fallback(newFallback);
1438
- }
1439
- }, timeout);
1440
- } else if (timeout === 0) {
1441
- suspense.fallback(newFallback);
1442
- }
1443
- }
1444
- }
1445
- }
1446
- }
1447
- let hasWarned = false;
1448
- function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
1449
- if (!hasWarned) {
1450
- hasWarned = true;
1451
- console[console.info ? "info" : "log"](
1452
- `<Suspense> is an experimental feature and its API will likely change.`
1453
- );
1454
- }
1455
- const {
1456
- p: patch,
1457
- m: move,
1458
- um: unmount,
1459
- n: next,
1460
- o: { parentNode, remove }
1461
- } = rendererInternals;
1462
- let parentSuspenseId;
1463
- const isSuspensible = isVNodeSuspensible(vnode);
1464
- if (isSuspensible) {
1465
- if (parentSuspense && parentSuspense.pendingBranch) {
1466
- parentSuspenseId = parentSuspense.pendingId;
1467
- parentSuspense.deps++;
1468
- }
1469
- }
1470
- const timeout = vnode.props ? shared.toNumber(vnode.props.timeout) : void 0;
1471
- {
1472
- assertNumber(timeout, `Suspense timeout`);
1473
- }
1474
- const initialAnchor = anchor;
1475
- const suspense = {
1476
- vnode,
1477
- parent: parentSuspense,
1478
- parentComponent,
1479
- namespace,
1480
- container,
1481
- hiddenContainer,
1482
- deps: 0,
1483
- pendingId: suspenseId++,
1484
- timeout: typeof timeout === "number" ? timeout : -1,
1485
- activeBranch: null,
1486
- pendingBranch: null,
1487
- isInFallback: !isHydrating,
1488
- isHydrating,
1489
- isUnmounted: false,
1490
- effects: [],
1491
- resolve(resume = false, sync = false) {
1492
- {
1493
- if (!resume && !suspense.pendingBranch) {
1494
- throw new Error(
1495
- `suspense.resolve() is called without a pending branch.`
1496
- );
1497
- }
1498
- if (suspense.isUnmounted) {
1499
- throw new Error(
1500
- `suspense.resolve() is called on an already unmounted suspense boundary.`
1501
- );
1502
- }
1503
- }
1504
- const {
1505
- vnode: vnode2,
1506
- activeBranch,
1507
- pendingBranch,
1508
- pendingId,
1509
- effects,
1510
- parentComponent: parentComponent2,
1511
- container: container2
1512
- } = suspense;
1513
- let delayEnter = false;
1514
- if (suspense.isHydrating) {
1515
- suspense.isHydrating = false;
1516
- } else if (!resume) {
1517
- delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
1518
- if (delayEnter) {
1519
- activeBranch.transition.afterLeave = () => {
1520
- if (pendingId === suspense.pendingId) {
1521
- move(
1522
- pendingBranch,
1523
- container2,
1524
- anchor === initialAnchor ? next(activeBranch) : anchor,
1525
- 0
1526
- );
1527
- queuePostFlushCb(effects);
1528
- }
1529
- };
1530
- }
1531
- if (activeBranch) {
1532
- if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
1533
- anchor = next(activeBranch);
1534
- }
1535
- unmount(activeBranch, parentComponent2, suspense, true);
1313
+ queuePostRenderEffect(() => {
1314
+ instance2.isDeactivated = false;
1315
+ if (instance2.a) {
1316
+ shared.invokeArrayFns(instance2.a);
1536
1317
  }
1537
- if (!delayEnter) {
1538
- move(pendingBranch, container2, anchor, 0);
1318
+ const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
1319
+ if (vnodeHook) {
1320
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1539
1321
  }
1322
+ }, parentSuspense);
1323
+ {
1324
+ devtoolsComponentAdded(instance2);
1540
1325
  }
1541
- setActiveBranch(suspense, pendingBranch);
1542
- suspense.pendingBranch = null;
1543
- suspense.isInFallback = false;
1544
- let parent = suspense.parent;
1545
- let hasUnresolvedAncestor = false;
1546
- while (parent) {
1547
- if (parent.pendingBranch) {
1548
- parent.effects.push(...effects);
1549
- hasUnresolvedAncestor = true;
1550
- break;
1326
+ };
1327
+ sharedContext.deactivate = (vnode) => {
1328
+ const instance2 = vnode.component;
1329
+ invalidateMount(instance2.m);
1330
+ invalidateMount(instance2.a);
1331
+ move(vnode, storageContainer, null, 1, parentSuspense);
1332
+ queuePostRenderEffect(() => {
1333
+ if (instance2.da) {
1334
+ shared.invokeArrayFns(instance2.da);
1551
1335
  }
1552
- parent = parent.parent;
1553
- }
1554
- if (!hasUnresolvedAncestor && !delayEnter) {
1555
- queuePostFlushCb(effects);
1556
- }
1557
- suspense.effects = [];
1558
- if (isSuspensible) {
1559
- if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
1560
- parentSuspense.deps--;
1561
- if (parentSuspense.deps === 0 && !sync) {
1562
- parentSuspense.resolve();
1563
- }
1336
+ const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
1337
+ if (vnodeHook) {
1338
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1564
1339
  }
1340
+ instance2.isDeactivated = true;
1341
+ }, parentSuspense);
1342
+ {
1343
+ devtoolsComponentAdded(instance2);
1565
1344
  }
1566
- triggerEvent(vnode2, "onResolve");
1567
- },
1568
- fallback(fallbackVNode) {
1569
- if (!suspense.pendingBranch) {
1570
- return;
1571
- }
1572
- const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
1573
- triggerEvent(vnode2, "onFallback");
1574
- const anchor2 = next(activeBranch);
1575
- const mountFallback = () => {
1576
- if (!suspense.isInFallback) {
1577
- return;
1345
+ };
1346
+ function unmount(vnode) {
1347
+ resetShapeFlag(vnode);
1348
+ _unmount(vnode, instance, parentSuspense, true);
1349
+ }
1350
+ function pruneCache(filter) {
1351
+ cache.forEach((vnode, key) => {
1352
+ const name = getComponentName(vnode.type);
1353
+ if (name && (!filter || !filter(name))) {
1354
+ pruneCacheEntry(key);
1578
1355
  }
1579
- patch(
1580
- null,
1581
- fallbackVNode,
1582
- container2,
1583
- anchor2,
1584
- parentComponent2,
1585
- null,
1586
- // fallback tree will not have suspense context
1587
- namespace2,
1588
- slotScopeIds,
1589
- optimized
1590
- );
1591
- setActiveBranch(suspense, fallbackVNode);
1592
- };
1593
- const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
1594
- if (delayEnter) {
1595
- activeBranch.transition.afterLeave = mountFallback;
1596
- }
1597
- suspense.isInFallback = true;
1598
- unmount(
1599
- activeBranch,
1600
- parentComponent2,
1601
- null,
1602
- // no suspense so unmount hooks fire now
1603
- true
1604
- // shouldRemove
1605
- );
1606
- if (!delayEnter) {
1607
- mountFallback();
1356
+ });
1357
+ }
1358
+ function pruneCacheEntry(key) {
1359
+ const cached = cache.get(key);
1360
+ if (!current || !isSameVNodeType(cached, current)) {
1361
+ unmount(cached);
1362
+ } else if (current) {
1363
+ resetShapeFlag(current);
1608
1364
  }
1609
- },
1610
- move(container2, anchor2, type) {
1611
- suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
1612
- suspense.container = container2;
1613
- },
1614
- next() {
1615
- return suspense.activeBranch && next(suspense.activeBranch);
1616
- },
1617
- registerDep(instance, setupRenderEffect, optimized2) {
1618
- const isInPendingSuspense = !!suspense.pendingBranch;
1619
- if (isInPendingSuspense) {
1620
- suspense.deps++;
1365
+ cache.delete(key);
1366
+ keys.delete(key);
1367
+ }
1368
+ watch(
1369
+ () => [props.include, props.exclude],
1370
+ ([include, exclude]) => {
1371
+ include && pruneCache((name) => matches(include, name));
1372
+ exclude && pruneCache((name) => !matches(exclude, name));
1373
+ },
1374
+ // prune post-render after `current` has been updated
1375
+ { flush: "post", deep: true }
1376
+ );
1377
+ let pendingCacheKey = null;
1378
+ const cacheSubtree = () => {
1379
+ if (pendingCacheKey != null) {
1380
+ if (isSuspense(instance.subTree.type)) {
1381
+ queuePostRenderEffect(() => {
1382
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1383
+ }, instance.subTree.suspense);
1384
+ } else {
1385
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1386
+ }
1621
1387
  }
1622
- const hydratedEl = instance.vnode.el;
1623
- instance.asyncDep.catch((err) => {
1624
- handleError(err, instance, 0);
1625
- }).then((asyncSetupResult) => {
1626
- if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
1388
+ };
1389
+ onMounted(cacheSubtree);
1390
+ onUpdated(cacheSubtree);
1391
+ onBeforeUnmount(() => {
1392
+ cache.forEach((cached) => {
1393
+ const { subTree, suspense } = instance;
1394
+ const vnode = getInnerChild(subTree);
1395
+ if (cached.type === vnode.type && cached.key === vnode.key) {
1396
+ resetShapeFlag(vnode);
1397
+ const da = vnode.component.da;
1398
+ da && queuePostRenderEffect(da, suspense);
1627
1399
  return;
1628
1400
  }
1629
- instance.asyncResolved = true;
1630
- const { vnode: vnode2 } = instance;
1401
+ unmount(cached);
1402
+ });
1403
+ });
1404
+ return () => {
1405
+ pendingCacheKey = null;
1406
+ if (!slots.default) {
1407
+ return null;
1408
+ }
1409
+ const children = slots.default();
1410
+ const rawVNode = children[0];
1411
+ if (children.length > 1) {
1631
1412
  {
1632
- pushWarningContext(vnode2);
1633
- }
1634
- handleSetupResult(instance, asyncSetupResult, false);
1635
- if (hydratedEl) {
1636
- vnode2.el = hydratedEl;
1413
+ warn$1(`KeepAlive should contain exactly one component child.`);
1637
1414
  }
1638
- const placeholder = !hydratedEl && instance.subTree.el;
1639
- setupRenderEffect(
1640
- instance,
1641
- vnode2,
1642
- // component may have been moved before resolve.
1643
- // if this is not a hydration, instance.subTree will be the comment
1644
- // placeholder.
1645
- parentNode(hydratedEl || instance.subTree.el),
1646
- // anchor will not be used if this is hydration, so only need to
1647
- // consider the comment placeholder case.
1648
- hydratedEl ? null : next(instance.subTree),
1649
- suspense,
1650
- namespace,
1651
- optimized2
1652
- );
1653
- if (placeholder) {
1654
- remove(placeholder);
1415
+ current = null;
1416
+ return children;
1417
+ } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
1418
+ current = null;
1419
+ return rawVNode;
1420
+ }
1421
+ let vnode = getInnerChild(rawVNode);
1422
+ const comp = vnode.type;
1423
+ const name = getComponentName(
1424
+ isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
1425
+ );
1426
+ const { include, exclude, max } = props;
1427
+ if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
1428
+ current = vnode;
1429
+ return rawVNode;
1430
+ }
1431
+ const key = vnode.key == null ? comp : vnode.key;
1432
+ const cachedVNode = cache.get(key);
1433
+ if (vnode.el) {
1434
+ vnode = cloneVNode(vnode);
1435
+ if (rawVNode.shapeFlag & 128) {
1436
+ rawVNode.ssContent = vnode;
1655
1437
  }
1656
- updateHOCHostEl(instance, vnode2.el);
1657
- {
1658
- popWarningContext();
1438
+ }
1439
+ pendingCacheKey = key;
1440
+ if (cachedVNode) {
1441
+ vnode.el = cachedVNode.el;
1442
+ vnode.component = cachedVNode.component;
1443
+ if (vnode.transition) {
1444
+ setTransitionHooks(vnode, vnode.transition);
1659
1445
  }
1660
- if (isInPendingSuspense && --suspense.deps === 0) {
1661
- suspense.resolve();
1446
+ vnode.shapeFlag |= 512;
1447
+ keys.delete(key);
1448
+ keys.add(key);
1449
+ } else {
1450
+ keys.add(key);
1451
+ if (max && keys.size > parseInt(max, 10)) {
1452
+ pruneCacheEntry(keys.values().next().value);
1662
1453
  }
1663
- });
1664
- },
1665
- unmount(parentSuspense2, doRemove) {
1666
- suspense.isUnmounted = true;
1667
- if (suspense.activeBranch) {
1668
- unmount(
1669
- suspense.activeBranch,
1670
- parentComponent,
1671
- parentSuspense2,
1672
- doRemove
1673
- );
1674
- }
1675
- if (suspense.pendingBranch) {
1676
- unmount(
1677
- suspense.pendingBranch,
1678
- parentComponent,
1679
- parentSuspense2,
1680
- doRemove
1681
- );
1682
1454
  }
1683
- }
1684
- };
1685
- return suspense;
1686
- }
1687
- function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
1688
- const suspense = vnode.suspense = createSuspenseBoundary(
1689
- vnode,
1690
- parentSuspense,
1691
- parentComponent,
1692
- node.parentNode,
1693
- // eslint-disable-next-line no-restricted-globals
1694
- document.createElement("div"),
1695
- null,
1696
- namespace,
1697
- slotScopeIds,
1698
- optimized,
1699
- rendererInternals,
1700
- true
1701
- );
1702
- const result = hydrateNode(
1703
- node,
1704
- suspense.pendingBranch = vnode.ssContent,
1705
- parentComponent,
1706
- suspense,
1707
- slotScopeIds,
1708
- optimized
1709
- );
1710
- if (suspense.deps === 0) {
1711
- suspense.resolve(false, true);
1455
+ vnode.shapeFlag |= 256;
1456
+ current = vnode;
1457
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
1458
+ };
1712
1459
  }
1713
- return result;
1460
+ };
1461
+ const KeepAlive = KeepAliveImpl;
1462
+ function matches(pattern, name) {
1463
+ if (shared.isArray(pattern)) {
1464
+ return pattern.some((p) => matches(p, name));
1465
+ } else if (shared.isString(pattern)) {
1466
+ return pattern.split(",").includes(name);
1467
+ } else if (shared.isRegExp(pattern)) {
1468
+ return pattern.test(name);
1469
+ }
1470
+ return false;
1714
1471
  }
1715
- function normalizeSuspenseChildren(vnode) {
1716
- const { shapeFlag, children } = vnode;
1717
- const isSlotChildren = shapeFlag & 32;
1718
- vnode.ssContent = normalizeSuspenseSlot(
1719
- isSlotChildren ? children.default : children
1720
- );
1721
- vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
1472
+ function onActivated(hook, target) {
1473
+ registerKeepAliveHook(hook, "a", target);
1722
1474
  }
1723
- function normalizeSuspenseSlot(s) {
1724
- let block;
1725
- if (shared.isFunction(s)) {
1726
- const trackBlock = isBlockTreeEnabled && s._c;
1727
- if (trackBlock) {
1728
- s._d = false;
1729
- openBlock();
1730
- }
1731
- s = s();
1732
- if (trackBlock) {
1733
- s._d = true;
1734
- block = currentBlock;
1735
- closeBlock();
1736
- }
1737
- }
1738
- if (shared.isArray(s)) {
1739
- const singleChild = filterSingleRoot(s);
1740
- if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
1741
- warn$1(`<Suspense> slots expect a single root node.`);
1742
- }
1743
- s = singleChild;
1744
- }
1745
- s = normalizeVNode(s);
1746
- if (block && !s.dynamicChildren) {
1747
- s.dynamicChildren = block.filter((c) => c !== s);
1748
- }
1749
- return s;
1475
+ function onDeactivated(hook, target) {
1476
+ registerKeepAliveHook(hook, "da", target);
1750
1477
  }
1751
- function queueEffectWithSuspense(fn, suspense) {
1752
- if (suspense && suspense.pendingBranch) {
1753
- if (shared.isArray(fn)) {
1754
- suspense.effects.push(...fn);
1755
- } else {
1756
- suspense.effects.push(fn);
1478
+ function registerKeepAliveHook(hook, type, target = currentInstance) {
1479
+ const wrappedHook = hook.__wdc || (hook.__wdc = () => {
1480
+ let current = target;
1481
+ while (current) {
1482
+ if (current.isDeactivated) {
1483
+ return;
1484
+ }
1485
+ current = current.parent;
1486
+ }
1487
+ return hook();
1488
+ });
1489
+ injectHook(type, wrappedHook, target);
1490
+ if (target) {
1491
+ let current = target.parent;
1492
+ while (current && current.parent) {
1493
+ if (isKeepAlive(current.parent.vnode)) {
1494
+ injectToKeepAliveRoot(wrappedHook, type, target, current);
1495
+ }
1496
+ current = current.parent;
1757
1497
  }
1758
- } else {
1759
- queuePostFlushCb(fn);
1760
1498
  }
1761
1499
  }
1762
- function setActiveBranch(suspense, branch) {
1763
- suspense.activeBranch = branch;
1764
- const { vnode, parentComponent } = suspense;
1765
- let el = branch.el;
1766
- while (!el && branch.component) {
1767
- branch = branch.component.subTree;
1768
- el = branch.el;
1769
- }
1770
- vnode.el = el;
1771
- if (parentComponent && parentComponent.subTree === vnode) {
1772
- parentComponent.vnode.el = el;
1773
- updateHOCHostEl(parentComponent, el);
1774
- }
1500
+ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
1501
+ const injected = injectHook(
1502
+ type,
1503
+ hook,
1504
+ keepAliveRoot,
1505
+ true
1506
+ /* prepend */
1507
+ );
1508
+ onUnmounted(() => {
1509
+ shared.remove(keepAliveRoot[type], injected);
1510
+ }, target);
1775
1511
  }
1776
- function isVNodeSuspensible(vnode) {
1777
- const suspensible = vnode.props && vnode.props.suspensible;
1778
- return suspensible != null && suspensible !== false;
1512
+ function resetShapeFlag(vnode) {
1513
+ vnode.shapeFlag &= ~256;
1514
+ vnode.shapeFlag &= ~512;
1515
+ }
1516
+ function getInnerChild(vnode) {
1517
+ return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
1779
1518
  }
1780
1519
 
1781
1520
  function injectHook(type, hook, target = currentInstance, prepend = false) {
@@ -1824,63 +1563,59 @@ function onErrorCaptured(hook, target = currentInstance) {
1824
1563
  injectHook("ec", hook, target);
1825
1564
  }
1826
1565
 
1827
- function validateDirectiveName(name) {
1828
- if (shared.isBuiltInDirective(name)) {
1829
- warn$1("Do not use built-in directive ids as custom directive id: " + name);
1830
- }
1566
+ const COMPONENTS = "components";
1567
+ const DIRECTIVES = "directives";
1568
+ function resolveComponent(name, maybeSelfReference) {
1569
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
1831
1570
  }
1832
- function withDirectives(vnode, directives) {
1833
- if (currentRenderingInstance === null) {
1834
- warn$1(`withDirectives can only be used inside render functions.`);
1835
- return vnode;
1571
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
1572
+ function resolveDynamicComponent(component) {
1573
+ if (shared.isString(component)) {
1574
+ return resolveAsset(COMPONENTS, component, false) || component;
1575
+ } else {
1576
+ return component || NULL_DYNAMIC_COMPONENT;
1836
1577
  }
1837
- const instance = getComponentPublicInstance(currentRenderingInstance);
1838
- const bindings = vnode.dirs || (vnode.dirs = []);
1839
- for (let i = 0; i < directives.length; i++) {
1840
- let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
1841
- if (dir) {
1842
- if (shared.isFunction(dir)) {
1843
- dir = {
1844
- mounted: dir,
1845
- updated: dir
1846
- };
1847
- }
1848
- if (dir.deep) {
1849
- traverse(value);
1578
+ }
1579
+ function resolveDirective(name) {
1580
+ return resolveAsset(DIRECTIVES, name);
1581
+ }
1582
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
1583
+ const instance = currentRenderingInstance || currentInstance;
1584
+ if (instance) {
1585
+ const Component = instance.type;
1586
+ if (type === COMPONENTS) {
1587
+ const selfName = getComponentName(
1588
+ Component,
1589
+ false
1590
+ );
1591
+ if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
1592
+ return Component;
1850
1593
  }
1851
- bindings.push({
1852
- dir,
1853
- instance,
1854
- value,
1855
- oldValue: void 0,
1856
- arg,
1857
- modifiers
1858
- });
1859
1594
  }
1860
- }
1861
- return vnode;
1862
- }
1863
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
1864
- const bindings = vnode.dirs;
1865
- const oldBindings = prevVNode && prevVNode.dirs;
1866
- for (let i = 0; i < bindings.length; i++) {
1867
- const binding = bindings[i];
1868
- if (oldBindings) {
1869
- binding.oldValue = oldBindings[i].value;
1595
+ const res = (
1596
+ // local registration
1597
+ // check instance[type] first which is resolved for options API
1598
+ resolve(instance[type] || Component[type], name) || // global registration
1599
+ resolve(instance.appContext[type], name)
1600
+ );
1601
+ if (!res && maybeSelfReference) {
1602
+ return Component;
1870
1603
  }
1871
- let hook = binding.dir[name];
1872
- if (hook) {
1873
- reactivity.pauseTracking();
1874
- callWithAsyncErrorHandling(hook, instance, 8, [
1875
- vnode.el,
1876
- binding,
1877
- vnode,
1878
- prevVNode
1879
- ]);
1880
- reactivity.resetTracking();
1604
+ if (warnMissing && !res) {
1605
+ const extra = type === COMPONENTS ? `
1606
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
1607
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
1881
1608
  }
1609
+ return res;
1610
+ } else {
1611
+ warn$1(
1612
+ `resolve${shared.capitalize(type.slice(0, -1))} can only be used in render() or setup().`
1613
+ );
1882
1614
  }
1883
1615
  }
1616
+ function resolve(registry, name) {
1617
+ return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
1618
+ }
1884
1619
 
1885
1620
  function renderList(source, renderItem, cache, index) {
1886
1621
  let ret;
@@ -1935,157 +1670,8 @@ function createSlots(slots, dynamicSlots) {
1935
1670
  return res;
1936
1671
  } : slot.fn;
1937
1672
  }
1938
- }
1939
- return slots;
1940
- }
1941
-
1942
- /*! #__NO_SIDE_EFFECTS__ */
1943
- // @__NO_SIDE_EFFECTS__
1944
- function defineComponent(options, extraOptions) {
1945
- return shared.isFunction(options) ? (
1946
- // #8326: extend call and options.name access are considered side-effects
1947
- // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1948
- /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
1949
- ) : options;
1950
- }
1951
-
1952
- const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
1953
- /*! #__NO_SIDE_EFFECTS__ */
1954
- // @__NO_SIDE_EFFECTS__
1955
- function defineAsyncComponent(source) {
1956
- if (shared.isFunction(source)) {
1957
- source = { loader: source };
1958
- }
1959
- const {
1960
- loader,
1961
- loadingComponent,
1962
- errorComponent,
1963
- delay = 200,
1964
- timeout,
1965
- // undefined = never times out
1966
- suspensible = true,
1967
- onError: userOnError
1968
- } = source;
1969
- let pendingRequest = null;
1970
- let resolvedComp;
1971
- let retries = 0;
1972
- const retry = () => {
1973
- retries++;
1974
- pendingRequest = null;
1975
- return load();
1976
- };
1977
- const load = () => {
1978
- let thisRequest;
1979
- return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
1980
- err = err instanceof Error ? err : new Error(String(err));
1981
- if (userOnError) {
1982
- return new Promise((resolve, reject) => {
1983
- const userRetry = () => resolve(retry());
1984
- const userFail = () => reject(err);
1985
- userOnError(err, userRetry, userFail, retries + 1);
1986
- });
1987
- } else {
1988
- throw err;
1989
- }
1990
- }).then((comp) => {
1991
- if (thisRequest !== pendingRequest && pendingRequest) {
1992
- return pendingRequest;
1993
- }
1994
- if (!comp) {
1995
- warn$1(
1996
- `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
1997
- );
1998
- }
1999
- if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
2000
- comp = comp.default;
2001
- }
2002
- if (comp && !shared.isObject(comp) && !shared.isFunction(comp)) {
2003
- throw new Error(`Invalid async component load result: ${comp}`);
2004
- }
2005
- resolvedComp = comp;
2006
- return comp;
2007
- }));
2008
- };
2009
- return defineComponent({
2010
- name: "AsyncComponentWrapper",
2011
- __asyncLoader: load,
2012
- get __asyncResolved() {
2013
- return resolvedComp;
2014
- },
2015
- setup() {
2016
- const instance = currentInstance;
2017
- if (resolvedComp) {
2018
- return () => createInnerComp(resolvedComp, instance);
2019
- }
2020
- const onError = (err) => {
2021
- pendingRequest = null;
2022
- handleError(
2023
- err,
2024
- instance,
2025
- 13,
2026
- !errorComponent
2027
- );
2028
- };
2029
- if (suspensible && instance.suspense || isInSSRComponentSetup) {
2030
- return load().then((comp) => {
2031
- return () => createInnerComp(comp, instance);
2032
- }).catch((err) => {
2033
- onError(err);
2034
- return () => errorComponent ? createVNode(errorComponent, {
2035
- error: err
2036
- }) : null;
2037
- });
2038
- }
2039
- const loaded = reactivity.ref(false);
2040
- const error = reactivity.ref();
2041
- const delayed = reactivity.ref(!!delay);
2042
- if (delay) {
2043
- setTimeout(() => {
2044
- delayed.value = false;
2045
- }, delay);
2046
- }
2047
- if (timeout != null) {
2048
- setTimeout(() => {
2049
- if (!loaded.value && !error.value) {
2050
- const err = new Error(
2051
- `Async component timed out after ${timeout}ms.`
2052
- );
2053
- onError(err);
2054
- error.value = err;
2055
- }
2056
- }, timeout);
2057
- }
2058
- load().then(() => {
2059
- loaded.value = true;
2060
- if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2061
- instance.parent.effect.dirty = true;
2062
- queueJob(instance.parent.update);
2063
- }
2064
- }).catch((err) => {
2065
- onError(err);
2066
- error.value = err;
2067
- });
2068
- return () => {
2069
- if (loaded.value && resolvedComp) {
2070
- return createInnerComp(resolvedComp, instance);
2071
- } else if (error.value && errorComponent) {
2072
- return createVNode(errorComponent, {
2073
- error: error.value
2074
- });
2075
- } else if (loadingComponent && !delayed.value) {
2076
- return createVNode(loadingComponent);
2077
- }
2078
- };
2079
- }
2080
- });
2081
- }
2082
- function createInnerComp(comp, parent) {
2083
- const { ref: ref2, props, children, ce } = parent.vnode;
2084
- const vnode = createVNode(comp, props, children);
2085
- vnode.ref = ref2;
2086
- vnode.ce = ce;
2087
- delete parent.vnode.ce;
2088
- return vnode;
1673
+ }
1674
+ return slots;
2089
1675
  }
2090
1676
 
2091
1677
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
@@ -2108,9 +1694,10 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
2108
1694
  const rendered = createBlock(
2109
1695
  Fragment,
2110
1696
  {
2111
- key: props.key || // slot content array of a dynamic conditional slot may have a branch
1697
+ key: (props.key || // slot content array of a dynamic conditional slot may have a branch
2112
1698
  // key attached in the `createSlots` helper, respect that
2113
- validSlotContent && validSlotContent.key || `_${name}`
1699
+ validSlotContent && validSlotContent.key || `_${name}`) + // #7256 force differentiate fallback content from actual content
1700
+ (!validSlotContent && fallback ? "_fb" : "")
2114
1701
  },
2115
1702
  validSlotContent || (fallback ? fallback() : []),
2116
1703
  validSlotContent && slots._ === 1 ? 64 : -2
@@ -3340,8 +2927,9 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
3340
2927
  }
3341
2928
  return value;
3342
2929
  }
2930
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
3343
2931
  function normalizePropsOptions(comp, appContext, asMixin = false) {
3344
- const cache = appContext.propsCache;
2932
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
3345
2933
  const cached = cache.get(comp);
3346
2934
  if (cached) {
3347
2935
  return cached;
@@ -3588,13 +3176,22 @@ const normalizeVNodeSlots = (instance, children) => {
3588
3176
  const normalized = normalizeSlotValue(children);
3589
3177
  instance.slots.default = () => normalized;
3590
3178
  };
3591
- const initSlots = (instance, children) => {
3179
+ const assignSlots = (slots, children, optimized) => {
3180
+ for (const key in children) {
3181
+ if (optimized || key !== "_") {
3182
+ slots[key] = children[key];
3183
+ }
3184
+ }
3185
+ };
3186
+ const initSlots = (instance, children, optimized) => {
3592
3187
  const slots = instance.slots = createInternalObject();
3593
3188
  if (instance.vnode.shapeFlag & 32) {
3594
3189
  const type = children._;
3595
3190
  if (type) {
3596
- shared.extend(slots, children);
3597
- shared.def(slots, "_", type, true);
3191
+ assignSlots(slots, children, optimized);
3192
+ if (optimized) {
3193
+ shared.def(slots, "_", type, true);
3194
+ }
3598
3195
  } else {
3599
3196
  normalizeObjectSlots(children, slots);
3600
3197
  }
@@ -3610,15 +3207,12 @@ const updateSlots = (instance, children, optimized) => {
3610
3207
  const type = children._;
3611
3208
  if (type) {
3612
3209
  if (isHmrUpdating) {
3613
- shared.extend(slots, children);
3210
+ assignSlots(slots, children, optimized);
3614
3211
  reactivity.trigger(instance, "set", "$slots");
3615
3212
  } else if (optimized && type === 1) {
3616
3213
  needDeletionCheck = false;
3617
3214
  } else {
3618
- shared.extend(slots, children);
3619
- if (!optimized && type === 1) {
3620
- delete slots._;
3621
- }
3215
+ assignSlots(slots, children, optimized);
3622
3216
  }
3623
3217
  } else {
3624
3218
  needDeletionCheck = !children.$stable;
@@ -3707,22 +3301,309 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3707
3301
  if (shared.hasOwn(setupState, ref)) {
3708
3302
  setupState[ref] = value;
3709
3303
  }
3710
- } else if (_isRef) {
3711
- ref.value = value;
3712
- if (rawRef.k) refs[rawRef.k] = value;
3713
- } else {
3714
- warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
3304
+ } else if (_isRef) {
3305
+ ref.value = value;
3306
+ if (rawRef.k) refs[rawRef.k] = value;
3307
+ } else {
3308
+ warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
3309
+ }
3310
+ };
3311
+ if (value) {
3312
+ doSet.id = -1;
3313
+ queuePostRenderEffect(doSet, parentSuspense);
3314
+ } else {
3315
+ doSet();
3316
+ }
3317
+ } else {
3318
+ warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
3319
+ }
3320
+ }
3321
+ }
3322
+
3323
+ const TeleportEndKey = Symbol("_vte");
3324
+ const isTeleport = (type) => type.__isTeleport;
3325
+ const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
3326
+ const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
3327
+ const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
3328
+ const resolveTarget = (props, select) => {
3329
+ const targetSelector = props && props.to;
3330
+ if (shared.isString(targetSelector)) {
3331
+ if (!select) {
3332
+ warn$1(
3333
+ `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
3334
+ );
3335
+ return null;
3336
+ } else {
3337
+ const target = select(targetSelector);
3338
+ if (!target && !isTeleportDisabled(props)) {
3339
+ warn$1(
3340
+ `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
3341
+ );
3342
+ }
3343
+ return target;
3344
+ }
3345
+ } else {
3346
+ if (!targetSelector && !isTeleportDisabled(props)) {
3347
+ warn$1(`Invalid Teleport target: ${targetSelector}`);
3348
+ }
3349
+ return targetSelector;
3350
+ }
3351
+ };
3352
+ const TeleportImpl = {
3353
+ name: "Teleport",
3354
+ __isTeleport: true,
3355
+ process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
3356
+ const {
3357
+ mc: mountChildren,
3358
+ pc: patchChildren,
3359
+ pbc: patchBlockChildren,
3360
+ o: { insert, querySelector, createText, createComment }
3361
+ } = internals;
3362
+ const disabled = isTeleportDisabled(n2.props);
3363
+ let { shapeFlag, children, dynamicChildren } = n2;
3364
+ if (isHmrUpdating) {
3365
+ optimized = false;
3366
+ dynamicChildren = null;
3367
+ }
3368
+ if (n1 == null) {
3369
+ const placeholder = n2.el = createComment("teleport start") ;
3370
+ const mainAnchor = n2.anchor = createComment("teleport end") ;
3371
+ const target = n2.target = resolveTarget(n2.props, querySelector);
3372
+ const targetStart = n2.targetStart = createText("");
3373
+ const targetAnchor = n2.targetAnchor = createText("");
3374
+ insert(placeholder, container, anchor);
3375
+ insert(mainAnchor, container, anchor);
3376
+ targetStart[TeleportEndKey] = targetAnchor;
3377
+ if (target) {
3378
+ insert(targetStart, target);
3379
+ insert(targetAnchor, target);
3380
+ if (namespace === "svg" || isTargetSVG(target)) {
3381
+ namespace = "svg";
3382
+ } else if (namespace === "mathml" || isTargetMathML(target)) {
3383
+ namespace = "mathml";
3384
+ }
3385
+ } else if (!disabled) {
3386
+ warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`);
3387
+ }
3388
+ const mount = (container2, anchor2) => {
3389
+ if (shapeFlag & 16) {
3390
+ mountChildren(
3391
+ children,
3392
+ container2,
3393
+ anchor2,
3394
+ parentComponent,
3395
+ parentSuspense,
3396
+ namespace,
3397
+ slotScopeIds,
3398
+ optimized
3399
+ );
3400
+ }
3401
+ };
3402
+ if (disabled) {
3403
+ mount(container, mainAnchor);
3404
+ } else if (target) {
3405
+ mount(target, targetAnchor);
3406
+ }
3407
+ } else {
3408
+ n2.el = n1.el;
3409
+ n2.targetStart = n1.targetStart;
3410
+ const mainAnchor = n2.anchor = n1.anchor;
3411
+ const target = n2.target = n1.target;
3412
+ const targetAnchor = n2.targetAnchor = n1.targetAnchor;
3413
+ const wasDisabled = isTeleportDisabled(n1.props);
3414
+ const currentContainer = wasDisabled ? container : target;
3415
+ const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
3416
+ if (namespace === "svg" || isTargetSVG(target)) {
3417
+ namespace = "svg";
3418
+ } else if (namespace === "mathml" || isTargetMathML(target)) {
3419
+ namespace = "mathml";
3420
+ }
3421
+ if (dynamicChildren) {
3422
+ patchBlockChildren(
3423
+ n1.dynamicChildren,
3424
+ dynamicChildren,
3425
+ currentContainer,
3426
+ parentComponent,
3427
+ parentSuspense,
3428
+ namespace,
3429
+ slotScopeIds
3430
+ );
3431
+ traverseStaticChildren(n1, n2, true);
3432
+ } else if (!optimized) {
3433
+ patchChildren(
3434
+ n1,
3435
+ n2,
3436
+ currentContainer,
3437
+ currentAnchor,
3438
+ parentComponent,
3439
+ parentSuspense,
3440
+ namespace,
3441
+ slotScopeIds,
3442
+ false
3443
+ );
3444
+ }
3445
+ if (disabled) {
3446
+ if (!wasDisabled) {
3447
+ moveTeleport(
3448
+ n2,
3449
+ container,
3450
+ mainAnchor,
3451
+ internals,
3452
+ 1
3453
+ );
3454
+ } else {
3455
+ if (n2.props && n1.props && n2.props.to !== n1.props.to) {
3456
+ n2.props.to = n1.props.to;
3457
+ }
3458
+ }
3459
+ } else {
3460
+ if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3461
+ const nextTarget = n2.target = resolveTarget(
3462
+ n2.props,
3463
+ querySelector
3464
+ );
3465
+ if (nextTarget) {
3466
+ moveTeleport(
3467
+ n2,
3468
+ nextTarget,
3469
+ null,
3470
+ internals,
3471
+ 0
3472
+ );
3473
+ } else {
3474
+ warn$1(
3475
+ "Invalid Teleport target on update:",
3476
+ target,
3477
+ `(${typeof target})`
3478
+ );
3479
+ }
3480
+ } else if (wasDisabled) {
3481
+ moveTeleport(
3482
+ n2,
3483
+ target,
3484
+ targetAnchor,
3485
+ internals,
3486
+ 1
3487
+ );
3488
+ }
3489
+ }
3490
+ }
3491
+ updateCssVars(n2);
3492
+ },
3493
+ remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
3494
+ const {
3495
+ shapeFlag,
3496
+ children,
3497
+ anchor,
3498
+ targetStart,
3499
+ targetAnchor,
3500
+ target,
3501
+ props
3502
+ } = vnode;
3503
+ if (target) {
3504
+ hostRemove(targetStart);
3505
+ hostRemove(targetAnchor);
3506
+ }
3507
+ doRemove && hostRemove(anchor);
3508
+ if (shapeFlag & 16) {
3509
+ const shouldRemove = doRemove || !isTeleportDisabled(props);
3510
+ for (let i = 0; i < children.length; i++) {
3511
+ const child = children[i];
3512
+ unmount(
3513
+ child,
3514
+ parentComponent,
3515
+ parentSuspense,
3516
+ shouldRemove,
3517
+ !!child.dynamicChildren
3518
+ );
3519
+ }
3520
+ }
3521
+ },
3522
+ move: moveTeleport,
3523
+ hydrate: hydrateTeleport
3524
+ };
3525
+ function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
3526
+ if (moveType === 0) {
3527
+ insert(vnode.targetAnchor, container, parentAnchor);
3528
+ }
3529
+ const { el, anchor, shapeFlag, children, props } = vnode;
3530
+ const isReorder = moveType === 2;
3531
+ if (isReorder) {
3532
+ insert(el, container, parentAnchor);
3533
+ }
3534
+ if (!isReorder || isTeleportDisabled(props)) {
3535
+ if (shapeFlag & 16) {
3536
+ for (let i = 0; i < children.length; i++) {
3537
+ move(
3538
+ children[i],
3539
+ container,
3540
+ parentAnchor,
3541
+ 2
3542
+ );
3543
+ }
3544
+ }
3545
+ }
3546
+ if (isReorder) {
3547
+ insert(anchor, container, parentAnchor);
3548
+ }
3549
+ }
3550
+ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
3551
+ o: { nextSibling, parentNode, querySelector }
3552
+ }, hydrateChildren) {
3553
+ const target = vnode.target = resolveTarget(
3554
+ vnode.props,
3555
+ querySelector
3556
+ );
3557
+ if (target) {
3558
+ const targetNode = target._lpa || target.firstChild;
3559
+ if (vnode.shapeFlag & 16) {
3560
+ if (isTeleportDisabled(vnode.props)) {
3561
+ vnode.anchor = hydrateChildren(
3562
+ nextSibling(node),
3563
+ vnode,
3564
+ parentNode(node),
3565
+ parentComponent,
3566
+ parentSuspense,
3567
+ slotScopeIds,
3568
+ optimized
3569
+ );
3570
+ vnode.targetAnchor = targetNode;
3571
+ } else {
3572
+ vnode.anchor = nextSibling(node);
3573
+ let targetAnchor = targetNode;
3574
+ while (targetAnchor) {
3575
+ targetAnchor = nextSibling(targetAnchor);
3576
+ if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
3577
+ vnode.targetAnchor = targetAnchor;
3578
+ target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
3579
+ break;
3580
+ }
3715
3581
  }
3716
- };
3717
- if (value) {
3718
- doSet.id = -1;
3719
- queuePostRenderEffect(doSet, parentSuspense);
3720
- } else {
3721
- doSet();
3582
+ hydrateChildren(
3583
+ targetNode,
3584
+ vnode,
3585
+ target,
3586
+ parentComponent,
3587
+ parentSuspense,
3588
+ slotScopeIds,
3589
+ optimized
3590
+ );
3722
3591
  }
3723
- } else {
3724
- warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
3725
3592
  }
3593
+ updateCssVars(vnode);
3594
+ }
3595
+ return vnode.anchor && nextSibling(vnode.anchor);
3596
+ }
3597
+ const Teleport = TeleportImpl;
3598
+ function updateCssVars(vnode) {
3599
+ const ctx = vnode.ctx;
3600
+ if (ctx && ctx.ut) {
3601
+ let node = vnode.children[0].el;
3602
+ while (node && node !== vnode.targetAnchor) {
3603
+ if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
3604
+ node = node.nextSibling;
3605
+ }
3606
+ ctx.ut();
3726
3607
  }
3727
3608
  }
3728
3609
 
@@ -4016,15 +3897,7 @@ Server rendered element contains more child nodes than client vdom.`
4016
3897
  }
4017
3898
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
4018
3899
  key[0] === ".") {
4019
- patchProp(
4020
- el,
4021
- key,
4022
- null,
4023
- props[key],
4024
- void 0,
4025
- void 0,
4026
- parentComponent
4027
- );
3900
+ patchProp(el, key, null, props[key], void 0, parentComponent);
4028
3901
  }
4029
3902
  }
4030
3903
  }
@@ -4053,7 +3926,21 @@ Server rendered element contains more child nodes than client vdom.`
4053
3926
  let hasWarned = false;
4054
3927
  for (let i = 0; i < l; i++) {
4055
3928
  const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
3929
+ const isText = vnode.type === Text;
4056
3930
  if (node) {
3931
+ if (isText && !optimized) {
3932
+ let next = children[i + 1];
3933
+ if (next && (next = normalizeVNode(next)).type === Text) {
3934
+ insert(
3935
+ createText(
3936
+ node.data.slice(vnode.children.length)
3937
+ ),
3938
+ container,
3939
+ nextSibling(node)
3940
+ );
3941
+ node.data = vnode.children;
3942
+ }
3943
+ }
4057
3944
  node = hydrateNode(
4058
3945
  node,
4059
3946
  vnode,
@@ -4062,7 +3949,7 @@ Server rendered element contains more child nodes than client vdom.`
4062
3949
  slotScopeIds,
4063
3950
  optimized
4064
3951
  );
4065
- } else if (vnode.type === Text && !vnode.children) {
3952
+ } else if (isText && !vnode.children) {
4066
3953
  insert(vnode.el = createText(""), container);
4067
3954
  } else {
4068
3955
  if (!hasWarned) {
@@ -4596,17 +4483,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4596
4483
  if (props) {
4597
4484
  for (const key in props) {
4598
4485
  if (key !== "value" && !shared.isReservedProp(key)) {
4599
- hostPatchProp(
4600
- el,
4601
- key,
4602
- null,
4603
- props[key],
4604
- namespace,
4605
- vnode.children,
4606
- parentComponent,
4607
- parentSuspense,
4608
- unmountChildren
4609
- );
4486
+ hostPatchProp(el, key, null, props[key], namespace, parentComponent);
4610
4487
  }
4611
4488
  }
4612
4489
  if ("value" in props) {
@@ -4701,6 +4578,9 @@ function baseCreateRenderer(options, createHydrationFns) {
4701
4578
  optimized = false;
4702
4579
  dynamicChildren = null;
4703
4580
  }
4581
+ if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
4582
+ hostSetElementText(el, "");
4583
+ }
4704
4584
  if (dynamicChildren) {
4705
4585
  patchBlockChildren(
4706
4586
  n1.dynamicChildren,
@@ -4729,15 +4609,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4729
4609
  }
4730
4610
  if (patchFlag > 0) {
4731
4611
  if (patchFlag & 16) {
4732
- patchProps(
4733
- el,
4734
- n2,
4735
- oldProps,
4736
- newProps,
4737
- parentComponent,
4738
- parentSuspense,
4739
- namespace
4740
- );
4612
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4741
4613
  } else {
4742
4614
  if (patchFlag & 2) {
4743
4615
  if (oldProps.class !== newProps.class) {
@@ -4754,17 +4626,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4754
4626
  const prev = oldProps[key];
4755
4627
  const next = newProps[key];
4756
4628
  if (next !== prev || key === "value") {
4757
- hostPatchProp(
4758
- el,
4759
- key,
4760
- prev,
4761
- next,
4762
- namespace,
4763
- n1.children,
4764
- parentComponent,
4765
- parentSuspense,
4766
- unmountChildren
4767
- );
4629
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4768
4630
  }
4769
4631
  }
4770
4632
  }
@@ -4775,15 +4637,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4775
4637
  }
4776
4638
  }
4777
4639
  } else if (!optimized && dynamicChildren == null) {
4778
- patchProps(
4779
- el,
4780
- n2,
4781
- oldProps,
4782
- newProps,
4783
- parentComponent,
4784
- parentSuspense,
4785
- namespace
4786
- );
4640
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4787
4641
  }
4788
4642
  if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
4789
4643
  queuePostRenderEffect(() => {
@@ -4823,7 +4677,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4823
4677
  );
4824
4678
  }
4825
4679
  };
4826
- const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
4680
+ const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
4827
4681
  if (oldProps !== newProps) {
4828
4682
  if (oldProps !== shared.EMPTY_OBJ) {
4829
4683
  for (const key in oldProps) {
@@ -4834,10 +4688,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4834
4688
  oldProps[key],
4835
4689
  null,
4836
4690
  namespace,
4837
- vnode.children,
4838
- parentComponent,
4839
- parentSuspense,
4840
- unmountChildren
4691
+ parentComponent
4841
4692
  );
4842
4693
  }
4843
4694
  }
@@ -4847,17 +4698,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4847
4698
  const next = newProps[key];
4848
4699
  const prev = oldProps[key];
4849
4700
  if (next !== prev && key !== "value") {
4850
- hostPatchProp(
4851
- el,
4852
- key,
4853
- prev,
4854
- next,
4855
- namespace,
4856
- vnode.children,
4857
- parentComponent,
4858
- parentSuspense,
4859
- unmountChildren
4860
- );
4701
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4861
4702
  }
4862
4703
  }
4863
4704
  if ("value" in newProps) {
@@ -4974,7 +4815,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4974
4815
  {
4975
4816
  startMeasure(instance, `init`);
4976
4817
  }
4977
- setupComponent(instance);
4818
+ setupComponent(instance, false, optimized);
4978
4819
  {
4979
4820
  endMeasure(instance, `init`);
4980
4821
  }
@@ -5211,12 +5052,12 @@ function baseCreateRenderer(options, createHydrationFns) {
5211
5052
  effect.run();
5212
5053
  }
5213
5054
  };
5055
+ update.i = instance;
5214
5056
  update.id = instance.uid;
5215
5057
  toggleRecurse(instance, true);
5216
5058
  {
5217
5059
  effect.onTrack = instance.rtc ? (e) => shared.invokeArrayFns(instance.rtc, e) : void 0;
5218
5060
  effect.onTrigger = instance.rtg ? (e) => shared.invokeArrayFns(instance.rtg, e) : void 0;
5219
- update.ownerInstance = instance;
5220
5061
  }
5221
5062
  update();
5222
5063
  };
@@ -5575,7 +5416,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5575
5416
  shapeFlag,
5576
5417
  patchFlag,
5577
5418
  dirs,
5578
- memoIndex
5419
+ cacheIndex
5579
5420
  } = vnode;
5580
5421
  if (patchFlag === -2) {
5581
5422
  optimized = false;
@@ -5583,8 +5424,8 @@ function baseCreateRenderer(options, createHydrationFns) {
5583
5424
  if (ref != null) {
5584
5425
  setRef(ref, null, parentSuspense, vnode, true);
5585
5426
  }
5586
- if (memoIndex != null) {
5587
- parentComponent.renderCache[memoIndex] = void 0;
5427
+ if (cacheIndex != null) {
5428
+ parentComponent.renderCache[cacheIndex] = void 0;
5588
5429
  }
5589
5430
  if (shapeFlag & 256) {
5590
5431
  parentComponent.ctx.deactivate(vnode);
@@ -5614,7 +5455,12 @@ function baseCreateRenderer(options, createHydrationFns) {
5614
5455
  internals,
5615
5456
  doRemove
5616
5457
  );
5617
- } else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
5458
+ } else if (dynamicChildren && // #5154
5459
+ // when v-once is used inside a block, setBlockTracking(-1) marks the
5460
+ // parent block with hasOnce: true
5461
+ // so that it doesn't take the fast path during unmount - otherwise
5462
+ // components nested in v-once are never unmounted.
5463
+ !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
5618
5464
  (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
5619
5465
  unmountChildren(
5620
5466
  dynamicChildren,
@@ -5727,7 +5573,9 @@ function baseCreateRenderer(options, createHydrationFns) {
5727
5573
  if (vnode.shapeFlag & 128) {
5728
5574
  return vnode.suspense.next();
5729
5575
  }
5730
- return hostNextSibling(vnode.anchor || vnode.el);
5576
+ const el = hostNextSibling(vnode.anchor || vnode.el);
5577
+ const teleportEnd = el && el[TeleportEndKey];
5578
+ return teleportEnd ? hostNextSibling(teleportEnd) : el;
5731
5579
  };
5732
5580
  let isFlushing = false;
5733
5581
  const render = (vnode, container, namespace) => {
@@ -6072,953 +5920,1169 @@ function doWatch(source, cb, {
6072
5920
  }
6073
5921
  };
6074
5922
  {
6075
- effect.onTrack = onTrack;
6076
- effect.onTrigger = onTrigger;
5923
+ effect.onTrack = onTrack;
5924
+ effect.onTrigger = onTrigger;
5925
+ }
5926
+ if (cb) {
5927
+ if (immediate) {
5928
+ job();
5929
+ } else {
5930
+ oldValue = effect.run();
5931
+ }
5932
+ } else if (flush === "post") {
5933
+ queuePostRenderEffect(
5934
+ effect.run.bind(effect),
5935
+ instance && instance.suspense
5936
+ );
5937
+ } else {
5938
+ effect.run();
5939
+ }
5940
+ if (ssrCleanup) ssrCleanup.push(unwatch);
5941
+ return unwatch;
5942
+ }
5943
+ function instanceWatch(source, value, options) {
5944
+ const publicThis = this.proxy;
5945
+ const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
5946
+ let cb;
5947
+ if (shared.isFunction(value)) {
5948
+ cb = value;
5949
+ } else {
5950
+ cb = value.handler;
5951
+ options = value;
5952
+ }
5953
+ const reset = setCurrentInstance(this);
5954
+ const res = doWatch(getter, cb.bind(publicThis), options);
5955
+ reset();
5956
+ return res;
5957
+ }
5958
+ function createPathGetter(ctx, path) {
5959
+ const segments = path.split(".");
5960
+ return () => {
5961
+ let cur = ctx;
5962
+ for (let i = 0; i < segments.length && cur; i++) {
5963
+ cur = cur[segments[i]];
5964
+ }
5965
+ return cur;
5966
+ };
5967
+ }
5968
+ function traverse(value, depth = Infinity, seen) {
5969
+ if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
5970
+ return value;
5971
+ }
5972
+ seen = seen || /* @__PURE__ */ new Set();
5973
+ if (seen.has(value)) {
5974
+ return value;
5975
+ }
5976
+ seen.add(value);
5977
+ depth--;
5978
+ if (reactivity.isRef(value)) {
5979
+ traverse(value.value, depth, seen);
5980
+ } else if (shared.isArray(value)) {
5981
+ for (let i = 0; i < value.length; i++) {
5982
+ traverse(value[i], depth, seen);
5983
+ }
5984
+ } else if (shared.isSet(value) || shared.isMap(value)) {
5985
+ value.forEach((v) => {
5986
+ traverse(v, depth, seen);
5987
+ });
5988
+ } else if (shared.isPlainObject(value)) {
5989
+ for (const key in value) {
5990
+ traverse(value[key], depth, seen);
5991
+ }
5992
+ for (const key of Object.getOwnPropertySymbols(value)) {
5993
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
5994
+ traverse(value[key], depth, seen);
5995
+ }
5996
+ }
5997
+ }
5998
+ return value;
5999
+ }
6000
+
6001
+ function useModel(props, name, options = shared.EMPTY_OBJ) {
6002
+ const i = getCurrentInstance();
6003
+ if (!i) {
6004
+ warn$1(`useModel() called without active instance.`);
6005
+ return reactivity.ref();
6006
+ }
6007
+ if (!i.propsOptions[0][name]) {
6008
+ warn$1(`useModel() called with prop "${name}" which is not declared.`);
6009
+ return reactivity.ref();
6010
+ }
6011
+ const camelizedName = shared.camelize(name);
6012
+ const hyphenatedName = shared.hyphenate(name);
6013
+ const modifiers = getModelModifiers(props, name);
6014
+ const res = reactivity.customRef((track, trigger) => {
6015
+ let localValue;
6016
+ let prevSetValue;
6017
+ let prevEmittedValue;
6018
+ watchSyncEffect(() => {
6019
+ const propValue = props[name];
6020
+ if (shared.hasChanged(localValue, propValue)) {
6021
+ localValue = propValue;
6022
+ trigger();
6023
+ }
6024
+ });
6025
+ return {
6026
+ get() {
6027
+ track();
6028
+ return options.get ? options.get(localValue) : localValue;
6029
+ },
6030
+ set(value) {
6031
+ if (!shared.hasChanged(value, localValue)) {
6032
+ return;
6033
+ }
6034
+ const rawProps = i.vnode.props;
6035
+ if (!(rawProps && // check if parent has passed v-model
6036
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
6037
+ localValue = value;
6038
+ trigger();
6039
+ }
6040
+ const emittedValue = options.set ? options.set(value) : value;
6041
+ i.emit(`update:${name}`, emittedValue);
6042
+ if (value !== emittedValue && value !== prevSetValue && emittedValue === prevEmittedValue) {
6043
+ trigger();
6044
+ }
6045
+ prevSetValue = value;
6046
+ prevEmittedValue = emittedValue;
6047
+ }
6048
+ };
6049
+ });
6050
+ res[Symbol.iterator] = () => {
6051
+ let i2 = 0;
6052
+ return {
6053
+ next() {
6054
+ if (i2 < 2) {
6055
+ return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
6056
+ } else {
6057
+ return { done: true };
6058
+ }
6059
+ }
6060
+ };
6061
+ };
6062
+ return res;
6063
+ }
6064
+ const getModelModifiers = (props, modelName) => {
6065
+ return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${shared.camelize(modelName)}Modifiers`] || props[`${shared.hyphenate(modelName)}Modifiers`];
6066
+ };
6067
+
6068
+ function emit(instance, event, ...rawArgs) {
6069
+ if (instance.isUnmounted) return;
6070
+ const props = instance.vnode.props || shared.EMPTY_OBJ;
6071
+ {
6072
+ const {
6073
+ emitsOptions,
6074
+ propsOptions: [propsOptions]
6075
+ } = instance;
6076
+ if (emitsOptions) {
6077
+ if (!(event in emitsOptions) && true) {
6078
+ if (!propsOptions || !(shared.toHandlerKey(event) in propsOptions)) {
6079
+ warn$1(
6080
+ `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(event)}" prop.`
6081
+ );
6082
+ }
6083
+ } else {
6084
+ const validator = emitsOptions[event];
6085
+ if (shared.isFunction(validator)) {
6086
+ const isValid = validator(...rawArgs);
6087
+ if (!isValid) {
6088
+ warn$1(
6089
+ `Invalid event arguments: event validation failed for event "${event}".`
6090
+ );
6091
+ }
6092
+ }
6093
+ }
6094
+ }
6095
+ }
6096
+ let args = rawArgs;
6097
+ const isModelListener = event.startsWith("update:");
6098
+ const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
6099
+ if (modifiers) {
6100
+ if (modifiers.trim) {
6101
+ args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
6102
+ }
6103
+ if (modifiers.number) {
6104
+ args = rawArgs.map(shared.looseToNumber);
6105
+ }
6106
+ }
6107
+ {
6108
+ devtoolsComponentEmit(instance, event, args);
6109
+ }
6110
+ {
6111
+ const lowerCaseEvent = event.toLowerCase();
6112
+ if (lowerCaseEvent !== event && props[shared.toHandlerKey(lowerCaseEvent)]) {
6113
+ warn$1(
6114
+ `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
6115
+ instance,
6116
+ instance.type
6117
+ )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${shared.hyphenate(
6118
+ event
6119
+ )}" instead of "${event}".`
6120
+ );
6121
+ }
6077
6122
  }
6078
- if (cb) {
6079
- if (immediate) {
6080
- job();
6081
- } else {
6082
- oldValue = effect.run();
6123
+ let handlerName;
6124
+ let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
6125
+ props[handlerName = shared.toHandlerKey(shared.camelize(event))];
6126
+ if (!handler && isModelListener) {
6127
+ handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
6128
+ }
6129
+ if (handler) {
6130
+ callWithAsyncErrorHandling(
6131
+ handler,
6132
+ instance,
6133
+ 6,
6134
+ args
6135
+ );
6136
+ }
6137
+ const onceHandler = props[handlerName + `Once`];
6138
+ if (onceHandler) {
6139
+ if (!instance.emitted) {
6140
+ instance.emitted = {};
6141
+ } else if (instance.emitted[handlerName]) {
6142
+ return;
6083
6143
  }
6084
- } else if (flush === "post") {
6085
- queuePostRenderEffect(
6086
- effect.run.bind(effect),
6087
- instance && instance.suspense
6144
+ instance.emitted[handlerName] = true;
6145
+ callWithAsyncErrorHandling(
6146
+ onceHandler,
6147
+ instance,
6148
+ 6,
6149
+ args
6088
6150
  );
6089
- } else {
6090
- effect.run();
6091
6151
  }
6092
- if (ssrCleanup) ssrCleanup.push(unwatch);
6093
- return unwatch;
6094
6152
  }
6095
- function instanceWatch(source, value, options) {
6096
- const publicThis = this.proxy;
6097
- const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
6098
- let cb;
6099
- if (shared.isFunction(value)) {
6100
- cb = value;
6101
- } else {
6102
- cb = value.handler;
6103
- options = value;
6153
+ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
6154
+ const cache = appContext.emitsCache;
6155
+ const cached = cache.get(comp);
6156
+ if (cached !== void 0) {
6157
+ return cached;
6104
6158
  }
6105
- const reset = setCurrentInstance(this);
6106
- const res = doWatch(getter, cb.bind(publicThis), options);
6107
- reset();
6108
- return res;
6109
- }
6110
- function createPathGetter(ctx, path) {
6111
- const segments = path.split(".");
6112
- return () => {
6113
- let cur = ctx;
6114
- for (let i = 0; i < segments.length && cur; i++) {
6115
- cur = cur[segments[i]];
6159
+ const raw = comp.emits;
6160
+ let normalized = {};
6161
+ let hasExtends = false;
6162
+ if (!shared.isFunction(comp)) {
6163
+ const extendEmits = (raw2) => {
6164
+ const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
6165
+ if (normalizedFromExtend) {
6166
+ hasExtends = true;
6167
+ shared.extend(normalized, normalizedFromExtend);
6168
+ }
6169
+ };
6170
+ if (!asMixin && appContext.mixins.length) {
6171
+ appContext.mixins.forEach(extendEmits);
6116
6172
  }
6117
- return cur;
6118
- };
6119
- }
6120
- function traverse(value, depth = Infinity, seen) {
6121
- if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
6122
- return value;
6123
- }
6124
- seen = seen || /* @__PURE__ */ new Set();
6125
- if (seen.has(value)) {
6126
- return value;
6127
- }
6128
- seen.add(value);
6129
- depth--;
6130
- if (reactivity.isRef(value)) {
6131
- traverse(value.value, depth, seen);
6132
- } else if (shared.isArray(value)) {
6133
- for (let i = 0; i < value.length; i++) {
6134
- traverse(value[i], depth, seen);
6173
+ if (comp.extends) {
6174
+ extendEmits(comp.extends);
6135
6175
  }
6136
- } else if (shared.isSet(value) || shared.isMap(value)) {
6137
- value.forEach((v) => {
6138
- traverse(v, depth, seen);
6139
- });
6140
- } else if (shared.isPlainObject(value)) {
6141
- for (const key in value) {
6142
- traverse(value[key], depth, seen);
6176
+ if (comp.mixins) {
6177
+ comp.mixins.forEach(extendEmits);
6143
6178
  }
6144
- for (const key of Object.getOwnPropertySymbols(value)) {
6145
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
6146
- traverse(value[key], depth, seen);
6147
- }
6179
+ }
6180
+ if (!raw && !hasExtends) {
6181
+ if (shared.isObject(comp)) {
6182
+ cache.set(comp, null);
6148
6183
  }
6184
+ return null;
6149
6185
  }
6150
- return value;
6186
+ if (shared.isArray(raw)) {
6187
+ raw.forEach((key) => normalized[key] = null);
6188
+ } else {
6189
+ shared.extend(normalized, raw);
6190
+ }
6191
+ if (shared.isObject(comp)) {
6192
+ cache.set(comp, normalized);
6193
+ }
6194
+ return normalized;
6195
+ }
6196
+ function isEmitListener(options, key) {
6197
+ if (!options || !shared.isOn(key)) {
6198
+ return false;
6199
+ }
6200
+ key = key.slice(2).replace(/Once$/, "");
6201
+ return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
6151
6202
  }
6152
6203
 
6153
- const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
6154
- const KeepAliveImpl = {
6155
- name: `KeepAlive`,
6156
- // Marker for special handling inside the renderer. We are not using a ===
6157
- // check directly on KeepAlive in the renderer, because importing it directly
6158
- // would prevent it from being tree-shaken.
6159
- __isKeepAlive: true,
6160
- props: {
6161
- include: [String, RegExp, Array],
6162
- exclude: [String, RegExp, Array],
6163
- max: [String, Number]
6164
- },
6165
- setup(props, { slots }) {
6166
- const instance = getCurrentInstance();
6167
- const sharedContext = instance.ctx;
6168
- if (!sharedContext.renderer) {
6169
- return () => {
6170
- const children = slots.default && slots.default();
6171
- return children && children.length === 1 ? children[0] : children;
6172
- };
6173
- }
6174
- const cache = /* @__PURE__ */ new Map();
6175
- const keys = /* @__PURE__ */ new Set();
6176
- let current = null;
6177
- {
6178
- instance.__v_cache = cache;
6179
- }
6180
- const parentSuspense = instance.suspense;
6181
- const {
6182
- renderer: {
6183
- p: patch,
6184
- m: move,
6185
- um: _unmount,
6186
- o: { createElement }
6204
+ let accessedAttrs = false;
6205
+ function markAttrsAccessed() {
6206
+ accessedAttrs = true;
6207
+ }
6208
+ function renderComponentRoot(instance) {
6209
+ const {
6210
+ type: Component,
6211
+ vnode,
6212
+ proxy,
6213
+ withProxy,
6214
+ propsOptions: [propsOptions],
6215
+ slots,
6216
+ attrs,
6217
+ emit,
6218
+ render,
6219
+ renderCache,
6220
+ props,
6221
+ data,
6222
+ setupState,
6223
+ ctx,
6224
+ inheritAttrs
6225
+ } = instance;
6226
+ const prev = setCurrentRenderingInstance(instance);
6227
+ let result;
6228
+ let fallthroughAttrs;
6229
+ {
6230
+ accessedAttrs = false;
6231
+ }
6232
+ try {
6233
+ if (vnode.shapeFlag & 4) {
6234
+ const proxyToUse = withProxy || proxy;
6235
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
6236
+ get(target, key, receiver) {
6237
+ warn$1(
6238
+ `Property '${String(
6239
+ key
6240
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
6241
+ );
6242
+ return Reflect.get(target, key, receiver);
6243
+ }
6244
+ }) : proxyToUse;
6245
+ result = normalizeVNode(
6246
+ render.call(
6247
+ thisProxy,
6248
+ proxyToUse,
6249
+ renderCache,
6250
+ true ? reactivity.shallowReadonly(props) : props,
6251
+ setupState,
6252
+ data,
6253
+ ctx
6254
+ )
6255
+ );
6256
+ fallthroughAttrs = attrs;
6257
+ } else {
6258
+ const render2 = Component;
6259
+ if (attrs === props) {
6260
+ markAttrsAccessed();
6187
6261
  }
6188
- } = sharedContext;
6189
- const storageContainer = createElement("div");
6190
- sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
6191
- const instance2 = vnode.component;
6192
- move(vnode, container, anchor, 0, parentSuspense);
6193
- patch(
6194
- instance2.vnode,
6195
- vnode,
6196
- container,
6197
- anchor,
6198
- instance2,
6199
- parentSuspense,
6200
- namespace,
6201
- vnode.slotScopeIds,
6202
- optimized
6262
+ result = normalizeVNode(
6263
+ render2.length > 1 ? render2(
6264
+ true ? reactivity.shallowReadonly(props) : props,
6265
+ true ? {
6266
+ get attrs() {
6267
+ markAttrsAccessed();
6268
+ return reactivity.shallowReadonly(attrs);
6269
+ },
6270
+ slots,
6271
+ emit
6272
+ } : { attrs, slots, emit }
6273
+ ) : render2(
6274
+ true ? reactivity.shallowReadonly(props) : props,
6275
+ null
6276
+ )
6203
6277
  );
6204
- queuePostRenderEffect(() => {
6205
- instance2.isDeactivated = false;
6206
- if (instance2.a) {
6207
- shared.invokeArrayFns(instance2.a);
6278
+ fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
6279
+ }
6280
+ } catch (err) {
6281
+ blockStack.length = 0;
6282
+ handleError(err, instance, 1);
6283
+ result = createVNode(Comment);
6284
+ }
6285
+ let root = result;
6286
+ let setRoot = void 0;
6287
+ if (result.patchFlag > 0 && result.patchFlag & 2048) {
6288
+ [root, setRoot] = getChildRoot(result);
6289
+ }
6290
+ if (fallthroughAttrs && inheritAttrs !== false) {
6291
+ const keys = Object.keys(fallthroughAttrs);
6292
+ const { shapeFlag } = root;
6293
+ if (keys.length) {
6294
+ if (shapeFlag & (1 | 6)) {
6295
+ if (propsOptions && keys.some(shared.isModelListener)) {
6296
+ fallthroughAttrs = filterModelListeners(
6297
+ fallthroughAttrs,
6298
+ propsOptions
6299
+ );
6208
6300
  }
6209
- const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
6210
- if (vnodeHook) {
6211
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
6301
+ root = cloneVNode(root, fallthroughAttrs, false, true);
6302
+ } else if (!accessedAttrs && root.type !== Comment) {
6303
+ const allAttrs = Object.keys(attrs);
6304
+ const eventAttrs = [];
6305
+ const extraAttrs = [];
6306
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
6307
+ const key = allAttrs[i];
6308
+ if (shared.isOn(key)) {
6309
+ if (!shared.isModelListener(key)) {
6310
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
6311
+ }
6312
+ } else {
6313
+ extraAttrs.push(key);
6314
+ }
6212
6315
  }
6213
- }, parentSuspense);
6214
- {
6215
- devtoolsComponentAdded(instance2);
6216
- }
6217
- };
6218
- sharedContext.deactivate = (vnode) => {
6219
- const instance2 = vnode.component;
6220
- invalidateMount(instance2.m);
6221
- invalidateMount(instance2.a);
6222
- move(vnode, storageContainer, null, 1, parentSuspense);
6223
- queuePostRenderEffect(() => {
6224
- if (instance2.da) {
6225
- shared.invokeArrayFns(instance2.da);
6316
+ if (extraAttrs.length) {
6317
+ warn$1(
6318
+ `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
6319
+ );
6226
6320
  }
6227
- const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
6228
- if (vnodeHook) {
6229
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
6321
+ if (eventAttrs.length) {
6322
+ warn$1(
6323
+ `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
6324
+ );
6230
6325
  }
6231
- instance2.isDeactivated = true;
6232
- }, parentSuspense);
6233
- {
6234
- devtoolsComponentAdded(instance2);
6235
6326
  }
6236
- };
6237
- function unmount(vnode) {
6238
- resetShapeFlag(vnode);
6239
- _unmount(vnode, instance, parentSuspense, true);
6240
6327
  }
6241
- function pruneCache(filter) {
6242
- cache.forEach((vnode, key) => {
6243
- const name = getComponentName(vnode.type);
6244
- if (name && (!filter || !filter(name))) {
6245
- pruneCacheEntry(key);
6246
- }
6247
- });
6328
+ }
6329
+ if (vnode.dirs) {
6330
+ if (!isElementRoot(root)) {
6331
+ warn$1(
6332
+ `Runtime directive used on component with non-element root node. The directives will not function as intended.`
6333
+ );
6248
6334
  }
6249
- function pruneCacheEntry(key) {
6250
- const cached = cache.get(key);
6251
- if (!current || !isSameVNodeType(cached, current)) {
6252
- unmount(cached);
6253
- } else if (current) {
6254
- resetShapeFlag(current);
6255
- }
6256
- cache.delete(key);
6257
- keys.delete(key);
6335
+ root = cloneVNode(root, null, false, true);
6336
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
6337
+ }
6338
+ if (vnode.transition) {
6339
+ if (!isElementRoot(root)) {
6340
+ warn$1(
6341
+ `Component inside <Transition> renders non-element root node that cannot be animated.`
6342
+ );
6258
6343
  }
6259
- watch(
6260
- () => [props.include, props.exclude],
6261
- ([include, exclude]) => {
6262
- include && pruneCache((name) => matches(include, name));
6263
- exclude && pruneCache((name) => !matches(exclude, name));
6264
- },
6265
- // prune post-render after `current` has been updated
6266
- { flush: "post", deep: true }
6267
- );
6268
- let pendingCacheKey = null;
6269
- const cacheSubtree = () => {
6270
- if (pendingCacheKey != null) {
6271
- if (isSuspense(instance.subTree.type)) {
6272
- queuePostRenderEffect(() => {
6273
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
6274
- }, instance.subTree.suspense);
6275
- } else {
6276
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
6277
- }
6344
+ root.transition = vnode.transition;
6345
+ }
6346
+ if (setRoot) {
6347
+ setRoot(root);
6348
+ } else {
6349
+ result = root;
6350
+ }
6351
+ setCurrentRenderingInstance(prev);
6352
+ return result;
6353
+ }
6354
+ const getChildRoot = (vnode) => {
6355
+ const rawChildren = vnode.children;
6356
+ const dynamicChildren = vnode.dynamicChildren;
6357
+ const childRoot = filterSingleRoot(rawChildren, false);
6358
+ if (!childRoot) {
6359
+ return [vnode, void 0];
6360
+ } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
6361
+ return getChildRoot(childRoot);
6362
+ }
6363
+ const index = rawChildren.indexOf(childRoot);
6364
+ const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
6365
+ const setRoot = (updatedRoot) => {
6366
+ rawChildren[index] = updatedRoot;
6367
+ if (dynamicChildren) {
6368
+ if (dynamicIndex > -1) {
6369
+ dynamicChildren[dynamicIndex] = updatedRoot;
6370
+ } else if (updatedRoot.patchFlag > 0) {
6371
+ vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
6278
6372
  }
6279
- };
6280
- onMounted(cacheSubtree);
6281
- onUpdated(cacheSubtree);
6282
- onBeforeUnmount(() => {
6283
- cache.forEach((cached) => {
6284
- const { subTree, suspense } = instance;
6285
- const vnode = getInnerChild(subTree);
6286
- if (cached.type === vnode.type && cached.key === vnode.key) {
6287
- resetShapeFlag(vnode);
6288
- const da = vnode.component.da;
6289
- da && queuePostRenderEffect(da, suspense);
6373
+ }
6374
+ };
6375
+ return [normalizeVNode(childRoot), setRoot];
6376
+ };
6377
+ function filterSingleRoot(children, recurse = true) {
6378
+ let singleRoot;
6379
+ for (let i = 0; i < children.length; i++) {
6380
+ const child = children[i];
6381
+ if (isVNode(child)) {
6382
+ if (child.type !== Comment || child.children === "v-if") {
6383
+ if (singleRoot) {
6290
6384
  return;
6385
+ } else {
6386
+ singleRoot = child;
6387
+ if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
6388
+ return filterSingleRoot(singleRoot.children);
6389
+ }
6291
6390
  }
6292
- unmount(cached);
6293
- });
6294
- });
6295
- return () => {
6296
- pendingCacheKey = null;
6297
- if (!slots.default) {
6298
- return null;
6299
- }
6300
- const children = slots.default();
6301
- const rawVNode = children[0];
6302
- if (children.length > 1) {
6303
- {
6304
- warn$1(`KeepAlive should contain exactly one component child.`);
6305
- }
6306
- current = null;
6307
- return children;
6308
- } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
6309
- current = null;
6310
- return rawVNode;
6311
6391
  }
6312
- let vnode = getInnerChild(rawVNode);
6313
- const comp = vnode.type;
6314
- const name = getComponentName(
6315
- isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
6316
- );
6317
- const { include, exclude, max } = props;
6318
- if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
6319
- current = vnode;
6320
- return rawVNode;
6392
+ } else {
6393
+ return;
6394
+ }
6395
+ }
6396
+ return singleRoot;
6397
+ }
6398
+ const getFunctionalFallthrough = (attrs) => {
6399
+ let res;
6400
+ for (const key in attrs) {
6401
+ if (key === "class" || key === "style" || shared.isOn(key)) {
6402
+ (res || (res = {}))[key] = attrs[key];
6403
+ }
6404
+ }
6405
+ return res;
6406
+ };
6407
+ const filterModelListeners = (attrs, props) => {
6408
+ const res = {};
6409
+ for (const key in attrs) {
6410
+ if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
6411
+ res[key] = attrs[key];
6412
+ }
6413
+ }
6414
+ return res;
6415
+ };
6416
+ const isElementRoot = (vnode) => {
6417
+ return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
6418
+ };
6419
+ function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
6420
+ const { props: prevProps, children: prevChildren, component } = prevVNode;
6421
+ const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
6422
+ const emits = component.emitsOptions;
6423
+ if ((prevChildren || nextChildren) && isHmrUpdating) {
6424
+ return true;
6425
+ }
6426
+ if (nextVNode.dirs || nextVNode.transition) {
6427
+ return true;
6428
+ }
6429
+ if (optimized && patchFlag >= 0) {
6430
+ if (patchFlag & 1024) {
6431
+ return true;
6432
+ }
6433
+ if (patchFlag & 16) {
6434
+ if (!prevProps) {
6435
+ return !!nextProps;
6321
6436
  }
6322
- const key = vnode.key == null ? comp : vnode.key;
6323
- const cachedVNode = cache.get(key);
6324
- if (vnode.el) {
6325
- vnode = cloneVNode(vnode);
6326
- if (rawVNode.shapeFlag & 128) {
6327
- rawVNode.ssContent = vnode;
6437
+ return hasPropsChanged(prevProps, nextProps, emits);
6438
+ } else if (patchFlag & 8) {
6439
+ const dynamicProps = nextVNode.dynamicProps;
6440
+ for (let i = 0; i < dynamicProps.length; i++) {
6441
+ const key = dynamicProps[i];
6442
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
6443
+ return true;
6328
6444
  }
6329
6445
  }
6330
- pendingCacheKey = key;
6331
- if (cachedVNode) {
6332
- vnode.el = cachedVNode.el;
6333
- vnode.component = cachedVNode.component;
6334
- if (vnode.transition) {
6335
- setTransitionHooks(vnode, vnode.transition);
6336
- }
6337
- vnode.shapeFlag |= 512;
6338
- keys.delete(key);
6339
- keys.add(key);
6340
- } else {
6341
- keys.add(key);
6342
- if (max && keys.size > parseInt(max, 10)) {
6343
- pruneCacheEntry(keys.values().next().value);
6344
- }
6446
+ }
6447
+ } else {
6448
+ if (prevChildren || nextChildren) {
6449
+ if (!nextChildren || !nextChildren.$stable) {
6450
+ return true;
6345
6451
  }
6346
- vnode.shapeFlag |= 256;
6347
- current = vnode;
6348
- return isSuspense(rawVNode.type) ? rawVNode : vnode;
6349
- };
6350
- }
6351
- };
6352
- const KeepAlive = KeepAliveImpl;
6353
- function matches(pattern, name) {
6354
- if (shared.isArray(pattern)) {
6355
- return pattern.some((p) => matches(p, name));
6356
- } else if (shared.isString(pattern)) {
6357
- return pattern.split(",").includes(name);
6358
- } else if (shared.isRegExp(pattern)) {
6359
- return pattern.test(name);
6452
+ }
6453
+ if (prevProps === nextProps) {
6454
+ return false;
6455
+ }
6456
+ if (!prevProps) {
6457
+ return !!nextProps;
6458
+ }
6459
+ if (!nextProps) {
6460
+ return true;
6461
+ }
6462
+ return hasPropsChanged(prevProps, nextProps, emits);
6360
6463
  }
6361
6464
  return false;
6362
6465
  }
6363
- function onActivated(hook, target) {
6364
- registerKeepAliveHook(hook, "a", target);
6365
- }
6366
- function onDeactivated(hook, target) {
6367
- registerKeepAliveHook(hook, "da", target);
6466
+ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
6467
+ const nextKeys = Object.keys(nextProps);
6468
+ if (nextKeys.length !== Object.keys(prevProps).length) {
6469
+ return true;
6470
+ }
6471
+ for (let i = 0; i < nextKeys.length; i++) {
6472
+ const key = nextKeys[i];
6473
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
6474
+ return true;
6475
+ }
6476
+ }
6477
+ return false;
6368
6478
  }
6369
- function registerKeepAliveHook(hook, type, target = currentInstance) {
6370
- const wrappedHook = hook.__wdc || (hook.__wdc = () => {
6371
- let current = target;
6372
- while (current) {
6373
- if (current.isDeactivated) {
6374
- return;
6375
- }
6376
- current = current.parent;
6479
+ function updateHOCHostEl({ vnode, parent }, el) {
6480
+ while (parent) {
6481
+ const root = parent.subTree;
6482
+ if (root.suspense && root.suspense.activeBranch === vnode) {
6483
+ root.el = vnode.el;
6377
6484
  }
6378
- return hook();
6379
- });
6380
- injectHook(type, wrappedHook, target);
6381
- if (target) {
6382
- let current = target.parent;
6383
- while (current && current.parent) {
6384
- if (isKeepAlive(current.parent.vnode)) {
6385
- injectToKeepAliveRoot(wrappedHook, type, target, current);
6386
- }
6387
- current = current.parent;
6485
+ if (root === vnode) {
6486
+ (vnode = parent.vnode).el = el;
6487
+ parent = parent.parent;
6488
+ } else {
6489
+ break;
6388
6490
  }
6389
6491
  }
6390
6492
  }
6391
- function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
6392
- const injected = injectHook(
6393
- type,
6394
- hook,
6395
- keepAliveRoot,
6396
- true
6397
- /* prepend */
6398
- );
6399
- onUnmounted(() => {
6400
- shared.remove(keepAliveRoot[type], injected);
6401
- }, target);
6402
- }
6403
- function resetShapeFlag(vnode) {
6404
- vnode.shapeFlag &= ~256;
6405
- vnode.shapeFlag &= ~512;
6406
- }
6407
- function getInnerChild(vnode) {
6408
- return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
6409
- }
6410
6493
 
6411
- const leaveCbKey = Symbol("_leaveCb");
6412
- const enterCbKey = Symbol("_enterCb");
6413
- function useTransitionState() {
6414
- const state = {
6415
- isMounted: false,
6416
- isLeaving: false,
6417
- isUnmounting: false,
6418
- leavingVNodes: /* @__PURE__ */ new Map()
6419
- };
6420
- onMounted(() => {
6421
- state.isMounted = true;
6422
- });
6423
- onBeforeUnmount(() => {
6424
- state.isUnmounting = true;
6425
- });
6426
- return state;
6427
- }
6428
- const TransitionHookValidator = [Function, Array];
6429
- const BaseTransitionPropsValidators = {
6430
- mode: String,
6431
- appear: Boolean,
6432
- persisted: Boolean,
6433
- // enter
6434
- onBeforeEnter: TransitionHookValidator,
6435
- onEnter: TransitionHookValidator,
6436
- onAfterEnter: TransitionHookValidator,
6437
- onEnterCancelled: TransitionHookValidator,
6438
- // leave
6439
- onBeforeLeave: TransitionHookValidator,
6440
- onLeave: TransitionHookValidator,
6441
- onAfterLeave: TransitionHookValidator,
6442
- onLeaveCancelled: TransitionHookValidator,
6443
- // appear
6444
- onBeforeAppear: TransitionHookValidator,
6445
- onAppear: TransitionHookValidator,
6446
- onAfterAppear: TransitionHookValidator,
6447
- onAppearCancelled: TransitionHookValidator
6448
- };
6449
- const recursiveGetSubtree = (instance) => {
6450
- const subTree = instance.subTree;
6451
- return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
6452
- };
6453
- const BaseTransitionImpl = {
6454
- name: `BaseTransition`,
6455
- props: BaseTransitionPropsValidators,
6456
- setup(props, { slots }) {
6457
- const instance = getCurrentInstance();
6458
- const state = useTransitionState();
6459
- return () => {
6460
- const children = slots.default && getTransitionRawChildren(slots.default(), true);
6461
- if (!children || !children.length) {
6462
- return;
6463
- }
6464
- let child = children[0];
6465
- if (children.length > 1) {
6466
- let hasFound = false;
6467
- for (const c of children) {
6468
- if (c.type !== Comment) {
6469
- if (hasFound) {
6470
- warn$1(
6471
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
6472
- );
6473
- break;
6474
- }
6475
- child = c;
6476
- hasFound = true;
6477
- }
6478
- }
6479
- }
6480
- const rawProps = reactivity.toRaw(props);
6481
- const { mode } = rawProps;
6482
- if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
6483
- warn$1(`invalid <transition> mode: ${mode}`);
6484
- }
6485
- if (state.isLeaving) {
6486
- return emptyPlaceholder(child);
6487
- }
6488
- const innerChild = getKeepAliveChild(child);
6489
- if (!innerChild) {
6490
- return emptyPlaceholder(child);
6491
- }
6492
- let enterHooks = resolveTransitionHooks(
6493
- innerChild,
6494
- rawProps,
6495
- state,
6496
- instance,
6497
- // #11061, ensure enterHooks is fresh after clone
6498
- (hooks) => enterHooks = hooks
6499
- );
6500
- setTransitionHooks(innerChild, enterHooks);
6501
- const oldChild = instance.subTree;
6502
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
6503
- if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
6504
- const leavingHooks = resolveTransitionHooks(
6505
- oldInnerChild,
6506
- rawProps,
6507
- state,
6508
- instance
6509
- );
6510
- setTransitionHooks(oldInnerChild, leavingHooks);
6511
- if (mode === "out-in" && innerChild.type !== Comment) {
6512
- state.isLeaving = true;
6513
- leavingHooks.afterLeave = () => {
6514
- state.isLeaving = false;
6515
- if (instance.update.active !== false) {
6516
- instance.effect.dirty = true;
6517
- instance.update();
6518
- }
6519
- };
6520
- return emptyPlaceholder(child);
6521
- } else if (mode === "in-out" && innerChild.type !== Comment) {
6522
- leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
6523
- const leavingVNodesCache = getLeavingNodesForType(
6524
- state,
6525
- oldInnerChild
6526
- );
6527
- leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
6528
- el[leaveCbKey] = () => {
6529
- earlyRemove();
6530
- el[leaveCbKey] = void 0;
6531
- delete enterHooks.delayedLeave;
6532
- };
6533
- enterHooks.delayedLeave = delayedLeave;
6534
- };
6535
- }
6494
+ const isSuspense = (type) => type.__isSuspense;
6495
+ let suspenseId = 0;
6496
+ const SuspenseImpl = {
6497
+ name: "Suspense",
6498
+ // In order to make Suspense tree-shakable, we need to avoid importing it
6499
+ // directly in the renderer. The renderer checks for the __isSuspense flag
6500
+ // on a vnode's type and calls the `process` method, passing in renderer
6501
+ // internals.
6502
+ __isSuspense: true,
6503
+ process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
6504
+ if (n1 == null) {
6505
+ mountSuspense(
6506
+ n2,
6507
+ container,
6508
+ anchor,
6509
+ parentComponent,
6510
+ parentSuspense,
6511
+ namespace,
6512
+ slotScopeIds,
6513
+ optimized,
6514
+ rendererInternals
6515
+ );
6516
+ } else {
6517
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
6518
+ n2.suspense = n1.suspense;
6519
+ n2.suspense.vnode = n2;
6520
+ n2.el = n1.el;
6521
+ return;
6536
6522
  }
6537
- return child;
6538
- };
6539
- }
6523
+ patchSuspense(
6524
+ n1,
6525
+ n2,
6526
+ container,
6527
+ anchor,
6528
+ parentComponent,
6529
+ namespace,
6530
+ slotScopeIds,
6531
+ optimized,
6532
+ rendererInternals
6533
+ );
6534
+ }
6535
+ },
6536
+ hydrate: hydrateSuspense,
6537
+ normalize: normalizeSuspenseChildren
6540
6538
  };
6541
- const BaseTransition = BaseTransitionImpl;
6542
- function getLeavingNodesForType(state, vnode) {
6543
- const { leavingVNodes } = state;
6544
- let leavingVNodesCache = leavingVNodes.get(vnode.type);
6545
- if (!leavingVNodesCache) {
6546
- leavingVNodesCache = /* @__PURE__ */ Object.create(null);
6547
- leavingVNodes.set(vnode.type, leavingVNodesCache);
6539
+ const Suspense = SuspenseImpl ;
6540
+ function triggerEvent(vnode, name) {
6541
+ const eventListener = vnode.props && vnode.props[name];
6542
+ if (shared.isFunction(eventListener)) {
6543
+ eventListener();
6548
6544
  }
6549
- return leavingVNodesCache;
6550
6545
  }
6551
- function resolveTransitionHooks(vnode, props, state, instance, postClone) {
6546
+ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
6552
6547
  const {
6553
- appear,
6554
- mode,
6555
- persisted = false,
6556
- onBeforeEnter,
6557
- onEnter,
6558
- onAfterEnter,
6559
- onEnterCancelled,
6560
- onBeforeLeave,
6561
- onLeave,
6562
- onAfterLeave,
6563
- onLeaveCancelled,
6564
- onBeforeAppear,
6565
- onAppear,
6566
- onAfterAppear,
6567
- onAppearCancelled
6568
- } = props;
6569
- const key = String(vnode.key);
6570
- const leavingVNodesCache = getLeavingNodesForType(state, vnode);
6571
- const callHook = (hook, args) => {
6572
- hook && callWithAsyncErrorHandling(
6573
- hook,
6574
- instance,
6575
- 9,
6576
- args
6548
+ p: patch,
6549
+ o: { createElement }
6550
+ } = rendererInternals;
6551
+ const hiddenContainer = createElement("div");
6552
+ const suspense = vnode.suspense = createSuspenseBoundary(
6553
+ vnode,
6554
+ parentSuspense,
6555
+ parentComponent,
6556
+ container,
6557
+ hiddenContainer,
6558
+ anchor,
6559
+ namespace,
6560
+ slotScopeIds,
6561
+ optimized,
6562
+ rendererInternals
6563
+ );
6564
+ patch(
6565
+ null,
6566
+ suspense.pendingBranch = vnode.ssContent,
6567
+ hiddenContainer,
6568
+ null,
6569
+ parentComponent,
6570
+ suspense,
6571
+ namespace,
6572
+ slotScopeIds
6573
+ );
6574
+ if (suspense.deps > 0) {
6575
+ triggerEvent(vnode, "onPending");
6576
+ triggerEvent(vnode, "onFallback");
6577
+ patch(
6578
+ null,
6579
+ vnode.ssFallback,
6580
+ container,
6581
+ anchor,
6582
+ parentComponent,
6583
+ null,
6584
+ // fallback tree will not have suspense context
6585
+ namespace,
6586
+ slotScopeIds
6577
6587
  );
6578
- };
6579
- const callAsyncHook = (hook, args) => {
6580
- const done = args[1];
6581
- callHook(hook, args);
6582
- if (shared.isArray(hook)) {
6583
- if (hook.every((hook2) => hook2.length <= 1)) done();
6584
- } else if (hook.length <= 1) {
6585
- done();
6586
- }
6587
- };
6588
- const hooks = {
6589
- mode,
6590
- persisted,
6591
- beforeEnter(el) {
6592
- let hook = onBeforeEnter;
6593
- if (!state.isMounted) {
6594
- if (appear) {
6595
- hook = onBeforeAppear || onBeforeEnter;
6596
- } else {
6597
- return;
6588
+ setActiveBranch(suspense, vnode.ssFallback);
6589
+ } else {
6590
+ suspense.resolve(false, true);
6591
+ }
6592
+ }
6593
+ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
6594
+ const suspense = n2.suspense = n1.suspense;
6595
+ suspense.vnode = n2;
6596
+ n2.el = n1.el;
6597
+ const newBranch = n2.ssContent;
6598
+ const newFallback = n2.ssFallback;
6599
+ const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
6600
+ if (pendingBranch) {
6601
+ suspense.pendingBranch = newBranch;
6602
+ if (isSameVNodeType(newBranch, pendingBranch)) {
6603
+ patch(
6604
+ pendingBranch,
6605
+ newBranch,
6606
+ suspense.hiddenContainer,
6607
+ null,
6608
+ parentComponent,
6609
+ suspense,
6610
+ namespace,
6611
+ slotScopeIds,
6612
+ optimized
6613
+ );
6614
+ if (suspense.deps <= 0) {
6615
+ suspense.resolve();
6616
+ } else if (isInFallback) {
6617
+ if (!isHydrating) {
6618
+ patch(
6619
+ activeBranch,
6620
+ newFallback,
6621
+ container,
6622
+ anchor,
6623
+ parentComponent,
6624
+ null,
6625
+ // fallback tree will not have suspense context
6626
+ namespace,
6627
+ slotScopeIds,
6628
+ optimized
6629
+ );
6630
+ setActiveBranch(suspense, newFallback);
6598
6631
  }
6599
6632
  }
6600
- if (el[leaveCbKey]) {
6601
- el[leaveCbKey](
6602
- true
6603
- /* cancelled */
6604
- );
6605
- }
6606
- const leavingVNode = leavingVNodesCache[key];
6607
- if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
6608
- leavingVNode.el[leaveCbKey]();
6609
- }
6610
- callHook(hook, [el]);
6611
- },
6612
- enter(el) {
6613
- let hook = onEnter;
6614
- let afterHook = onAfterEnter;
6615
- let cancelHook = onEnterCancelled;
6616
- if (!state.isMounted) {
6617
- if (appear) {
6618
- hook = onAppear || onEnter;
6619
- afterHook = onAfterAppear || onAfterEnter;
6620
- cancelHook = onAppearCancelled || onEnterCancelled;
6621
- } else {
6622
- return;
6623
- }
6633
+ } else {
6634
+ suspense.pendingId = suspenseId++;
6635
+ if (isHydrating) {
6636
+ suspense.isHydrating = false;
6637
+ suspense.activeBranch = pendingBranch;
6638
+ } else {
6639
+ unmount(pendingBranch, parentComponent, suspense);
6624
6640
  }
6625
- let called = false;
6626
- const done = el[enterCbKey] = (cancelled) => {
6627
- if (called) return;
6628
- called = true;
6629
- if (cancelled) {
6630
- callHook(cancelHook, [el]);
6641
+ suspense.deps = 0;
6642
+ suspense.effects.length = 0;
6643
+ suspense.hiddenContainer = createElement("div");
6644
+ if (isInFallback) {
6645
+ patch(
6646
+ null,
6647
+ newBranch,
6648
+ suspense.hiddenContainer,
6649
+ null,
6650
+ parentComponent,
6651
+ suspense,
6652
+ namespace,
6653
+ slotScopeIds,
6654
+ optimized
6655
+ );
6656
+ if (suspense.deps <= 0) {
6657
+ suspense.resolve();
6631
6658
  } else {
6632
- callHook(afterHook, [el]);
6633
- }
6634
- if (hooks.delayedLeave) {
6635
- hooks.delayedLeave();
6659
+ patch(
6660
+ activeBranch,
6661
+ newFallback,
6662
+ container,
6663
+ anchor,
6664
+ parentComponent,
6665
+ null,
6666
+ // fallback tree will not have suspense context
6667
+ namespace,
6668
+ slotScopeIds,
6669
+ optimized
6670
+ );
6671
+ setActiveBranch(suspense, newFallback);
6636
6672
  }
6637
- el[enterCbKey] = void 0;
6638
- };
6639
- if (hook) {
6640
- callAsyncHook(hook, [el, done]);
6673
+ } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
6674
+ patch(
6675
+ activeBranch,
6676
+ newBranch,
6677
+ container,
6678
+ anchor,
6679
+ parentComponent,
6680
+ suspense,
6681
+ namespace,
6682
+ slotScopeIds,
6683
+ optimized
6684
+ );
6685
+ suspense.resolve(true);
6641
6686
  } else {
6642
- done();
6643
- }
6644
- },
6645
- leave(el, remove) {
6646
- const key2 = String(vnode.key);
6647
- if (el[enterCbKey]) {
6648
- el[enterCbKey](
6649
- true
6650
- /* cancelled */
6687
+ patch(
6688
+ null,
6689
+ newBranch,
6690
+ suspense.hiddenContainer,
6691
+ null,
6692
+ parentComponent,
6693
+ suspense,
6694
+ namespace,
6695
+ slotScopeIds,
6696
+ optimized
6651
6697
  );
6652
- }
6653
- if (state.isUnmounting) {
6654
- return remove();
6655
- }
6656
- callHook(onBeforeLeave, [el]);
6657
- let called = false;
6658
- const done = el[leaveCbKey] = (cancelled) => {
6659
- if (called) return;
6660
- called = true;
6661
- remove();
6662
- if (cancelled) {
6663
- callHook(onLeaveCancelled, [el]);
6664
- } else {
6665
- callHook(onAfterLeave, [el]);
6666
- }
6667
- el[leaveCbKey] = void 0;
6668
- if (leavingVNodesCache[key2] === vnode) {
6669
- delete leavingVNodesCache[key2];
6698
+ if (suspense.deps <= 0) {
6699
+ suspense.resolve();
6670
6700
  }
6671
- };
6672
- leavingVNodesCache[key2] = vnode;
6673
- if (onLeave) {
6674
- callAsyncHook(onLeave, [el, done]);
6701
+ }
6702
+ }
6703
+ } else {
6704
+ if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
6705
+ patch(
6706
+ activeBranch,
6707
+ newBranch,
6708
+ container,
6709
+ anchor,
6710
+ parentComponent,
6711
+ suspense,
6712
+ namespace,
6713
+ slotScopeIds,
6714
+ optimized
6715
+ );
6716
+ setActiveBranch(suspense, newBranch);
6717
+ } else {
6718
+ triggerEvent(n2, "onPending");
6719
+ suspense.pendingBranch = newBranch;
6720
+ if (newBranch.shapeFlag & 512) {
6721
+ suspense.pendingId = newBranch.component.suspenseId;
6675
6722
  } else {
6676
- done();
6723
+ suspense.pendingId = suspenseId++;
6677
6724
  }
6678
- },
6679
- clone(vnode2) {
6680
- const hooks2 = resolveTransitionHooks(
6681
- vnode2,
6682
- props,
6683
- state,
6684
- instance,
6685
- postClone
6725
+ patch(
6726
+ null,
6727
+ newBranch,
6728
+ suspense.hiddenContainer,
6729
+ null,
6730
+ parentComponent,
6731
+ suspense,
6732
+ namespace,
6733
+ slotScopeIds,
6734
+ optimized
6686
6735
  );
6687
- if (postClone) postClone(hooks2);
6688
- return hooks2;
6689
- }
6690
- };
6691
- return hooks;
6692
- }
6693
- function emptyPlaceholder(vnode) {
6694
- if (isKeepAlive(vnode)) {
6695
- vnode = cloneVNode(vnode);
6696
- vnode.children = null;
6697
- return vnode;
6698
- }
6699
- }
6700
- function getKeepAliveChild(vnode) {
6701
- if (!isKeepAlive(vnode)) {
6702
- return vnode;
6703
- }
6704
- if (vnode.component) {
6705
- return vnode.component.subTree;
6706
- }
6707
- const { shapeFlag, children } = vnode;
6708
- if (children) {
6709
- if (shapeFlag & 16) {
6710
- return children[0];
6711
- }
6712
- if (shapeFlag & 32 && shared.isFunction(children.default)) {
6713
- return children.default();
6736
+ if (suspense.deps <= 0) {
6737
+ suspense.resolve();
6738
+ } else {
6739
+ const { timeout, pendingId } = suspense;
6740
+ if (timeout > 0) {
6741
+ setTimeout(() => {
6742
+ if (suspense.pendingId === pendingId) {
6743
+ suspense.fallback(newFallback);
6744
+ }
6745
+ }, timeout);
6746
+ } else if (timeout === 0) {
6747
+ suspense.fallback(newFallback);
6748
+ }
6749
+ }
6714
6750
  }
6715
6751
  }
6716
6752
  }
6717
- function setTransitionHooks(vnode, hooks) {
6718
- if (vnode.shapeFlag & 6 && vnode.component) {
6719
- setTransitionHooks(vnode.component.subTree, hooks);
6720
- } else if (vnode.shapeFlag & 128) {
6721
- vnode.ssContent.transition = hooks.clone(vnode.ssContent);
6722
- vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
6723
- } else {
6724
- vnode.transition = hooks;
6753
+ let hasWarned = false;
6754
+ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
6755
+ if (!hasWarned) {
6756
+ hasWarned = true;
6757
+ console[console.info ? "info" : "log"](
6758
+ `<Suspense> is an experimental feature and its API will likely change.`
6759
+ );
6725
6760
  }
6726
- }
6727
- function getTransitionRawChildren(children, keepComment = false, parentKey) {
6728
- let ret = [];
6729
- let keyedFragmentCount = 0;
6730
- for (let i = 0; i < children.length; i++) {
6731
- let child = children[i];
6732
- const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
6733
- if (child.type === Fragment) {
6734
- if (child.patchFlag & 128) keyedFragmentCount++;
6735
- ret = ret.concat(
6736
- getTransitionRawChildren(child.children, keepComment, key)
6737
- );
6738
- } else if (keepComment || child.type !== Comment) {
6739
- ret.push(key != null ? cloneVNode(child, { key }) : child);
6761
+ const {
6762
+ p: patch,
6763
+ m: move,
6764
+ um: unmount,
6765
+ n: next,
6766
+ o: { parentNode, remove }
6767
+ } = rendererInternals;
6768
+ let parentSuspenseId;
6769
+ const isSuspensible = isVNodeSuspensible(vnode);
6770
+ if (isSuspensible) {
6771
+ if (parentSuspense && parentSuspense.pendingBranch) {
6772
+ parentSuspenseId = parentSuspense.pendingId;
6773
+ parentSuspense.deps++;
6740
6774
  }
6741
6775
  }
6742
- if (keyedFragmentCount > 1) {
6743
- for (let i = 0; i < ret.length; i++) {
6744
- ret[i].patchFlag = -2;
6745
- }
6776
+ const timeout = vnode.props ? shared.toNumber(vnode.props.timeout) : void 0;
6777
+ {
6778
+ assertNumber(timeout, `Suspense timeout`);
6746
6779
  }
6747
- return ret;
6748
- }
6749
-
6750
- const isTeleport = (type) => type.__isTeleport;
6751
- const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
6752
- const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
6753
- const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
6754
- const resolveTarget = (props, select) => {
6755
- const targetSelector = props && props.to;
6756
- if (shared.isString(targetSelector)) {
6757
- if (!select) {
6758
- warn$1(
6759
- `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
6760
- );
6761
- return null;
6762
- } else {
6763
- const target = select(targetSelector);
6764
- if (!target && !isTeleportDisabled(props)) {
6765
- warn$1(
6766
- `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
6767
- );
6780
+ const initialAnchor = anchor;
6781
+ const suspense = {
6782
+ vnode,
6783
+ parent: parentSuspense,
6784
+ parentComponent,
6785
+ namespace,
6786
+ container,
6787
+ hiddenContainer,
6788
+ deps: 0,
6789
+ pendingId: suspenseId++,
6790
+ timeout: typeof timeout === "number" ? timeout : -1,
6791
+ activeBranch: null,
6792
+ pendingBranch: null,
6793
+ isInFallback: !isHydrating,
6794
+ isHydrating,
6795
+ isUnmounted: false,
6796
+ effects: [],
6797
+ resolve(resume = false, sync = false) {
6798
+ {
6799
+ if (!resume && !suspense.pendingBranch) {
6800
+ throw new Error(
6801
+ `suspense.resolve() is called without a pending branch.`
6802
+ );
6803
+ }
6804
+ if (suspense.isUnmounted) {
6805
+ throw new Error(
6806
+ `suspense.resolve() is called on an already unmounted suspense boundary.`
6807
+ );
6808
+ }
6809
+ }
6810
+ const {
6811
+ vnode: vnode2,
6812
+ activeBranch,
6813
+ pendingBranch,
6814
+ pendingId,
6815
+ effects,
6816
+ parentComponent: parentComponent2,
6817
+ container: container2
6818
+ } = suspense;
6819
+ let delayEnter = false;
6820
+ if (suspense.isHydrating) {
6821
+ suspense.isHydrating = false;
6822
+ } else if (!resume) {
6823
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
6824
+ if (delayEnter) {
6825
+ activeBranch.transition.afterLeave = () => {
6826
+ if (pendingId === suspense.pendingId) {
6827
+ move(
6828
+ pendingBranch,
6829
+ container2,
6830
+ anchor === initialAnchor ? next(activeBranch) : anchor,
6831
+ 0
6832
+ );
6833
+ queuePostFlushCb(effects);
6834
+ }
6835
+ };
6836
+ }
6837
+ if (activeBranch) {
6838
+ if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
6839
+ anchor = next(activeBranch);
6840
+ }
6841
+ unmount(activeBranch, parentComponent2, suspense, true);
6842
+ }
6843
+ if (!delayEnter) {
6844
+ move(pendingBranch, container2, anchor, 0);
6845
+ }
6768
6846
  }
6769
- return target;
6770
- }
6771
- } else {
6772
- if (!targetSelector && !isTeleportDisabled(props)) {
6773
- warn$1(`Invalid Teleport target: ${targetSelector}`);
6774
- }
6775
- return targetSelector;
6776
- }
6777
- };
6778
- const TeleportImpl = {
6779
- name: "Teleport",
6780
- __isTeleport: true,
6781
- process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
6782
- const {
6783
- mc: mountChildren,
6784
- pc: patchChildren,
6785
- pbc: patchBlockChildren,
6786
- o: { insert, querySelector, createText, createComment }
6787
- } = internals;
6788
- const disabled = isTeleportDisabled(n2.props);
6789
- let { shapeFlag, children, dynamicChildren } = n2;
6790
- if (isHmrUpdating) {
6791
- optimized = false;
6792
- dynamicChildren = null;
6793
- }
6794
- if (n1 == null) {
6795
- const placeholder = n2.el = createComment("teleport start") ;
6796
- const mainAnchor = n2.anchor = createComment("teleport end") ;
6797
- insert(placeholder, container, anchor);
6798
- insert(mainAnchor, container, anchor);
6799
- const target = n2.target = resolveTarget(n2.props, querySelector);
6800
- const targetAnchor = n2.targetAnchor = createText("");
6801
- if (target) {
6802
- insert(targetAnchor, target);
6803
- if (namespace === "svg" || isTargetSVG(target)) {
6804
- namespace = "svg";
6805
- } else if (namespace === "mathml" || isTargetMathML(target)) {
6806
- namespace = "mathml";
6847
+ setActiveBranch(suspense, pendingBranch);
6848
+ suspense.pendingBranch = null;
6849
+ suspense.isInFallback = false;
6850
+ let parent = suspense.parent;
6851
+ let hasUnresolvedAncestor = false;
6852
+ while (parent) {
6853
+ if (parent.pendingBranch) {
6854
+ parent.effects.push(...effects);
6855
+ hasUnresolvedAncestor = true;
6856
+ break;
6807
6857
  }
6808
- } else if (!disabled) {
6809
- warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`);
6858
+ parent = parent.parent;
6810
6859
  }
6811
- const mount = (container2, anchor2) => {
6812
- if (shapeFlag & 16) {
6813
- mountChildren(
6814
- children,
6815
- container2,
6816
- anchor2,
6817
- parentComponent,
6818
- parentSuspense,
6819
- namespace,
6820
- slotScopeIds,
6821
- optimized
6822
- );
6860
+ if (!hasUnresolvedAncestor && !delayEnter) {
6861
+ queuePostFlushCb(effects);
6862
+ }
6863
+ suspense.effects = [];
6864
+ if (isSuspensible) {
6865
+ if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
6866
+ parentSuspense.deps--;
6867
+ if (parentSuspense.deps === 0 && !sync) {
6868
+ parentSuspense.resolve();
6869
+ }
6823
6870
  }
6824
- };
6825
- if (disabled) {
6826
- mount(container, mainAnchor);
6827
- } else if (target) {
6828
- mount(target, targetAnchor);
6829
6871
  }
6830
- } else {
6831
- n2.el = n1.el;
6832
- const mainAnchor = n2.anchor = n1.anchor;
6833
- const target = n2.target = n1.target;
6834
- const targetAnchor = n2.targetAnchor = n1.targetAnchor;
6835
- const wasDisabled = isTeleportDisabled(n1.props);
6836
- const currentContainer = wasDisabled ? container : target;
6837
- const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
6838
- if (namespace === "svg" || isTargetSVG(target)) {
6839
- namespace = "svg";
6840
- } else if (namespace === "mathml" || isTargetMathML(target)) {
6841
- namespace = "mathml";
6872
+ triggerEvent(vnode2, "onResolve");
6873
+ },
6874
+ fallback(fallbackVNode) {
6875
+ if (!suspense.pendingBranch) {
6876
+ return;
6842
6877
  }
6843
- if (dynamicChildren) {
6844
- patchBlockChildren(
6845
- n1.dynamicChildren,
6846
- dynamicChildren,
6847
- currentContainer,
6848
- parentComponent,
6849
- parentSuspense,
6850
- namespace,
6851
- slotScopeIds
6852
- );
6853
- traverseStaticChildren(n1, n2, true);
6854
- } else if (!optimized) {
6855
- patchChildren(
6856
- n1,
6857
- n2,
6858
- currentContainer,
6859
- currentAnchor,
6860
- parentComponent,
6861
- parentSuspense,
6862
- namespace,
6878
+ const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
6879
+ triggerEvent(vnode2, "onFallback");
6880
+ const anchor2 = next(activeBranch);
6881
+ const mountFallback = () => {
6882
+ if (!suspense.isInFallback) {
6883
+ return;
6884
+ }
6885
+ patch(
6886
+ null,
6887
+ fallbackVNode,
6888
+ container2,
6889
+ anchor2,
6890
+ parentComponent2,
6891
+ null,
6892
+ // fallback tree will not have suspense context
6893
+ namespace2,
6863
6894
  slotScopeIds,
6864
- false
6895
+ optimized
6865
6896
  );
6897
+ setActiveBranch(suspense, fallbackVNode);
6898
+ };
6899
+ const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
6900
+ if (delayEnter) {
6901
+ activeBranch.transition.afterLeave = mountFallback;
6866
6902
  }
6867
- if (disabled) {
6868
- if (!wasDisabled) {
6869
- moveTeleport(
6870
- n2,
6871
- container,
6872
- mainAnchor,
6873
- internals,
6874
- 1
6875
- );
6876
- } else {
6877
- if (n2.props && n1.props && n2.props.to !== n1.props.to) {
6878
- n2.props.to = n1.props.to;
6879
- }
6903
+ suspense.isInFallback = true;
6904
+ unmount(
6905
+ activeBranch,
6906
+ parentComponent2,
6907
+ null,
6908
+ // no suspense so unmount hooks fire now
6909
+ true
6910
+ // shouldRemove
6911
+ );
6912
+ if (!delayEnter) {
6913
+ mountFallback();
6914
+ }
6915
+ },
6916
+ move(container2, anchor2, type) {
6917
+ suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
6918
+ suspense.container = container2;
6919
+ },
6920
+ next() {
6921
+ return suspense.activeBranch && next(suspense.activeBranch);
6922
+ },
6923
+ registerDep(instance, setupRenderEffect, optimized2) {
6924
+ const isInPendingSuspense = !!suspense.pendingBranch;
6925
+ if (isInPendingSuspense) {
6926
+ suspense.deps++;
6927
+ }
6928
+ const hydratedEl = instance.vnode.el;
6929
+ instance.asyncDep.catch((err) => {
6930
+ handleError(err, instance, 0);
6931
+ }).then((asyncSetupResult) => {
6932
+ if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
6933
+ return;
6880
6934
  }
6881
- } else {
6882
- if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
6883
- const nextTarget = n2.target = resolveTarget(
6884
- n2.props,
6885
- querySelector
6886
- );
6887
- if (nextTarget) {
6888
- moveTeleport(
6889
- n2,
6890
- nextTarget,
6891
- null,
6892
- internals,
6893
- 0
6894
- );
6895
- } else {
6896
- warn$1(
6897
- "Invalid Teleport target on update:",
6898
- target,
6899
- `(${typeof target})`
6900
- );
6901
- }
6902
- } else if (wasDisabled) {
6903
- moveTeleport(
6904
- n2,
6905
- target,
6906
- targetAnchor,
6907
- internals,
6908
- 1
6909
- );
6935
+ instance.asyncResolved = true;
6936
+ const { vnode: vnode2 } = instance;
6937
+ {
6938
+ pushWarningContext(vnode2);
6939
+ }
6940
+ handleSetupResult(instance, asyncSetupResult, false);
6941
+ if (hydratedEl) {
6942
+ vnode2.el = hydratedEl;
6943
+ }
6944
+ const placeholder = !hydratedEl && instance.subTree.el;
6945
+ setupRenderEffect(
6946
+ instance,
6947
+ vnode2,
6948
+ // component may have been moved before resolve.
6949
+ // if this is not a hydration, instance.subTree will be the comment
6950
+ // placeholder.
6951
+ parentNode(hydratedEl || instance.subTree.el),
6952
+ // anchor will not be used if this is hydration, so only need to
6953
+ // consider the comment placeholder case.
6954
+ hydratedEl ? null : next(instance.subTree),
6955
+ suspense,
6956
+ namespace,
6957
+ optimized2
6958
+ );
6959
+ if (placeholder) {
6960
+ remove(placeholder);
6961
+ }
6962
+ updateHOCHostEl(instance, vnode2.el);
6963
+ {
6964
+ popWarningContext();
6965
+ }
6966
+ if (isInPendingSuspense && --suspense.deps === 0) {
6967
+ suspense.resolve();
6910
6968
  }
6969
+ });
6970
+ },
6971
+ unmount(parentSuspense2, doRemove) {
6972
+ suspense.isUnmounted = true;
6973
+ if (suspense.activeBranch) {
6974
+ unmount(
6975
+ suspense.activeBranch,
6976
+ parentComponent,
6977
+ parentSuspense2,
6978
+ doRemove
6979
+ );
6911
6980
  }
6912
- }
6913
- updateCssVars(n2);
6914
- },
6915
- remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
6916
- const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
6917
- if (target) {
6918
- hostRemove(targetAnchor);
6919
- }
6920
- doRemove && hostRemove(anchor);
6921
- if (shapeFlag & 16) {
6922
- const shouldRemove = doRemove || !isTeleportDisabled(props);
6923
- for (let i = 0; i < children.length; i++) {
6924
- const child = children[i];
6981
+ if (suspense.pendingBranch) {
6925
6982
  unmount(
6926
- child,
6983
+ suspense.pendingBranch,
6927
6984
  parentComponent,
6928
- parentSuspense,
6929
- shouldRemove,
6930
- !!child.dynamicChildren
6985
+ parentSuspense2,
6986
+ doRemove
6931
6987
  );
6932
6988
  }
6933
6989
  }
6934
- },
6935
- move: moveTeleport,
6936
- hydrate: hydrateTeleport
6937
- };
6938
- function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
6939
- if (moveType === 0) {
6940
- insert(vnode.targetAnchor, container, parentAnchor);
6990
+ };
6991
+ return suspense;
6992
+ }
6993
+ function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
6994
+ const suspense = vnode.suspense = createSuspenseBoundary(
6995
+ vnode,
6996
+ parentSuspense,
6997
+ parentComponent,
6998
+ node.parentNode,
6999
+ // eslint-disable-next-line no-restricted-globals
7000
+ document.createElement("div"),
7001
+ null,
7002
+ namespace,
7003
+ slotScopeIds,
7004
+ optimized,
7005
+ rendererInternals,
7006
+ true
7007
+ );
7008
+ const result = hydrateNode(
7009
+ node,
7010
+ suspense.pendingBranch = vnode.ssContent,
7011
+ parentComponent,
7012
+ suspense,
7013
+ slotScopeIds,
7014
+ optimized
7015
+ );
7016
+ if (suspense.deps === 0) {
7017
+ suspense.resolve(false, true);
6941
7018
  }
6942
- const { el, anchor, shapeFlag, children, props } = vnode;
6943
- const isReorder = moveType === 2;
6944
- if (isReorder) {
6945
- insert(el, container, parentAnchor);
7019
+ return result;
7020
+ }
7021
+ function normalizeSuspenseChildren(vnode) {
7022
+ const { shapeFlag, children } = vnode;
7023
+ const isSlotChildren = shapeFlag & 32;
7024
+ vnode.ssContent = normalizeSuspenseSlot(
7025
+ isSlotChildren ? children.default : children
7026
+ );
7027
+ vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
7028
+ }
7029
+ function normalizeSuspenseSlot(s) {
7030
+ let block;
7031
+ if (shared.isFunction(s)) {
7032
+ const trackBlock = isBlockTreeEnabled && s._c;
7033
+ if (trackBlock) {
7034
+ s._d = false;
7035
+ openBlock();
7036
+ }
7037
+ s = s();
7038
+ if (trackBlock) {
7039
+ s._d = true;
7040
+ block = currentBlock;
7041
+ closeBlock();
7042
+ }
6946
7043
  }
6947
- if (!isReorder || isTeleportDisabled(props)) {
6948
- if (shapeFlag & 16) {
6949
- for (let i = 0; i < children.length; i++) {
6950
- move(
6951
- children[i],
6952
- container,
6953
- parentAnchor,
6954
- 2
6955
- );
6956
- }
7044
+ if (shared.isArray(s)) {
7045
+ const singleChild = filterSingleRoot(s);
7046
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
7047
+ warn$1(`<Suspense> slots expect a single root node.`);
6957
7048
  }
7049
+ s = singleChild;
6958
7050
  }
6959
- if (isReorder) {
6960
- insert(anchor, container, parentAnchor);
7051
+ s = normalizeVNode(s);
7052
+ if (block && !s.dynamicChildren) {
7053
+ s.dynamicChildren = block.filter((c) => c !== s);
6961
7054
  }
7055
+ return s;
6962
7056
  }
6963
- function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
6964
- o: { nextSibling, parentNode, querySelector }
6965
- }, hydrateChildren) {
6966
- const target = vnode.target = resolveTarget(
6967
- vnode.props,
6968
- querySelector
6969
- );
6970
- if (target) {
6971
- const targetNode = target._lpa || target.firstChild;
6972
- if (vnode.shapeFlag & 16) {
6973
- if (isTeleportDisabled(vnode.props)) {
6974
- vnode.anchor = hydrateChildren(
6975
- nextSibling(node),
6976
- vnode,
6977
- parentNode(node),
6978
- parentComponent,
6979
- parentSuspense,
6980
- slotScopeIds,
6981
- optimized
6982
- );
6983
- vnode.targetAnchor = targetNode;
6984
- } else {
6985
- vnode.anchor = nextSibling(node);
6986
- let targetAnchor = targetNode;
6987
- while (targetAnchor) {
6988
- targetAnchor = nextSibling(targetAnchor);
6989
- if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
6990
- vnode.targetAnchor = targetAnchor;
6991
- target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
6992
- break;
6993
- }
6994
- }
6995
- hydrateChildren(
6996
- targetNode,
6997
- vnode,
6998
- target,
6999
- parentComponent,
7000
- parentSuspense,
7001
- slotScopeIds,
7002
- optimized
7003
- );
7004
- }
7057
+ function queueEffectWithSuspense(fn, suspense) {
7058
+ if (suspense && suspense.pendingBranch) {
7059
+ if (shared.isArray(fn)) {
7060
+ suspense.effects.push(...fn);
7061
+ } else {
7062
+ suspense.effects.push(fn);
7005
7063
  }
7006
- updateCssVars(vnode);
7064
+ } else {
7065
+ queuePostFlushCb(fn);
7007
7066
  }
7008
- return vnode.anchor && nextSibling(vnode.anchor);
7009
7067
  }
7010
- const Teleport = TeleportImpl;
7011
- function updateCssVars(vnode) {
7012
- const ctx = vnode.ctx;
7013
- if (ctx && ctx.ut) {
7014
- let node = vnode.children[0].el;
7015
- while (node && node !== vnode.targetAnchor) {
7016
- if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
7017
- node = node.nextSibling;
7018
- }
7019
- ctx.ut();
7068
+ function setActiveBranch(suspense, branch) {
7069
+ suspense.activeBranch = branch;
7070
+ const { vnode, parentComponent } = suspense;
7071
+ let el = branch.el;
7072
+ while (!el && branch.component) {
7073
+ branch = branch.component.subTree;
7074
+ el = branch.el;
7075
+ }
7076
+ vnode.el = el;
7077
+ if (parentComponent && parentComponent.subTree === vnode) {
7078
+ parentComponent.vnode.el = el;
7079
+ updateHOCHostEl(parentComponent, el);
7020
7080
  }
7021
7081
  }
7082
+ function isVNodeSuspensible(vnode) {
7083
+ const suspensible = vnode.props && vnode.props.suspensible;
7084
+ return suspensible != null && suspensible !== false;
7085
+ }
7022
7086
 
7023
7087
  const Fragment = Symbol.for("v-fgt");
7024
7088
  const Text = Symbol.for("v-txt");
@@ -7036,6 +7100,9 @@ function closeBlock() {
7036
7100
  let isBlockTreeEnabled = 1;
7037
7101
  function setBlockTracking(value) {
7038
7102
  isBlockTreeEnabled += value;
7103
+ if (value < 0 && currentBlock) {
7104
+ currentBlock.hasOnce = true;
7105
+ }
7039
7106
  }
7040
7107
  function setupBlock(vnode) {
7041
7108
  vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || shared.EMPTY_ARR : null;
@@ -7074,10 +7141,13 @@ function isVNode(value) {
7074
7141
  return value ? value.__v_isVNode === true : false;
7075
7142
  }
7076
7143
  function isSameVNodeType(n1, n2) {
7077
- if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
7078
- n1.shapeFlag &= ~256;
7079
- n2.shapeFlag &= ~512;
7080
- return false;
7144
+ if (n2.shapeFlag & 6 && n1.component) {
7145
+ const dirtyInstances = hmrDirtyComponents.get(n2.type);
7146
+ if (dirtyInstances && dirtyInstances.has(n1.component)) {
7147
+ n1.shapeFlag &= ~256;
7148
+ n2.shapeFlag &= ~512;
7149
+ return false;
7150
+ }
7081
7151
  }
7082
7152
  return n1.type === n2.type && n1.key === n2.key;
7083
7153
  }
@@ -7121,6 +7191,7 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
7121
7191
  el: null,
7122
7192
  anchor: null,
7123
7193
  target: null,
7194
+ targetStart: null,
7124
7195
  targetAnchor: null,
7125
7196
  staticCount: 0,
7126
7197
  shapeFlag,
@@ -7242,6 +7313,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
7242
7313
  slotScopeIds: vnode.slotScopeIds,
7243
7314
  children: patchFlag === -1 && shared.isArray(children) ? children.map(deepCloneVNode) : children,
7244
7315
  target: vnode.target,
7316
+ targetStart: vnode.targetStart,
7245
7317
  targetAnchor: vnode.targetAnchor,
7246
7318
  staticCount: vnode.staticCount,
7247
7319
  shapeFlag: vnode.shapeFlag,
@@ -7529,12 +7601,12 @@ function isStatefulComponent(instance) {
7529
7601
  return instance.vnode.shapeFlag & 4;
7530
7602
  }
7531
7603
  let isInSSRComponentSetup = false;
7532
- function setupComponent(instance, isSSR = false) {
7604
+ function setupComponent(instance, isSSR = false, optimized = false) {
7533
7605
  isSSR && setInSSRSetupState(isSSR);
7534
7606
  const { props, children } = instance.vnode;
7535
7607
  const isStateful = isStatefulComponent(instance);
7536
7608
  initProps(instance, props, isStateful, isSSR);
7537
- initSlots(instance, children);
7609
+ initSlots(instance, children, optimized);
7538
7610
  const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
7539
7611
  isSSR && setInSSRSetupState(false);
7540
7612
  return setupResult;
@@ -7822,59 +7894,6 @@ const computed = (getterOrOptions, debugOptions) => {
7822
7894
  return c;
7823
7895
  };
7824
7896
 
7825
- function useModel(props, name, options = shared.EMPTY_OBJ) {
7826
- const i = getCurrentInstance();
7827
- if (!i) {
7828
- warn$1(`useModel() called without active instance.`);
7829
- return reactivity.ref();
7830
- }
7831
- if (!i.propsOptions[0][name]) {
7832
- warn$1(`useModel() called with prop "${name}" which is not declared.`);
7833
- return reactivity.ref();
7834
- }
7835
- const camelizedName = shared.camelize(name);
7836
- const hyphenatedName = shared.hyphenate(name);
7837
- const res = reactivity.customRef((track, trigger) => {
7838
- let localValue;
7839
- watchSyncEffect(() => {
7840
- const propValue = props[name];
7841
- if (shared.hasChanged(localValue, propValue)) {
7842
- localValue = propValue;
7843
- trigger();
7844
- }
7845
- });
7846
- return {
7847
- get() {
7848
- track();
7849
- return options.get ? options.get(localValue) : localValue;
7850
- },
7851
- set(value) {
7852
- const rawProps = i.vnode.props;
7853
- if (!(rawProps && // check if parent has passed v-model
7854
- (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && shared.hasChanged(value, localValue)) {
7855
- localValue = value;
7856
- trigger();
7857
- }
7858
- i.emit(`update:${name}`, options.set ? options.set(value) : value);
7859
- }
7860
- };
7861
- });
7862
- const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
7863
- res[Symbol.iterator] = () => {
7864
- let i2 = 0;
7865
- return {
7866
- next() {
7867
- if (i2 < 2) {
7868
- return { value: i2++ ? props[modifierKey] || {} : res, done: false };
7869
- } else {
7870
- return { done: true };
7871
- }
7872
- }
7873
- };
7874
- };
7875
- return res;
7876
- }
7877
-
7878
7897
  function h(type, propsOrChildren, children) {
7879
7898
  const l = arguments.length;
7880
7899
  if (l === 2) {
@@ -7905,6 +7924,7 @@ function initCustomFormatter() {
7905
7924
  const stringStyle = { style: "color:#f5222d" };
7906
7925
  const keywordStyle = { style: "color:#eb2f96" };
7907
7926
  const formatter = {
7927
+ __vue_custom_formatter: true,
7908
7928
  header(obj) {
7909
7929
  if (!shared.isObject(obj)) {
7910
7930
  return null;
@@ -8079,7 +8099,7 @@ function withMemo(memo, render, cache, index) {
8079
8099
  }
8080
8100
  const ret = render();
8081
8101
  ret.memo = memo.slice();
8082
- ret.memoIndex = index;
8102
+ ret.cacheIndex = index;
8083
8103
  return cache[index] = ret;
8084
8104
  }
8085
8105
  function isMemoSame(cached, memo) {
@@ -8098,7 +8118,7 @@ function isMemoSame(cached, memo) {
8098
8118
  return true;
8099
8119
  }
8100
8120
 
8101
- const version = "3.4.31";
8121
+ const version = "3.4.32";
8102
8122
  const warn = warn$1 ;
8103
8123
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8104
8124
  const devtools = devtools$1 ;