@cabloy/vue-runtime-core 3.4.33 → 3.4.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @cabloy/vue-runtime-core v3.4.31
2
+ * @cabloy/vue-runtime-core v3.4.34
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -44,7 +44,9 @@ const ErrorCodes = {
44
44
  "ASYNC_COMPONENT_LOADER": 13,
45
45
  "13": "ASYNC_COMPONENT_LOADER",
46
46
  "SCHEDULER": 14,
47
- "14": "SCHEDULER"
47
+ "14": "SCHEDULER",
48
+ "COMPONENT_UPDATE": 15,
49
+ "15": "COMPONENT_UPDATE"
48
50
  };
49
51
  const ErrorTypeStrings$1 = {
50
52
  ["sp"]: "serverPrefetch hook",
@@ -75,7 +77,8 @@ const ErrorTypeStrings$1 = {
75
77
  [11]: "app warnHandler",
76
78
  [12]: "ref function",
77
79
  [13]: "async component loader",
78
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
80
+ [14]: "scheduler flush",
81
+ [15]: "component update"
79
82
  };
80
83
  function callWithErrorHandling(fn, instance, type, args) {
81
84
  try {
@@ -256,7 +259,11 @@ function flushJobs(seen) {
256
259
  const job = queue[flushIndex];
257
260
  if (job && job.active !== false) {
258
261
  if (false) ;
259
- callWithErrorHandling(job, null, 14);
262
+ callWithErrorHandling(
263
+ job,
264
+ job.i,
265
+ job.i ? 15 : 14
266
+ );
260
267
  }
261
268
  }
262
269
  } finally {
@@ -271,103 +278,6 @@ function flushJobs(seen) {
271
278
  }
272
279
  }
273
280
 
274
- function emit(instance, event, ...rawArgs) {
275
- if (instance.isUnmounted) return;
276
- const props = instance.vnode.props || shared.EMPTY_OBJ;
277
- let args = rawArgs;
278
- const isModelListener = event.startsWith("update:");
279
- const modelArg = isModelListener && event.slice(7);
280
- if (modelArg && modelArg in props) {
281
- const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
282
- const { number, trim } = props[modifiersKey] || shared.EMPTY_OBJ;
283
- if (trim) {
284
- args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
285
- }
286
- if (number) {
287
- args = rawArgs.map(shared.looseToNumber);
288
- }
289
- }
290
- let handlerName;
291
- let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
292
- props[handlerName = shared.toHandlerKey(shared.camelize(event))];
293
- if (!handler && isModelListener) {
294
- handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
295
- }
296
- if (handler) {
297
- callWithAsyncErrorHandling(
298
- handler,
299
- instance,
300
- 6,
301
- args
302
- );
303
- }
304
- const onceHandler = props[handlerName + `Once`];
305
- if (onceHandler) {
306
- if (!instance.emitted) {
307
- instance.emitted = {};
308
- } else if (instance.emitted[handlerName]) {
309
- return;
310
- }
311
- instance.emitted[handlerName] = true;
312
- callWithAsyncErrorHandling(
313
- onceHandler,
314
- instance,
315
- 6,
316
- args
317
- );
318
- }
319
- }
320
- function normalizeEmitsOptions(comp, appContext, asMixin = false) {
321
- const cache = appContext.emitsCache;
322
- const cached = cache.get(comp);
323
- if (cached !== void 0) {
324
- return cached;
325
- }
326
- const raw = comp.emits;
327
- let normalized = {};
328
- let hasExtends = false;
329
- if (!shared.isFunction(comp)) {
330
- const extendEmits = (raw2) => {
331
- const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
332
- if (normalizedFromExtend) {
333
- hasExtends = true;
334
- shared.extend(normalized, normalizedFromExtend);
335
- }
336
- };
337
- if (!asMixin && appContext.mixins.length) {
338
- appContext.mixins.forEach(extendEmits);
339
- }
340
- if (comp.extends) {
341
- extendEmits(comp.extends);
342
- }
343
- if (comp.mixins) {
344
- comp.mixins.forEach(extendEmits);
345
- }
346
- }
347
- if (!raw && !hasExtends) {
348
- if (shared.isObject(comp)) {
349
- cache.set(comp, null);
350
- }
351
- return null;
352
- }
353
- if (shared.isArray(raw)) {
354
- raw.forEach((key) => normalized[key] = null);
355
- } else {
356
- shared.extend(normalized, raw);
357
- }
358
- if (shared.isObject(comp)) {
359
- cache.set(comp, normalized);
360
- }
361
- return normalized;
362
- }
363
- function isEmitListener(options, key) {
364
- if (!options || !shared.isOn(key)) {
365
- return false;
366
- }
367
- key = key.slice(2).replace(/Once$/, "");
368
- return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
369
- }
370
-
371
281
  let currentRenderingInstance = null;
372
282
  let currentScopeId = null;
373
283
  function setCurrentRenderingInstance(instance) {
@@ -410,822 +320,769 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
410
320
  return renderFnWithContext;
411
321
  }
412
322
 
413
- function markAttrsAccessed() {
414
- }
415
- function renderComponentRoot(instance) {
416
- const {
417
- type: Component,
418
- vnode,
419
- proxy,
420
- withProxy,
421
- propsOptions: [propsOptions],
422
- slots,
423
- attrs,
424
- emit,
425
- render,
426
- renderCache,
427
- props,
428
- data,
429
- setupState,
430
- ctx,
431
- inheritAttrs
432
- } = instance;
433
- const prev = setCurrentRenderingInstance(instance);
434
- let result;
435
- let fallthroughAttrs;
436
- try {
437
- if (vnode.shapeFlag & 4) {
438
- const proxyToUse = withProxy || proxy;
439
- const thisProxy = false ? new Proxy(proxyToUse, {
440
- get(target, key, receiver) {
441
- warn(
442
- `Property '${String(
443
- key
444
- )}' was accessed via 'this'. Avoid using 'this' in templates.`
445
- );
446
- return Reflect.get(target, key, receiver);
447
- }
448
- }) : proxyToUse;
449
- result = normalizeVNode(
450
- render.call(
451
- thisProxy,
452
- proxyToUse,
453
- renderCache,
454
- false ? shallowReadonly(props) : props,
455
- setupState,
456
- data,
457
- ctx
458
- )
459
- );
460
- fallthroughAttrs = attrs;
461
- } else {
462
- const render2 = Component;
463
- if (false) ;
464
- result = normalizeVNode(
465
- render2.length > 1 ? render2(
466
- false ? shallowReadonly(props) : props,
467
- false ? {
468
- get attrs() {
469
- markAttrsAccessed();
470
- return shallowReadonly(attrs);
471
- },
472
- slots,
473
- emit
474
- } : { attrs, slots, emit }
475
- ) : render2(
476
- false ? shallowReadonly(props) : props,
477
- null
478
- )
479
- );
480
- fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
481
- }
482
- } catch (err) {
483
- blockStack.length = 0;
484
- handleError(err, instance, 1);
485
- result = createVNode(Comment);
323
+ function withDirectives(vnode, directives) {
324
+ if (currentRenderingInstance === null) {
325
+ return vnode;
486
326
  }
487
- let root = result;
488
- if (fallthroughAttrs && inheritAttrs !== false) {
489
- const keys = Object.keys(fallthroughAttrs);
490
- const { shapeFlag } = root;
491
- if (keys.length) {
492
- if (shapeFlag & (1 | 6)) {
493
- if (propsOptions && keys.some(shared.isModelListener)) {
494
- fallthroughAttrs = filterModelListeners(
495
- fallthroughAttrs,
496
- propsOptions
497
- );
498
- }
499
- root = cloneVNode(root, fallthroughAttrs, false, true);
327
+ const instance = getComponentPublicInstance(currentRenderingInstance);
328
+ const bindings = vnode.dirs || (vnode.dirs = []);
329
+ for (let i = 0; i < directives.length; i++) {
330
+ let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
331
+ if (dir) {
332
+ if (shared.isFunction(dir)) {
333
+ dir = {
334
+ mounted: dir,
335
+ updated: dir
336
+ };
500
337
  }
501
- }
502
- }
503
- if (vnode.dirs) {
504
- root = cloneVNode(root, null, false, true);
505
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
506
- }
507
- if (vnode.transition) {
508
- root.transition = vnode.transition;
509
- }
510
- {
511
- result = root;
512
- }
513
- setCurrentRenderingInstance(prev);
514
- return result;
515
- }
516
- function filterSingleRoot(children, recurse = true) {
517
- let singleRoot;
518
- for (let i = 0; i < children.length; i++) {
519
- const child = children[i];
520
- if (isVNode(child)) {
521
- if (child.type !== Comment || child.children === "v-if") {
522
- if (singleRoot) {
523
- return;
524
- } else {
525
- singleRoot = child;
526
- }
338
+ if (dir.deep) {
339
+ traverse(value);
527
340
  }
528
- } else {
529
- return;
341
+ bindings.push({
342
+ dir,
343
+ instance,
344
+ value,
345
+ oldValue: void 0,
346
+ arg,
347
+ modifiers
348
+ });
530
349
  }
531
350
  }
532
- return singleRoot;
351
+ return vnode;
533
352
  }
534
- const getFunctionalFallthrough = (attrs) => {
535
- let res;
536
- for (const key in attrs) {
537
- if (key === "class" || key === "style" || shared.isOn(key)) {
538
- (res || (res = {}))[key] = attrs[key];
353
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
354
+ const bindings = vnode.dirs;
355
+ const oldBindings = prevVNode && prevVNode.dirs;
356
+ for (let i = 0; i < bindings.length; i++) {
357
+ const binding = bindings[i];
358
+ if (oldBindings) {
359
+ binding.oldValue = oldBindings[i].value;
360
+ }
361
+ let hook = binding.dir[name];
362
+ if (hook) {
363
+ reactivity.pauseTracking();
364
+ callWithAsyncErrorHandling(hook, instance, 8, [
365
+ vnode.el,
366
+ binding,
367
+ vnode,
368
+ prevVNode
369
+ ]);
370
+ reactivity.resetTracking();
539
371
  }
540
372
  }
541
- return res;
542
- };
543
- const filterModelListeners = (attrs, props) => {
544
- const res = {};
545
- for (const key in attrs) {
546
- if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
547
- res[key] = attrs[key];
548
- }
549
- }
550
- return res;
373
+ }
374
+
375
+ const leaveCbKey = Symbol("_leaveCb");
376
+ const enterCbKey = Symbol("_enterCb");
377
+ function useTransitionState() {
378
+ const state = {
379
+ isMounted: false,
380
+ isLeaving: false,
381
+ isUnmounting: false,
382
+ leavingVNodes: /* @__PURE__ */ new Map()
383
+ };
384
+ onMounted(() => {
385
+ state.isMounted = true;
386
+ });
387
+ onBeforeUnmount(() => {
388
+ state.isUnmounting = true;
389
+ });
390
+ return state;
391
+ }
392
+ const TransitionHookValidator = [Function, Array];
393
+ const BaseTransitionPropsValidators = {
394
+ mode: String,
395
+ appear: Boolean,
396
+ persisted: Boolean,
397
+ // enter
398
+ onBeforeEnter: TransitionHookValidator,
399
+ onEnter: TransitionHookValidator,
400
+ onAfterEnter: TransitionHookValidator,
401
+ onEnterCancelled: TransitionHookValidator,
402
+ // leave
403
+ onBeforeLeave: TransitionHookValidator,
404
+ onLeave: TransitionHookValidator,
405
+ onAfterLeave: TransitionHookValidator,
406
+ onLeaveCancelled: TransitionHookValidator,
407
+ // appear
408
+ onBeforeAppear: TransitionHookValidator,
409
+ onAppear: TransitionHookValidator,
410
+ onAfterAppear: TransitionHookValidator,
411
+ onAppearCancelled: TransitionHookValidator
551
412
  };
552
- function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
553
- const { props: prevProps, children: prevChildren, component } = prevVNode;
554
- const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
555
- const emits = component.emitsOptions;
556
- if (nextVNode.dirs || nextVNode.transition) {
557
- return true;
558
- }
559
- if (optimized && patchFlag >= 0) {
560
- if (patchFlag & 1024) {
561
- return true;
562
- }
563
- if (patchFlag & 16) {
564
- if (!prevProps) {
565
- return !!nextProps;
413
+ const recursiveGetSubtree = (instance) => {
414
+ const subTree = instance.subTree;
415
+ return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
416
+ };
417
+ const BaseTransitionImpl = {
418
+ name: `BaseTransition`,
419
+ props: BaseTransitionPropsValidators,
420
+ setup(props, { slots }) {
421
+ const instance = getCurrentInstance();
422
+ const state = useTransitionState();
423
+ return () => {
424
+ const children = slots.default && getTransitionRawChildren(slots.default(), true);
425
+ if (!children || !children.length) {
426
+ return;
566
427
  }
567
- return hasPropsChanged(prevProps, nextProps, emits);
568
- } else if (patchFlag & 8) {
569
- const dynamicProps = nextVNode.dynamicProps;
570
- for (let i = 0; i < dynamicProps.length; i++) {
571
- const key = dynamicProps[i];
572
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
573
- return true;
428
+ let child = children[0];
429
+ if (children.length > 1) {
430
+ for (const c of children) {
431
+ if (c.type !== Comment) {
432
+ child = c;
433
+ break;
434
+ }
574
435
  }
575
436
  }
576
- }
577
- } else {
578
- if (prevChildren || nextChildren) {
579
- if (!nextChildren || !nextChildren.$stable) {
580
- return true;
437
+ const rawProps = reactivity.toRaw(props);
438
+ const { mode } = rawProps;
439
+ if (state.isLeaving) {
440
+ return emptyPlaceholder(child);
581
441
  }
582
- }
583
- if (prevProps === nextProps) {
584
- return false;
585
- }
586
- if (!prevProps) {
587
- return !!nextProps;
588
- }
589
- if (!nextProps) {
590
- return true;
591
- }
592
- return hasPropsChanged(prevProps, nextProps, emits);
593
- }
594
- return false;
595
- }
596
- function hasPropsChanged(prevProps, nextProps, emitsOptions) {
597
- const nextKeys = Object.keys(nextProps);
598
- if (nextKeys.length !== Object.keys(prevProps).length) {
599
- return true;
600
- }
601
- for (let i = 0; i < nextKeys.length; i++) {
602
- const key = nextKeys[i];
603
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
604
- return true;
605
- }
606
- }
607
- return false;
608
- }
609
- function updateHOCHostEl({ vnode, parent }, el) {
610
- while (parent) {
611
- const root = parent.subTree;
612
- if (root.suspense && root.suspense.activeBranch === vnode) {
613
- root.el = vnode.el;
614
- }
615
- if (root === vnode) {
616
- (vnode = parent.vnode).el = el;
617
- parent = parent.parent;
618
- } else {
619
- break;
620
- }
621
- }
622
- }
623
-
624
- const COMPONENTS = "components";
625
- const DIRECTIVES = "directives";
626
- function resolveComponent(name, maybeSelfReference) {
627
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
628
- }
629
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
630
- function resolveDynamicComponent(component) {
631
- if (shared.isString(component)) {
632
- return resolveAsset(COMPONENTS, component, false) || component;
633
- } else {
634
- return component || NULL_DYNAMIC_COMPONENT;
635
- }
636
- }
637
- function resolveDirective(name) {
638
- return resolveAsset(DIRECTIVES, name);
639
- }
640
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
641
- const instance = currentRenderingInstance || currentInstance;
642
- if (instance) {
643
- const Component = instance.type;
644
- if (type === COMPONENTS) {
645
- const selfName = getComponentName(
646
- Component,
647
- false
442
+ const innerChild = getKeepAliveChild(child);
443
+ if (!innerChild) {
444
+ return emptyPlaceholder(child);
445
+ }
446
+ let enterHooks = resolveTransitionHooks(
447
+ innerChild,
448
+ rawProps,
449
+ state,
450
+ instance,
451
+ // #11061, ensure enterHooks is fresh after clone
452
+ (hooks) => enterHooks = hooks
648
453
  );
649
- if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
650
- return Component;
454
+ setTransitionHooks(innerChild, enterHooks);
455
+ const oldChild = instance.subTree;
456
+ const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
457
+ if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
458
+ const leavingHooks = resolveTransitionHooks(
459
+ oldInnerChild,
460
+ rawProps,
461
+ state,
462
+ instance
463
+ );
464
+ setTransitionHooks(oldInnerChild, leavingHooks);
465
+ if (mode === "out-in" && innerChild.type !== Comment) {
466
+ state.isLeaving = true;
467
+ leavingHooks.afterLeave = () => {
468
+ state.isLeaving = false;
469
+ if (instance.update.active !== false) {
470
+ instance.effect.dirty = true;
471
+ instance.update();
472
+ }
473
+ };
474
+ return emptyPlaceholder(child);
475
+ } else if (mode === "in-out" && innerChild.type !== Comment) {
476
+ leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
477
+ const leavingVNodesCache = getLeavingNodesForType(
478
+ state,
479
+ oldInnerChild
480
+ );
481
+ leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
482
+ el[leaveCbKey] = () => {
483
+ earlyRemove();
484
+ el[leaveCbKey] = void 0;
485
+ delete enterHooks.delayedLeave;
486
+ };
487
+ enterHooks.delayedLeave = delayedLeave;
488
+ };
489
+ }
651
490
  }
652
- }
653
- const res = (
654
- // local registration
655
- // check instance[type] first which is resolved for options API
656
- resolve(instance[type] || Component[type], name) || // global registration
657
- resolve(instance.appContext[type], name)
658
- );
659
- if (!res && maybeSelfReference) {
660
- return Component;
661
- }
662
- return res;
491
+ return child;
492
+ };
663
493
  }
494
+ };
495
+ const BaseTransition = BaseTransitionImpl;
496
+ function getLeavingNodesForType(state, vnode) {
497
+ const { leavingVNodes } = state;
498
+ let leavingVNodesCache = leavingVNodes.get(vnode.type);
499
+ if (!leavingVNodesCache) {
500
+ leavingVNodesCache = /* @__PURE__ */ Object.create(null);
501
+ leavingVNodes.set(vnode.type, leavingVNodesCache);
502
+ }
503
+ return leavingVNodesCache;
664
504
  }
665
- function resolve(registry, name) {
666
- return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
667
- }
668
-
669
- const isSuspense = (type) => type.__isSuspense;
670
- let suspenseId = 0;
671
- const SuspenseImpl = {
672
- name: "Suspense",
673
- // In order to make Suspense tree-shakable, we need to avoid importing it
674
- // directly in the renderer. The renderer checks for the __isSuspense flag
675
- // on a vnode's type and calls the `process` method, passing in renderer
676
- // internals.
677
- __isSuspense: true,
678
- process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
679
- if (n1 == null) {
680
- mountSuspense(
681
- n2,
682
- container,
683
- anchor,
684
- parentComponent,
685
- parentSuspense,
686
- namespace,
687
- slotScopeIds,
688
- optimized,
689
- rendererInternals
690
- );
691
- } else {
692
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
693
- n2.suspense = n1.suspense;
694
- n2.suspense.vnode = n2;
695
- n2.el = n1.el;
696
- return;
505
+ function resolveTransitionHooks(vnode, props, state, instance, postClone) {
506
+ const {
507
+ appear,
508
+ mode,
509
+ persisted = false,
510
+ onBeforeEnter,
511
+ onEnter,
512
+ onAfterEnter,
513
+ onEnterCancelled,
514
+ onBeforeLeave,
515
+ onLeave,
516
+ onAfterLeave,
517
+ onLeaveCancelled,
518
+ onBeforeAppear,
519
+ onAppear,
520
+ onAfterAppear,
521
+ onAppearCancelled
522
+ } = props;
523
+ const key = String(vnode.key);
524
+ const leavingVNodesCache = getLeavingNodesForType(state, vnode);
525
+ const callHook = (hook, args) => {
526
+ hook && callWithAsyncErrorHandling(
527
+ hook,
528
+ instance,
529
+ 9,
530
+ args
531
+ );
532
+ };
533
+ const callAsyncHook = (hook, args) => {
534
+ const done = args[1];
535
+ callHook(hook, args);
536
+ if (shared.isArray(hook)) {
537
+ if (hook.every((hook2) => hook2.length <= 1)) done();
538
+ } else if (hook.length <= 1) {
539
+ done();
540
+ }
541
+ };
542
+ const hooks = {
543
+ mode,
544
+ persisted,
545
+ beforeEnter(el) {
546
+ let hook = onBeforeEnter;
547
+ if (!state.isMounted) {
548
+ if (appear) {
549
+ hook = onBeforeAppear || onBeforeEnter;
550
+ } else {
551
+ return;
552
+ }
697
553
  }
698
- patchSuspense(
699
- n1,
700
- n2,
701
- container,
702
- anchor,
703
- parentComponent,
704
- namespace,
705
- slotScopeIds,
706
- optimized,
707
- rendererInternals
554
+ if (el[leaveCbKey]) {
555
+ el[leaveCbKey](
556
+ true
557
+ /* cancelled */
558
+ );
559
+ }
560
+ const leavingVNode = leavingVNodesCache[key];
561
+ if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
562
+ leavingVNode.el[leaveCbKey]();
563
+ }
564
+ callHook(hook, [el]);
565
+ },
566
+ enter(el) {
567
+ let hook = onEnter;
568
+ let afterHook = onAfterEnter;
569
+ let cancelHook = onEnterCancelled;
570
+ if (!state.isMounted) {
571
+ if (appear) {
572
+ hook = onAppear || onEnter;
573
+ afterHook = onAfterAppear || onAfterEnter;
574
+ cancelHook = onAppearCancelled || onEnterCancelled;
575
+ } else {
576
+ return;
577
+ }
578
+ }
579
+ let called = false;
580
+ const done = el[enterCbKey] = (cancelled) => {
581
+ if (called) return;
582
+ called = true;
583
+ if (cancelled) {
584
+ callHook(cancelHook, [el]);
585
+ } else {
586
+ callHook(afterHook, [el]);
587
+ }
588
+ if (hooks.delayedLeave) {
589
+ hooks.delayedLeave();
590
+ }
591
+ el[enterCbKey] = void 0;
592
+ };
593
+ if (hook) {
594
+ callAsyncHook(hook, [el, done]);
595
+ } else {
596
+ done();
597
+ }
598
+ },
599
+ leave(el, remove) {
600
+ const key2 = String(vnode.key);
601
+ if (el[enterCbKey]) {
602
+ el[enterCbKey](
603
+ true
604
+ /* cancelled */
605
+ );
606
+ }
607
+ if (state.isUnmounting) {
608
+ return remove();
609
+ }
610
+ callHook(onBeforeLeave, [el]);
611
+ let called = false;
612
+ const done = el[leaveCbKey] = (cancelled) => {
613
+ if (called) return;
614
+ called = true;
615
+ remove();
616
+ if (cancelled) {
617
+ callHook(onLeaveCancelled, [el]);
618
+ } else {
619
+ callHook(onAfterLeave, [el]);
620
+ }
621
+ el[leaveCbKey] = void 0;
622
+ if (leavingVNodesCache[key2] === vnode) {
623
+ delete leavingVNodesCache[key2];
624
+ }
625
+ };
626
+ leavingVNodesCache[key2] = vnode;
627
+ if (onLeave) {
628
+ callAsyncHook(onLeave, [el, done]);
629
+ } else {
630
+ done();
631
+ }
632
+ },
633
+ clone(vnode2) {
634
+ const hooks2 = resolveTransitionHooks(
635
+ vnode2,
636
+ props,
637
+ state,
638
+ instance,
639
+ postClone
708
640
  );
641
+ if (postClone) postClone(hooks2);
642
+ return hooks2;
709
643
  }
710
- },
711
- hydrate: hydrateSuspense,
712
- normalize: normalizeSuspenseChildren
713
- };
714
- const Suspense = SuspenseImpl ;
715
- function triggerEvent(vnode, name) {
716
- const eventListener = vnode.props && vnode.props[name];
717
- if (shared.isFunction(eventListener)) {
718
- eventListener();
644
+ };
645
+ return hooks;
646
+ }
647
+ function emptyPlaceholder(vnode) {
648
+ if (isKeepAlive(vnode)) {
649
+ vnode = cloneVNode(vnode);
650
+ vnode.children = null;
651
+ return vnode;
719
652
  }
720
653
  }
721
- function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
722
- const {
723
- p: patch,
724
- o: { createElement }
725
- } = rendererInternals;
726
- const hiddenContainer = createElement("div");
727
- const suspense = vnode.suspense = createSuspenseBoundary(
728
- vnode,
729
- parentSuspense,
730
- parentComponent,
731
- container,
732
- hiddenContainer,
733
- anchor,
734
- namespace,
735
- slotScopeIds,
736
- optimized,
737
- rendererInternals
738
- );
739
- patch(
740
- null,
741
- suspense.pendingBranch = vnode.ssContent,
742
- hiddenContainer,
743
- null,
744
- parentComponent,
745
- suspense,
746
- namespace,
747
- slotScopeIds
748
- );
749
- if (suspense.deps > 0) {
750
- triggerEvent(vnode, "onPending");
751
- triggerEvent(vnode, "onFallback");
752
- patch(
753
- null,
754
- vnode.ssFallback,
755
- container,
756
- anchor,
757
- parentComponent,
758
- null,
759
- // fallback tree will not have suspense context
760
- namespace,
761
- slotScopeIds
762
- );
763
- setActiveBranch(suspense, vnode.ssFallback);
654
+ function getKeepAliveChild(vnode) {
655
+ if (!isKeepAlive(vnode)) {
656
+ return vnode;
657
+ }
658
+ const { shapeFlag, children } = vnode;
659
+ if (children) {
660
+ if (shapeFlag & 16) {
661
+ return children[0];
662
+ }
663
+ if (shapeFlag & 32 && shared.isFunction(children.default)) {
664
+ return children.default();
665
+ }
666
+ }
667
+ }
668
+ function setTransitionHooks(vnode, hooks) {
669
+ if (vnode.shapeFlag & 6 && vnode.component) {
670
+ setTransitionHooks(vnode.component.subTree, hooks);
671
+ } else if (vnode.shapeFlag & 128) {
672
+ vnode.ssContent.transition = hooks.clone(vnode.ssContent);
673
+ vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
764
674
  } else {
765
- suspense.resolve(false, true);
675
+ vnode.transition = hooks;
766
676
  }
767
677
  }
768
- function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
769
- const suspense = n2.suspense = n1.suspense;
770
- suspense.vnode = n2;
771
- n2.el = n1.el;
772
- const newBranch = n2.ssContent;
773
- const newFallback = n2.ssFallback;
774
- const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
775
- if (pendingBranch) {
776
- suspense.pendingBranch = newBranch;
777
- if (isSameVNodeType(newBranch, pendingBranch)) {
778
- patch(
779
- pendingBranch,
780
- newBranch,
781
- suspense.hiddenContainer,
782
- null,
783
- parentComponent,
784
- suspense,
785
- namespace,
786
- slotScopeIds,
787
- optimized
678
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
679
+ let ret = [];
680
+ let keyedFragmentCount = 0;
681
+ for (let i = 0; i < children.length; i++) {
682
+ let child = children[i];
683
+ const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
684
+ if (child.type === Fragment) {
685
+ if (child.patchFlag & 128) keyedFragmentCount++;
686
+ ret = ret.concat(
687
+ getTransitionRawChildren(child.children, keepComment, key)
788
688
  );
789
- if (suspense.deps <= 0) {
790
- suspense.resolve();
791
- } else if (isInFallback) {
792
- if (!isHydrating) {
793
- patch(
794
- activeBranch,
795
- newFallback,
796
- container,
797
- anchor,
798
- parentComponent,
799
- null,
800
- // fallback tree will not have suspense context
801
- namespace,
802
- slotScopeIds,
803
- optimized
804
- );
805
- setActiveBranch(suspense, newFallback);
806
- }
807
- }
808
- } else {
809
- suspense.pendingId = suspenseId++;
810
- if (isHydrating) {
811
- suspense.isHydrating = false;
812
- suspense.activeBranch = pendingBranch;
689
+ } else if (keepComment || child.type !== Comment) {
690
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
691
+ }
692
+ }
693
+ if (keyedFragmentCount > 1) {
694
+ for (let i = 0; i < ret.length; i++) {
695
+ ret[i].patchFlag = -2;
696
+ }
697
+ }
698
+ return ret;
699
+ }
700
+
701
+ /*! #__NO_SIDE_EFFECTS__ */
702
+ // @__NO_SIDE_EFFECTS__
703
+ function defineComponent(options, extraOptions) {
704
+ return shared.isFunction(options) ? (
705
+ // #8326: extend call and options.name access are considered side-effects
706
+ // by Rollup, so we have to wrap it in a pure-annotated IIFE.
707
+ /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
708
+ ) : options;
709
+ }
710
+
711
+ const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
712
+ /*! #__NO_SIDE_EFFECTS__ */
713
+ // @__NO_SIDE_EFFECTS__
714
+ function defineAsyncComponent(source) {
715
+ if (shared.isFunction(source)) {
716
+ source = { loader: source };
717
+ }
718
+ const {
719
+ loader,
720
+ loadingComponent,
721
+ errorComponent,
722
+ delay = 200,
723
+ timeout,
724
+ // undefined = never times out
725
+ suspensible = true,
726
+ onError: userOnError
727
+ } = source;
728
+ let pendingRequest = null;
729
+ let resolvedComp;
730
+ let retries = 0;
731
+ const retry = () => {
732
+ retries++;
733
+ pendingRequest = null;
734
+ return load();
735
+ };
736
+ const load = () => {
737
+ let thisRequest;
738
+ return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
739
+ err = err instanceof Error ? err : new Error(String(err));
740
+ if (userOnError) {
741
+ return new Promise((resolve, reject) => {
742
+ const userRetry = () => resolve(retry());
743
+ const userFail = () => reject(err);
744
+ userOnError(err, userRetry, userFail, retries + 1);
745
+ });
813
746
  } else {
814
- unmount(pendingBranch, parentComponent, suspense);
747
+ throw err;
815
748
  }
816
- suspense.deps = 0;
817
- suspense.effects.length = 0;
818
- suspense.hiddenContainer = createElement("div");
819
- if (isInFallback) {
820
- patch(
821
- null,
822
- newBranch,
823
- suspense.hiddenContainer,
824
- null,
825
- parentComponent,
826
- suspense,
827
- namespace,
828
- slotScopeIds,
829
- optimized
749
+ }).then((comp) => {
750
+ if (thisRequest !== pendingRequest && pendingRequest) {
751
+ return pendingRequest;
752
+ }
753
+ if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
754
+ comp = comp.default;
755
+ }
756
+ resolvedComp = comp;
757
+ return comp;
758
+ }));
759
+ };
760
+ return defineComponent({
761
+ name: "AsyncComponentWrapper",
762
+ __asyncLoader: load,
763
+ get __asyncResolved() {
764
+ return resolvedComp;
765
+ },
766
+ setup() {
767
+ const instance = currentInstance;
768
+ if (resolvedComp) {
769
+ return () => createInnerComp(resolvedComp, instance);
770
+ }
771
+ const onError = (err) => {
772
+ pendingRequest = null;
773
+ handleError(
774
+ err,
775
+ instance,
776
+ 13,
777
+ !errorComponent
830
778
  );
831
- if (suspense.deps <= 0) {
832
- suspense.resolve();
833
- } else {
834
- patch(
835
- activeBranch,
836
- newFallback,
837
- container,
838
- anchor,
839
- parentComponent,
840
- null,
841
- // fallback tree will not have suspense context
842
- namespace,
843
- slotScopeIds,
844
- optimized
845
- );
846
- setActiveBranch(suspense, newFallback);
779
+ };
780
+ if (suspensible && instance.suspense || isInSSRComponentSetup) {
781
+ return load().then((comp) => {
782
+ return () => createInnerComp(comp, instance);
783
+ }).catch((err) => {
784
+ onError(err);
785
+ return () => errorComponent ? createVNode(errorComponent, {
786
+ error: err
787
+ }) : null;
788
+ });
789
+ }
790
+ const loaded = reactivity.ref(false);
791
+ const error = reactivity.ref();
792
+ const delayed = reactivity.ref(!!delay);
793
+ if (delay) {
794
+ setTimeout(() => {
795
+ delayed.value = false;
796
+ }, delay);
797
+ }
798
+ if (timeout != null) {
799
+ setTimeout(() => {
800
+ if (!loaded.value && !error.value) {
801
+ const err = new Error(
802
+ `Async component timed out after ${timeout}ms.`
803
+ );
804
+ onError(err);
805
+ error.value = err;
806
+ }
807
+ }, timeout);
808
+ }
809
+ load().then(() => {
810
+ loaded.value = true;
811
+ if (instance.parent && isKeepAlive(instance.parent.vnode)) {
812
+ instance.parent.effect.dirty = true;
813
+ queueJob(instance.parent.update);
847
814
  }
848
- } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
849
- patch(
850
- activeBranch,
851
- newBranch,
852
- container,
853
- anchor,
854
- parentComponent,
855
- suspense,
856
- namespace,
857
- slotScopeIds,
858
- optimized
859
- );
860
- suspense.resolve(true);
861
- } else {
862
- patch(
863
- null,
864
- newBranch,
865
- suspense.hiddenContainer,
866
- null,
867
- parentComponent,
868
- suspense,
869
- namespace,
870
- slotScopeIds,
871
- optimized
872
- );
873
- if (suspense.deps <= 0) {
874
- suspense.resolve();
815
+ }).catch((err) => {
816
+ onError(err);
817
+ error.value = err;
818
+ });
819
+ return () => {
820
+ if (loaded.value && resolvedComp) {
821
+ return createInnerComp(resolvedComp, instance);
822
+ } else if (error.value && errorComponent) {
823
+ return createVNode(errorComponent, {
824
+ error: error.value
825
+ });
826
+ } else if (loadingComponent && !delayed.value) {
827
+ return createVNode(loadingComponent);
875
828
  }
876
- }
829
+ };
830
+ }
831
+ });
832
+ }
833
+ function createInnerComp(comp, parent) {
834
+ const { ref: ref2, props, children, ce } = parent.vnode;
835
+ const vnode = createVNode(comp, props, children);
836
+ vnode.ref = ref2;
837
+ vnode.ce = ce;
838
+ delete parent.vnode.ce;
839
+ return vnode;
840
+ }
841
+
842
+ const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
843
+ const KeepAliveImpl = {
844
+ name: `KeepAlive`,
845
+ // Marker for special handling inside the renderer. We are not using a ===
846
+ // check directly on KeepAlive in the renderer, because importing it directly
847
+ // would prevent it from being tree-shaken.
848
+ __isKeepAlive: true,
849
+ props: {
850
+ include: [String, RegExp, Array],
851
+ exclude: [String, RegExp, Array],
852
+ max: [String, Number]
853
+ },
854
+ setup(props, { slots }) {
855
+ const instance = getCurrentInstance();
856
+ const sharedContext = instance.ctx;
857
+ if (!sharedContext.renderer) {
858
+ return () => {
859
+ const children = slots.default && slots.default();
860
+ return children && children.length === 1 ? children[0] : children;
861
+ };
877
862
  }
878
- } else {
879
- if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
863
+ const cache = /* @__PURE__ */ new Map();
864
+ const keys = /* @__PURE__ */ new Set();
865
+ let current = null;
866
+ const parentSuspense = instance.suspense;
867
+ const {
868
+ renderer: {
869
+ p: patch,
870
+ m: move,
871
+ um: _unmount,
872
+ o: { createElement }
873
+ }
874
+ } = sharedContext;
875
+ const storageContainer = createElement("div");
876
+ sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
877
+ const instance2 = vnode.component;
878
+ move(vnode, container, anchor, 0, parentSuspense);
880
879
  patch(
881
- activeBranch,
882
- newBranch,
880
+ instance2.vnode,
881
+ vnode,
883
882
  container,
884
883
  anchor,
885
- parentComponent,
886
- suspense,
887
- namespace,
888
- slotScopeIds,
889
- optimized
890
- );
891
- setActiveBranch(suspense, newBranch);
892
- } else {
893
- triggerEvent(n2, "onPending");
894
- suspense.pendingBranch = newBranch;
895
- if (newBranch.shapeFlag & 512) {
896
- suspense.pendingId = newBranch.component.suspenseId;
897
- } else {
898
- suspense.pendingId = suspenseId++;
899
- }
900
- patch(
901
- null,
902
- newBranch,
903
- suspense.hiddenContainer,
904
- null,
905
- parentComponent,
906
- suspense,
884
+ instance2,
885
+ parentSuspense,
907
886
  namespace,
908
- slotScopeIds,
887
+ vnode.slotScopeIds,
909
888
  optimized
910
889
  );
911
- if (suspense.deps <= 0) {
912
- suspense.resolve();
913
- } else {
914
- const { timeout, pendingId } = suspense;
915
- if (timeout > 0) {
916
- setTimeout(() => {
917
- if (suspense.pendingId === pendingId) {
918
- suspense.fallback(newFallback);
919
- }
920
- }, timeout);
921
- } else if (timeout === 0) {
922
- suspense.fallback(newFallback);
890
+ queuePostRenderEffect(() => {
891
+ instance2.isDeactivated = false;
892
+ if (instance2.a) {
893
+ shared.invokeArrayFns(instance2.a);
923
894
  }
924
- }
925
- }
926
- }
927
- }
928
- function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
929
- const {
930
- p: patch,
931
- m: move,
932
- um: unmount,
933
- n: next,
934
- o: { parentNode, remove }
935
- } = rendererInternals;
936
- let parentSuspenseId;
937
- const isSuspensible = isVNodeSuspensible(vnode);
938
- if (isSuspensible) {
939
- if (parentSuspense && parentSuspense.pendingBranch) {
940
- parentSuspenseId = parentSuspense.pendingId;
941
- parentSuspense.deps++;
942
- }
943
- }
944
- const timeout = vnode.props ? shared.toNumber(vnode.props.timeout) : void 0;
945
- const initialAnchor = anchor;
946
- const suspense = {
947
- vnode,
948
- parent: parentSuspense,
949
- parentComponent,
950
- namespace,
951
- container,
952
- hiddenContainer,
953
- deps: 0,
954
- pendingId: suspenseId++,
955
- timeout: typeof timeout === "number" ? timeout : -1,
956
- activeBranch: null,
957
- pendingBranch: null,
958
- isInFallback: !isHydrating,
959
- isHydrating,
960
- isUnmounted: false,
961
- effects: [],
962
- resolve(resume = false, sync = false) {
963
- const {
964
- vnode: vnode2,
965
- activeBranch,
966
- pendingBranch,
967
- pendingId,
968
- effects,
969
- parentComponent: parentComponent2,
970
- container: container2
971
- } = suspense;
972
- let delayEnter = false;
973
- if (suspense.isHydrating) {
974
- suspense.isHydrating = false;
975
- } else if (!resume) {
976
- delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
977
- if (delayEnter) {
978
- activeBranch.transition.afterLeave = () => {
979
- if (pendingId === suspense.pendingId) {
980
- move(
981
- pendingBranch,
982
- container2,
983
- anchor === initialAnchor ? next(activeBranch) : anchor,
984
- 0
985
- );
986
- queuePostFlushCb(effects);
987
- }
988
- };
895
+ const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
896
+ if (vnodeHook) {
897
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
989
898
  }
990
- if (activeBranch) {
991
- if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
992
- anchor = next(activeBranch);
993
- }
994
- unmount(activeBranch, parentComponent2, suspense, true);
899
+ }, parentSuspense);
900
+ };
901
+ sharedContext.deactivate = (vnode) => {
902
+ const instance2 = vnode.component;
903
+ invalidateMount(instance2.m);
904
+ invalidateMount(instance2.a);
905
+ move(vnode, storageContainer, null, 1, parentSuspense);
906
+ queuePostRenderEffect(() => {
907
+ if (instance2.da) {
908
+ shared.invokeArrayFns(instance2.da);
995
909
  }
996
- if (!delayEnter) {
997
- move(pendingBranch, container2, anchor, 0);
910
+ const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
911
+ if (vnodeHook) {
912
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
998
913
  }
999
- }
1000
- setActiveBranch(suspense, pendingBranch);
1001
- suspense.pendingBranch = null;
1002
- suspense.isInFallback = false;
1003
- let parent = suspense.parent;
1004
- let hasUnresolvedAncestor = false;
1005
- while (parent) {
1006
- if (parent.pendingBranch) {
1007
- parent.effects.push(...effects);
1008
- hasUnresolvedAncestor = true;
1009
- break;
914
+ instance2.isDeactivated = true;
915
+ }, parentSuspense);
916
+ };
917
+ function unmount(vnode) {
918
+ resetShapeFlag(vnode);
919
+ _unmount(vnode, instance, parentSuspense, true);
920
+ }
921
+ function pruneCache(filter) {
922
+ cache.forEach((vnode, key) => {
923
+ const name = getComponentName(vnode.type);
924
+ if (name && (!filter || !filter(name))) {
925
+ pruneCacheEntry(key);
1010
926
  }
1011
- parent = parent.parent;
1012
- }
1013
- if (!hasUnresolvedAncestor && !delayEnter) {
1014
- queuePostFlushCb(effects);
927
+ });
928
+ }
929
+ function pruneCacheEntry(key) {
930
+ const cached = cache.get(key);
931
+ if (!current || !isSameVNodeType(cached, current)) {
932
+ unmount(cached);
933
+ } else if (current) {
934
+ resetShapeFlag(current);
1015
935
  }
1016
- suspense.effects = [];
1017
- if (isSuspensible) {
1018
- if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
1019
- parentSuspense.deps--;
1020
- if (parentSuspense.deps === 0 && !sync) {
1021
- parentSuspense.resolve();
1022
- }
936
+ cache.delete(key);
937
+ keys.delete(key);
938
+ }
939
+ watch(
940
+ () => [props.include, props.exclude],
941
+ ([include, exclude]) => {
942
+ include && pruneCache((name) => matches(include, name));
943
+ exclude && pruneCache((name) => !matches(exclude, name));
944
+ },
945
+ // prune post-render after `current` has been updated
946
+ { flush: "post", deep: true }
947
+ );
948
+ let pendingCacheKey = null;
949
+ const cacheSubtree = () => {
950
+ if (pendingCacheKey != null) {
951
+ if (isSuspense(instance.subTree.type)) {
952
+ queuePostRenderEffect(() => {
953
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
954
+ }, instance.subTree.suspense);
955
+ } else {
956
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1023
957
  }
1024
958
  }
1025
- triggerEvent(vnode2, "onResolve");
1026
- },
1027
- fallback(fallbackVNode) {
1028
- if (!suspense.pendingBranch) {
1029
- return;
1030
- }
1031
- const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
1032
- triggerEvent(vnode2, "onFallback");
1033
- const anchor2 = next(activeBranch);
1034
- const mountFallback = () => {
1035
- if (!suspense.isInFallback) {
959
+ };
960
+ onMounted(cacheSubtree);
961
+ onUpdated(cacheSubtree);
962
+ onBeforeUnmount(() => {
963
+ cache.forEach((cached) => {
964
+ const { subTree, suspense } = instance;
965
+ const vnode = getInnerChild(subTree);
966
+ if (cached.type === vnode.type && cached.key === vnode.key) {
967
+ resetShapeFlag(vnode);
968
+ const da = vnode.component.da;
969
+ da && queuePostRenderEffect(da, suspense);
1036
970
  return;
1037
971
  }
1038
- patch(
1039
- null,
1040
- fallbackVNode,
1041
- container2,
1042
- anchor2,
1043
- parentComponent2,
1044
- null,
1045
- // fallback tree will not have suspense context
1046
- namespace2,
1047
- slotScopeIds,
1048
- optimized
1049
- );
1050
- setActiveBranch(suspense, fallbackVNode);
1051
- };
1052
- const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
1053
- if (delayEnter) {
1054
- activeBranch.transition.afterLeave = mountFallback;
972
+ unmount(cached);
973
+ });
974
+ });
975
+ return () => {
976
+ pendingCacheKey = null;
977
+ if (!slots.default) {
978
+ return null;
1055
979
  }
1056
- suspense.isInFallback = true;
1057
- unmount(
1058
- activeBranch,
1059
- parentComponent2,
1060
- null,
1061
- // no suspense so unmount hooks fire now
1062
- true
1063
- // shouldRemove
1064
- );
1065
- if (!delayEnter) {
1066
- mountFallback();
980
+ const children = slots.default();
981
+ const rawVNode = children[0];
982
+ if (children.length > 1) {
983
+ current = null;
984
+ return children;
985
+ } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
986
+ current = null;
987
+ return rawVNode;
1067
988
  }
1068
- },
1069
- move(container2, anchor2, type) {
1070
- suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
1071
- suspense.container = container2;
1072
- },
1073
- next() {
1074
- return suspense.activeBranch && next(suspense.activeBranch);
1075
- },
1076
- registerDep(instance, setupRenderEffect, optimized2) {
1077
- const isInPendingSuspense = !!suspense.pendingBranch;
1078
- if (isInPendingSuspense) {
1079
- suspense.deps++;
989
+ let vnode = getInnerChild(rawVNode);
990
+ const comp = vnode.type;
991
+ const name = getComponentName(
992
+ isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
993
+ );
994
+ const { include, exclude, max } = props;
995
+ if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
996
+ current = vnode;
997
+ return rawVNode;
1080
998
  }
1081
- const hydratedEl = instance.vnode.el;
1082
- instance.asyncDep.catch((err) => {
1083
- handleError(err, instance, 0);
1084
- }).then((asyncSetupResult) => {
1085
- if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
1086
- return;
1087
- }
1088
- instance.asyncResolved = true;
1089
- const { vnode: vnode2 } = instance;
1090
- handleSetupResult(instance, asyncSetupResult, false);
1091
- if (hydratedEl) {
1092
- vnode2.el = hydratedEl;
999
+ const key = vnode.key == null ? comp : vnode.key;
1000
+ const cachedVNode = cache.get(key);
1001
+ if (vnode.el) {
1002
+ vnode = cloneVNode(vnode);
1003
+ if (rawVNode.shapeFlag & 128) {
1004
+ rawVNode.ssContent = vnode;
1093
1005
  }
1094
- const placeholder = !hydratedEl && instance.subTree.el;
1095
- setupRenderEffect(
1096
- instance,
1097
- vnode2,
1098
- // component may have been moved before resolve.
1099
- // if this is not a hydration, instance.subTree will be the comment
1100
- // placeholder.
1101
- parentNode(hydratedEl || instance.subTree.el),
1102
- // anchor will not be used if this is hydration, so only need to
1103
- // consider the comment placeholder case.
1104
- hydratedEl ? null : next(instance.subTree),
1105
- suspense,
1106
- namespace,
1107
- optimized2
1108
- );
1109
- if (placeholder) {
1110
- remove(placeholder);
1006
+ }
1007
+ pendingCacheKey = key;
1008
+ if (cachedVNode) {
1009
+ vnode.el = cachedVNode.el;
1010
+ vnode.component = cachedVNode.component;
1011
+ if (vnode.transition) {
1012
+ setTransitionHooks(vnode, vnode.transition);
1111
1013
  }
1112
- updateHOCHostEl(instance, vnode2.el);
1113
- if (isInPendingSuspense && --suspense.deps === 0) {
1114
- suspense.resolve();
1014
+ vnode.shapeFlag |= 512;
1015
+ keys.delete(key);
1016
+ keys.add(key);
1017
+ } else {
1018
+ keys.add(key);
1019
+ if (max && keys.size > parseInt(max, 10)) {
1020
+ pruneCacheEntry(keys.values().next().value);
1115
1021
  }
1116
- });
1117
- },
1118
- unmount(parentSuspense2, doRemove) {
1119
- suspense.isUnmounted = true;
1120
- if (suspense.activeBranch) {
1121
- unmount(
1122
- suspense.activeBranch,
1123
- parentComponent,
1124
- parentSuspense2,
1125
- doRemove
1126
- );
1127
1022
  }
1128
- if (suspense.pendingBranch) {
1129
- unmount(
1130
- suspense.pendingBranch,
1131
- parentComponent,
1132
- parentSuspense2,
1133
- doRemove
1134
- );
1135
- }
1136
- }
1137
- };
1138
- return suspense;
1139
- }
1140
- function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
1141
- const suspense = vnode.suspense = createSuspenseBoundary(
1142
- vnode,
1143
- parentSuspense,
1144
- parentComponent,
1145
- node.parentNode,
1146
- // eslint-disable-next-line no-restricted-globals
1147
- document.createElement("div"),
1148
- null,
1149
- namespace,
1150
- slotScopeIds,
1151
- optimized,
1152
- rendererInternals,
1153
- true
1154
- );
1155
- const result = hydrateNode(
1156
- node,
1157
- suspense.pendingBranch = vnode.ssContent,
1158
- parentComponent,
1159
- suspense,
1160
- slotScopeIds,
1161
- optimized
1162
- );
1163
- if (suspense.deps === 0) {
1164
- suspense.resolve(false, true);
1023
+ vnode.shapeFlag |= 256;
1024
+ current = vnode;
1025
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
1026
+ };
1165
1027
  }
1166
- return result;
1028
+ };
1029
+ const KeepAlive = KeepAliveImpl;
1030
+ function matches(pattern, name) {
1031
+ if (shared.isArray(pattern)) {
1032
+ return pattern.some((p) => matches(p, name));
1033
+ } else if (shared.isString(pattern)) {
1034
+ return pattern.split(",").includes(name);
1035
+ } else if (shared.isRegExp(pattern)) {
1036
+ return pattern.test(name);
1037
+ }
1038
+ return false;
1167
1039
  }
1168
- function normalizeSuspenseChildren(vnode) {
1169
- const { shapeFlag, children } = vnode;
1170
- const isSlotChildren = shapeFlag & 32;
1171
- vnode.ssContent = normalizeSuspenseSlot(
1172
- isSlotChildren ? children.default : children
1173
- );
1174
- vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
1040
+ function onActivated(hook, target) {
1041
+ registerKeepAliveHook(hook, "a", target);
1175
1042
  }
1176
- function normalizeSuspenseSlot(s) {
1177
- let block;
1178
- if (shared.isFunction(s)) {
1179
- const trackBlock = isBlockTreeEnabled && s._c;
1180
- if (trackBlock) {
1181
- s._d = false;
1182
- openBlock();
1183
- }
1184
- s = s();
1185
- if (trackBlock) {
1186
- s._d = true;
1187
- block = currentBlock;
1188
- closeBlock();
1189
- }
1190
- }
1191
- if (shared.isArray(s)) {
1192
- const singleChild = filterSingleRoot(s);
1193
- s = singleChild;
1194
- }
1195
- s = normalizeVNode(s);
1196
- if (block && !s.dynamicChildren) {
1197
- s.dynamicChildren = block.filter((c) => c !== s);
1198
- }
1199
- return s;
1043
+ function onDeactivated(hook, target) {
1044
+ registerKeepAliveHook(hook, "da", target);
1200
1045
  }
1201
- function queueEffectWithSuspense(fn, suspense) {
1202
- if (suspense && suspense.pendingBranch) {
1203
- if (shared.isArray(fn)) {
1204
- suspense.effects.push(...fn);
1205
- } else {
1206
- suspense.effects.push(fn);
1046
+ function registerKeepAliveHook(hook, type, target = currentInstance) {
1047
+ const wrappedHook = hook.__wdc || (hook.__wdc = () => {
1048
+ let current = target;
1049
+ while (current) {
1050
+ if (current.isDeactivated) {
1051
+ return;
1052
+ }
1053
+ current = current.parent;
1054
+ }
1055
+ return hook();
1056
+ });
1057
+ injectHook(type, wrappedHook, target);
1058
+ if (target) {
1059
+ let current = target.parent;
1060
+ while (current && current.parent) {
1061
+ if (isKeepAlive(current.parent.vnode)) {
1062
+ injectToKeepAliveRoot(wrappedHook, type, target, current);
1063
+ }
1064
+ current = current.parent;
1207
1065
  }
1208
- } else {
1209
- queuePostFlushCb(fn);
1210
- }
1211
- }
1212
- function setActiveBranch(suspense, branch) {
1213
- suspense.activeBranch = branch;
1214
- const { vnode, parentComponent } = suspense;
1215
- let el = branch.el;
1216
- while (!el && branch.component) {
1217
- branch = branch.component.subTree;
1218
- el = branch.el;
1219
- }
1220
- vnode.el = el;
1221
- if (parentComponent && parentComponent.subTree === vnode) {
1222
- parentComponent.vnode.el = el;
1223
- updateHOCHostEl(parentComponent, el);
1224
1066
  }
1225
1067
  }
1226
- function isVNodeSuspensible(vnode) {
1227
- const suspensible = vnode.props && vnode.props.suspensible;
1228
- return suspensible != null && suspensible !== false;
1068
+ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
1069
+ const injected = injectHook(
1070
+ type,
1071
+ hook,
1072
+ keepAliveRoot,
1073
+ true
1074
+ /* prepend */
1075
+ );
1076
+ onUnmounted(() => {
1077
+ shared.remove(keepAliveRoot[type], injected);
1078
+ }, target);
1079
+ }
1080
+ function resetShapeFlag(vnode) {
1081
+ vnode.shapeFlag &= ~256;
1082
+ vnode.shapeFlag &= ~512;
1083
+ }
1084
+ function getInnerChild(vnode) {
1085
+ return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
1229
1086
  }
1230
1087
 
1231
1088
  function injectHook(type, hook, target = currentInstance, prepend = false) {
@@ -1272,57 +1129,50 @@ function onErrorCaptured(hook, target = currentInstance) {
1272
1129
  injectHook("ec", hook, target);
1273
1130
  }
1274
1131
 
1275
- function withDirectives(vnode, directives) {
1276
- if (currentRenderingInstance === null) {
1277
- return vnode;
1278
- }
1279
- const instance = getComponentPublicInstance(currentRenderingInstance);
1280
- const bindings = vnode.dirs || (vnode.dirs = []);
1281
- for (let i = 0; i < directives.length; i++) {
1282
- let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
1283
- if (dir) {
1284
- if (shared.isFunction(dir)) {
1285
- dir = {
1286
- mounted: dir,
1287
- updated: dir
1288
- };
1289
- }
1290
- if (dir.deep) {
1291
- traverse(value);
1292
- }
1293
- bindings.push({
1294
- dir,
1295
- instance,
1296
- value,
1297
- oldValue: void 0,
1298
- arg,
1299
- modifiers
1300
- });
1301
- }
1132
+ const COMPONENTS = "components";
1133
+ const DIRECTIVES = "directives";
1134
+ function resolveComponent(name, maybeSelfReference) {
1135
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
1136
+ }
1137
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
1138
+ function resolveDynamicComponent(component) {
1139
+ if (shared.isString(component)) {
1140
+ return resolveAsset(COMPONENTS, component, false) || component;
1141
+ } else {
1142
+ return component || NULL_DYNAMIC_COMPONENT;
1302
1143
  }
1303
- return vnode;
1304
1144
  }
1305
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
1306
- const bindings = vnode.dirs;
1307
- const oldBindings = prevVNode && prevVNode.dirs;
1308
- for (let i = 0; i < bindings.length; i++) {
1309
- const binding = bindings[i];
1310
- if (oldBindings) {
1311
- binding.oldValue = oldBindings[i].value;
1145
+ function resolveDirective(name) {
1146
+ return resolveAsset(DIRECTIVES, name);
1147
+ }
1148
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
1149
+ const instance = currentRenderingInstance || currentInstance;
1150
+ if (instance) {
1151
+ const Component = instance.type;
1152
+ if (type === COMPONENTS) {
1153
+ const selfName = getComponentName(
1154
+ Component,
1155
+ false
1156
+ );
1157
+ if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
1158
+ return Component;
1159
+ }
1312
1160
  }
1313
- let hook = binding.dir[name];
1314
- if (hook) {
1315
- reactivity.pauseTracking();
1316
- callWithAsyncErrorHandling(hook, instance, 8, [
1317
- vnode.el,
1318
- binding,
1319
- vnode,
1320
- prevVNode
1321
- ]);
1322
- reactivity.resetTracking();
1161
+ const res = (
1162
+ // local registration
1163
+ // check instance[type] first which is resolved for options API
1164
+ resolve(instance[type] || Component[type], name) || // global registration
1165
+ resolve(instance.appContext[type], name)
1166
+ );
1167
+ if (!res && maybeSelfReference) {
1168
+ return Component;
1323
1169
  }
1170
+ return res;
1324
1171
  }
1325
1172
  }
1173
+ function resolve(registry, name) {
1174
+ return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
1175
+ }
1326
1176
 
1327
1177
  function renderList(source, renderItem, cache, index) {
1328
1178
  let ret;
@@ -1359,164 +1209,23 @@ function renderList(source, renderItem, cache, index) {
1359
1209
  }
1360
1210
  return ret;
1361
1211
  }
1362
-
1363
- function createSlots(slots, dynamicSlots) {
1364
- for (let i = 0; i < dynamicSlots.length; i++) {
1365
- const slot = dynamicSlots[i];
1366
- if (shared.isArray(slot)) {
1367
- for (let j = 0; j < slot.length; j++) {
1368
- slots[slot[j].name] = slot[j].fn;
1369
- }
1370
- } else if (slot) {
1371
- slots[slot.name] = slot.key ? (...args) => {
1372
- const res = slot.fn(...args);
1373
- if (res) res.key = slot.key;
1374
- return res;
1375
- } : slot.fn;
1376
- }
1377
- }
1378
- return slots;
1379
- }
1380
-
1381
- /*! #__NO_SIDE_EFFECTS__ */
1382
- // @__NO_SIDE_EFFECTS__
1383
- function defineComponent(options, extraOptions) {
1384
- return shared.isFunction(options) ? (
1385
- // #8326: extend call and options.name access are considered side-effects
1386
- // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1387
- /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
1388
- ) : options;
1389
- }
1390
-
1391
- const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
1392
- /*! #__NO_SIDE_EFFECTS__ */
1393
- // @__NO_SIDE_EFFECTS__
1394
- function defineAsyncComponent(source) {
1395
- if (shared.isFunction(source)) {
1396
- source = { loader: source };
1397
- }
1398
- const {
1399
- loader,
1400
- loadingComponent,
1401
- errorComponent,
1402
- delay = 200,
1403
- timeout,
1404
- // undefined = never times out
1405
- suspensible = true,
1406
- onError: userOnError
1407
- } = source;
1408
- let pendingRequest = null;
1409
- let resolvedComp;
1410
- let retries = 0;
1411
- const retry = () => {
1412
- retries++;
1413
- pendingRequest = null;
1414
- return load();
1415
- };
1416
- const load = () => {
1417
- let thisRequest;
1418
- return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
1419
- err = err instanceof Error ? err : new Error(String(err));
1420
- if (userOnError) {
1421
- return new Promise((resolve, reject) => {
1422
- const userRetry = () => resolve(retry());
1423
- const userFail = () => reject(err);
1424
- userOnError(err, userRetry, userFail, retries + 1);
1425
- });
1426
- } else {
1427
- throw err;
1428
- }
1429
- }).then((comp) => {
1430
- if (thisRequest !== pendingRequest && pendingRequest) {
1431
- return pendingRequest;
1432
- }
1433
- if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
1434
- comp = comp.default;
1435
- }
1436
- resolvedComp = comp;
1437
- return comp;
1438
- }));
1439
- };
1440
- return defineComponent({
1441
- name: "AsyncComponentWrapper",
1442
- __asyncLoader: load,
1443
- get __asyncResolved() {
1444
- return resolvedComp;
1445
- },
1446
- setup() {
1447
- const instance = currentInstance;
1448
- if (resolvedComp) {
1449
- return () => createInnerComp(resolvedComp, instance);
1450
- }
1451
- const onError = (err) => {
1452
- pendingRequest = null;
1453
- handleError(
1454
- err,
1455
- instance,
1456
- 13,
1457
- !errorComponent
1458
- );
1459
- };
1460
- if (suspensible && instance.suspense || isInSSRComponentSetup) {
1461
- return load().then((comp) => {
1462
- return () => createInnerComp(comp, instance);
1463
- }).catch((err) => {
1464
- onError(err);
1465
- return () => errorComponent ? createVNode(errorComponent, {
1466
- error: err
1467
- }) : null;
1468
- });
1469
- }
1470
- const loaded = reactivity.ref(false);
1471
- const error = reactivity.ref();
1472
- const delayed = reactivity.ref(!!delay);
1473
- if (delay) {
1474
- setTimeout(() => {
1475
- delayed.value = false;
1476
- }, delay);
1477
- }
1478
- if (timeout != null) {
1479
- setTimeout(() => {
1480
- if (!loaded.value && !error.value) {
1481
- const err = new Error(
1482
- `Async component timed out after ${timeout}ms.`
1483
- );
1484
- onError(err);
1485
- error.value = err;
1486
- }
1487
- }, timeout);
1488
- }
1489
- load().then(() => {
1490
- loaded.value = true;
1491
- if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1492
- instance.parent.effect.dirty = true;
1493
- queueJob(instance.parent.update);
1494
- }
1495
- }).catch((err) => {
1496
- onError(err);
1497
- error.value = err;
1498
- });
1499
- return () => {
1500
- if (loaded.value && resolvedComp) {
1501
- return createInnerComp(resolvedComp, instance);
1502
- } else if (error.value && errorComponent) {
1503
- return createVNode(errorComponent, {
1504
- error: error.value
1505
- });
1506
- } else if (loadingComponent && !delayed.value) {
1507
- return createVNode(loadingComponent);
1508
- }
1509
- };
1510
- }
1511
- });
1512
- }
1513
- function createInnerComp(comp, parent) {
1514
- const { ref: ref2, props, children, ce } = parent.vnode;
1515
- const vnode = createVNode(comp, props, children);
1516
- vnode.ref = ref2;
1517
- vnode.ce = ce;
1518
- delete parent.vnode.ce;
1519
- return vnode;
1212
+
1213
+ function createSlots(slots, dynamicSlots) {
1214
+ for (let i = 0; i < dynamicSlots.length; i++) {
1215
+ const slot = dynamicSlots[i];
1216
+ if (shared.isArray(slot)) {
1217
+ for (let j = 0; j < slot.length; j++) {
1218
+ slots[slot[j].name] = slot[j].fn;
1219
+ }
1220
+ } else if (slot) {
1221
+ slots[slot.name] = slot.key ? (...args) => {
1222
+ const res = slot.fn(...args);
1223
+ if (res) res.key = slot.key;
1224
+ return res;
1225
+ } : slot.fn;
1226
+ }
1227
+ }
1228
+ return slots;
1520
1229
  }
1521
1230
 
1522
1231
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
@@ -1533,9 +1242,10 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
1533
1242
  const rendered = createBlock(
1534
1243
  Fragment,
1535
1244
  {
1536
- key: props.key || // slot content array of a dynamic conditional slot may have a branch
1245
+ key: (props.key || // slot content array of a dynamic conditional slot may have a branch
1537
1246
  // key attached in the `createSlots` helper, respect that
1538
- validSlotContent && validSlotContent.key || `_${name}`
1247
+ validSlotContent && validSlotContent.key || `_${name}`) + // #7256 force differentiate fallback content from actual content
1248
+ (!validSlotContent && fallback ? "_fb" : "")
1539
1249
  },
1540
1250
  validSlotContent || (fallback ? fallback() : []),
1541
1251
  validSlotContent && slots._ === 1 ? 64 : -2
@@ -2461,8 +2171,9 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
2461
2171
  }
2462
2172
  return value;
2463
2173
  }
2174
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
2464
2175
  function normalizePropsOptions(comp, appContext, asMixin = false) {
2465
- const cache = appContext.propsCache;
2176
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
2466
2177
  const cached = cache.get(comp);
2467
2178
  if (cached) {
2468
2179
  return cached;
@@ -2585,13 +2296,22 @@ const normalizeVNodeSlots = (instance, children) => {
2585
2296
  const normalized = normalizeSlotValue(children);
2586
2297
  instance.slots.default = () => normalized;
2587
2298
  };
2588
- const initSlots = (instance, children) => {
2299
+ const assignSlots = (slots, children, optimized) => {
2300
+ for (const key in children) {
2301
+ if (optimized || key !== "_") {
2302
+ slots[key] = children[key];
2303
+ }
2304
+ }
2305
+ };
2306
+ const initSlots = (instance, children, optimized) => {
2589
2307
  const slots = instance.slots = createInternalObject();
2590
2308
  if (instance.vnode.shapeFlag & 32) {
2591
2309
  const type = children._;
2592
2310
  if (type) {
2593
- shared.extend(slots, children);
2594
- shared.def(slots, "_", type, true);
2311
+ assignSlots(slots, children, optimized);
2312
+ if (optimized) {
2313
+ shared.def(slots, "_", type, true);
2314
+ }
2595
2315
  } else {
2596
2316
  normalizeObjectSlots(children, slots);
2597
2317
  }
@@ -2609,10 +2329,7 @@ const updateSlots = (instance, children, optimized) => {
2609
2329
  if (optimized && type === 1) {
2610
2330
  needDeletionCheck = false;
2611
2331
  } else {
2612
- shared.extend(slots, children);
2613
- if (!optimized && type === 1) {
2614
- delete slots._;
2615
- }
2332
+ assignSlots(slots, children, optimized);
2616
2333
  }
2617
2334
  } else {
2618
2335
  needDeletionCheck = !children.$stable;
@@ -2645,68 +2362,332 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
2645
2362
  );
2646
2363
  return;
2647
2364
  }
2648
- if (isAsyncWrapper(vnode) && !isUnmount) {
2649
- return;
2365
+ if (isAsyncWrapper(vnode) && !isUnmount) {
2366
+ return;
2367
+ }
2368
+ const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
2369
+ const value = isUnmount ? null : refValue;
2370
+ const { i: owner, r: ref } = rawRef;
2371
+ const oldRef = oldRawRef && oldRawRef.r;
2372
+ const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
2373
+ const setupState = owner.setupState;
2374
+ if (oldRef != null && oldRef !== ref) {
2375
+ if (shared.isString(oldRef)) {
2376
+ refs[oldRef] = null;
2377
+ if (shared.hasOwn(setupState, oldRef)) {
2378
+ setupState[oldRef] = null;
2379
+ }
2380
+ } else if (reactivity.isRef(oldRef)) {
2381
+ oldRef.value = null;
2382
+ }
2383
+ }
2384
+ if (shared.isFunction(ref)) {
2385
+ callWithErrorHandling(ref, owner, 12, [value, refs]);
2386
+ } else {
2387
+ const _isString = shared.isString(ref);
2388
+ const _isRef = reactivity.isRef(ref);
2389
+ if (_isString || _isRef) {
2390
+ const doSet = () => {
2391
+ if (rawRef.f) {
2392
+ const existing = _isString ? shared.hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
2393
+ if (isUnmount) {
2394
+ shared.isArray(existing) && shared.remove(existing, refValue);
2395
+ } else {
2396
+ if (!shared.isArray(existing)) {
2397
+ if (_isString) {
2398
+ refs[ref] = [refValue];
2399
+ if (shared.hasOwn(setupState, ref)) {
2400
+ setupState[ref] = refs[ref];
2401
+ }
2402
+ } else {
2403
+ ref.value = [refValue];
2404
+ if (rawRef.k) refs[rawRef.k] = ref.value;
2405
+ }
2406
+ } else if (!existing.includes(refValue)) {
2407
+ existing.push(refValue);
2408
+ }
2409
+ }
2410
+ } else if (_isString) {
2411
+ refs[ref] = value;
2412
+ if (shared.hasOwn(setupState, ref)) {
2413
+ setupState[ref] = value;
2414
+ }
2415
+ } else if (_isRef) {
2416
+ ref.value = value;
2417
+ if (rawRef.k) refs[rawRef.k] = value;
2418
+ } else ;
2419
+ };
2420
+ if (value) {
2421
+ doSet.id = -1;
2422
+ queuePostRenderEffect(doSet, parentSuspense);
2423
+ } else {
2424
+ doSet();
2425
+ }
2426
+ }
2427
+ }
2428
+ }
2429
+
2430
+ const TeleportEndKey = Symbol("_vte");
2431
+ const isTeleport = (type) => type.__isTeleport;
2432
+ const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
2433
+ const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
2434
+ const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
2435
+ const resolveTarget = (props, select) => {
2436
+ const targetSelector = props && props.to;
2437
+ if (shared.isString(targetSelector)) {
2438
+ if (!select) {
2439
+ return null;
2440
+ } else {
2441
+ const target = select(targetSelector);
2442
+ return target;
2443
+ }
2444
+ } else {
2445
+ return targetSelector;
2446
+ }
2447
+ };
2448
+ const TeleportImpl = {
2449
+ name: "Teleport",
2450
+ __isTeleport: true,
2451
+ process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
2452
+ const {
2453
+ mc: mountChildren,
2454
+ pc: patchChildren,
2455
+ pbc: patchBlockChildren,
2456
+ o: { insert, querySelector, createText, createComment }
2457
+ } = internals;
2458
+ const disabled = isTeleportDisabled(n2.props);
2459
+ let { shapeFlag, children, dynamicChildren } = n2;
2460
+ if (n1 == null) {
2461
+ const placeholder = n2.el = createText("");
2462
+ const mainAnchor = n2.anchor = createText("");
2463
+ const target = n2.target = resolveTarget(n2.props, querySelector);
2464
+ const targetStart = n2.targetStart = createText("");
2465
+ const targetAnchor = n2.targetAnchor = createText("");
2466
+ insert(placeholder, container, anchor);
2467
+ insert(mainAnchor, container, anchor);
2468
+ targetStart[TeleportEndKey] = targetAnchor;
2469
+ if (target) {
2470
+ insert(targetStart, target);
2471
+ insert(targetAnchor, target);
2472
+ if (namespace === "svg" || isTargetSVG(target)) {
2473
+ namespace = "svg";
2474
+ } else if (namespace === "mathml" || isTargetMathML(target)) {
2475
+ namespace = "mathml";
2476
+ }
2477
+ }
2478
+ const mount = (container2, anchor2) => {
2479
+ if (shapeFlag & 16) {
2480
+ mountChildren(
2481
+ children,
2482
+ container2,
2483
+ anchor2,
2484
+ parentComponent,
2485
+ parentSuspense,
2486
+ namespace,
2487
+ slotScopeIds,
2488
+ optimized
2489
+ );
2490
+ }
2491
+ };
2492
+ if (disabled) {
2493
+ mount(container, mainAnchor);
2494
+ } else if (target) {
2495
+ mount(target, targetAnchor);
2496
+ }
2497
+ } else {
2498
+ n2.el = n1.el;
2499
+ n2.targetStart = n1.targetStart;
2500
+ const mainAnchor = n2.anchor = n1.anchor;
2501
+ const target = n2.target = n1.target;
2502
+ const targetAnchor = n2.targetAnchor = n1.targetAnchor;
2503
+ const wasDisabled = isTeleportDisabled(n1.props);
2504
+ const currentContainer = wasDisabled ? container : target;
2505
+ const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
2506
+ if (namespace === "svg" || isTargetSVG(target)) {
2507
+ namespace = "svg";
2508
+ } else if (namespace === "mathml" || isTargetMathML(target)) {
2509
+ namespace = "mathml";
2510
+ }
2511
+ if (dynamicChildren) {
2512
+ patchBlockChildren(
2513
+ n1.dynamicChildren,
2514
+ dynamicChildren,
2515
+ currentContainer,
2516
+ parentComponent,
2517
+ parentSuspense,
2518
+ namespace,
2519
+ slotScopeIds
2520
+ );
2521
+ traverseStaticChildren(n1, n2, true);
2522
+ } else if (!optimized) {
2523
+ patchChildren(
2524
+ n1,
2525
+ n2,
2526
+ currentContainer,
2527
+ currentAnchor,
2528
+ parentComponent,
2529
+ parentSuspense,
2530
+ namespace,
2531
+ slotScopeIds,
2532
+ false
2533
+ );
2534
+ }
2535
+ if (disabled) {
2536
+ if (!wasDisabled) {
2537
+ moveTeleport(
2538
+ n2,
2539
+ container,
2540
+ mainAnchor,
2541
+ internals,
2542
+ 1
2543
+ );
2544
+ } else {
2545
+ if (n2.props && n1.props && n2.props.to !== n1.props.to) {
2546
+ n2.props.to = n1.props.to;
2547
+ }
2548
+ }
2549
+ } else {
2550
+ if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
2551
+ const nextTarget = n2.target = resolveTarget(
2552
+ n2.props,
2553
+ querySelector
2554
+ );
2555
+ if (nextTarget) {
2556
+ moveTeleport(
2557
+ n2,
2558
+ nextTarget,
2559
+ null,
2560
+ internals,
2561
+ 0
2562
+ );
2563
+ }
2564
+ } else if (wasDisabled) {
2565
+ moveTeleport(
2566
+ n2,
2567
+ target,
2568
+ targetAnchor,
2569
+ internals,
2570
+ 1
2571
+ );
2572
+ }
2573
+ }
2574
+ }
2575
+ updateCssVars(n2);
2576
+ },
2577
+ remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
2578
+ const {
2579
+ shapeFlag,
2580
+ children,
2581
+ anchor,
2582
+ targetStart,
2583
+ targetAnchor,
2584
+ target,
2585
+ props
2586
+ } = vnode;
2587
+ if (target) {
2588
+ hostRemove(targetStart);
2589
+ hostRemove(targetAnchor);
2590
+ }
2591
+ doRemove && hostRemove(anchor);
2592
+ if (shapeFlag & 16) {
2593
+ const shouldRemove = doRemove || !isTeleportDisabled(props);
2594
+ for (let i = 0; i < children.length; i++) {
2595
+ const child = children[i];
2596
+ unmount(
2597
+ child,
2598
+ parentComponent,
2599
+ parentSuspense,
2600
+ shouldRemove,
2601
+ !!child.dynamicChildren
2602
+ );
2603
+ }
2604
+ }
2605
+ },
2606
+ move: moveTeleport,
2607
+ hydrate: hydrateTeleport
2608
+ };
2609
+ function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
2610
+ if (moveType === 0) {
2611
+ insert(vnode.targetAnchor, container, parentAnchor);
2612
+ }
2613
+ const { el, anchor, shapeFlag, children, props } = vnode;
2614
+ const isReorder = moveType === 2;
2615
+ if (isReorder) {
2616
+ insert(el, container, parentAnchor);
2650
2617
  }
2651
- const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
2652
- const value = isUnmount ? null : refValue;
2653
- const { i: owner, r: ref } = rawRef;
2654
- const oldRef = oldRawRef && oldRawRef.r;
2655
- const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
2656
- const setupState = owner.setupState;
2657
- if (oldRef != null && oldRef !== ref) {
2658
- if (shared.isString(oldRef)) {
2659
- refs[oldRef] = null;
2660
- if (shared.hasOwn(setupState, oldRef)) {
2661
- setupState[oldRef] = null;
2618
+ if (!isReorder || isTeleportDisabled(props)) {
2619
+ if (shapeFlag & 16) {
2620
+ for (let i = 0; i < children.length; i++) {
2621
+ move(
2622
+ children[i],
2623
+ container,
2624
+ parentAnchor,
2625
+ 2
2626
+ );
2662
2627
  }
2663
- } else if (reactivity.isRef(oldRef)) {
2664
- oldRef.value = null;
2665
2628
  }
2666
2629
  }
2667
- if (shared.isFunction(ref)) {
2668
- callWithErrorHandling(ref, owner, 12, [value, refs]);
2669
- } else {
2670
- const _isString = shared.isString(ref);
2671
- const _isRef = reactivity.isRef(ref);
2672
- if (_isString || _isRef) {
2673
- const doSet = () => {
2674
- if (rawRef.f) {
2675
- const existing = _isString ? shared.hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
2676
- if (isUnmount) {
2677
- shared.isArray(existing) && shared.remove(existing, refValue);
2678
- } else {
2679
- if (!shared.isArray(existing)) {
2680
- if (_isString) {
2681
- refs[ref] = [refValue];
2682
- if (shared.hasOwn(setupState, ref)) {
2683
- setupState[ref] = refs[ref];
2684
- }
2685
- } else {
2686
- ref.value = [refValue];
2687
- if (rawRef.k) refs[rawRef.k] = ref.value;
2688
- }
2689
- } else if (!existing.includes(refValue)) {
2690
- existing.push(refValue);
2691
- }
2692
- }
2693
- } else if (_isString) {
2694
- refs[ref] = value;
2695
- if (shared.hasOwn(setupState, ref)) {
2696
- setupState[ref] = value;
2697
- }
2698
- } else if (_isRef) {
2699
- ref.value = value;
2700
- if (rawRef.k) refs[rawRef.k] = value;
2701
- } else ;
2702
- };
2703
- if (value) {
2704
- doSet.id = -1;
2705
- queuePostRenderEffect(doSet, parentSuspense);
2630
+ if (isReorder) {
2631
+ insert(anchor, container, parentAnchor);
2632
+ }
2633
+ }
2634
+ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
2635
+ o: { nextSibling, parentNode, querySelector }
2636
+ }, hydrateChildren) {
2637
+ const target = vnode.target = resolveTarget(
2638
+ vnode.props,
2639
+ querySelector
2640
+ );
2641
+ if (target) {
2642
+ const targetNode = target._lpa || target.firstChild;
2643
+ if (vnode.shapeFlag & 16) {
2644
+ if (isTeleportDisabled(vnode.props)) {
2645
+ vnode.anchor = hydrateChildren(
2646
+ nextSibling(node),
2647
+ vnode,
2648
+ parentNode(node),
2649
+ parentComponent,
2650
+ parentSuspense,
2651
+ slotScopeIds,
2652
+ optimized
2653
+ );
2654
+ vnode.targetAnchor = targetNode;
2706
2655
  } else {
2707
- doSet();
2656
+ vnode.anchor = nextSibling(node);
2657
+ let targetAnchor = targetNode;
2658
+ while (targetAnchor) {
2659
+ targetAnchor = nextSibling(targetAnchor);
2660
+ if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
2661
+ vnode.targetAnchor = targetAnchor;
2662
+ target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
2663
+ break;
2664
+ }
2665
+ }
2666
+ hydrateChildren(
2667
+ targetNode,
2668
+ vnode,
2669
+ target,
2670
+ parentComponent,
2671
+ parentSuspense,
2672
+ slotScopeIds,
2673
+ optimized
2674
+ );
2708
2675
  }
2709
2676
  }
2677
+ updateCssVars(vnode);
2678
+ }
2679
+ return vnode.anchor && nextSibling(vnode.anchor);
2680
+ }
2681
+ const Teleport = TeleportImpl;
2682
+ function updateCssVars(vnode) {
2683
+ const ctx = vnode.ctx;
2684
+ if (ctx && ctx.ut) {
2685
+ let node = vnode.children[0].el;
2686
+ while (node && node !== vnode.targetAnchor) {
2687
+ if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
2688
+ node = node.nextSibling;
2689
+ }
2690
+ ctx.ut();
2710
2691
  }
2711
2692
  }
2712
2693
 
@@ -2960,15 +2941,7 @@ function createHydrationFunctions(rendererInternals) {
2960
2941
  for (const key in props) {
2961
2942
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
2962
2943
  key[0] === ".") {
2963
- patchProp(
2964
- el,
2965
- key,
2966
- null,
2967
- props[key],
2968
- void 0,
2969
- void 0,
2970
- parentComponent
2971
- );
2944
+ patchProp(el, key, null, props[key], void 0, parentComponent);
2972
2945
  }
2973
2946
  }
2974
2947
  } else if (props.onClick) {
@@ -2978,9 +2951,10 @@ function createHydrationFunctions(rendererInternals) {
2978
2951
  null,
2979
2952
  props.onClick,
2980
2953
  void 0,
2981
- void 0,
2982
2954
  parentComponent
2983
2955
  );
2956
+ } else if (patchFlag & 4 && reactivity.isReactive(props.style)) {
2957
+ for (const key in props.style) props.style[key];
2984
2958
  }
2985
2959
  }
2986
2960
  let vnodeHooks;
@@ -3006,7 +2980,21 @@ function createHydrationFunctions(rendererInternals) {
3006
2980
  const l = children.length;
3007
2981
  for (let i = 0; i < l; i++) {
3008
2982
  const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
2983
+ const isText = vnode.type === Text;
3009
2984
  if (node) {
2985
+ if (isText && !optimized) {
2986
+ let next = children[i + 1];
2987
+ if (next && (next = normalizeVNode(next)).type === Text) {
2988
+ insert(
2989
+ createText(
2990
+ node.data.slice(vnode.children.length)
2991
+ ),
2992
+ container,
2993
+ nextSibling(node)
2994
+ );
2995
+ node.data = vnode.children;
2996
+ }
2997
+ }
3010
2998
  node = hydrateNode(
3011
2999
  node,
3012
3000
  vnode,
@@ -3015,7 +3003,7 @@ function createHydrationFunctions(rendererInternals) {
3015
3003
  slotScopeIds,
3016
3004
  optimized
3017
3005
  );
3018
- } else if (vnode.type === Text && !vnode.children) {
3006
+ } else if (isText && !vnode.children) {
3019
3007
  insert(vnode.el = createText(""), container);
3020
3008
  } else {
3021
3009
  logMismatchError();
@@ -3354,17 +3342,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3354
3342
  if (props) {
3355
3343
  for (const key in props) {
3356
3344
  if (key !== "value" && !shared.isReservedProp(key)) {
3357
- hostPatchProp(
3358
- el,
3359
- key,
3360
- null,
3361
- props[key],
3362
- namespace,
3363
- vnode.children,
3364
- parentComponent,
3365
- parentSuspense,
3366
- unmountChildren
3367
- );
3345
+ hostPatchProp(el, key, null, props[key], namespace, parentComponent);
3368
3346
  }
3369
3347
  }
3370
3348
  if ("value" in props) {
@@ -3444,6 +3422,9 @@ function baseCreateRenderer(options, createHydrationFns) {
3444
3422
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
3445
3423
  }
3446
3424
  parentComponent && toggleRecurse(parentComponent, true);
3425
+ if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
3426
+ hostSetElementText(el, "");
3427
+ }
3447
3428
  if (dynamicChildren) {
3448
3429
  patchBlockChildren(
3449
3430
  n1.dynamicChildren,
@@ -3469,15 +3450,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3469
3450
  }
3470
3451
  if (patchFlag > 0) {
3471
3452
  if (patchFlag & 16) {
3472
- patchProps(
3473
- el,
3474
- n2,
3475
- oldProps,
3476
- newProps,
3477
- parentComponent,
3478
- parentSuspense,
3479
- namespace
3480
- );
3453
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
3481
3454
  } else {
3482
3455
  if (patchFlag & 2) {
3483
3456
  if (oldProps.class !== newProps.class) {
@@ -3494,17 +3467,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3494
3467
  const prev = oldProps[key];
3495
3468
  const next = newProps[key];
3496
3469
  if (next !== prev || key === "value") {
3497
- hostPatchProp(
3498
- el,
3499
- key,
3500
- prev,
3501
- next,
3502
- namespace,
3503
- n1.children,
3504
- parentComponent,
3505
- parentSuspense,
3506
- unmountChildren
3507
- );
3470
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
3508
3471
  }
3509
3472
  }
3510
3473
  }
@@ -3515,15 +3478,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3515
3478
  }
3516
3479
  }
3517
3480
  } else if (!optimized && dynamicChildren == null) {
3518
- patchProps(
3519
- el,
3520
- n2,
3521
- oldProps,
3522
- newProps,
3523
- parentComponent,
3524
- parentSuspense,
3525
- namespace
3526
- );
3481
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
3527
3482
  }
3528
3483
  if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
3529
3484
  queuePostRenderEffect(() => {
@@ -3563,7 +3518,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3563
3518
  );
3564
3519
  }
3565
3520
  };
3566
- const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
3521
+ const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
3567
3522
  if (oldProps !== newProps) {
3568
3523
  if (oldProps !== shared.EMPTY_OBJ) {
3569
3524
  for (const key in oldProps) {
@@ -3574,10 +3529,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3574
3529
  oldProps[key],
3575
3530
  null,
3576
3531
  namespace,
3577
- vnode.children,
3578
- parentComponent,
3579
- parentSuspense,
3580
- unmountChildren
3532
+ parentComponent
3581
3533
  );
3582
3534
  }
3583
3535
  }
@@ -3587,17 +3539,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3587
3539
  const next = newProps[key];
3588
3540
  const prev = oldProps[key];
3589
3541
  if (next !== prev && key !== "value") {
3590
- hostPatchProp(
3591
- el,
3592
- key,
3593
- prev,
3594
- next,
3595
- namespace,
3596
- vnode.children,
3597
- parentComponent,
3598
- parentSuspense,
3599
- unmountChildren
3600
- );
3542
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
3601
3543
  }
3602
3544
  }
3603
3545
  if ("value" in newProps) {
@@ -3707,7 +3649,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3707
3649
  instance.ctx.renderer = internals;
3708
3650
  }
3709
3651
  {
3710
- setupComponent(instance);
3652
+ setupComponent(instance, false, optimized);
3711
3653
  }
3712
3654
  if (instance.asyncDep) {
3713
3655
  parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
@@ -3883,6 +3825,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3883
3825
  effect.run();
3884
3826
  }
3885
3827
  };
3828
+ update.i = instance;
3886
3829
  update.id = instance.uid;
3887
3830
  toggleRecurse(instance, true);
3888
3831
  update();
@@ -4235,7 +4178,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4235
4178
  shapeFlag,
4236
4179
  patchFlag,
4237
4180
  dirs,
4238
- memoIndex
4181
+ cacheIndex
4239
4182
  } = vnode;
4240
4183
  if (patchFlag === -2) {
4241
4184
  optimized = false;
@@ -4243,8 +4186,8 @@ function baseCreateRenderer(options, createHydrationFns) {
4243
4186
  if (ref != null) {
4244
4187
  setRef(ref, null, parentSuspense, vnode, true);
4245
4188
  }
4246
- if (memoIndex != null) {
4247
- parentComponent.renderCache[memoIndex] = void 0;
4189
+ if (cacheIndex != null) {
4190
+ parentComponent.renderCache[cacheIndex] = void 0;
4248
4191
  }
4249
4192
  if (shapeFlag & 256) {
4250
4193
  parentComponent.ctx.deactivate(vnode);
@@ -4274,7 +4217,12 @@ function baseCreateRenderer(options, createHydrationFns) {
4274
4217
  internals,
4275
4218
  doRemove
4276
4219
  );
4277
- } else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
4220
+ } else if (dynamicChildren && // #5154
4221
+ // when v-once is used inside a block, setBlockTracking(-1) marks the
4222
+ // parent block with hasOnce: true
4223
+ // so that it doesn't take the fast path during unmount - otherwise
4224
+ // components nested in v-once are never unmounted.
4225
+ !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
4278
4226
  (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
4279
4227
  unmountChildren(
4280
4228
  dynamicChildren,
@@ -4373,7 +4321,9 @@ function baseCreateRenderer(options, createHydrationFns) {
4373
4321
  if (vnode.shapeFlag & 128) {
4374
4322
  return vnode.suspense.next();
4375
4323
  }
4376
- return hostNextSibling(vnode.anchor || vnode.el);
4324
+ const el = hostNextSibling(vnode.anchor || vnode.el);
4325
+ const teleportEnd = el && el[TeleportEndKey];
4326
+ return teleportEnd ? hostNextSibling(teleportEnd) : el;
4377
4327
  };
4378
4328
  let isFlushing = false;
4379
4329
  const render = (vnode, container, namespace) => {
@@ -4747,827 +4697,932 @@ function traverse(value, depth = Infinity, seen) {
4747
4697
  return value;
4748
4698
  }
4749
4699
 
4750
- const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
4751
- const KeepAliveImpl = {
4752
- name: `KeepAlive`,
4753
- // Marker for special handling inside the renderer. We are not using a ===
4754
- // check directly on KeepAlive in the renderer, because importing it directly
4755
- // would prevent it from being tree-shaken.
4756
- __isKeepAlive: true,
4757
- props: {
4758
- include: [String, RegExp, Array],
4759
- exclude: [String, RegExp, Array],
4760
- max: [String, Number]
4761
- },
4762
- setup(props, { slots }) {
4763
- const instance = getCurrentInstance();
4764
- const sharedContext = instance.ctx;
4765
- if (!sharedContext.renderer) {
4766
- return () => {
4767
- const children = slots.default && slots.default();
4768
- return children && children.length === 1 ? children[0] : children;
4769
- };
4770
- }
4771
- const cache = /* @__PURE__ */ new Map();
4772
- const keys = /* @__PURE__ */ new Set();
4773
- let current = null;
4774
- const parentSuspense = instance.suspense;
4775
- const {
4776
- renderer: {
4777
- p: patch,
4778
- m: move,
4779
- um: _unmount,
4780
- o: { createElement }
4700
+ function useModel(props, name, options = shared.EMPTY_OBJ) {
4701
+ const i = getCurrentInstance();
4702
+ const camelizedName = shared.camelize(name);
4703
+ const hyphenatedName = shared.hyphenate(name);
4704
+ const modifiers = getModelModifiers(props, name);
4705
+ const res = reactivity.customRef((track, trigger) => {
4706
+ let localValue;
4707
+ let prevSetValue = shared.EMPTY_OBJ;
4708
+ let prevEmittedValue;
4709
+ watchSyncEffect(() => {
4710
+ const propValue = props[name];
4711
+ if (shared.hasChanged(localValue, propValue)) {
4712
+ localValue = propValue;
4713
+ trigger();
4781
4714
  }
4782
- } = sharedContext;
4783
- const storageContainer = createElement("div");
4784
- sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
4785
- const instance2 = vnode.component;
4786
- move(vnode, container, anchor, 0, parentSuspense);
4787
- patch(
4788
- instance2.vnode,
4789
- vnode,
4790
- container,
4791
- anchor,
4792
- instance2,
4793
- parentSuspense,
4794
- namespace,
4795
- vnode.slotScopeIds,
4796
- optimized
4797
- );
4798
- queuePostRenderEffect(() => {
4799
- instance2.isDeactivated = false;
4800
- if (instance2.a) {
4801
- shared.invokeArrayFns(instance2.a);
4802
- }
4803
- const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
4804
- if (vnodeHook) {
4805
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
4715
+ });
4716
+ return {
4717
+ get() {
4718
+ track();
4719
+ return options.get ? options.get(localValue) : localValue;
4720
+ },
4721
+ set(value) {
4722
+ if (!shared.hasChanged(value, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
4723
+ return;
4806
4724
  }
4807
- }, parentSuspense);
4808
- };
4809
- sharedContext.deactivate = (vnode) => {
4810
- const instance2 = vnode.component;
4811
- invalidateMount(instance2.m);
4812
- invalidateMount(instance2.a);
4813
- move(vnode, storageContainer, null, 1, parentSuspense);
4814
- queuePostRenderEffect(() => {
4815
- if (instance2.da) {
4816
- shared.invokeArrayFns(instance2.da);
4725
+ const rawProps = i.vnode.props;
4726
+ if (!(rawProps && // check if parent has passed v-model
4727
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
4728
+ localValue = value;
4729
+ trigger();
4817
4730
  }
4818
- const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
4819
- if (vnodeHook) {
4820
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
4731
+ const emittedValue = options.set ? options.set(value) : value;
4732
+ i.emit(`update:${name}`, emittedValue);
4733
+ if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
4734
+ trigger();
4821
4735
  }
4822
- instance2.isDeactivated = true;
4823
- }, parentSuspense);
4736
+ prevSetValue = value;
4737
+ prevEmittedValue = emittedValue;
4738
+ }
4824
4739
  };
4825
- function unmount(vnode) {
4826
- resetShapeFlag(vnode);
4827
- _unmount(vnode, instance, parentSuspense, true);
4828
- }
4829
- function pruneCache(filter) {
4830
- cache.forEach((vnode, key) => {
4831
- const name = getComponentName(vnode.type);
4832
- if (name && (!filter || !filter(name))) {
4833
- pruneCacheEntry(key);
4740
+ });
4741
+ res[Symbol.iterator] = () => {
4742
+ let i2 = 0;
4743
+ return {
4744
+ next() {
4745
+ if (i2 < 2) {
4746
+ return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
4747
+ } else {
4748
+ return { done: true };
4834
4749
  }
4835
- });
4836
- }
4837
- function pruneCacheEntry(key) {
4838
- const cached = cache.get(key);
4839
- if (!current || !isSameVNodeType(cached, current)) {
4840
- unmount(cached);
4841
- } else if (current) {
4842
- resetShapeFlag(current);
4843
4750
  }
4844
- cache.delete(key);
4845
- keys.delete(key);
4751
+ };
4752
+ };
4753
+ return res;
4754
+ }
4755
+ const getModelModifiers = (props, modelName) => {
4756
+ return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${shared.camelize(modelName)}Modifiers`] || props[`${shared.hyphenate(modelName)}Modifiers`];
4757
+ };
4758
+
4759
+ function emit(instance, event, ...rawArgs) {
4760
+ if (instance.isUnmounted) return;
4761
+ const props = instance.vnode.props || shared.EMPTY_OBJ;
4762
+ let args = rawArgs;
4763
+ const isModelListener = event.startsWith("update:");
4764
+ const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
4765
+ if (modifiers) {
4766
+ if (modifiers.trim) {
4767
+ args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
4846
4768
  }
4847
- watch(
4848
- () => [props.include, props.exclude],
4849
- ([include, exclude]) => {
4850
- include && pruneCache((name) => matches(include, name));
4851
- exclude && pruneCache((name) => !matches(exclude, name));
4852
- },
4853
- // prune post-render after `current` has been updated
4854
- { flush: "post", deep: true }
4769
+ if (modifiers.number) {
4770
+ args = rawArgs.map(shared.looseToNumber);
4771
+ }
4772
+ }
4773
+ let handlerName;
4774
+ let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
4775
+ props[handlerName = shared.toHandlerKey(shared.camelize(event))];
4776
+ if (!handler && isModelListener) {
4777
+ handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
4778
+ }
4779
+ if (handler) {
4780
+ callWithAsyncErrorHandling(
4781
+ handler,
4782
+ instance,
4783
+ 6,
4784
+ args
4855
4785
  );
4856
- let pendingCacheKey = null;
4857
- const cacheSubtree = () => {
4858
- if (pendingCacheKey != null) {
4859
- if (isSuspense(instance.subTree.type)) {
4860
- queuePostRenderEffect(() => {
4861
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
4862
- }, instance.subTree.suspense);
4863
- } else {
4864
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
4865
- }
4786
+ }
4787
+ const onceHandler = props[handlerName + `Once`];
4788
+ if (onceHandler) {
4789
+ if (!instance.emitted) {
4790
+ instance.emitted = {};
4791
+ } else if (instance.emitted[handlerName]) {
4792
+ return;
4793
+ }
4794
+ instance.emitted[handlerName] = true;
4795
+ callWithAsyncErrorHandling(
4796
+ onceHandler,
4797
+ instance,
4798
+ 6,
4799
+ args
4800
+ );
4801
+ }
4802
+ }
4803
+ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
4804
+ const cache = appContext.emitsCache;
4805
+ const cached = cache.get(comp);
4806
+ if (cached !== void 0) {
4807
+ return cached;
4808
+ }
4809
+ const raw = comp.emits;
4810
+ let normalized = {};
4811
+ let hasExtends = false;
4812
+ if (!shared.isFunction(comp)) {
4813
+ const extendEmits = (raw2) => {
4814
+ const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
4815
+ if (normalizedFromExtend) {
4816
+ hasExtends = true;
4817
+ shared.extend(normalized, normalizedFromExtend);
4866
4818
  }
4867
4819
  };
4868
- onMounted(cacheSubtree);
4869
- onUpdated(cacheSubtree);
4870
- onBeforeUnmount(() => {
4871
- cache.forEach((cached) => {
4872
- const { subTree, suspense } = instance;
4873
- const vnode = getInnerChild(subTree);
4874
- if (cached.type === vnode.type && cached.key === vnode.key) {
4875
- resetShapeFlag(vnode);
4876
- const da = vnode.component.da;
4877
- da && queuePostRenderEffect(da, suspense);
4878
- return;
4820
+ if (!asMixin && appContext.mixins.length) {
4821
+ appContext.mixins.forEach(extendEmits);
4822
+ }
4823
+ if (comp.extends) {
4824
+ extendEmits(comp.extends);
4825
+ }
4826
+ if (comp.mixins) {
4827
+ comp.mixins.forEach(extendEmits);
4828
+ }
4829
+ }
4830
+ if (!raw && !hasExtends) {
4831
+ if (shared.isObject(comp)) {
4832
+ cache.set(comp, null);
4833
+ }
4834
+ return null;
4835
+ }
4836
+ if (shared.isArray(raw)) {
4837
+ raw.forEach((key) => normalized[key] = null);
4838
+ } else {
4839
+ shared.extend(normalized, raw);
4840
+ }
4841
+ if (shared.isObject(comp)) {
4842
+ cache.set(comp, normalized);
4843
+ }
4844
+ return normalized;
4845
+ }
4846
+ function isEmitListener(options, key) {
4847
+ if (!options || !shared.isOn(key)) {
4848
+ return false;
4849
+ }
4850
+ key = key.slice(2).replace(/Once$/, "");
4851
+ return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
4852
+ }
4853
+
4854
+ function markAttrsAccessed() {
4855
+ }
4856
+ function renderComponentRoot(instance) {
4857
+ const {
4858
+ type: Component,
4859
+ vnode,
4860
+ proxy,
4861
+ withProxy,
4862
+ propsOptions: [propsOptions],
4863
+ slots,
4864
+ attrs,
4865
+ emit,
4866
+ render,
4867
+ renderCache,
4868
+ props,
4869
+ data,
4870
+ setupState,
4871
+ ctx,
4872
+ inheritAttrs
4873
+ } = instance;
4874
+ const prev = setCurrentRenderingInstance(instance);
4875
+ let result;
4876
+ let fallthroughAttrs;
4877
+ try {
4878
+ if (vnode.shapeFlag & 4) {
4879
+ const proxyToUse = withProxy || proxy;
4880
+ const thisProxy = false ? new Proxy(proxyToUse, {
4881
+ get(target, key, receiver) {
4882
+ warn(
4883
+ `Property '${String(
4884
+ key
4885
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
4886
+ );
4887
+ return Reflect.get(target, key, receiver);
4879
4888
  }
4880
- unmount(cached);
4881
- });
4882
- });
4883
- return () => {
4884
- pendingCacheKey = null;
4885
- if (!slots.default) {
4886
- return null;
4887
- }
4888
- const children = slots.default();
4889
- const rawVNode = children[0];
4890
- if (children.length > 1) {
4891
- current = null;
4892
- return children;
4893
- } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
4894
- current = null;
4895
- return rawVNode;
4896
- }
4897
- let vnode = getInnerChild(rawVNode);
4898
- const comp = vnode.type;
4899
- const name = getComponentName(
4900
- isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
4889
+ }) : proxyToUse;
4890
+ result = normalizeVNode(
4891
+ render.call(
4892
+ thisProxy,
4893
+ proxyToUse,
4894
+ renderCache,
4895
+ false ? shallowReadonly(props) : props,
4896
+ setupState,
4897
+ data,
4898
+ ctx
4899
+ )
4901
4900
  );
4902
- const { include, exclude, max } = props;
4903
- if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
4904
- current = vnode;
4905
- return rawVNode;
4906
- }
4907
- const key = vnode.key == null ? comp : vnode.key;
4908
- const cachedVNode = cache.get(key);
4909
- if (vnode.el) {
4910
- vnode = cloneVNode(vnode);
4911
- if (rawVNode.shapeFlag & 128) {
4912
- rawVNode.ssContent = vnode;
4913
- }
4914
- }
4915
- pendingCacheKey = key;
4916
- if (cachedVNode) {
4917
- vnode.el = cachedVNode.el;
4918
- vnode.component = cachedVNode.component;
4919
- if (vnode.transition) {
4920
- setTransitionHooks(vnode, vnode.transition);
4921
- }
4922
- vnode.shapeFlag |= 512;
4923
- keys.delete(key);
4924
- keys.add(key);
4925
- } else {
4926
- keys.add(key);
4927
- if (max && keys.size > parseInt(max, 10)) {
4928
- pruneCacheEntry(keys.values().next().value);
4901
+ fallthroughAttrs = attrs;
4902
+ } else {
4903
+ const render2 = Component;
4904
+ if (false) ;
4905
+ result = normalizeVNode(
4906
+ render2.length > 1 ? render2(
4907
+ false ? shallowReadonly(props) : props,
4908
+ false ? {
4909
+ get attrs() {
4910
+ markAttrsAccessed();
4911
+ return shallowReadonly(attrs);
4912
+ },
4913
+ slots,
4914
+ emit
4915
+ } : { attrs, slots, emit }
4916
+ ) : render2(
4917
+ false ? shallowReadonly(props) : props,
4918
+ null
4919
+ )
4920
+ );
4921
+ fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
4922
+ }
4923
+ } catch (err) {
4924
+ blockStack.length = 0;
4925
+ handleError(err, instance, 1);
4926
+ result = createVNode(Comment);
4927
+ }
4928
+ let root = result;
4929
+ if (fallthroughAttrs && inheritAttrs !== false) {
4930
+ const keys = Object.keys(fallthroughAttrs);
4931
+ const { shapeFlag } = root;
4932
+ if (keys.length) {
4933
+ if (shapeFlag & (1 | 6)) {
4934
+ if (propsOptions && keys.some(shared.isModelListener)) {
4935
+ fallthroughAttrs = filterModelListeners(
4936
+ fallthroughAttrs,
4937
+ propsOptions
4938
+ );
4929
4939
  }
4940
+ root = cloneVNode(root, fallthroughAttrs, false, true);
4930
4941
  }
4931
- vnode.shapeFlag |= 256;
4932
- current = vnode;
4933
- return isSuspense(rawVNode.type) ? rawVNode : vnode;
4934
- };
4942
+ }
4935
4943
  }
4936
- };
4937
- const KeepAlive = KeepAliveImpl;
4938
- function matches(pattern, name) {
4939
- if (shared.isArray(pattern)) {
4940
- return pattern.some((p) => matches(p, name));
4941
- } else if (shared.isString(pattern)) {
4942
- return pattern.split(",").includes(name);
4943
- } else if (shared.isRegExp(pattern)) {
4944
- return pattern.test(name);
4944
+ if (vnode.dirs) {
4945
+ root = cloneVNode(root, null, false, true);
4946
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
4945
4947
  }
4946
- return false;
4947
- }
4948
- function onActivated(hook, target) {
4949
- registerKeepAliveHook(hook, "a", target);
4950
- }
4951
- function onDeactivated(hook, target) {
4952
- registerKeepAliveHook(hook, "da", target);
4948
+ if (vnode.transition) {
4949
+ root.transition = vnode.transition;
4950
+ }
4951
+ {
4952
+ result = root;
4953
+ }
4954
+ setCurrentRenderingInstance(prev);
4955
+ return result;
4953
4956
  }
4954
- function registerKeepAliveHook(hook, type, target = currentInstance) {
4955
- const wrappedHook = hook.__wdc || (hook.__wdc = () => {
4956
- let current = target;
4957
- while (current) {
4958
- if (current.isDeactivated) {
4959
- return;
4960
- }
4961
- current = current.parent;
4962
- }
4963
- return hook();
4964
- });
4965
- injectHook(type, wrappedHook, target);
4966
- if (target) {
4967
- let current = target.parent;
4968
- while (current && current.parent) {
4969
- if (isKeepAlive(current.parent.vnode)) {
4970
- injectToKeepAliveRoot(wrappedHook, type, target, current);
4957
+ function filterSingleRoot(children, recurse = true) {
4958
+ let singleRoot;
4959
+ for (let i = 0; i < children.length; i++) {
4960
+ const child = children[i];
4961
+ if (isVNode(child)) {
4962
+ if (child.type !== Comment || child.children === "v-if") {
4963
+ if (singleRoot) {
4964
+ return;
4965
+ } else {
4966
+ singleRoot = child;
4967
+ }
4971
4968
  }
4972
- current = current.parent;
4969
+ } else {
4970
+ return;
4973
4971
  }
4974
4972
  }
4973
+ return singleRoot;
4975
4974
  }
4976
- function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4977
- const injected = injectHook(
4978
- type,
4979
- hook,
4980
- keepAliveRoot,
4981
- true
4982
- /* prepend */
4983
- );
4984
- onUnmounted(() => {
4985
- shared.remove(keepAliveRoot[type], injected);
4986
- }, target);
4987
- }
4988
- function resetShapeFlag(vnode) {
4989
- vnode.shapeFlag &= ~256;
4990
- vnode.shapeFlag &= ~512;
4991
- }
4992
- function getInnerChild(vnode) {
4993
- return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
4994
- }
4995
-
4996
- const leaveCbKey = Symbol("_leaveCb");
4997
- const enterCbKey = Symbol("_enterCb");
4998
- function useTransitionState() {
4999
- const state = {
5000
- isMounted: false,
5001
- isLeaving: false,
5002
- isUnmounting: false,
5003
- leavingVNodes: /* @__PURE__ */ new Map()
5004
- };
5005
- onMounted(() => {
5006
- state.isMounted = true;
5007
- });
5008
- onBeforeUnmount(() => {
5009
- state.isUnmounting = true;
5010
- });
5011
- return state;
5012
- }
5013
- const TransitionHookValidator = [Function, Array];
5014
- const BaseTransitionPropsValidators = {
5015
- mode: String,
5016
- appear: Boolean,
5017
- persisted: Boolean,
5018
- // enter
5019
- onBeforeEnter: TransitionHookValidator,
5020
- onEnter: TransitionHookValidator,
5021
- onAfterEnter: TransitionHookValidator,
5022
- onEnterCancelled: TransitionHookValidator,
5023
- // leave
5024
- onBeforeLeave: TransitionHookValidator,
5025
- onLeave: TransitionHookValidator,
5026
- onAfterLeave: TransitionHookValidator,
5027
- onLeaveCancelled: TransitionHookValidator,
5028
- // appear
5029
- onBeforeAppear: TransitionHookValidator,
5030
- onAppear: TransitionHookValidator,
5031
- onAfterAppear: TransitionHookValidator,
5032
- onAppearCancelled: TransitionHookValidator
4975
+ const getFunctionalFallthrough = (attrs) => {
4976
+ let res;
4977
+ for (const key in attrs) {
4978
+ if (key === "class" || key === "style" || shared.isOn(key)) {
4979
+ (res || (res = {}))[key] = attrs[key];
4980
+ }
4981
+ }
4982
+ return res;
5033
4983
  };
5034
- const recursiveGetSubtree = (instance) => {
5035
- const subTree = instance.subTree;
5036
- return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
4984
+ const filterModelListeners = (attrs, props) => {
4985
+ const res = {};
4986
+ for (const key in attrs) {
4987
+ if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
4988
+ res[key] = attrs[key];
4989
+ }
4990
+ }
4991
+ return res;
5037
4992
  };
5038
- const BaseTransitionImpl = {
5039
- name: `BaseTransition`,
5040
- props: BaseTransitionPropsValidators,
5041
- setup(props, { slots }) {
5042
- const instance = getCurrentInstance();
5043
- const state = useTransitionState();
5044
- return () => {
5045
- const children = slots.default && getTransitionRawChildren(slots.default(), true);
5046
- if (!children || !children.length) {
5047
- return;
5048
- }
5049
- let child = children[0];
5050
- if (children.length > 1) {
5051
- for (const c of children) {
5052
- if (c.type !== Comment) {
5053
- child = c;
5054
- break;
5055
- }
5056
- }
5057
- }
5058
- const rawProps = reactivity.toRaw(props);
5059
- const { mode } = rawProps;
5060
- if (state.isLeaving) {
5061
- return emptyPlaceholder(child);
5062
- }
5063
- const innerChild = getKeepAliveChild(child);
5064
- if (!innerChild) {
5065
- return emptyPlaceholder(child);
5066
- }
5067
- let enterHooks = resolveTransitionHooks(
5068
- innerChild,
5069
- rawProps,
5070
- state,
5071
- instance,
5072
- // #11061, ensure enterHooks is fresh after clone
5073
- (hooks) => enterHooks = hooks
5074
- );
5075
- setTransitionHooks(innerChild, enterHooks);
5076
- const oldChild = instance.subTree;
5077
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
5078
- if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
5079
- const leavingHooks = resolveTransitionHooks(
5080
- oldInnerChild,
5081
- rawProps,
5082
- state,
5083
- instance
5084
- );
5085
- setTransitionHooks(oldInnerChild, leavingHooks);
5086
- if (mode === "out-in" && innerChild.type !== Comment) {
5087
- state.isLeaving = true;
5088
- leavingHooks.afterLeave = () => {
5089
- state.isLeaving = false;
5090
- if (instance.update.active !== false) {
5091
- instance.effect.dirty = true;
5092
- instance.update();
5093
- }
5094
- };
5095
- return emptyPlaceholder(child);
5096
- } else if (mode === "in-out" && innerChild.type !== Comment) {
5097
- leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
5098
- const leavingVNodesCache = getLeavingNodesForType(
5099
- state,
5100
- oldInnerChild
5101
- );
5102
- leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
5103
- el[leaveCbKey] = () => {
5104
- earlyRemove();
5105
- el[leaveCbKey] = void 0;
5106
- delete enterHooks.delayedLeave;
5107
- };
5108
- enterHooks.delayedLeave = delayedLeave;
5109
- };
4993
+ function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
4994
+ const { props: prevProps, children: prevChildren, component } = prevVNode;
4995
+ const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
4996
+ const emits = component.emitsOptions;
4997
+ if (nextVNode.dirs || nextVNode.transition) {
4998
+ return true;
4999
+ }
5000
+ if (optimized && patchFlag >= 0) {
5001
+ if (patchFlag & 1024) {
5002
+ return true;
5003
+ }
5004
+ if (patchFlag & 16) {
5005
+ if (!prevProps) {
5006
+ return !!nextProps;
5007
+ }
5008
+ return hasPropsChanged(prevProps, nextProps, emits);
5009
+ } else if (patchFlag & 8) {
5010
+ const dynamicProps = nextVNode.dynamicProps;
5011
+ for (let i = 0; i < dynamicProps.length; i++) {
5012
+ const key = dynamicProps[i];
5013
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
5014
+ return true;
5110
5015
  }
5111
5016
  }
5112
- return child;
5113
- };
5017
+ }
5018
+ } else {
5019
+ if (prevChildren || nextChildren) {
5020
+ if (!nextChildren || !nextChildren.$stable) {
5021
+ return true;
5022
+ }
5023
+ }
5024
+ if (prevProps === nextProps) {
5025
+ return false;
5026
+ }
5027
+ if (!prevProps) {
5028
+ return !!nextProps;
5029
+ }
5030
+ if (!nextProps) {
5031
+ return true;
5032
+ }
5033
+ return hasPropsChanged(prevProps, nextProps, emits);
5114
5034
  }
5035
+ return false;
5036
+ }
5037
+ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
5038
+ const nextKeys = Object.keys(nextProps);
5039
+ if (nextKeys.length !== Object.keys(prevProps).length) {
5040
+ return true;
5041
+ }
5042
+ for (let i = 0; i < nextKeys.length; i++) {
5043
+ const key = nextKeys[i];
5044
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
5045
+ return true;
5046
+ }
5047
+ }
5048
+ return false;
5049
+ }
5050
+ function updateHOCHostEl({ vnode, parent }, el) {
5051
+ while (parent) {
5052
+ const root = parent.subTree;
5053
+ if (root.suspense && root.suspense.activeBranch === vnode) {
5054
+ root.el = vnode.el;
5055
+ }
5056
+ if (root === vnode) {
5057
+ (vnode = parent.vnode).el = el;
5058
+ parent = parent.parent;
5059
+ } else {
5060
+ break;
5061
+ }
5062
+ }
5063
+ }
5064
+
5065
+ const isSuspense = (type) => type.__isSuspense;
5066
+ let suspenseId = 0;
5067
+ const SuspenseImpl = {
5068
+ name: "Suspense",
5069
+ // In order to make Suspense tree-shakable, we need to avoid importing it
5070
+ // directly in the renderer. The renderer checks for the __isSuspense flag
5071
+ // on a vnode's type and calls the `process` method, passing in renderer
5072
+ // internals.
5073
+ __isSuspense: true,
5074
+ process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
5075
+ if (n1 == null) {
5076
+ mountSuspense(
5077
+ n2,
5078
+ container,
5079
+ anchor,
5080
+ parentComponent,
5081
+ parentSuspense,
5082
+ namespace,
5083
+ slotScopeIds,
5084
+ optimized,
5085
+ rendererInternals
5086
+ );
5087
+ } else {
5088
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
5089
+ n2.suspense = n1.suspense;
5090
+ n2.suspense.vnode = n2;
5091
+ n2.el = n1.el;
5092
+ return;
5093
+ }
5094
+ patchSuspense(
5095
+ n1,
5096
+ n2,
5097
+ container,
5098
+ anchor,
5099
+ parentComponent,
5100
+ namespace,
5101
+ slotScopeIds,
5102
+ optimized,
5103
+ rendererInternals
5104
+ );
5105
+ }
5106
+ },
5107
+ hydrate: hydrateSuspense,
5108
+ normalize: normalizeSuspenseChildren
5115
5109
  };
5116
- const BaseTransition = BaseTransitionImpl;
5117
- function getLeavingNodesForType(state, vnode) {
5118
- const { leavingVNodes } = state;
5119
- let leavingVNodesCache = leavingVNodes.get(vnode.type);
5120
- if (!leavingVNodesCache) {
5121
- leavingVNodesCache = /* @__PURE__ */ Object.create(null);
5122
- leavingVNodes.set(vnode.type, leavingVNodesCache);
5110
+ const Suspense = SuspenseImpl ;
5111
+ function triggerEvent(vnode, name) {
5112
+ const eventListener = vnode.props && vnode.props[name];
5113
+ if (shared.isFunction(eventListener)) {
5114
+ eventListener();
5123
5115
  }
5124
- return leavingVNodesCache;
5125
5116
  }
5126
- function resolveTransitionHooks(vnode, props, state, instance, postClone) {
5117
+ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
5127
5118
  const {
5128
- appear,
5129
- mode,
5130
- persisted = false,
5131
- onBeforeEnter,
5132
- onEnter,
5133
- onAfterEnter,
5134
- onEnterCancelled,
5135
- onBeforeLeave,
5136
- onLeave,
5137
- onAfterLeave,
5138
- onLeaveCancelled,
5139
- onBeforeAppear,
5140
- onAppear,
5141
- onAfterAppear,
5142
- onAppearCancelled
5143
- } = props;
5144
- const key = String(vnode.key);
5145
- const leavingVNodesCache = getLeavingNodesForType(state, vnode);
5146
- const callHook = (hook, args) => {
5147
- hook && callWithAsyncErrorHandling(
5148
- hook,
5149
- instance,
5150
- 9,
5151
- args
5119
+ p: patch,
5120
+ o: { createElement }
5121
+ } = rendererInternals;
5122
+ const hiddenContainer = createElement("div");
5123
+ const suspense = vnode.suspense = createSuspenseBoundary(
5124
+ vnode,
5125
+ parentSuspense,
5126
+ parentComponent,
5127
+ container,
5128
+ hiddenContainer,
5129
+ anchor,
5130
+ namespace,
5131
+ slotScopeIds,
5132
+ optimized,
5133
+ rendererInternals
5134
+ );
5135
+ patch(
5136
+ null,
5137
+ suspense.pendingBranch = vnode.ssContent,
5138
+ hiddenContainer,
5139
+ null,
5140
+ parentComponent,
5141
+ suspense,
5142
+ namespace,
5143
+ slotScopeIds
5144
+ );
5145
+ if (suspense.deps > 0) {
5146
+ triggerEvent(vnode, "onPending");
5147
+ triggerEvent(vnode, "onFallback");
5148
+ patch(
5149
+ null,
5150
+ vnode.ssFallback,
5151
+ container,
5152
+ anchor,
5153
+ parentComponent,
5154
+ null,
5155
+ // fallback tree will not have suspense context
5156
+ namespace,
5157
+ slotScopeIds
5152
5158
  );
5153
- };
5154
- const callAsyncHook = (hook, args) => {
5155
- const done = args[1];
5156
- callHook(hook, args);
5157
- if (shared.isArray(hook)) {
5158
- if (hook.every((hook2) => hook2.length <= 1)) done();
5159
- } else if (hook.length <= 1) {
5160
- done();
5161
- }
5162
- };
5163
- const hooks = {
5164
- mode,
5165
- persisted,
5166
- beforeEnter(el) {
5167
- let hook = onBeforeEnter;
5168
- if (!state.isMounted) {
5169
- if (appear) {
5170
- hook = onBeforeAppear || onBeforeEnter;
5171
- } else {
5172
- return;
5173
- }
5174
- }
5175
- if (el[leaveCbKey]) {
5176
- el[leaveCbKey](
5177
- true
5178
- /* cancelled */
5179
- );
5180
- }
5181
- const leavingVNode = leavingVNodesCache[key];
5182
- if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
5183
- leavingVNode.el[leaveCbKey]();
5184
- }
5185
- callHook(hook, [el]);
5186
- },
5187
- enter(el) {
5188
- let hook = onEnter;
5189
- let afterHook = onAfterEnter;
5190
- let cancelHook = onEnterCancelled;
5191
- if (!state.isMounted) {
5192
- if (appear) {
5193
- hook = onAppear || onEnter;
5194
- afterHook = onAfterAppear || onAfterEnter;
5195
- cancelHook = onAppearCancelled || onEnterCancelled;
5196
- } else {
5197
- return;
5159
+ setActiveBranch(suspense, vnode.ssFallback);
5160
+ } else {
5161
+ suspense.resolve(false, true);
5162
+ }
5163
+ }
5164
+ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
5165
+ const suspense = n2.suspense = n1.suspense;
5166
+ suspense.vnode = n2;
5167
+ n2.el = n1.el;
5168
+ const newBranch = n2.ssContent;
5169
+ const newFallback = n2.ssFallback;
5170
+ const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
5171
+ if (pendingBranch) {
5172
+ suspense.pendingBranch = newBranch;
5173
+ if (isSameVNodeType(newBranch, pendingBranch)) {
5174
+ patch(
5175
+ pendingBranch,
5176
+ newBranch,
5177
+ suspense.hiddenContainer,
5178
+ null,
5179
+ parentComponent,
5180
+ suspense,
5181
+ namespace,
5182
+ slotScopeIds,
5183
+ optimized
5184
+ );
5185
+ if (suspense.deps <= 0) {
5186
+ suspense.resolve();
5187
+ } else if (isInFallback) {
5188
+ if (!isHydrating) {
5189
+ patch(
5190
+ activeBranch,
5191
+ newFallback,
5192
+ container,
5193
+ anchor,
5194
+ parentComponent,
5195
+ null,
5196
+ // fallback tree will not have suspense context
5197
+ namespace,
5198
+ slotScopeIds,
5199
+ optimized
5200
+ );
5201
+ setActiveBranch(suspense, newFallback);
5198
5202
  }
5199
5203
  }
5200
- let called = false;
5201
- const done = el[enterCbKey] = (cancelled) => {
5202
- if (called) return;
5203
- called = true;
5204
- if (cancelled) {
5205
- callHook(cancelHook, [el]);
5206
- } else {
5207
- callHook(afterHook, [el]);
5208
- }
5209
- if (hooks.delayedLeave) {
5210
- hooks.delayedLeave();
5211
- }
5212
- el[enterCbKey] = void 0;
5213
- };
5214
- if (hook) {
5215
- callAsyncHook(hook, [el, done]);
5204
+ } else {
5205
+ suspense.pendingId = suspenseId++;
5206
+ if (isHydrating) {
5207
+ suspense.isHydrating = false;
5208
+ suspense.activeBranch = pendingBranch;
5216
5209
  } else {
5217
- done();
5210
+ unmount(pendingBranch, parentComponent, suspense);
5218
5211
  }
5219
- },
5220
- leave(el, remove) {
5221
- const key2 = String(vnode.key);
5222
- if (el[enterCbKey]) {
5223
- el[enterCbKey](
5224
- true
5225
- /* cancelled */
5212
+ suspense.deps = 0;
5213
+ suspense.effects.length = 0;
5214
+ suspense.hiddenContainer = createElement("div");
5215
+ if (isInFallback) {
5216
+ patch(
5217
+ null,
5218
+ newBranch,
5219
+ suspense.hiddenContainer,
5220
+ null,
5221
+ parentComponent,
5222
+ suspense,
5223
+ namespace,
5224
+ slotScopeIds,
5225
+ optimized
5226
5226
  );
5227
- }
5228
- if (state.isUnmounting) {
5229
- return remove();
5230
- }
5231
- callHook(onBeforeLeave, [el]);
5232
- let called = false;
5233
- const done = el[leaveCbKey] = (cancelled) => {
5234
- if (called) return;
5235
- called = true;
5236
- remove();
5237
- if (cancelled) {
5238
- callHook(onLeaveCancelled, [el]);
5227
+ if (suspense.deps <= 0) {
5228
+ suspense.resolve();
5239
5229
  } else {
5240
- callHook(onAfterLeave, [el]);
5241
- }
5242
- el[leaveCbKey] = void 0;
5243
- if (leavingVNodesCache[key2] === vnode) {
5244
- delete leavingVNodesCache[key2];
5230
+ patch(
5231
+ activeBranch,
5232
+ newFallback,
5233
+ container,
5234
+ anchor,
5235
+ parentComponent,
5236
+ null,
5237
+ // fallback tree will not have suspense context
5238
+ namespace,
5239
+ slotScopeIds,
5240
+ optimized
5241
+ );
5242
+ setActiveBranch(suspense, newFallback);
5245
5243
  }
5246
- };
5247
- leavingVNodesCache[key2] = vnode;
5248
- if (onLeave) {
5249
- callAsyncHook(onLeave, [el, done]);
5244
+ } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
5245
+ patch(
5246
+ activeBranch,
5247
+ newBranch,
5248
+ container,
5249
+ anchor,
5250
+ parentComponent,
5251
+ suspense,
5252
+ namespace,
5253
+ slotScopeIds,
5254
+ optimized
5255
+ );
5256
+ suspense.resolve(true);
5250
5257
  } else {
5251
- done();
5258
+ patch(
5259
+ null,
5260
+ newBranch,
5261
+ suspense.hiddenContainer,
5262
+ null,
5263
+ parentComponent,
5264
+ suspense,
5265
+ namespace,
5266
+ slotScopeIds,
5267
+ optimized
5268
+ );
5269
+ if (suspense.deps <= 0) {
5270
+ suspense.resolve();
5271
+ }
5252
5272
  }
5253
- },
5254
- clone(vnode2) {
5255
- const hooks2 = resolveTransitionHooks(
5256
- vnode2,
5257
- props,
5258
- state,
5259
- instance,
5260
- postClone
5261
- );
5262
- if (postClone) postClone(hooks2);
5263
- return hooks2;
5264
- }
5265
- };
5266
- return hooks;
5267
- }
5268
- function emptyPlaceholder(vnode) {
5269
- if (isKeepAlive(vnode)) {
5270
- vnode = cloneVNode(vnode);
5271
- vnode.children = null;
5272
- return vnode;
5273
- }
5274
- }
5275
- function getKeepAliveChild(vnode) {
5276
- if (!isKeepAlive(vnode)) {
5277
- return vnode;
5278
- }
5279
- const { shapeFlag, children } = vnode;
5280
- if (children) {
5281
- if (shapeFlag & 16) {
5282
- return children[0];
5283
- }
5284
- if (shapeFlag & 32 && shared.isFunction(children.default)) {
5285
- return children.default();
5286
5273
  }
5287
- }
5288
- }
5289
- function setTransitionHooks(vnode, hooks) {
5290
- if (vnode.shapeFlag & 6 && vnode.component) {
5291
- setTransitionHooks(vnode.component.subTree, hooks);
5292
- } else if (vnode.shapeFlag & 128) {
5293
- vnode.ssContent.transition = hooks.clone(vnode.ssContent);
5294
- vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
5295
5274
  } else {
5296
- vnode.transition = hooks;
5297
- }
5298
- }
5299
- function getTransitionRawChildren(children, keepComment = false, parentKey) {
5300
- let ret = [];
5301
- let keyedFragmentCount = 0;
5302
- for (let i = 0; i < children.length; i++) {
5303
- let child = children[i];
5304
- const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
5305
- if (child.type === Fragment) {
5306
- if (child.patchFlag & 128) keyedFragmentCount++;
5307
- ret = ret.concat(
5308
- getTransitionRawChildren(child.children, keepComment, key)
5275
+ if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
5276
+ patch(
5277
+ activeBranch,
5278
+ newBranch,
5279
+ container,
5280
+ anchor,
5281
+ parentComponent,
5282
+ suspense,
5283
+ namespace,
5284
+ slotScopeIds,
5285
+ optimized
5309
5286
  );
5310
- } else if (keepComment || child.type !== Comment) {
5311
- ret.push(key != null ? cloneVNode(child, { key }) : child);
5312
- }
5313
- }
5314
- if (keyedFragmentCount > 1) {
5315
- for (let i = 0; i < ret.length; i++) {
5316
- ret[i].patchFlag = -2;
5287
+ setActiveBranch(suspense, newBranch);
5288
+ } else {
5289
+ triggerEvent(n2, "onPending");
5290
+ suspense.pendingBranch = newBranch;
5291
+ if (newBranch.shapeFlag & 512) {
5292
+ suspense.pendingId = newBranch.component.suspenseId;
5293
+ } else {
5294
+ suspense.pendingId = suspenseId++;
5295
+ }
5296
+ patch(
5297
+ null,
5298
+ newBranch,
5299
+ suspense.hiddenContainer,
5300
+ null,
5301
+ parentComponent,
5302
+ suspense,
5303
+ namespace,
5304
+ slotScopeIds,
5305
+ optimized
5306
+ );
5307
+ if (suspense.deps <= 0) {
5308
+ suspense.resolve();
5309
+ } else {
5310
+ const { timeout, pendingId } = suspense;
5311
+ if (timeout > 0) {
5312
+ setTimeout(() => {
5313
+ if (suspense.pendingId === pendingId) {
5314
+ suspense.fallback(newFallback);
5315
+ }
5316
+ }, timeout);
5317
+ } else if (timeout === 0) {
5318
+ suspense.fallback(newFallback);
5319
+ }
5320
+ }
5317
5321
  }
5318
5322
  }
5319
- return ret;
5320
5323
  }
5321
-
5322
- const isTeleport = (type) => type.__isTeleport;
5323
- const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
5324
- const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
5325
- const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
5326
- const resolveTarget = (props, select) => {
5327
- const targetSelector = props && props.to;
5328
- if (shared.isString(targetSelector)) {
5329
- if (!select) {
5330
- return null;
5331
- } else {
5332
- const target = select(targetSelector);
5333
- return target;
5324
+ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
5325
+ const {
5326
+ p: patch,
5327
+ m: move,
5328
+ um: unmount,
5329
+ n: next,
5330
+ o: { parentNode, remove }
5331
+ } = rendererInternals;
5332
+ let parentSuspenseId;
5333
+ const isSuspensible = isVNodeSuspensible(vnode);
5334
+ if (isSuspensible) {
5335
+ if (parentSuspense && parentSuspense.pendingBranch) {
5336
+ parentSuspenseId = parentSuspense.pendingId;
5337
+ parentSuspense.deps++;
5334
5338
  }
5335
- } else {
5336
- return targetSelector;
5337
5339
  }
5338
- };
5339
- const TeleportImpl = {
5340
- name: "Teleport",
5341
- __isTeleport: true,
5342
- process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
5343
- const {
5344
- mc: mountChildren,
5345
- pc: patchChildren,
5346
- pbc: patchBlockChildren,
5347
- o: { insert, querySelector, createText, createComment }
5348
- } = internals;
5349
- const disabled = isTeleportDisabled(n2.props);
5350
- let { shapeFlag, children, dynamicChildren } = n2;
5351
- if (n1 == null) {
5352
- const placeholder = n2.el = createText("");
5353
- const mainAnchor = n2.anchor = createText("");
5354
- insert(placeholder, container, anchor);
5355
- insert(mainAnchor, container, anchor);
5356
- const target = n2.target = resolveTarget(n2.props, querySelector);
5357
- const targetAnchor = n2.targetAnchor = createText("");
5358
- if (target) {
5359
- insert(targetAnchor, target);
5360
- if (namespace === "svg" || isTargetSVG(target)) {
5361
- namespace = "svg";
5362
- } else if (namespace === "mathml" || isTargetMathML(target)) {
5363
- namespace = "mathml";
5340
+ const timeout = vnode.props ? shared.toNumber(vnode.props.timeout) : void 0;
5341
+ const initialAnchor = anchor;
5342
+ const suspense = {
5343
+ vnode,
5344
+ parent: parentSuspense,
5345
+ parentComponent,
5346
+ namespace,
5347
+ container,
5348
+ hiddenContainer,
5349
+ deps: 0,
5350
+ pendingId: suspenseId++,
5351
+ timeout: typeof timeout === "number" ? timeout : -1,
5352
+ activeBranch: null,
5353
+ pendingBranch: null,
5354
+ isInFallback: !isHydrating,
5355
+ isHydrating,
5356
+ isUnmounted: false,
5357
+ effects: [],
5358
+ resolve(resume = false, sync = false) {
5359
+ const {
5360
+ vnode: vnode2,
5361
+ activeBranch,
5362
+ pendingBranch,
5363
+ pendingId,
5364
+ effects,
5365
+ parentComponent: parentComponent2,
5366
+ container: container2
5367
+ } = suspense;
5368
+ let delayEnter = false;
5369
+ if (suspense.isHydrating) {
5370
+ suspense.isHydrating = false;
5371
+ } else if (!resume) {
5372
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
5373
+ if (delayEnter) {
5374
+ activeBranch.transition.afterLeave = () => {
5375
+ if (pendingId === suspense.pendingId) {
5376
+ move(
5377
+ pendingBranch,
5378
+ container2,
5379
+ anchor === initialAnchor ? next(activeBranch) : anchor,
5380
+ 0
5381
+ );
5382
+ queuePostFlushCb(effects);
5383
+ }
5384
+ };
5385
+ }
5386
+ if (activeBranch) {
5387
+ if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
5388
+ anchor = next(activeBranch);
5389
+ }
5390
+ unmount(activeBranch, parentComponent2, suspense, true);
5391
+ }
5392
+ if (!delayEnter) {
5393
+ move(pendingBranch, container2, anchor, 0);
5364
5394
  }
5365
5395
  }
5366
- const mount = (container2, anchor2) => {
5367
- if (shapeFlag & 16) {
5368
- mountChildren(
5369
- children,
5370
- container2,
5371
- anchor2,
5372
- parentComponent,
5373
- parentSuspense,
5374
- namespace,
5375
- slotScopeIds,
5376
- optimized
5377
- );
5396
+ setActiveBranch(suspense, pendingBranch);
5397
+ suspense.pendingBranch = null;
5398
+ suspense.isInFallback = false;
5399
+ let parent = suspense.parent;
5400
+ let hasUnresolvedAncestor = false;
5401
+ while (parent) {
5402
+ if (parent.pendingBranch) {
5403
+ parent.effects.push(...effects);
5404
+ hasUnresolvedAncestor = true;
5405
+ break;
5378
5406
  }
5379
- };
5380
- if (disabled) {
5381
- mount(container, mainAnchor);
5382
- } else if (target) {
5383
- mount(target, targetAnchor);
5407
+ parent = parent.parent;
5384
5408
  }
5385
- } else {
5386
- n2.el = n1.el;
5387
- const mainAnchor = n2.anchor = n1.anchor;
5388
- const target = n2.target = n1.target;
5389
- const targetAnchor = n2.targetAnchor = n1.targetAnchor;
5390
- const wasDisabled = isTeleportDisabled(n1.props);
5391
- const currentContainer = wasDisabled ? container : target;
5392
- const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
5393
- if (namespace === "svg" || isTargetSVG(target)) {
5394
- namespace = "svg";
5395
- } else if (namespace === "mathml" || isTargetMathML(target)) {
5396
- namespace = "mathml";
5409
+ if (!hasUnresolvedAncestor && !delayEnter) {
5410
+ queuePostFlushCb(effects);
5397
5411
  }
5398
- if (dynamicChildren) {
5399
- patchBlockChildren(
5400
- n1.dynamicChildren,
5401
- dynamicChildren,
5402
- currentContainer,
5403
- parentComponent,
5404
- parentSuspense,
5405
- namespace,
5406
- slotScopeIds
5407
- );
5408
- traverseStaticChildren(n1, n2, true);
5409
- } else if (!optimized) {
5410
- patchChildren(
5411
- n1,
5412
- n2,
5413
- currentContainer,
5414
- currentAnchor,
5415
- parentComponent,
5416
- parentSuspense,
5417
- namespace,
5412
+ suspense.effects = [];
5413
+ if (isSuspensible) {
5414
+ if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
5415
+ parentSuspense.deps--;
5416
+ if (parentSuspense.deps === 0 && !sync) {
5417
+ parentSuspense.resolve();
5418
+ }
5419
+ }
5420
+ }
5421
+ triggerEvent(vnode2, "onResolve");
5422
+ },
5423
+ fallback(fallbackVNode) {
5424
+ if (!suspense.pendingBranch) {
5425
+ return;
5426
+ }
5427
+ const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
5428
+ triggerEvent(vnode2, "onFallback");
5429
+ const anchor2 = next(activeBranch);
5430
+ const mountFallback = () => {
5431
+ if (!suspense.isInFallback) {
5432
+ return;
5433
+ }
5434
+ patch(
5435
+ null,
5436
+ fallbackVNode,
5437
+ container2,
5438
+ anchor2,
5439
+ parentComponent2,
5440
+ null,
5441
+ // fallback tree will not have suspense context
5442
+ namespace2,
5418
5443
  slotScopeIds,
5419
- false
5444
+ optimized
5420
5445
  );
5446
+ setActiveBranch(suspense, fallbackVNode);
5447
+ };
5448
+ const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
5449
+ if (delayEnter) {
5450
+ activeBranch.transition.afterLeave = mountFallback;
5421
5451
  }
5422
- if (disabled) {
5423
- if (!wasDisabled) {
5424
- moveTeleport(
5425
- n2,
5426
- container,
5427
- mainAnchor,
5428
- internals,
5429
- 1
5430
- );
5431
- } else {
5432
- if (n2.props && n1.props && n2.props.to !== n1.props.to) {
5433
- n2.props.to = n1.props.to;
5434
- }
5452
+ suspense.isInFallback = true;
5453
+ unmount(
5454
+ activeBranch,
5455
+ parentComponent2,
5456
+ null,
5457
+ // no suspense so unmount hooks fire now
5458
+ true
5459
+ // shouldRemove
5460
+ );
5461
+ if (!delayEnter) {
5462
+ mountFallback();
5463
+ }
5464
+ },
5465
+ move(container2, anchor2, type) {
5466
+ suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
5467
+ suspense.container = container2;
5468
+ },
5469
+ next() {
5470
+ return suspense.activeBranch && next(suspense.activeBranch);
5471
+ },
5472
+ registerDep(instance, setupRenderEffect, optimized2) {
5473
+ const isInPendingSuspense = !!suspense.pendingBranch;
5474
+ if (isInPendingSuspense) {
5475
+ suspense.deps++;
5476
+ }
5477
+ const hydratedEl = instance.vnode.el;
5478
+ instance.asyncDep.catch((err) => {
5479
+ handleError(err, instance, 0);
5480
+ }).then((asyncSetupResult) => {
5481
+ if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
5482
+ return;
5435
5483
  }
5436
- } else {
5437
- if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
5438
- const nextTarget = n2.target = resolveTarget(
5439
- n2.props,
5440
- querySelector
5441
- );
5442
- if (nextTarget) {
5443
- moveTeleport(
5444
- n2,
5445
- nextTarget,
5446
- null,
5447
- internals,
5448
- 0
5449
- );
5450
- }
5451
- } else if (wasDisabled) {
5452
- moveTeleport(
5453
- n2,
5454
- target,
5455
- targetAnchor,
5456
- internals,
5457
- 1
5458
- );
5484
+ instance.asyncResolved = true;
5485
+ const { vnode: vnode2 } = instance;
5486
+ handleSetupResult(instance, asyncSetupResult, false);
5487
+ if (hydratedEl) {
5488
+ vnode2.el = hydratedEl;
5459
5489
  }
5460
- }
5461
- }
5462
- updateCssVars(n2);
5463
- },
5464
- remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
5465
- const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
5466
- if (target) {
5467
- hostRemove(targetAnchor);
5468
- }
5469
- doRemove && hostRemove(anchor);
5470
- if (shapeFlag & 16) {
5471
- const shouldRemove = doRemove || !isTeleportDisabled(props);
5472
- for (let i = 0; i < children.length; i++) {
5473
- const child = children[i];
5490
+ const placeholder = !hydratedEl && instance.subTree.el;
5491
+ setupRenderEffect(
5492
+ instance,
5493
+ vnode2,
5494
+ // component may have been moved before resolve.
5495
+ // if this is not a hydration, instance.subTree will be the comment
5496
+ // placeholder.
5497
+ parentNode(hydratedEl || instance.subTree.el),
5498
+ // anchor will not be used if this is hydration, so only need to
5499
+ // consider the comment placeholder case.
5500
+ hydratedEl ? null : next(instance.subTree),
5501
+ suspense,
5502
+ namespace,
5503
+ optimized2
5504
+ );
5505
+ if (placeholder) {
5506
+ remove(placeholder);
5507
+ }
5508
+ updateHOCHostEl(instance, vnode2.el);
5509
+ if (isInPendingSuspense && --suspense.deps === 0) {
5510
+ suspense.resolve();
5511
+ }
5512
+ });
5513
+ },
5514
+ unmount(parentSuspense2, doRemove) {
5515
+ suspense.isUnmounted = true;
5516
+ if (suspense.activeBranch) {
5474
5517
  unmount(
5475
- child,
5518
+ suspense.activeBranch,
5476
5519
  parentComponent,
5477
- parentSuspense,
5478
- shouldRemove,
5479
- !!child.dynamicChildren
5520
+ parentSuspense2,
5521
+ doRemove
5480
5522
  );
5481
5523
  }
5482
- }
5483
- },
5484
- move: moveTeleport,
5485
- hydrate: hydrateTeleport
5486
- };
5487
- function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
5488
- if (moveType === 0) {
5489
- insert(vnode.targetAnchor, container, parentAnchor);
5490
- }
5491
- const { el, anchor, shapeFlag, children, props } = vnode;
5492
- const isReorder = moveType === 2;
5493
- if (isReorder) {
5494
- insert(el, container, parentAnchor);
5495
- }
5496
- if (!isReorder || isTeleportDisabled(props)) {
5497
- if (shapeFlag & 16) {
5498
- for (let i = 0; i < children.length; i++) {
5499
- move(
5500
- children[i],
5501
- container,
5502
- parentAnchor,
5503
- 2
5524
+ if (suspense.pendingBranch) {
5525
+ unmount(
5526
+ suspense.pendingBranch,
5527
+ parentComponent,
5528
+ parentSuspense2,
5529
+ doRemove
5504
5530
  );
5505
5531
  }
5506
5532
  }
5533
+ };
5534
+ return suspense;
5535
+ }
5536
+ function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
5537
+ const suspense = vnode.suspense = createSuspenseBoundary(
5538
+ vnode,
5539
+ parentSuspense,
5540
+ parentComponent,
5541
+ node.parentNode,
5542
+ // eslint-disable-next-line no-restricted-globals
5543
+ document.createElement("div"),
5544
+ null,
5545
+ namespace,
5546
+ slotScopeIds,
5547
+ optimized,
5548
+ rendererInternals,
5549
+ true
5550
+ );
5551
+ const result = hydrateNode(
5552
+ node,
5553
+ suspense.pendingBranch = vnode.ssContent,
5554
+ parentComponent,
5555
+ suspense,
5556
+ slotScopeIds,
5557
+ optimized
5558
+ );
5559
+ if (suspense.deps === 0) {
5560
+ suspense.resolve(false, true);
5507
5561
  }
5508
- if (isReorder) {
5509
- insert(anchor, container, parentAnchor);
5510
- }
5562
+ return result;
5511
5563
  }
5512
- function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
5513
- o: { nextSibling, parentNode, querySelector }
5514
- }, hydrateChildren) {
5515
- const target = vnode.target = resolveTarget(
5516
- vnode.props,
5517
- querySelector
5564
+ function normalizeSuspenseChildren(vnode) {
5565
+ const { shapeFlag, children } = vnode;
5566
+ const isSlotChildren = shapeFlag & 32;
5567
+ vnode.ssContent = normalizeSuspenseSlot(
5568
+ isSlotChildren ? children.default : children
5518
5569
  );
5519
- if (target) {
5520
- const targetNode = target._lpa || target.firstChild;
5521
- if (vnode.shapeFlag & 16) {
5522
- if (isTeleportDisabled(vnode.props)) {
5523
- vnode.anchor = hydrateChildren(
5524
- nextSibling(node),
5525
- vnode,
5526
- parentNode(node),
5527
- parentComponent,
5528
- parentSuspense,
5529
- slotScopeIds,
5530
- optimized
5531
- );
5532
- vnode.targetAnchor = targetNode;
5533
- } else {
5534
- vnode.anchor = nextSibling(node);
5535
- let targetAnchor = targetNode;
5536
- while (targetAnchor) {
5537
- targetAnchor = nextSibling(targetAnchor);
5538
- if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
5539
- vnode.targetAnchor = targetAnchor;
5540
- target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
5541
- break;
5542
- }
5543
- }
5544
- hydrateChildren(
5545
- targetNode,
5546
- vnode,
5547
- target,
5548
- parentComponent,
5549
- parentSuspense,
5550
- slotScopeIds,
5551
- optimized
5552
- );
5553
- }
5570
+ vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
5571
+ }
5572
+ function normalizeSuspenseSlot(s) {
5573
+ let block;
5574
+ if (shared.isFunction(s)) {
5575
+ const trackBlock = isBlockTreeEnabled && s._c;
5576
+ if (trackBlock) {
5577
+ s._d = false;
5578
+ openBlock();
5579
+ }
5580
+ s = s();
5581
+ if (trackBlock) {
5582
+ s._d = true;
5583
+ block = currentBlock;
5584
+ closeBlock();
5554
5585
  }
5555
- updateCssVars(vnode);
5556
5586
  }
5557
- return vnode.anchor && nextSibling(vnode.anchor);
5587
+ if (shared.isArray(s)) {
5588
+ const singleChild = filterSingleRoot(s);
5589
+ s = singleChild;
5590
+ }
5591
+ s = normalizeVNode(s);
5592
+ if (block && !s.dynamicChildren) {
5593
+ s.dynamicChildren = block.filter((c) => c !== s);
5594
+ }
5595
+ return s;
5558
5596
  }
5559
- const Teleport = TeleportImpl;
5560
- function updateCssVars(vnode) {
5561
- const ctx = vnode.ctx;
5562
- if (ctx && ctx.ut) {
5563
- let node = vnode.children[0].el;
5564
- while (node && node !== vnode.targetAnchor) {
5565
- if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
5566
- node = node.nextSibling;
5597
+ function queueEffectWithSuspense(fn, suspense) {
5598
+ if (suspense && suspense.pendingBranch) {
5599
+ if (shared.isArray(fn)) {
5600
+ suspense.effects.push(...fn);
5601
+ } else {
5602
+ suspense.effects.push(fn);
5567
5603
  }
5568
- ctx.ut();
5604
+ } else {
5605
+ queuePostFlushCb(fn);
5606
+ }
5607
+ }
5608
+ function setActiveBranch(suspense, branch) {
5609
+ suspense.activeBranch = branch;
5610
+ const { vnode, parentComponent } = suspense;
5611
+ let el = branch.el;
5612
+ while (!el && branch.component) {
5613
+ branch = branch.component.subTree;
5614
+ el = branch.el;
5615
+ }
5616
+ vnode.el = el;
5617
+ if (parentComponent && parentComponent.subTree === vnode) {
5618
+ parentComponent.vnode.el = el;
5619
+ updateHOCHostEl(parentComponent, el);
5569
5620
  }
5570
5621
  }
5622
+ function isVNodeSuspensible(vnode) {
5623
+ const suspensible = vnode.props && vnode.props.suspensible;
5624
+ return suspensible != null && suspensible !== false;
5625
+ }
5571
5626
 
5572
5627
  const Fragment = Symbol.for("v-fgt");
5573
5628
  const Text = Symbol.for("v-txt");
@@ -5585,6 +5640,9 @@ function closeBlock() {
5585
5640
  let isBlockTreeEnabled = 1;
5586
5641
  function setBlockTracking(value) {
5587
5642
  isBlockTreeEnabled += value;
5643
+ if (value < 0 && currentBlock) {
5644
+ currentBlock.hasOnce = true;
5645
+ }
5588
5646
  }
5589
5647
  function setupBlock(vnode) {
5590
5648
  vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || shared.EMPTY_ARR : null;
@@ -5658,6 +5716,7 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
5658
5716
  el: null,
5659
5717
  anchor: null,
5660
5718
  target: null,
5719
+ targetStart: null,
5661
5720
  targetAnchor: null,
5662
5721
  staticCount: 0,
5663
5722
  shapeFlag,
@@ -5764,6 +5823,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
5764
5823
  slotScopeIds: vnode.slotScopeIds,
5765
5824
  children: children,
5766
5825
  target: vnode.target,
5826
+ targetStart: vnode.targetStart,
5767
5827
  targetAnchor: vnode.targetAnchor,
5768
5828
  staticCount: vnode.staticCount,
5769
5829
  shapeFlag: vnode.shapeFlag,
@@ -5958,8 +6018,6 @@ function createComponentInstance(vnode, parent, suspense) {
5958
6018
  refs: shared.EMPTY_OBJ,
5959
6019
  setupState: shared.EMPTY_OBJ,
5960
6020
  setupContext: null,
5961
- attrsProxy: null,
5962
- slotsProxy: null,
5963
6021
  // suspense related
5964
6022
  suspense,
5965
6023
  suspenseId: suspense ? suspense.pendingId : 0,
@@ -6036,12 +6094,12 @@ function isStatefulComponent(instance) {
6036
6094
  return instance.vnode.shapeFlag & 4;
6037
6095
  }
6038
6096
  let isInSSRComponentSetup = false;
6039
- function setupComponent(instance, isSSR = false) {
6097
+ function setupComponent(instance, isSSR = false, optimized = false) {
6040
6098
  isSSR && setInSSRSetupState(isSSR);
6041
6099
  const { props, children } = instance.vnode;
6042
6100
  const isStateful = isStatefulComponent(instance);
6043
6101
  initProps(instance, props, isStateful, isSSR);
6044
- initSlots(instance, children);
6102
+ initSlots(instance, children, optimized);
6045
6103
  const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
6046
6104
  isSSR && setInSSRSetupState(false);
6047
6105
  return setupResult;
@@ -6193,51 +6251,6 @@ const computed = (getterOrOptions, debugOptions) => {
6193
6251
  return c;
6194
6252
  };
6195
6253
 
6196
- function useModel(props, name, options = shared.EMPTY_OBJ) {
6197
- const i = getCurrentInstance();
6198
- const camelizedName = shared.camelize(name);
6199
- const hyphenatedName = shared.hyphenate(name);
6200
- const res = reactivity.customRef((track, trigger) => {
6201
- let localValue;
6202
- watchSyncEffect(() => {
6203
- const propValue = props[name];
6204
- if (shared.hasChanged(localValue, propValue)) {
6205
- localValue = propValue;
6206
- trigger();
6207
- }
6208
- });
6209
- return {
6210
- get() {
6211
- track();
6212
- return options.get ? options.get(localValue) : localValue;
6213
- },
6214
- set(value) {
6215
- const rawProps = i.vnode.props;
6216
- if (!(rawProps && // check if parent has passed v-model
6217
- (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)) {
6218
- localValue = value;
6219
- trigger();
6220
- }
6221
- i.emit(`update:${name}`, options.set ? options.set(value) : value);
6222
- }
6223
- };
6224
- });
6225
- const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
6226
- res[Symbol.iterator] = () => {
6227
- let i2 = 0;
6228
- return {
6229
- next() {
6230
- if (i2 < 2) {
6231
- return { value: i2++ ? props[modifierKey] || {} : res, done: false };
6232
- } else {
6233
- return { done: true };
6234
- }
6235
- }
6236
- };
6237
- };
6238
- return res;
6239
- }
6240
-
6241
6254
  function h(type, propsOrChildren, children) {
6242
6255
  const l = arguments.length;
6243
6256
  if (l === 2) {
@@ -6272,7 +6285,7 @@ function withMemo(memo, render, cache, index) {
6272
6285
  }
6273
6286
  const ret = render();
6274
6287
  ret.memo = memo.slice();
6275
- ret.memoIndex = index;
6288
+ ret.cacheIndex = index;
6276
6289
  return cache[index] = ret;
6277
6290
  }
6278
6291
  function isMemoSame(cached, memo) {
@@ -6291,7 +6304,7 @@ function isMemoSame(cached, memo) {
6291
6304
  return true;
6292
6305
  }
6293
6306
 
6294
- const version = "3.4.31";
6307
+ const version = "3.4.34";
6295
6308
  const warn$1 = shared.NOOP;
6296
6309
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
6297
6310
  const devtools = void 0;