@cabloy/vue-runtime-core 3.4.33 → 3.4.35

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