@vue/runtime-core 3.6.0-beta.9 → 3.6.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.6.0-beta.9
2
+ * @vue/runtime-core v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -169,8 +169,8 @@ function findInsertionIndex(order, queue, start, end) {
169
169
  /**
170
170
  * @internal for runtime-vapor only
171
171
  */
172
- function queueJob(job, id, isPre = false) {
173
- if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : id * 2 + 1, jobs, jobsLength, flushIndex)) {
172
+ function queueJob(job, id, isPre = false, order = 0) {
173
+ if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : order ? id * 2 + 1 + order / (order + 1) : id * 2 + 1, jobs, jobsLength, flushIndex)) {
174
174
  jobsLength++;
175
175
  queueFlush();
176
176
  }
@@ -273,6 +273,7 @@ function flushJobs(seen) {
273
273
  }
274
274
  flushIndex = 0;
275
275
  jobsLength = 0;
276
+ jobs.length = 0;
276
277
  flushPostFlushCbs(seen);
277
278
  currentFlushPromise = null;
278
279
  if (jobsLength || postJobs.length) flushJobs(seen);
@@ -332,10 +333,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
332
333
  const renderFnWithContext = (...args) => {
333
334
  if (renderFnWithContext._d) setBlockTracking(-1);
334
335
  const prevInstance = setCurrentRenderingInstance(ctx);
336
+ const prevStackSize = blockStack.length;
335
337
  let res;
336
338
  try {
337
339
  res = fn(...args);
338
340
  } finally {
341
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
339
342
  setCurrentRenderingInstance(prevInstance);
340
343
  if (renderFnWithContext._d) setBlockTracking(1);
341
344
  }
@@ -525,6 +528,7 @@ function createPathGetter(ctx, path) {
525
528
  }
526
529
  //#endregion
527
530
  //#region packages/runtime-core/src/components/Teleport.ts
531
+ const pendingMounts = /* @__PURE__ */ new WeakMap();
528
532
  const TeleportEndKey = Symbol("_vte");
529
533
  const isTeleport = (type) => type.__isTeleport;
530
534
  const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
@@ -541,54 +545,66 @@ const TeleportImpl = {
541
545
  name: "Teleport",
542
546
  __isTeleport: true,
543
547
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
544
- const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
548
+ const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment, parentNode } } = internals;
545
549
  const disabled = isTeleportDisabled(n2.props);
546
- let { shapeFlag, children, dynamicChildren } = n2;
550
+ let { dynamicChildren } = n2;
551
+ const mount = (vnode, container, anchor) => {
552
+ if (vnode.shapeFlag & 16) mountChildren(vnode.children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized);
553
+ };
554
+ const mountToTarget = (vnode = n2) => {
555
+ const disabled = isTeleportDisabled(vnode.props);
556
+ const target = vnode.target = resolveTarget(vnode.props, querySelector);
557
+ const targetAnchor = prepareAnchor(target, vnode, createText, insert);
558
+ if (target) {
559
+ if (namespace !== "svg" && isTargetSVG(target)) namespace = "svg";
560
+ else if (namespace !== "mathml" && isTargetMathML(target)) namespace = "mathml";
561
+ if (parentComponent && parentComponent.isCE) (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
562
+ if (!disabled) {
563
+ mount(vnode, target, targetAnchor);
564
+ updateCssVars(vnode, false);
565
+ }
566
+ }
567
+ };
568
+ const queuePendingMount = (vnode) => {
569
+ const mountJob = () => {
570
+ if (pendingMounts.get(vnode) !== mountJob) return;
571
+ pendingMounts.delete(vnode);
572
+ if (isTeleportDisabled(vnode.props)) {
573
+ mount(vnode, parentNode(vnode.el) || container, vnode.anchor);
574
+ updateCssVars(vnode, true);
575
+ }
576
+ mountToTarget(vnode);
577
+ };
578
+ pendingMounts.set(vnode, mountJob);
579
+ queuePostRenderEffect(mountJob, void 0, parentSuspense);
580
+ };
547
581
  if (n1 == null) {
548
582
  const placeholder = n2.el = createText("");
549
583
  const mainAnchor = n2.anchor = createText("");
550
584
  insert(placeholder, container, anchor);
551
585
  insert(mainAnchor, container, anchor);
552
- const mount = (container, anchor) => {
553
- if (shapeFlag & 16) mountChildren(children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized);
554
- };
555
- const mountToTarget = () => {
556
- const target = n2.target = resolveTarget(n2.props, querySelector);
557
- const targetAnchor = prepareAnchor(target, n2, createText, insert);
558
- if (target) {
559
- if (namespace !== "svg" && isTargetSVG(target)) namespace = "svg";
560
- else if (namespace !== "mathml" && isTargetMathML(target)) namespace = "mathml";
561
- if (parentComponent && parentComponent.isCE) (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
562
- if (!disabled) {
563
- mount(target, targetAnchor);
564
- updateCssVars(n2, false);
565
- }
566
- }
567
- };
586
+ if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) {
587
+ queuePendingMount(n2);
588
+ return;
589
+ }
568
590
  if (disabled) {
569
- mount(container, mainAnchor);
591
+ mount(n2, container, mainAnchor);
570
592
  updateCssVars(n2, true);
571
593
  }
572
- if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) {
573
- n2.el.__isMounted = false;
574
- queuePostRenderEffect(() => {
575
- if (n2.el.__isMounted !== false) return;
576
- mountToTarget();
577
- delete n2.el.__isMounted;
578
- }, void 0, parentSuspense);
579
- } else mountToTarget();
594
+ mountToTarget();
580
595
  } else {
581
596
  n2.el = n1.el;
582
- n2.targetStart = n1.targetStart;
583
597
  const mainAnchor = n2.anchor = n1.anchor;
584
- const target = n2.target = n1.target;
585
- const targetAnchor = n2.targetAnchor = n1.targetAnchor;
586
- if (n1.el.__isMounted === false) {
587
- queuePostRenderEffect(() => {
588
- TeleportImpl.process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals);
589
- }, void 0, parentSuspense);
598
+ const pendingMount = pendingMounts.get(n1);
599
+ if (pendingMount) {
600
+ pendingMount.flags |= 4;
601
+ pendingMounts.delete(n1);
602
+ queuePendingMount(n2);
590
603
  return;
591
604
  }
605
+ n2.targetStart = n1.targetStart;
606
+ const target = n2.target = n1.target;
607
+ const targetAnchor = n2.targetAnchor = n1.targetAnchor;
592
608
  const wasDisabled = isTeleportDisabled(n1.props);
593
609
  const currentContainer = wasDisabled ? container : target;
594
610
  const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
@@ -602,23 +618,30 @@ const TeleportImpl = {
602
618
  if (!wasDisabled) moveTeleport(n2, container, mainAnchor, internals, parentComponent, 1);
603
619
  else if (n2.props && n1.props && n2.props.to !== n1.props.to) n2.props.to = n1.props.to;
604
620
  } else if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
605
- const nextTarget = n2.target = resolveTarget(n2.props, querySelector);
606
- if (nextTarget) moveTeleport(n2, nextTarget, null, internals, parentComponent, 0);
621
+ const nextTarget = resolveTarget(n2.props, querySelector);
622
+ if (nextTarget) {
623
+ n2.target = nextTarget;
624
+ moveTeleport(n2, nextTarget, null, internals, parentComponent, 0);
625
+ }
607
626
  } else if (wasDisabled) moveTeleport(n2, target, targetAnchor, internals, parentComponent, 1);
