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