608
627
  updateCssVars(n2, disabled);
609
628
  }
610
629
  },
611
630
  remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
612
- const { shapeFlag, children, anchor, targetStart, targetAnchor, props } = vnode;
631
+ const { shapeFlag, children, anchor, targetStart, targetAnchor, target, props } = vnode;
632
+ const disabled = isTeleportDisabled(props);
633
+ const shouldRemove = doRemove || !disabled;
634
+ const pendingMount = pendingMounts.get(vnode);
635
+ if (pendingMount) {
636
+ pendingMount.flags |= 4;
637
+ pendingMounts.delete(vnode);
638
+ }
613
639
  if (targetStart) hostRemove(targetStart);
614
640
  if (targetAnchor) hostRemove(targetAnchor);
615
641
  doRemove && hostRemove(anchor);
616
- if (shapeFlag & 16) {
617
- const shouldRemove = doRemove || !isTeleportDisabled(props);
618
- for (let i = 0; i < children.length; i++) {
619
- const child = children[i];
620
- unmount(child, parentComponent, parentSuspense, shouldRemove, !!child.dynamicChildren);
621
- }
642
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) for (let i = 0; i < children.length; i++) {
643
+ const child = children[i];
644
+ unmount(child, parentComponent, parentSuspense, shouldRemove, !!child.dynamicChildren);
622
645
  }
623
646
  },
624
647
  move: moveTeleport,
@@ -629,7 +652,7 @@ function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }
629
652
  const { el, anchor, shapeFlag, children, props } = vnode;
630
653
  const isReorder = moveType === 2;
631
654
  if (isReorder) insert(el, container, parentAnchor);
632
- if (!isReorder || isTeleportDisabled(props)) {
655
+ if (!pendingMounts.has(vnode) && (!isReorder || isTeleportDisabled(props))) {
633
656
  if (shapeFlag & 16) for (let i = 0; i < children.length; i++) move(children[i], container, parentAnchor, 2, parentComponent);
634
657
  }
635
658
  if (isReorder) insert(anchor, container, parentAnchor);
@@ -754,8 +777,8 @@ const BaseTransitionImpl = {
754
777
  const state = useTransitionState();
755
778
  return () => {
756
779
  const children = slots.default && getTransitionRawChildren(slots.default(), true);
757
- if (!children || !children.length) return;
758
- const child = findNonCommentChild(children);
780
+ const child = children && children.length ? findNonCommentChild(children) : instance.subTree ? createCommentVNode() : void 0;
781
+ if (!child) return;
759
782
  const rawProps = (0, _vue_reactivity.toRaw)(props);
760
783
  const { mode } = rawProps;
761
784
  if (state.isLeaving) return emptyPlaceholder(child);
@@ -1179,7 +1202,7 @@ function createHydrationFunctions(rendererInternals) {
1179
1202
  else nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
1180
1203
  break;
1181
1204
  case VaporSlot:
1182
- nextNode = getVaporInterface(parentComponent, vnode).hydrateSlot(vnode, node);
1205
+ nextNode = getVaporInterface(parentComponent, vnode).hydrateSlot(vnode, node, parentComponent, parentSuspense);
1183
1206
  break;
1184
1207
  default: if (shapeFlag & 1) if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) nextNode = onMismatch();
1185
1208
  else nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
@@ -1189,16 +1212,31 @@ function createHydrationFunctions(rendererInternals) {
1189
1212
  if (isFragmentStart) nextNode = locateClosingAnchor(node);
1190
1213
  else if (isComment(node) && node.data === "teleport start") nextNode = locateClosingAnchor(node, node.data, "teleport end");
1191
1214
  else nextNode = nextSibling(node);
1192
- if (vnode.type.__vapor) getVaporInterface(parentComponent, vnode).hydrate(vnode, node, container, null, parentComponent, parentSuspense);
1193
- else mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
1194
- if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
1195
- let subTree;
1196
- if (isFragmentStart) {
1197
- subTree = createVNode(Fragment);
1198
- subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
1199
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
1200
- subTree.el = node;
1201
- vnode.component.subTree = subTree;
1215
+ if (vnode.type.__vapor) {
1216
+ const vnodeBeforeMountHook = !isAsyncWrapper(vnode) && vnode.props && vnode.props.onVnodeBeforeMount;
1217
+ getVaporInterface(parentComponent, vnode).hydrate(vnode, node, container, nextNode, parentComponent, parentSuspense, () => {
1218
+ if (vnode.dirs) {
1219
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
1220
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
1221
+ }
1222
+ }, () => {
1223
+ if (vnodeBeforeMountHook) invokeVNodeHook(vnodeBeforeMountHook, parentComponent, vnode);
1224
+ });
1225
+ if (vnode.dirs) queueEffectWithSuspense(() => invokeDirectiveHook(vnode, null, parentComponent, "mounted"), void 0, parentSuspense);
1226
+ const vnodeMountedHook = !isAsyncWrapper(vnode) && vnode.props && vnode.props.onVnodeMounted;
1227
+ if (vnodeMountedHook) queueEffectWithSuspense(() => invokeVNodeHook(vnodeMountedHook, parentComponent, vnode), void 0, parentSuspense);
1228
+ } else {
1229
+ mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
1230
+ const component = vnode.component;
1231
+ if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved || component.asyncDep && !component.asyncResolved) {
1232
+ let subTree;
1233
+ if (isFragmentStart) {
1234
+ subTree = createVNode(Fragment);
1235
+ subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
1236
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
1237
+ subTree.el = node;
1238
+ component.subTree = subTree;
1239
+ }
1202
1240
  }
1203
1241
  } else if (shapeFlag & 64) if (domType !== 8) nextNode = onMismatch();
1204
1242
  else nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
@@ -1209,9 +1247,10 @@ function createHydrationFunctions(rendererInternals) {
1209
1247
  };
1210
1248
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1211
1249
  optimized = optimized || !!vnode.dynamicChildren;
1212
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
1250
+ const { type, dynamicProps, props, patchFlag, shapeFlag, dirs, transition } = vnode;
1213
1251
  const forcePatch = type === "input" || type === "option";
1214
- if (forcePatch || patchFlag !== -1) {
1252
+ const hasDynamicProps = !!dynamicProps;
1253
+ if (forcePatch || hasDynamicProps || patchFlag !== -1) {
1215
1254
  if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "created");
1216
1255
  let needCallTransitionHooks = false;
1217
1256
  if (isTemplateNode(el)) {
@@ -1227,8 +1266,8 @@ function createHydrationFunctions(rendererInternals) {
1227
1266
  }
1228
1267
  if (shapeFlag & 16 && !(props && (props.innerHTML || props.textContent))) {
1229
1268
  let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
1269
+ if (next && !isMismatchAllowed(el, 1)) logMismatchError();
1230
1270
  while (next) {
1231
- if (!isMismatchAllowed(el, 1)) logMismatchError();
1232
1271
  const cur = next;
1233
1272
  next = next.nextSibling;
1234
1273
  remove(cur);
@@ -1243,9 +1282,10 @@ function createHydrationFunctions(rendererInternals) {
1243
1282
  }
1244
1283
  }
1245
1284
  if (props) {
1246
- if (forcePatch || !optimized || patchFlag & 48) {
1285
+ if (forcePatch || hasDynamicProps || !optimized || patchFlag & 48) {
1247
1286
  const isCustomElement = el.tagName.includes("-");
1248
- for (const key in props) if (forcePatch && (key.endsWith("value") || key === "indeterminate") || (0, _vue_shared.isOn)(key) && !(0, _vue_shared.isReservedProp)(key) || key[0] === "." || isCustomElement && !(0, _vue_shared.isReservedProp)(key)) patchProp(el, key, null, props[key], void 0, parentComponent);
1287
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
1288
+ for (const key in props) if (forcePatch && (key.endsWith("value") || key === "indeterminate") || (0, _vue_shared.isOn)(key) && !(0, _vue_shared.isReservedProp)(key) || key[0] === "." || isCustomElement && !(0, _vue_shared.isReservedProp)(key) || dynamicProps && dynamicProps.includes(key)) patchProp(el, key, null, props[key], namespace, parentComponent);
1249
1289
  } else if (props.onClick) patchProp(el, "onClick", null, props.onClick, void 0, parentComponent);
1250
1290
  else if (patchFlag & 4 && (0, _vue_reactivity.isReactive)(props.style)) for (const key in props.style) props.style[key];
1251
1291
  }
@@ -1264,6 +1304,7 @@ function createHydrationFunctions(rendererInternals) {
1264
1304
  optimized = optimized || !!parentVNode.dynamicChildren;
1265
1305
  const children = parentVNode.children;
1266
1306
  const l = children.length;
1307
+ let hasCheckedMismatch = false;
1267
1308
  for (let i = 0; i < l; i++) {
1268
1309
  const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
1269
1310
  const isText = vnode.type === Text;
@@ -1277,7 +1318,10 @@ function createHydrationFunctions(rendererInternals) {
1277
1318
  node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
1278
1319
  } else if (isText && !vnode.children) insert(vnode.el = createText(""), container);
1279
1320
  else {
1280
- if (!isMismatchAllowed(container, 1)) logMismatchError();
1321
+ if (!hasCheckedMismatch) {
1322
+ hasCheckedMismatch = true;
1323
+ if (!isMismatchAllowed(container, 1)) logMismatchError();
1324
+ }
1281
1325
  patch(null, vnode, container, null, parentComponent, parentSuspense, getContainerType(container), slotScopeIds);
1282
1326
  }
1283
1327
  }
@@ -1296,7 +1340,7 @@ function createHydrationFunctions(rendererInternals) {
1296
1340
  }
1297
1341
  };
1298
1342
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
1299
- if (!isMismatchAllowed(node.parentElement, 1)) logMismatchError();
1343
+ if (!isNodeMismatchAllowed(node, vnode)) logMismatchError();
1300
1344
  vnode.el = null;
1301
1345
  if (isFragment) {
1302
1346
  const end = locateClosingAnchor(node);
@@ -1352,7 +1396,9 @@ const MismatchTypeString = {
1352
1396
  };
1353
1397
  function isMismatchAllowed(el, allowedType) {
1354
1398
  if (allowedType === 0 || allowedType === 1) while (el && !el.hasAttribute(allowMismatchAttr)) el = el.parentElement;
1355
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
1399
+ return isMismatchAllowedByAttr(el && el.getAttribute(allowMismatchAttr), allowedType);
1400
+ }
1401
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
1356
1402
  if (allowedAttr == null) return false;
1357
1403
  else if (allowedAttr === "") return true;
1358
1404
  else {
@@ -1361,6 +1407,16 @@ function isMismatchAllowed(el, allowedType) {
1361
1407
  return list.includes(MismatchTypeString[allowedType]);
1362
1408
  }
1363
1409
  }
1410
+ function isNodeMismatchAllowed(node, vnode) {
1411
+ return isMismatchAllowed(node.parentElement, 1) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
1412
+ }
1413
+ function isMismatchAllowedByNode(node) {
1414
+ return node.nodeType === 1 && isMismatchAllowedByAttr(node.getAttribute(allowMismatchAttr), 1);
1415
+ }
1416
+ function isMismatchAllowedByVNode({ props }) {
1417
+ const allowedAttr = props && props[allowMismatchAttr];
1418
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1);
1419
+ }
1364
1420
  //#endregion
1365
1421
  //#region packages/runtime-core/src/hydrationStrategies.ts
1366
1422
  let requestIdleCallback;
@@ -1479,11 +1535,16 @@ function defineAsyncComponent(source) {
1479
1535
  onError(err);
1480
1536
  return () => errorComponent ? createVNode(errorComponent, { error: err }) : null;
1481
1537
  });
1482
- const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError);
1538
+ const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError, instance);
1483
1539
  load().then(() => {
1540
+ if (instance.isUnmounted) return;
1484
1541
  loaded.value = true;
1485
1542
  if (instance.parent && instance.parent.vnode && isKeepAlive(instance.parent.vnode)) instance.parent.update();
1486
1543
  }).catch((err) => {
1544
+ if (instance.isUnmounted) {
1545
+ setPendingRequest(null);
1546
+ return;
1547
+ }
1487
1548
  onError(err);
1488
1549
  error.value = err;
1489
1550
  });
@@ -1539,14 +1600,22 @@ function createAsyncComponentContext(source) {
1539
1600
  setPendingRequest: (request) => pendingRequest = request
1540
1601
  };
1541
1602
  }
1542
- const useAsyncComponentState = (delay, timeout, onError) => {
1603
+ const useAsyncComponentState = (delay, timeout, onError, instance = currentInstance) => {
1543
1604
  const loaded = (0, _vue_reactivity.ref)(false);
1544
1605
  const error = (0, _vue_reactivity.ref)();
1545
1606
  const delayed = (0, _vue_reactivity.ref)(!!delay);
1546
- if (delay) setTimeout(() => {
1607
+ let timeoutTimer;
1608
+ let delayTimer;
1609
+ if (instance) onUnmounted(() => {
1610
+ if (timeoutTimer != null) clearTimeout(timeoutTimer);
1611
+ if (delayTimer != null) clearTimeout(delayTimer);
1612
+ }, instance);
1613
+ if (delay) delayTimer = setTimeout(() => {
1614
+ if (instance && instance.isUnmounted) return;
1547
1615
  delayed.value = false;
1548
1616
  }, delay);
1549
- if (timeout != null) setTimeout(() => {
1617
+ if (timeout != null) timeoutTimer = setTimeout(() => {
1618
+ if (instance && instance.isUnmounted) return;
1550
1619
  if (!loaded.value && !error.value) {
1551
1620
  const err = /* @__PURE__ */ new Error(`Async component timed out after ${timeout}ms.`);
1552
1621
  onError(err);
@@ -1564,10 +1633,12 @@ const useAsyncComponentState = (delay, timeout, onError) => {
1564
1633
  * @internal
1565
1634
  */
1566
1635
  function performAsyncHydrate(el, instance, hydrate, getResolvedComp, load, hydrateStrategy) {
1636
+ const wasConnected = el.isConnected;
1567
1637
  let patched = false;
1568
1638
  (instance.bu || (instance.bu = [])).push(() => patched = true);
1569
1639
  const performHydrate = () => {
1570
1640
  if (patched) return;
1641
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
1571
1642
  hydrate();
1572
1643
  };
1573
1644
  const doHydrate = hydrateStrategy ? () => {
@@ -1925,8 +1996,9 @@ function createSlots(slots, dynamicSlots) {
1925
1996
  * Compiler runtime helper for rendering `<slot/>`
1926
1997
  * @private
1927
1998
  */
1928
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
1999
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
1929
2000
  let slot = slots[name];
2001
+ if (fallback) fallback.__vdom = true;
1930
2002
  const vaporSlot = slot && (slot.__vs || (slot.__vapor ? slot : null));
1931
2003
  if (vaporSlot) {
1932
2004
  const ret = (openBlock(), createBlock(VaporSlot, props));
@@ -1934,21 +2006,31 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
1934
2006
  slot: vaporSlot,
1935
2007
  fallback
1936
2008
  };
2009
+ if (!noSlotted && ret.scopeId) ret.slotScopeIds = [ret.scopeId + "-s"];
1937
2010
  return ret;
1938
2011
  }
1939
2012
  if (currentRenderingInstance && (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce)) {
1940
- const hasProps = Object.keys(props).length > 0;
1941
- if (name !== "default") props.name = name;
1942
- return openBlock(), createBlock(Fragment, null, [createVNode("slot", props, fallback && fallback())], hasProps ? -2 : 64);
2013
+ const slotProps = branchKey != null && props.key == null ? (0, _vue_shared.extend)({}, props, { key: branchKey }) : props;
2014
+ const hasProps = Object.keys(slotProps).length > 0;
2015
+ if (name !== "default") slotProps.name = name;
2016
+ return openBlock(), createBlock(Fragment, null, [createVNode("slot", slotProps, fallback && fallback())], hasProps ? -2 : 64);
1943
2017
  }
1944
2018
  if (slot && slot._c) slot._d = false;
2019
+ const prevStackSize = blockStack.length;
1945
2020
  openBlock();
1946
- const validSlotContent = slot && ensureValidVNode(slot(props));
1947
- ensureVaporSlotFallback(validSlotContent, fallback);
1948
- const slotKey = props.key || validSlotContent && validSlotContent.key;
1949
- const rendered = createBlock(Fragment, { key: (slotKey && !(0, _vue_shared.isSymbol)(slotKey) ? slotKey : `_${name}`) + (!validSlotContent && fallback ? "_fb" : "") }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 ? 64 : -2);
2021
+ let rendered;
2022
+ try {
2023
+ const validSlotContent = slot && ensureValidVNode(slot(props));
2024
+ ensureVaporSlotFallback(validSlotContent, fallback);
2025
+ const slotKey = props.key || branchKey || validSlotContent && validSlotContent.key;
2026
+ rendered = createBlock(Fragment, { key: (slotKey && !(0, _vue_shared.isSymbol)(slotKey) ? slotKey : `_${name}`) + (!validSlotContent && fallback ? "_fb" : "") }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 ? 64 : -2);
2027
+ } catch (err) {
2028
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
2029
+ throw err;
2030
+ } finally {
2031
+ if (slot && slot._c) slot._d = true;
2032
+ }
1950
2033
  if (!noSlotted && rendered.scopeId) rendered.slotScopeIds = [rendered.scopeId + "-s"];
1951
- if (slot && slot._c) slot._d = true;
1952
2034
  return rendered;
1953
2035
  }
1954
2036
  function ensureValidVNode(vnodes) {
@@ -1961,9 +2043,7 @@ function ensureValidVNode(vnodes) {
1961
2043
  }
1962
2044
  function ensureVaporSlotFallback(vnodes, fallback) {
1963
2045
  let vaporSlot;
1964
- if (vnodes && vnodes.length === 1 && isVNode(vnodes[0]) && (vaporSlot = vnodes[0].vs)) {
1965
- if (!vaporSlot.fallback && fallback) vaporSlot.fallback = fallback;
1966
- }
2046
+ if (vnodes && vnodes.length === 1 && isVNode(vnodes[0]) && (vaporSlot = vnodes[0].vs)) vaporSlot.outletFallback = fallback;
1967
2047
  }
1968
2048
  //#endregion
1969
2049
  //#region packages/runtime-core/src/helpers/toHandlers.ts
@@ -2239,25 +2319,38 @@ function createPropsRestProxy(props, excludedKeys) {
2239
2319
  function withAsyncContext(getAwaitable) {
2240
2320
  const ctx = getCurrentGenericInstance();
2241
2321
  const inSSRSetup = isInSSRComponentSetup;
2322
+ const restoreAsyncContext = ctx && ctx.restoreAsyncContext ? ctx.restoreAsyncContext.bind(ctx) : void 0;
2242
2323
  let awaitable = getAwaitable();
2243
2324
  setCurrentInstance(null, void 0);
2244
2325
  if (inSSRSetup) setInSSRSetupState(false);
2245
2326
  const restore = () => {
2327
+ const resetStoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
2246
2328
  setCurrentInstance(ctx);
2247
2329
  if (inSSRSetup) setInSSRSetupState(true);
2330
+ const reset = restoreAsyncContext && restoreAsyncContext();
2331
+ return () => {
2332
+ if (reset) reset();
2333
+ if (resetStoppedScope) resetStoppedScope.reset();
2334
+ };
2248
2335
  };
2249
2336
  const cleanup = () => {
2250
2337
  setCurrentInstance(null, void 0);
2251
2338
  if (inSSRSetup) setInSSRSetupState(false);
2252
2339
  };
2253
2340
  if ((0, _vue_shared.isPromise)(awaitable)) awaitable = awaitable.catch((e) => {
2254
- restore();
2255
- Promise.resolve().then(() => Promise.resolve().then(cleanup));
2341
+ const reset = restore();
2342
+ Promise.resolve().then(() => Promise.resolve().then(() => {
2343
+ if (reset) reset();
2344
+ cleanup();
2345
+ }));
2256
2346
  throw e;
2257
2347
  });
2258
2348
  return [awaitable, () => {
2259
- restore();
2260
- Promise.resolve().then(cleanup);
2349
+ const reset = restore();
2350
+ Promise.resolve().then(() => {
2351
+ if (reset) reset();
2352
+ cleanup();
2353
+ });
2261
2354
  }];
2262
2355
  }
2263
2356
  //#endregion
@@ -2612,12 +2705,13 @@ function useModel(props, name, options = _vue_shared.EMPTY_OBJ) {
2612
2705
  for (const key of rawPropKeys) if (key === name || key === camelizedName || key === hyphenatedName) parentPassedModelValue = true;
2613
2706
  else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) parentPassedModelUpdater = true;
2614
2707
  }
2615
- if (!parentPassedModelValue || !parentPassedModelUpdater) {
2708
+ const hasVModel = parentPassedModelValue && parentPassedModelUpdater;
2709
+ if (!hasVModel) {
2616
2710
  localValue = value;
2617
2711
  trigger();
2618
2712
  }
2619
2713
  i.emit(`update:${name}`, emittedValue);
2620
- if ((0, _vue_shared.hasChanged)(value, emittedValue) && (0, _vue_shared.hasChanged)(value, prevSetValue) && !(0, _vue_shared.hasChanged)(emittedValue, prevEmittedValue)) trigger();
2714
+ if ((0, _vue_shared.hasChanged)(value, prevSetValue) && ((0, _vue_shared.hasChanged)(value, emittedValue) && !(0, _vue_shared.hasChanged)(emittedValue, prevEmittedValue) || hasVModel && prevSetValue !== _vue_shared.EMPTY_OBJ && !(0, _vue_shared.hasChanged)(emittedValue, localValue))) trigger();
2621
2715
  prevSetValue = value;
2622
2716
  prevEmittedValue = emittedValue;
2623
2717
  }
@@ -2708,7 +2802,8 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
2708
2802
  */
2709
2803
  function isEmitListener(options, key) {
2710
2804
  if (!options || !(0, _vue_shared.isOn)(key)) return false;
2711
- key = key.slice(2).replace(/Once$/, "");
2805
+ key = key.slice(2);
2806
+ key = key === "Once" ? key : key.replace(/Once$/, "");
2712
2807
  return (0, _vue_shared.hasOwn)(options, key[0].toLowerCase() + key.slice(1)) || (0, _vue_shared.hasOwn)(options, (0, _vue_shared.hyphenate)(key)) || (0, _vue_shared.hasOwn)(options, key);
2713
2808
  }
2714
2809
  //#endregion
@@ -3259,6 +3354,11 @@ function baseCreateRenderer(options, createHydrationFns) {
3259
3354
  if (vnodeHook = newProps.onVnodeBeforeUpdate) invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3260
3355
  if (dirs) invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
3261
3356
  parentComponent && toggleRecurse(parentComponent, true);
3357
+ if (dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)) {
3358
+ patchFlag = 0;
3359
+ optimized = false;
3360
+ dynamicChildren = null;
3361
+ }
3262
3362
  if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) hostSetElementText(el, "");
3263
3363
  if (dynamicChildren) patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, resolveChildrenNamespace(n2, namespace), slotScopeIds);
3264
3364
  else if (!optimized) patchChildren(n1, n2, el, null, parentComponent, parentSuspense, resolveChildrenNamespace(n2, namespace), slotScopeIds, false);
@@ -3327,19 +3427,35 @@ function baseCreateRenderer(options, createHydrationFns) {
3327
3427
  n2.slotScopeIds = slotScopeIds;
3328
3428
  if (n2.type.__vapor) if (n1 == null) if (n2.shapeFlag & 512) getVaporInterface(parentComponent, n2).activate(n2, container, anchor, parentComponent);
3329
3429
  else {
3430
+ const vnodeBeforeMountHook = !isAsyncWrapper(n2) && n2.props && n2.props.onVnodeBeforeMount;
3330
3431
  getVaporInterface(parentComponent, n2).mount(n2, container, anchor, parentComponent, parentSuspense, () => {
3331
3432
  if (n2.dirs) {
3332
3433
  invokeDirectiveHook(n2, null, parentComponent, "created");
3333
3434
  invokeDirectiveHook(n2, null, parentComponent, "beforeMount");
3334
3435
  }
3436
+ }, () => {
3437
+ if (vnodeBeforeMountHook) invokeVNodeHook(vnodeBeforeMountHook, parentComponent, n2);
3335
3438
  });
3336
3439
  if (n2.dirs) queuePostRenderEffect(() => invokeDirectiveHook(n2, null, parentComponent, "mounted"), void 0, parentSuspense);
3440
+ const vnodeMountedHook = !isAsyncWrapper(n2) && n2.props && n2.props.onVnodeMounted;
3441
+ if (vnodeMountedHook) {
3442
+ const scopedVNode = n2;
3443
+ queuePostRenderEffect(() => invokeVNodeHook(vnodeMountedHook, parentComponent, scopedVNode), void 0, parentSuspense);
3444
+ }
3337
3445
  }
3338
3446
  else {
3339
- getVaporInterface(parentComponent, n2).update(n1, n2, shouldUpdateComponent(n1, n2, optimized), () => {
3447
+ const shouldUpdate = shouldUpdateComponent(n1, n2, optimized);
3448
+ getVaporInterface(parentComponent, n2).update(n1, n2, shouldUpdate, () => {
3340
3449
  if (n2.dirs) invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
3450
+ }, () => {
3451
+ const vnodeBeforeUpdateHook = n2.props && n2.props.onVnodeBeforeUpdate;
3452
+ if (vnodeBeforeUpdateHook) invokeVNodeHook(vnodeBeforeUpdateHook, parentComponent, n2, n1);
3341
3453
  });
3342
- if (n2.dirs) queuePostRenderEffect(() => invokeDirectiveHook(n2, n1, parentComponent, "updated"), void 0, parentSuspense);
3454
+ const vnodeUpdatedHook = n2.props && n2.props.onVnodeUpdated;
3455
+ if (shouldUpdate && (vnodeUpdatedHook || n2.dirs)) queuePostRenderEffect(() => {
3456
+ n2.dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
3457
+ vnodeUpdatedHook && invokeVNodeHook(vnodeUpdatedHook, parentComponent, n2, n1);
3458
+ }, void 0, parentSuspense);
3343
3459
  }
3344
3460
  else if (n1 == null) if (n2.shapeFlag & 512) parentComponent.ctx.activate(n2, container, anchor, namespace, optimized);
3345
3461
  else mountComponent(n2, container, anchor, parentComponent, parentSuspense, namespace, optimized);
@@ -3652,8 +3768,10 @@ function baseCreateRenderer(options, createHydrationFns) {
3652
3768
  else hostInsert(el, container, anchor);
3653
3769
  };
3654
3770
  const performLeave = () => {
3771
+ const wasLeaving = el._isLeaving || !!el[leaveCbKey];
3655
3772
  if (el._isLeaving) el[leaveCbKey](true);
3656
- leave(el, () => {
3773
+ if (transition.persisted && !wasLeaving) remove();
3774
+ else leave(el, () => {
3657
3775
  remove();
3658
3776
  afterLeave && afterLeave();
3659
3777
  });
@@ -3684,7 +3802,10 @@ function baseCreateRenderer(options, createHydrationFns) {
3684
3802
  if (shapeFlag & 6) if (isVaporComponent(type)) {
3685
3803
  if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
3686
3804
  getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
3687
- if (dirs) queuePostRenderEffect(() => invokeDirectiveHook(vnode, null, parentComponent, "unmounted"), void 0, parentSuspense);
3805
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || dirs) queuePostRenderEffect(() => {
3806
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
3807
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
3808
+ }, void 0, parentSuspense);
3688
3809
  return;
3689
3810
  } else unmountComponent(vnode.component, parentSuspense, doRemove);
3690
3811
  else {
@@ -3740,7 +3861,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3740
3861
  if (effect) {
3741
3862
  effect.stop();
3742
3863
  unmount(subTree, instance, parentSuspense, doRemove);
3743
- }
3864
+ } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
3744
3865
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
3745
3866
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
3746
3867
  };
@@ -3859,6 +3980,10 @@ function invalidateMount(hooks) {
3859
3980
  if (hooks) for (let i = 0; i < hooks.length; i++) hooks[i].flags |= 4;
3860
3981
  }
3861
3982
  function performTransitionEnter(el, transition, insert, parentSuspense, force = false) {
3983
+ if (force && transition.persisted && !el[leaveCbKey]) {
3984
+ insert();
3985
+ return;
3986
+ }
3862
3987
  if (force || needTransition(parentSuspense, transition)) {
3863
3988
  transition.beforeEnter(el);
3864
3989
  insert();
@@ -4048,15 +4173,19 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
4048
4173
  if (suspense.isHydrating) suspense.isHydrating = false;
4049
4174
  else if (!resume) {
4050
4175
  delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
4176
+ let hasUpdatedAnchor = false;
4051
4177
  if (delayEnter) activeBranch.transition.afterLeave = () => {
4052
4178
  if (pendingId === suspense.pendingId) {
4053
- move(pendingBranch, container, anchor === initialAnchor ? next(activeBranch) : anchor, 0, parentComponent);
4179
+ move(pendingBranch, container, anchor === initialAnchor && !hasUpdatedAnchor ? next(activeBranch) : anchor, 0, parentComponent);
4054
4180
  queuePostFlushCb(effects);
4055
4181
  if (isInFallback && vnode.ssFallback) vnode.ssFallback.el = null;
4056
4182
  }
4057
4183
  };
4058
4184
  if (activeBranch && !suspense.isFallbackMountPending) {
4059
- if (parentNode(activeBranch.el) === container) anchor = next(activeBranch);
4185
+ if (parentNode(activeBranch.el) === container) {
4186
+ anchor = next(activeBranch);
4187
+ hasUpdatedAnchor = true;
4188
+ }
4060
4189
  unmount(activeBranch, parentComponent, suspense, true);
4061
4190
  if (!delayEnter && isInFallback && vnode.ssFallback) queuePostRenderEffect(() => vnode.ssFallback.el = null, void 0, suspense);
4062
4191
  }
@@ -4120,6 +4249,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
4120
4249
  handleError(err, instance, 0);
4121
4250
  }).then((asyncSetupResult) => {
4122
4251
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
4252
+ setCurrentInstance(null, void 0);
4123
4253
  instance.asyncResolved = true;
4124
4254
  onResolve(asyncSetupResult);
4125
4255
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -4383,11 +4513,29 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
4383
4513
  el: vnode.el,
4384
4514
  anchor: vnode.anchor,
4385
4515
  ctx: vnode.ctx,
4386
- ce: vnode.ce
4516
+ ce: vnode.ce,
4517
+ vi: vnode.vi,
4518
+ vs: cloneVaporSlotMeta(vnode),
4519
+ vb: vnode.vb
4387
4520
  };
4388
4521
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
4389
4522
  return cloned;
4390
4523
  }
4524
+ function cloneVaporSlotMeta(vnode) {
4525
+ const vaporSlot = vnode.vs;
4526
+ if (!vaporSlot) return vaporSlot;
4527
+ const cloned = {
4528
+ slot: vaporSlot.slot,
4529
+ fallback: vaporSlot.fallback,
4530
+ outletFallback: vaporSlot.outletFallback
4531
+ };
4532
+ if (vnode.el) {
4533
+ cloned.state = vaporSlot.state;
4534
+ cloned.ref = vaporSlot.ref;
4535
+ cloned.scope = vaporSlot.scope;
4536
+ }
4537
+ return cloned;
4538
+ }
4391
4539
  /**
4392
4540
  * @private
4393
4541
  */
@@ -4441,6 +4589,10 @@ function normalizeChildren(vnode, children) {
4441
4589
  }
4442
4590
  }
4443
4591
  else if ((0, _vue_shared.isFunction)(children)) {
4592
+ if (shapeFlag & 65) {
4593
+ normalizeChildren(vnode, { default: children });
4594
+ return;
4595
+ }
4444
4596
  children = {
4445
4597
  default: children,
4446
4598
  _ctx: currentRenderingInstance
@@ -4799,7 +4951,7 @@ function isMemoSame(cached, memo) {
4799
4951
  }
4800
4952
  //#endregion
4801
4953
  //#region packages/runtime-core/src/index.ts
4802
- const version = "3.6.0-beta.9";
4954
+ const version = "3.6.0-rc.1";
4803
4955
  const warn = _vue_shared.NOOP;
4804
4956
  /**
4805
4957
  * Runtime error messages. Only exposed in dev or esm builds.