@vue/runtime-core 3.3.6 → 3.4.0-alpha.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.
@@ -119,7 +119,7 @@ function assertNumber(val, type) {
119
119
  }
120
120
  }
121
121
 
122
- const ErrorTypeStrings = {
122
+ const ErrorTypeStrings$1 = {
123
123
  ["sp"]: "serverPrefetch hook",
124
124
  ["bc"]: "beforeCreate hook",
125
125
  ["c"]: "created hook",
@@ -180,7 +180,7 @@ function handleError(err, instance, type, throwInDev = true) {
180
180
  if (instance) {
181
181
  let cur = instance.parent;
182
182
  const exposedInstance = instance.proxy;
183
- const errorInfo = ErrorTypeStrings[type] ;
183
+ const errorInfo = ErrorTypeStrings$1[type] ;
184
184
  while (cur) {
185
185
  const errorCapturedHooks = cur.ec;
186
186
  if (errorCapturedHooks) {
@@ -207,7 +207,7 @@ function handleError(err, instance, type, throwInDev = true) {
207
207
  }
208
208
  function logError(err, type, contextVNode, throwInDev = true) {
209
209
  {
210
- const info = ErrorTypeStrings[type];
210
+ const info = ErrorTypeStrings$1[type];
211
211
  if (contextVNode) {
212
212
  pushWarningContext(contextVNode);
213
213
  }
@@ -242,8 +242,13 @@ function findInsertionIndex(id) {
242
242
  let end = queue.length;
243
243
  while (start < end) {
244
244
  const middle = start + end >>> 1;
245
- const middleJobId = getId(queue[middle]);
246
- middleJobId < id ? start = middle + 1 : end = middle;
245
+ const middleJob = queue[middle];
246
+ const middleJobId = getId(middleJob);
247
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
248
+ start = middle + 1;
249
+ } else {
250
+ end = middle;
251
+ }
247
252
  }
248
253
  return start;
249
254
  }
@@ -430,6 +435,7 @@ function rerender(id, newRender) {
430
435
  }
431
436
  instance.renderCache = [];
432
437
  isHmrUpdating = true;
438
+ instance.effect.dirty = true;
433
439
  instance.update();
434
440
  isHmrUpdating = false;
435
441
  });
@@ -457,6 +463,7 @@ function reload(id, newComp) {
457
463
  instance.ceReload(newComp.styles);
458
464
  hmrDirtyComponents.delete(oldComp);
459
465
  } else if (instance.parent) {
466
+ instance.parent.effect.dirty = true;
460
467
  queueJob(instance.parent.update);
461
468
  } else if (instance.appContext.reload) {
462
469
  instance.appContext.reload();
@@ -1358,14 +1365,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
1358
1365
  parentComponent: parentComponent2,
1359
1366
  container: container2
1360
1367
  } = suspense;
1368
+ let delayEnter = false;
1361
1369
  if (suspense.isHydrating) {
1362
1370
  suspense.isHydrating = false;
1363
1371
  } else if (!resume) {
1364
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
1372
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
1365
1373
  if (delayEnter) {
1366
1374
  activeBranch.transition.afterLeave = () => {
1367
1375
  if (pendingId === suspense.pendingId) {
1368
1376
  move(pendingBranch, container2, anchor2, 0);
1377
+ queuePostFlushCb(effects);
1369
1378
  }
1370
1379
  };
1371
1380
  }
@@ -1391,7 +1400,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
1391
1400
  }
1392
1401
  parent = parent.parent;
1393
1402
  }
1394
- if (!hasUnresolvedAncestor) {
1403
+ if (!hasUnresolvedAncestor && !delayEnter) {
1395
1404
  queuePostFlushCb(effects);
1396
1405
  }
1397
1406
  suspense.effects = [];
@@ -1639,8 +1648,15 @@ function watch(source, cb, options) {
1639
1648
  }
1640
1649
  return doWatch(source, cb, options);
1641
1650
  }
1642
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = shared.EMPTY_OBJ) {
1651
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = shared.EMPTY_OBJ) {
1643
1652
  var _a;
1653
+ if (cb && once) {
1654
+ const _cb = cb;
1655
+ cb = (...args) => {
1656
+ _cb(...args);
1657
+ unwatch();
1658
+ };
1659
+ }
1644
1660
  if (!cb) {
1645
1661
  if (immediate !== void 0) {
1646
1662
  warn(
@@ -1652,6 +1668,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1652
1668
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
1653
1669
  );
1654
1670
  }
1671
+ if (once !== void 0) {
1672
+ warn(
1673
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
1674
+ );
1675
+ }
1655
1676
  }
1656
1677
  const warnInvalidSource = (s) => {
1657
1678
  warn(
@@ -1738,7 +1759,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1738
1759
  }
1739
1760
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1740
1761
  const job = () => {
1741
- if (!effect.active) {
1762
+ if (!effect.active || !effect.dirty) {
1742
1763
  return;
1743
1764
  }
1744
1765
  if (cb) {
@@ -1771,7 +1792,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1771
1792
  job.id = instance.uid;
1772
1793
  scheduler = () => queueJob(job);
1773
1794
  }
1774
- const effect = new reactivity.ReactiveEffect(getter, scheduler);
1795
+ const effect = new reactivity.ReactiveEffect(getter, shared.NOOP, scheduler);
1796
+ const unwatch = () => {
1797
+ effect.stop();
1798
+ if (instance && instance.scope) {
1799
+ shared.remove(instance.scope.effects, effect);
1800
+ }
1801
+ };
1775
1802
  {
1776
1803
  effect.onTrack = onTrack;
1777
1804
  effect.onTrigger = onTrigger;
@@ -1790,12 +1817,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1790
1817
  } else {
1791
1818
  effect.run();
1792
1819
  }
1793
- const unwatch = () => {
1794
- effect.stop();
1795
- if (instance && instance.scope) {
1796
- shared.remove(instance.scope.effects, effect);
1797
- }
1798
- };
1799
1820
  if (ssrCleanup)
1800
1821
  ssrCleanup.push(unwatch);
1801
1822
  return unwatch;
@@ -2027,6 +2048,7 @@ const BaseTransitionImpl = {
2027
2048
  leavingHooks.afterLeave = () => {
2028
2049
  state.isLeaving = false;
2029
2050
  if (instance.update.active !== false) {
2051
+ instance.effect.dirty = true;
2030
2052
  instance.update();
2031
2053
  }
2032
2054
  };
@@ -2362,6 +2384,7 @@ function defineAsyncComponent(source) {
2362
2384
  load().then(() => {
2363
2385
  loaded.value = true;
2364
2386
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2387
+ instance.parent.effect.dirty = true;
2365
2388
  queueJob(instance.parent.update);
2366
2389
  }
2367
2390
  }).catch((err) => {
@@ -2662,7 +2685,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
2662
2685
  }
2663
2686
  return wrappedHook;
2664
2687
  } else {
2665
- const apiName = shared.toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
2688
+ const apiName = shared.toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
2666
2689
  warn(
2667
2690
  `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
2668
2691
  );
@@ -2884,7 +2907,10 @@ const publicPropertiesMap = (
2884
2907
  $root: (i) => getPublicInstance(i.root),
2885
2908
  $emit: (i) => i.emit,
2886
2909
  $options: (i) => resolveMergedOptions(i) ,
2887
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
2910
+ $forceUpdate: (i) => i.f || (i.f = () => {
2911
+ i.effect.dirty = true;
2912
+ queueJob(i.update);
2913
+ }),
2888
2914
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
2889
2915
  $watch: (i) => instanceWatch.bind(i)
2890
2916
  })
@@ -4560,7 +4586,14 @@ function createHydrationFunctions(rendererInternals) {
4560
4586
  break;
4561
4587
  case Comment:
4562
4588
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
4563
- nextNode = onMismatch();
4589
+ if (node.tagName.toLowerCase() === "template") {
4590
+ const content = vnode.el.content.firstChild;
4591
+ replaceNode(content, node, parentComponent);
4592
+ vnode.el = node = content;
4593
+ nextNode = nextSibling(node);
4594
+ } else {
4595
+ nextNode = onMismatch();
4596
+ }
4564
4597
  } else {
4565
4598
  nextNode = nextSibling(node);
4566
4599
  }
@@ -4602,7 +4635,7 @@ function createHydrationFunctions(rendererInternals) {
4602
4635
  break;
4603
4636
  default:
4604
4637
  if (shapeFlag & 1) {
4605
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
4638
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
4606
4639
  nextNode = onMismatch();
4607
4640
  } else {
4608
4641
  nextNode = hydrateElement(
@@ -4617,6 +4650,13 @@ function createHydrationFunctions(rendererInternals) {
4617
4650
  } else if (shapeFlag & 6) {
4618
4651
  vnode.slotScopeIds = slotScopeIds;
4619
4652
  const container = parentNode(node);
4653
+ if (isFragmentStart) {
4654
+ nextNode = locateClosingAnchor(node);
4655
+ } else if (isComment(node) && node.data === "teleport start") {
4656
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
4657
+ } else {
4658
+ nextNode = nextSibling(node);
4659
+ }
4620
4660
  mountComponent(
4621
4661
  vnode,
4622
4662
  container,
@@ -4626,10 +4666,6 @@ function createHydrationFunctions(rendererInternals) {
4626
4666
  isSVGContainer(container),
4627
4667
  optimized
4628
4668
  );
4629
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
4630
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
4631
- nextNode = nextSibling(nextNode);
4632
- }
4633
4669
  if (isAsyncWrapper(vnode)) {
4634
4670
  let subTree;
4635
4671
  if (isFragmentStart) {
@@ -4679,7 +4715,7 @@ function createHydrationFunctions(rendererInternals) {
4679
4715
  };
4680
4716
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4681
4717
  optimized = optimized || !!vnode.dynamicChildren;
4682
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
4718
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4683
4719
  const forcePatchValue = type === "input" && dirs || type === "option";
4684
4720
  {
4685
4721
  if (dirs) {
@@ -4716,12 +4752,23 @@ function createHydrationFunctions(rendererInternals) {
4716
4752
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
4717
4753
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
4718
4754
  }
4755
+ let needCallTransitionHooks = false;
4756
+ if (isTemplateNode(el)) {
4757
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
4758
+ const content = el.content.firstChild;
4759
+ if (needCallTransitionHooks) {
4760
+ transition.beforeEnter(content);
4761
+ }
4762
+ replaceNode(content, el, parentComponent);
4763
+ vnode.el = el = content;
4764
+ }
4719
4765
  if (dirs) {
4720
4766
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4721
4767
  }
4722
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
4768
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
4723
4769
  queueEffectWithSuspense(() => {
4724
4770
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
4771
+ needCallTransitionHooks && transition.enter(el);
4725
4772
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4726
4773
  }, parentSuspense);
4727
4774
  }
@@ -4839,7 +4886,7 @@ function createHydrationFunctions(rendererInternals) {
4839
4886
  );
4840
4887
  vnode.el = null;
4841
4888
  if (isFragment) {
4842
- const end = locateClosingAsyncAnchor(node);
4889
+ const end = locateClosingAnchor(node);
4843
4890
  while (true) {
4844
4891
  const next2 = nextSibling(node);
4845
4892
  if (next2 && next2 !== end) {
@@ -4864,14 +4911,14 @@ function createHydrationFunctions(rendererInternals) {
4864
4911
  );
4865
4912
  return next;
4866
4913
  };
4867
- const locateClosingAsyncAnchor = (node) => {
4914
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
4868
4915
  let match = 0;
4869
4916
  while (node) {
4870
4917
  node = nextSibling(node);
4871
4918
  if (node && isComment(node)) {
4872
- if (node.data === "[")
4919
+ if (node.data === open)
4873
4920
  match++;
4874
- if (node.data === "]") {
4921
+ if (node.data === close) {
4875
4922
  if (match === 0) {
4876
4923
  return nextSibling(node);
4877
4924
  } else {
@@ -4882,6 +4929,23 @@ function createHydrationFunctions(rendererInternals) {
4882
4929
  }
4883
4930
  return node;
4884
4931
  };
4932
+ const replaceNode = (newNode, oldNode, parentComponent) => {
4933
+ const parentNode2 = oldNode.parentNode;
4934
+ if (parentNode2) {
4935
+ parentNode2.replaceChild(newNode, oldNode);
4936
+ }
4937
+ let parent = parentComponent;
4938
+ while (parent) {
4939
+ if (parent.vnode.el === oldNode) {
4940
+ parent.vnode.el = newNode;
4941
+ parent.subTree.el = newNode;
4942
+ }
4943
+ parent = parent.parent;
4944
+ }
4945
+ };
4946
+ const isTemplateNode = (node) => {
4947
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
4948
+ };
4885
4949
  return [hydrate, hydrateNode];
4886
4950
  }
4887
4951
 
@@ -5209,7 +5273,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5209
5273
  if (dirs) {
5210
5274
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
5211
5275
  }
5212
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5276
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
5213
5277
  if (needCallTransitionHooks) {
5214
5278
  transition.beforeEnter(el);
5215
5279
  }
@@ -5597,6 +5661,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5597
5661
  } else {
5598
5662
  instance.next = n2;
5599
5663
  invalidateJob(instance.update);
5664
+ instance.effect.dirty = true;
5600
5665
  instance.update();
5601
5666
  }
5602
5667
  } else {
@@ -5766,11 +5831,16 @@ function baseCreateRenderer(options, createHydrationFns) {
5766
5831
  };
5767
5832
  const effect = instance.effect = new reactivity.ReactiveEffect(
5768
5833
  componentUpdateFn,
5834
+ shared.NOOP,
5769
5835
  () => queueJob(update),
5770
5836
  instance.scope
5771
5837
  // track it in component's effect scope
5772
5838
  );
5773
- const update = instance.update = () => effect.run();
5839
+ const update = instance.update = () => {
5840
+ if (effect.dirty) {
5841
+ effect.run();
5842
+ }
5843
+ };
5774
5844
  update.id = instance.uid;
5775
5845
  toggleRecurse(instance, true);
5776
5846
  {
@@ -6101,8 +6171,8 @@ function baseCreateRenderer(options, createHydrationFns) {
6101
6171
  moveStaticNode(vnode, container, anchor);
6102
6172
  return;
6103
6173
  }
6104
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
6105
- if (needTransition) {
6174
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
6175
+ if (needTransition2) {
6106
6176
  if (moveType === 0) {
6107
6177
  transition.beforeEnter(el);
6108
6178
  hostInsert(el, container, anchor);
@@ -6322,6 +6392,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6322
6392
  function toggleRecurse({ effect, update }, allowed) {
6323
6393
  effect.allowRecurse = update.allowRecurse = allowed;
6324
6394
  }
6395
+ function needTransition(parentSuspense, transition) {
6396
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
6397
+ }
6325
6398
  function traverseStaticChildren(n1, n2, shallow = false) {
6326
6399
  const ch1 = n1.children;
6327
6400
  const ch2 = n2.children;
@@ -7673,7 +7746,8 @@ function isMemoSame(cached, memo) {
7673
7746
  return true;
7674
7747
  }
7675
7748
 
7676
- const version = "3.3.6";
7749
+ const version = "3.4.0-alpha.1";
7750
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
7677
7751
  const _ssrUtils = {
7678
7752
  createComponentInstance,
7679
7753
  setupComponent,
@@ -7723,6 +7797,7 @@ exports.toHandlerKey = shared.toHandlerKey;
7723
7797
  exports.BaseTransition = BaseTransition;
7724
7798
  exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
7725
7799
  exports.Comment = Comment;
7800
+ exports.ErrorTypeStrings = ErrorTypeStrings;
7726
7801
  exports.Fragment = Fragment;
7727
7802
  exports.KeepAlive = KeepAlive;
7728
7803
  exports.Static = Static;
@@ -91,8 +91,13 @@ function findInsertionIndex(id) {
91
91
  let end = queue.length;
92
92
  while (start < end) {
93
93
  const middle = start + end >>> 1;
94
- const middleJobId = getId(queue[middle]);
95
- middleJobId < id ? start = middle + 1 : end = middle;
94
+ const middleJob = queue[middle];
95
+ const middleJobId = getId(middleJob);
96
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
97
+ start = middle + 1;
98
+ } else {
99
+ end = middle;
100
+ }
96
101
  }
97
102
  return start;
98
103
  }
@@ -854,14 +859,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
854
859
  parentComponent: parentComponent2,
855
860
  container: container2
856
861
  } = suspense;
862
+ let delayEnter = false;
857
863
  if (suspense.isHydrating) {
858
864
  suspense.isHydrating = false;
859
865
  } else if (!resume) {
860
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
866
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
861
867
  if (delayEnter) {
862
868
  activeBranch.transition.afterLeave = () => {
863
869
  if (pendingId === suspense.pendingId) {
864
870
  move(pendingBranch, container2, anchor2, 0);
871
+ queuePostFlushCb(effects);
865
872
  }
866
873
  };
867
874
  }
@@ -887,7 +894,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
887
894
  }
888
895
  parent = parent.parent;
889
896
  }
890
- if (!hasUnresolvedAncestor) {
897
+ if (!hasUnresolvedAncestor && !delayEnter) {
891
898
  queuePostFlushCb(effects);
892
899
  }
893
900
  suspense.effects = [];
@@ -1121,8 +1128,15 @@ const INITIAL_WATCHER_VALUE = {};
1121
1128
  function watch(source, cb, options) {
1122
1129
  return doWatch(source, cb, options);
1123
1130
  }
1124
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = shared.EMPTY_OBJ) {
1131
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = shared.EMPTY_OBJ) {
1125
1132
  var _a;
1133
+ if (cb && once) {
1134
+ const _cb = cb;
1135
+ cb = (...args) => {
1136
+ _cb(...args);
1137
+ unwatch();
1138
+ };
1139
+ }
1126
1140
  const instance = reactivity.getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
1127
1141
  let getter;
1128
1142
  let forceTrigger = false;
@@ -1198,7 +1212,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1198
1212
  }
1199
1213
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1200
1214
  const job = () => {
1201
- if (!effect.active) {
1215
+ if (!effect.active || !effect.dirty) {
1202
1216
  return;
1203
1217
  }
1204
1218
  if (cb) {
@@ -1231,7 +1245,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1231
1245
  job.id = instance.uid;
1232
1246
  scheduler = () => queueJob(job);
1233
1247
  }
1234
- const effect = new reactivity.ReactiveEffect(getter, scheduler);
1248
+ const effect = new reactivity.ReactiveEffect(getter, shared.NOOP, scheduler);
1249
+ const unwatch = () => {
1250
+ effect.stop();
1251
+ if (instance && instance.scope) {
1252
+ shared.remove(instance.scope.effects, effect);
1253
+ }
1254
+ };
1235
1255
  if (cb) {
1236
1256
  if (immediate) {
1237
1257
  job();
@@ -1246,12 +1266,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh
1246
1266
  } else {
1247
1267
  effect.run();
1248
1268
  }
1249
- const unwatch = () => {
1250
- effect.stop();
1251
- if (instance && instance.scope) {
1252
- shared.remove(instance.scope.effects, effect);
1253
- }
1254
- };
1255
1269
  if (ssrCleanup)
1256
1270
  ssrCleanup.push(unwatch);
1257
1271
  return unwatch;
@@ -1467,6 +1481,7 @@ const BaseTransitionImpl = {
1467
1481
  leavingHooks.afterLeave = () => {
1468
1482
  state.isLeaving = false;
1469
1483
  if (instance.update.active !== false) {
1484
+ instance.effect.dirty = true;
1470
1485
  instance.update();
1471
1486
  }
1472
1487
  };
@@ -1794,6 +1809,7 @@ function defineAsyncComponent(source) {
1794
1809
  load().then(() => {
1795
1810
  loaded.value = true;
1796
1811
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1812
+ instance.parent.effect.dirty = true;
1797
1813
  queueJob(instance.parent.update);
1798
1814
  }
1799
1815
  }).catch((err) => {
@@ -2277,7 +2293,10 @@ const publicPropertiesMap = (
2277
2293
  $root: (i) => getPublicInstance(i.root),
2278
2294
  $emit: (i) => i.emit,
2279
2295
  $options: (i) => resolveMergedOptions(i) ,
2280
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
2296
+ $forceUpdate: (i) => i.f || (i.f = () => {
2297
+ i.effect.dirty = true;
2298
+ queueJob(i.update);
2299
+ }),
2281
2300
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
2282
2301
  $watch: (i) => instanceWatch.bind(i)
2283
2302
  })
@@ -3492,7 +3511,14 @@ function createHydrationFunctions(rendererInternals) {
3492
3511
  break;
3493
3512
  case Comment:
3494
3513
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
3495
- nextNode = onMismatch();
3514
+ if (node.tagName.toLowerCase() === "template") {
3515
+ const content = vnode.el.content.firstChild;
3516
+ replaceNode(content, node, parentComponent);
3517
+ vnode.el = node = content;
3518
+ nextNode = nextSibling(node);
3519
+ } else {
3520
+ nextNode = onMismatch();
3521
+ }
3496
3522
  } else {
3497
3523
  nextNode = nextSibling(node);
3498
3524
  }
@@ -3534,7 +3560,7 @@ function createHydrationFunctions(rendererInternals) {
3534
3560
  break;
3535
3561
  default:
3536
3562
  if (shapeFlag & 1) {
3537
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
3563
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
3538
3564
  nextNode = onMismatch();
3539
3565
  } else {
3540
3566
  nextNode = hydrateElement(
@@ -3549,6 +3575,13 @@ function createHydrationFunctions(rendererInternals) {
3549
3575
  } else if (shapeFlag & 6) {
3550
3576
  vnode.slotScopeIds = slotScopeIds;
3551
3577
  const container = parentNode(node);
3578
+ if (isFragmentStart) {
3579
+ nextNode = locateClosingAnchor(node);
3580
+ } else if (isComment(node) && node.data === "teleport start") {
3581
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
3582
+ } else {
3583
+ nextNode = nextSibling(node);
3584
+ }
3552
3585
  mountComponent(
3553
3586
  vnode,
3554
3587
  container,
@@ -3558,10 +3591,6 @@ function createHydrationFunctions(rendererInternals) {
3558
3591
  isSVGContainer(container),
3559
3592
  optimized
3560
3593
  );
3561
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
3562
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
3563
- nextNode = nextSibling(nextNode);
3564
- }
3565
3594
  if (isAsyncWrapper(vnode)) {
3566
3595
  let subTree;
3567
3596
  if (isFragmentStart) {
@@ -3609,7 +3638,7 @@ function createHydrationFunctions(rendererInternals) {
3609
3638
  };
3610
3639
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
3611
3640
  optimized = optimized || !!vnode.dynamicChildren;
3612
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
3641
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
3613
3642
  const forcePatchValue = type === "input" && dirs || type === "option";
3614
3643
  if (forcePatchValue || patchFlag !== -1) {
3615
3644
  if (dirs) {
@@ -3646,12 +3675,23 @@ function createHydrationFunctions(rendererInternals) {
3646
3675
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
3647
3676
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
3648
3677
  }
3678
+ let needCallTransitionHooks = false;
3679
+ if (isTemplateNode(el)) {
3680
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
3681
+ const content = el.content.firstChild;
3682
+ if (needCallTransitionHooks) {
3683
+ transition.beforeEnter(content);
3684
+ }
3685
+ replaceNode(content, el, parentComponent);
3686
+ vnode.el = el = content;
3687
+ }
3649
3688
  if (dirs) {
3650
3689
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
3651
3690
  }
3652
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
3691
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
3653
3692
  queueEffectWithSuspense(() => {
3654
3693
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
3694
+ needCallTransitionHooks && transition.enter(el);
3655
3695
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
3656
3696
  }, parentSuspense);
3657
3697
  }
@@ -3741,7 +3781,7 @@ function createHydrationFunctions(rendererInternals) {
3741
3781
  hasMismatch = true;
3742
3782
  vnode.el = null;
3743
3783
  if (isFragment) {
3744
- const end = locateClosingAsyncAnchor(node);
3784
+ const end = locateClosingAnchor(node);
3745
3785
  while (true) {
3746
3786
  const next2 = nextSibling(node);
3747
3787
  if (next2 && next2 !== end) {
@@ -3766,14 +3806,14 @@ function createHydrationFunctions(rendererInternals) {
3766
3806
  );
3767
3807
  return next;
3768
3808
  };
3769
- const locateClosingAsyncAnchor = (node) => {
3809
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
3770
3810
  let match = 0;
3771
3811
  while (node) {
3772
3812
  node = nextSibling(node);
3773
3813
  if (node && isComment(node)) {
3774
- if (node.data === "[")
3814
+ if (node.data === open)
3775
3815
  match++;
3776
- if (node.data === "]") {
3816
+ if (node.data === close) {
3777
3817
  if (match === 0) {
3778
3818
  return nextSibling(node);
3779
3819
  } else {
@@ -3784,6 +3824,23 @@ function createHydrationFunctions(rendererInternals) {
3784
3824
  }
3785
3825
  return node;
3786
3826
  };
3827
+ const replaceNode = (newNode, oldNode, parentComponent) => {
3828
+ const parentNode2 = oldNode.parentNode;
3829
+ if (parentNode2) {
3830
+ parentNode2.replaceChild(newNode, oldNode);
3831
+ }
3832
+ let parent = parentComponent;
3833
+ while (parent) {
3834
+ if (parent.vnode.el === oldNode) {
3835
+ parent.vnode.el = newNode;
3836
+ parent.subTree.el = newNode;
3837
+ }
3838
+ parent = parent.parent;
3839
+ }
3840
+ };
3841
+ const isTemplateNode = (node) => {
3842
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
3843
+ };
3787
3844
  return [hydrate, hydrateNode];
3788
3845
  }
3789
3846
 
@@ -4039,7 +4096,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4039
4096
  if (dirs) {
4040
4097
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4041
4098
  }
4042
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
4099
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
4043
4100
  if (needCallTransitionHooks) {
4044
4101
  transition.beforeEnter(el);
4045
4102
  }
@@ -4396,6 +4453,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4396
4453
  } else {
4397
4454
  instance.next = n2;
4398
4455
  invalidateJob(instance.update);
4456
+ instance.effect.dirty = true;
4399
4457
  instance.update();
4400
4458
  }
4401
4459
  } else {
@@ -4517,11 +4575,16 @@ function baseCreateRenderer(options, createHydrationFns) {
4517
4575
  };
4518
4576
  const effect = instance.effect = new reactivity.ReactiveEffect(
4519
4577
  componentUpdateFn,
4578
+ shared.NOOP,
4520
4579
  () => queueJob(update),
4521
4580
  instance.scope
4522
4581
  // track it in component's effect scope
4523
4582
  );
4524
- const update = instance.update = () => effect.run();
4583
+ const update = instance.update = () => {
4584
+ if (effect.dirty) {
4585
+ effect.run();
4586
+ }
4587
+ };
4525
4588
  update.id = instance.uid;
4526
4589
  toggleRecurse(instance, true);
4527
4590
  update();
@@ -4840,8 +4903,8 @@ function baseCreateRenderer(options, createHydrationFns) {
4840
4903
  moveStaticNode(vnode, container, anchor);
4841
4904
  return;
4842
4905
  }
4843
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
4844
- if (needTransition) {
4906
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
4907
+ if (needTransition2) {
4845
4908
  if (moveType === 0) {
4846
4909
  transition.beforeEnter(el);
4847
4910
  hostInsert(el, container, anchor);
@@ -5047,6 +5110,9 @@ function baseCreateRenderer(options, createHydrationFns) {
5047
5110
  function toggleRecurse({ effect, update }, allowed) {
5048
5111
  effect.allowRecurse = update.allowRecurse = allowed;
5049
5112
  }
5113
+ function needTransition(parentSuspense, transition) {
5114
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5115
+ }
5050
5116
  function traverseStaticChildren(n1, n2, shallow = false) {
5051
5117
  const ch1 = n1.children;
5052
5118
  const ch2 = n2.children;
@@ -6022,7 +6088,8 @@ function isMemoSame(cached, memo) {
6022
6088
  return true;
6023
6089
  }
6024
6090
 
6025
- const version = "3.3.6";
6091
+ const version = "3.4.0-alpha.1";
6092
+ const ErrorTypeStrings = null;
6026
6093
  const _ssrUtils = {
6027
6094
  createComponentInstance,
6028
6095
  setupComponent,
@@ -6072,6 +6139,7 @@ exports.toHandlerKey = shared.toHandlerKey;
6072
6139
  exports.BaseTransition = BaseTransition;
6073
6140
  exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
6074
6141
  exports.Comment = Comment;
6142
+ exports.ErrorTypeStrings = ErrorTypeStrings;
6075
6143
  exports.Fragment = Fragment;
6076
6144
  exports.KeepAlive = KeepAlive;
6077
6145
  exports.Static = Static;
@@ -114,7 +114,7 @@ D = {}, // return from data()
114
114
  C extends ComputedOptions = {}, M extends MethodOptions = {}, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>, I extends ComponentInjectOptions = {}, S extends SlotsType = {}> = {
115
115
  $: ComponentInternalInstance;
116
116
  $data: D;
117
- $props: Prettify<MakeDefaultsOptional extends true ? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults> : P & PublicProps>;
117
+ $props: MakeDefaultsOptional extends true ? Partial<Defaults> & Omit<Prettify<P> & PublicProps, keyof Defaults> : Prettify<P> & PublicProps;
118
118
  $attrs: Data;
119
119
  $refs: Data;
120
120
  $slots: UnwrapSlotsType<S>;
@@ -207,6 +207,69 @@ export type RootHydrateFunction = (vnode: VNode<Node, Element>, container: (Elem
207
207
  _vnode?: VNode;
208
208
  }) => void;
209
209
 
210
+ type Hook<T = () => void> = T | T[];
211
+ export interface BaseTransitionProps<HostElement = RendererElement> {
212
+ mode?: 'in-out' | 'out-in' | 'default';
213
+ appear?: boolean;
214
+ persisted?: boolean;
215
+ onBeforeEnter?: Hook<(el: HostElement) => void>;
216
+ onEnter?: Hook<(el: HostElement, done: () => void) => void>;
217
+ onAfterEnter?: Hook<(el: HostElement) => void>;
218
+ onEnterCancelled?: Hook<(el: HostElement) => void>;
219
+ onBeforeLeave?: Hook<(el: HostElement) => void>;
220
+ onLeave?: Hook<(el: HostElement, done: () => void) => void>;
221
+ onAfterLeave?: Hook<(el: HostElement) => void>;
222
+ onLeaveCancelled?: Hook<(el: HostElement) => void>;
223
+ onBeforeAppear?: Hook<(el: HostElement) => void>;
224
+ onAppear?: Hook<(el: HostElement, done: () => void) => void>;
225
+ onAfterAppear?: Hook<(el: HostElement) => void>;
226
+ onAppearCancelled?: Hook<(el: HostElement) => void>;
227
+ }
228
+ export interface TransitionHooks<HostElement = RendererElement> {
229
+ mode: BaseTransitionProps['mode'];
230
+ persisted: boolean;
231
+ beforeEnter(el: HostElement): void;
232
+ enter(el: HostElement): void;
233
+ leave(el: HostElement, remove: () => void): void;
234
+ clone(vnode: VNode): TransitionHooks<HostElement>;
235
+ afterLeave?(): void;
236
+ delayLeave?(el: HostElement, earlyRemove: () => void, delayedLeave: () => void): void;
237
+ delayedLeave?(): void;
238
+ }
239
+ export interface TransitionState {
240
+ isMounted: boolean;
241
+ isLeaving: boolean;
242
+ isUnmounting: boolean;
243
+ leavingVNodes: Map<any, Record<string, VNode>>;
244
+ }
245
+ export declare function useTransitionState(): TransitionState;
246
+ export declare const BaseTransitionPropsValidators: {
247
+ mode: StringConstructor;
248
+ appear: BooleanConstructor;
249
+ persisted: BooleanConstructor;
250
+ onBeforeEnter: (ArrayConstructor | FunctionConstructor)[];
251
+ onEnter: (ArrayConstructor | FunctionConstructor)[];
252
+ onAfterEnter: (ArrayConstructor | FunctionConstructor)[];
253
+ onEnterCancelled: (ArrayConstructor | FunctionConstructor)[];
254
+ onBeforeLeave: (ArrayConstructor | FunctionConstructor)[];
255
+ onLeave: (ArrayConstructor | FunctionConstructor)[];
256
+ onAfterLeave: (ArrayConstructor | FunctionConstructor)[];
257
+ onLeaveCancelled: (ArrayConstructor | FunctionConstructor)[];
258
+ onBeforeAppear: (ArrayConstructor | FunctionConstructor)[];
259
+ onAppear: (ArrayConstructor | FunctionConstructor)[];
260
+ onAfterAppear: (ArrayConstructor | FunctionConstructor)[];
261
+ onAppearCancelled: (ArrayConstructor | FunctionConstructor)[];
262
+ };
263
+ export declare const BaseTransition: new () => {
264
+ $props: BaseTransitionProps<any>;
265
+ $slots: {
266
+ default(): VNode[];
267
+ };
268
+ };
269
+ export declare function resolveTransitionHooks(vnode: VNode, props: BaseTransitionProps<any>, state: TransitionState, instance: ComponentInternalInstance): TransitionHooks;
270
+ export declare function setTransitionHooks(vnode: VNode, hooks: TransitionHooks): void;
271
+ export declare function getTransitionRawChildren(children: VNode[], keepComment?: boolean, parentKey?: VNode['key']): VNode[];
272
+
210
273
  export interface Renderer<HostElement = RendererElement> {
211
274
  render: RootRenderFunction<HostElement>;
212
275
  createApp: CreateAppFunction<HostElement>;
@@ -745,69 +808,6 @@ export type Plugin<Options = any[]> = (PluginInstallFunction<Options> & {
745
808
  };
746
809
  export type CreateAppFunction<HostElement> = (rootComponent: Component, rootProps?: Data | null) => App<HostElement>;
747
810
 
748
- type Hook<T = () => void> = T | T[];
749
- export interface BaseTransitionProps<HostElement = RendererElement> {
750
- mode?: 'in-out' | 'out-in' | 'default';
751
- appear?: boolean;
752
- persisted?: boolean;
753
- onBeforeEnter?: Hook<(el: HostElement) => void>;
754
- onEnter?: Hook<(el: HostElement, done: () => void) => void>;
755
- onAfterEnter?: Hook<(el: HostElement) => void>;
756
- onEnterCancelled?: Hook<(el: HostElement) => void>;
757
- onBeforeLeave?: Hook<(el: HostElement) => void>;
758
- onLeave?: Hook<(el: HostElement, done: () => void) => void>;
759
- onAfterLeave?: Hook<(el: HostElement) => void>;
760
- onLeaveCancelled?: Hook<(el: HostElement) => void>;
761
- onBeforeAppear?: Hook<(el: HostElement) => void>;
762
- onAppear?: Hook<(el: HostElement, done: () => void) => void>;
763
- onAfterAppear?: Hook<(el: HostElement) => void>;
764
- onAppearCancelled?: Hook<(el: HostElement) => void>;
765
- }
766
- export interface TransitionHooks<HostElement = RendererElement> {
767
- mode: BaseTransitionProps['mode'];
768
- persisted: boolean;
769
- beforeEnter(el: HostElement): void;
770
- enter(el: HostElement): void;
771
- leave(el: HostElement, remove: () => void): void;
772
- clone(vnode: VNode): TransitionHooks<HostElement>;
773
- afterLeave?(): void;
774
- delayLeave?(el: HostElement, earlyRemove: () => void, delayedLeave: () => void): void;
775
- delayedLeave?(): void;
776
- }
777
- export interface TransitionState {
778
- isMounted: boolean;
779
- isLeaving: boolean;
780
- isUnmounting: boolean;
781
- leavingVNodes: Map<any, Record<string, VNode>>;
782
- }
783
- export declare function useTransitionState(): TransitionState;
784
- export declare const BaseTransitionPropsValidators: {
785
- mode: StringConstructor;
786
- appear: BooleanConstructor;
787
- persisted: BooleanConstructor;
788
- onBeforeEnter: (ArrayConstructor | FunctionConstructor)[];
789
- onEnter: (ArrayConstructor | FunctionConstructor)[];
790
- onAfterEnter: (ArrayConstructor | FunctionConstructor)[];
791
- onEnterCancelled: (ArrayConstructor | FunctionConstructor)[];
792
- onBeforeLeave: (ArrayConstructor | FunctionConstructor)[];
793
- onLeave: (ArrayConstructor | FunctionConstructor)[];
794
- onAfterLeave: (ArrayConstructor | FunctionConstructor)[];
795
- onLeaveCancelled: (ArrayConstructor | FunctionConstructor)[];
796
- onBeforeAppear: (ArrayConstructor | FunctionConstructor)[];
797
- onAppear: (ArrayConstructor | FunctionConstructor)[];
798
- onAfterAppear: (ArrayConstructor | FunctionConstructor)[];
799
- onAppearCancelled: (ArrayConstructor | FunctionConstructor)[];
800
- };
801
- export declare const BaseTransition: new () => {
802
- $props: BaseTransitionProps<any>;
803
- $slots: {
804
- default(): VNode[];
805
- };
806
- };
807
- export declare function resolveTransitionHooks(vnode: VNode, props: BaseTransitionProps<any>, state: TransitionState, instance: ComponentInternalInstance): TransitionHooks;
808
- export declare function setTransitionHooks(vnode: VNode, hooks: TransitionHooks): void;
809
- export declare function getTransitionRawChildren(children: VNode[], keepComment?: boolean, parentKey?: VNode['key']): VNode[];
810
-
811
811
  type TeleportVNode = VNode<RendererNode, RendererElement, TeleportProps>;
812
812
  export interface TeleportProps {
813
813
  to: string | RendererElement | null | undefined;
@@ -1112,6 +1112,7 @@ export interface WatchOptionsBase extends DebuggerOptions {
1112
1112
  export interface WatchOptions<Immediate = boolean> extends WatchOptionsBase {
1113
1113
  immediate?: Immediate;
1114
1114
  deep?: boolean;
1115
+ once?: boolean;
1115
1116
  }
1116
1117
  export type WatchStopHandle = () => void;
1117
1118
  export declare function watchEffect(effect: WatchEffect, options?: WatchOptionsBase): WatchStopHandle;
@@ -1383,6 +1384,8 @@ export declare function h(type: Constructor, children?: RawChildren): VNode;
1383
1384
  export declare function h<P>(type: Constructor<P>, props?: (RawProps & P) | ({} extends P ? null : never), children?: RawChildren | RawSlots): VNode;
1384
1385
  export declare function h(type: DefineComponent, children?: RawChildren): VNode;
1385
1386
  export declare function h<P>(type: DefineComponent<P>, props?: (RawProps & P) | ({} extends P ? null : never), children?: RawChildren | RawSlots): VNode;
1387
+ export declare function h(type: string | Component, children?: RawChildren): VNode;
1388
+ export declare function h<P>(type: string | Component<P>, props?: (RawProps & P) | ({} extends P ? null : never), children?: RawChildren | RawSlots): VNode;
1386
1389
 
1387
1390
  export declare const ssrContextKey: unique symbol;
1388
1391
  export declare const useSSRContext: <T = Record<string, any>>() => T | undefined;
@@ -121,7 +121,7 @@ function assertNumber(val, type) {
121
121
  }
122
122
  }
123
123
 
124
- const ErrorTypeStrings = {
124
+ const ErrorTypeStrings$1 = {
125
125
  ["sp"]: "serverPrefetch hook",
126
126
  ["bc"]: "beforeCreate hook",
127
127
  ["c"]: "created hook",
@@ -182,7 +182,7 @@ function handleError(err, instance, type, throwInDev = true) {
182
182
  if (instance) {
183
183
  let cur = instance.parent;
184
184
  const exposedInstance = instance.proxy;
185
- const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : type;
185
+ const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : type;
186
186
  while (cur) {
187
187
  const errorCapturedHooks = cur.ec;
188
188
  if (errorCapturedHooks) {
@@ -209,7 +209,7 @@ function handleError(err, instance, type, throwInDev = true) {
209
209
  }
210
210
  function logError(err, type, contextVNode, throwInDev = true) {
211
211
  if (!!(process.env.NODE_ENV !== "production")) {
212
- const info = ErrorTypeStrings[type];
212
+ const info = ErrorTypeStrings$1[type];
213
213
  if (contextVNode) {
214
214
  pushWarningContext(contextVNode);
215
215
  }
@@ -246,8 +246,13 @@ function findInsertionIndex(id) {
246
246
  let end = queue.length;
247
247
  while (start < end) {
248
248
  const middle = start + end >>> 1;
249
- const middleJobId = getId(queue[middle]);
250
- middleJobId < id ? start = middle + 1 : end = middle;
249
+ const middleJob = queue[middle];
250
+ const middleJobId = getId(middleJob);
251
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
252
+ start = middle + 1;
253
+ } else {
254
+ end = middle;
255
+ }
251
256
  }
252
257
  return start;
253
258
  }
@@ -434,6 +439,7 @@ function rerender(id, newRender) {
434
439
  }
435
440
  instance.renderCache = [];
436
441
  isHmrUpdating = true;
442
+ instance.effect.dirty = true;
437
443
  instance.update();
438
444
  isHmrUpdating = false;
439
445
  });
@@ -461,6 +467,7 @@ function reload(id, newComp) {
461
467
  instance.ceReload(newComp.styles);
462
468
  hmrDirtyComponents.delete(oldComp);
463
469
  } else if (instance.parent) {
470
+ instance.parent.effect.dirty = true;
464
471
  queueJob(instance.parent.update);
465
472
  } else if (instance.appContext.reload) {
466
473
  instance.appContext.reload();
@@ -1362,14 +1369,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
1362
1369
  parentComponent: parentComponent2,
1363
1370
  container: container2
1364
1371
  } = suspense;
1372
+ let delayEnter = false;
1365
1373
  if (suspense.isHydrating) {
1366
1374
  suspense.isHydrating = false;
1367
1375
  } else if (!resume) {
1368
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
1376
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
1369
1377
  if (delayEnter) {
1370
1378
  activeBranch.transition.afterLeave = () => {
1371
1379
  if (pendingId === suspense.pendingId) {
1372
1380
  move(pendingBranch, container2, anchor2, 0);
1381
+ queuePostFlushCb(effects);
1373
1382
  }
1374
1383
  };
1375
1384
  }
@@ -1395,7 +1404,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
1395
1404
  }
1396
1405
  parent = parent.parent;
1397
1406
  }
1398
- if (!hasUnresolvedAncestor) {
1407
+ if (!hasUnresolvedAncestor && !delayEnter) {
1399
1408
  queuePostFlushCb(effects);
1400
1409
  }
1401
1410
  suspense.effects = [];
@@ -1643,8 +1652,15 @@ function watch(source, cb, options) {
1643
1652
  }
1644
1653
  return doWatch(source, cb, options);
1645
1654
  }
1646
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
1655
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
1647
1656
  var _a;
1657
+ if (cb && once) {
1658
+ const _cb = cb;
1659
+ cb = (...args) => {
1660
+ _cb(...args);
1661
+ unwatch();
1662
+ };
1663
+ }
1648
1664
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
1649
1665
  if (immediate !== void 0) {
1650
1666
  warn(
@@ -1656,6 +1672,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
1656
1672
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
1657
1673
  );
1658
1674
  }
1675
+ if (once !== void 0) {
1676
+ warn(
1677
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
1678
+ );
1679
+ }
1659
1680
  }
1660
1681
  const warnInvalidSource = (s) => {
1661
1682
  warn(
@@ -1742,7 +1763,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
1742
1763
  }
1743
1764
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1744
1765
  const job = () => {
1745
- if (!effect.active) {
1766
+ if (!effect.active || !effect.dirty) {
1746
1767
  return;
1747
1768
  }
1748
1769
  if (cb) {
@@ -1775,7 +1796,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
1775
1796
  job.id = instance.uid;
1776
1797
  scheduler = () => queueJob(job);
1777
1798
  }
1778
- const effect = new ReactiveEffect(getter, scheduler);
1799
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
1800
+ const unwatch = () => {
1801
+ effect.stop();
1802
+ if (instance && instance.scope) {
1803
+ remove(instance.scope.effects, effect);
1804
+ }
1805
+ };
1779
1806
  if (!!(process.env.NODE_ENV !== "production")) {
1780
1807
  effect.onTrack = onTrack;
1781
1808
  effect.onTrigger = onTrigger;
@@ -1794,12 +1821,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
1794
1821
  } else {
1795
1822
  effect.run();
1796
1823
  }
1797
- const unwatch = () => {
1798
- effect.stop();
1799
- if (instance && instance.scope) {
1800
- remove(instance.scope.effects, effect);
1801
- }
1802
- };
1803
1824
  if (ssrCleanup)
1804
1825
  ssrCleanup.push(unwatch);
1805
1826
  return unwatch;
@@ -2033,6 +2054,7 @@ const BaseTransitionImpl = {
2033
2054
  leavingHooks.afterLeave = () => {
2034
2055
  state.isLeaving = false;
2035
2056
  if (instance.update.active !== false) {
2057
+ instance.effect.dirty = true;
2036
2058
  instance.update();
2037
2059
  }
2038
2060
  };
@@ -2368,6 +2390,7 @@ function defineAsyncComponent(source) {
2368
2390
  load().then(() => {
2369
2391
  loaded.value = true;
2370
2392
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2393
+ instance.parent.effect.dirty = true;
2371
2394
  queueJob(instance.parent.update);
2372
2395
  }
2373
2396
  }).catch((err) => {
@@ -2668,7 +2691,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
2668
2691
  }
2669
2692
  return wrappedHook;
2670
2693
  } else if (!!(process.env.NODE_ENV !== "production")) {
2671
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
2694
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
2672
2695
  warn(
2673
2696
  `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
2674
2697
  );
@@ -2890,7 +2913,10 @@ const publicPropertiesMap = (
2890
2913
  $root: (i) => getPublicInstance(i.root),
2891
2914
  $emit: (i) => i.emit,
2892
2915
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
2893
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
2916
+ $forceUpdate: (i) => i.f || (i.f = () => {
2917
+ i.effect.dirty = true;
2918
+ queueJob(i.update);
2919
+ }),
2894
2920
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
2895
2921
  $watch: (i) => __VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP
2896
2922
  })
@@ -4570,7 +4596,14 @@ function createHydrationFunctions(rendererInternals) {
4570
4596
  break;
4571
4597
  case Comment:
4572
4598
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
4573
- nextNode = onMismatch();
4599
+ if (node.tagName.toLowerCase() === "template") {
4600
+ const content = vnode.el.content.firstChild;
4601
+ replaceNode(content, node, parentComponent);
4602
+ vnode.el = node = content;
4603
+ nextNode = nextSibling(node);
4604
+ } else {
4605
+ nextNode = onMismatch();
4606
+ }
4574
4607
  } else {
4575
4608
  nextNode = nextSibling(node);
4576
4609
  }
@@ -4612,7 +4645,7 @@ function createHydrationFunctions(rendererInternals) {
4612
4645
  break;
4613
4646
  default:
4614
4647
  if (shapeFlag & 1) {
4615
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
4648
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
4616
4649
  nextNode = onMismatch();
4617
4650
  } else {
4618
4651
  nextNode = hydrateElement(
@@ -4627,6 +4660,13 @@ function createHydrationFunctions(rendererInternals) {
4627
4660
  } else if (shapeFlag & 6) {
4628
4661
  vnode.slotScopeIds = slotScopeIds;
4629
4662
  const container = parentNode(node);
4663
+ if (isFragmentStart) {
4664
+ nextNode = locateClosingAnchor(node);
4665
+ } else if (isComment(node) && node.data === "teleport start") {
4666
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
4667
+ } else {
4668
+ nextNode = nextSibling(node);
4669
+ }
4630
4670
  mountComponent(
4631
4671
  vnode,
4632
4672
  container,
@@ -4636,10 +4676,6 @@ function createHydrationFunctions(rendererInternals) {
4636
4676
  isSVGContainer(container),
4637
4677
  optimized
4638
4678
  );
4639
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
4640
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
4641
- nextNode = nextSibling(nextNode);
4642
- }
4643
4679
  if (isAsyncWrapper(vnode)) {
4644
4680
  let subTree;
4645
4681
  if (isFragmentStart) {
@@ -4689,7 +4725,7 @@ function createHydrationFunctions(rendererInternals) {
4689
4725
  };
4690
4726
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4691
4727
  optimized = optimized || !!vnode.dynamicChildren;
4692
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
4728
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4693
4729
  const forcePatchValue = type === "input" && dirs || type === "option";
4694
4730
  if (!!(process.env.NODE_ENV !== "production") || forcePatchValue || patchFlag !== -1) {
4695
4731
  if (dirs) {
@@ -4726,12 +4762,23 @@ function createHydrationFunctions(rendererInternals) {
4726
4762
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
4727
4763
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
4728
4764
  }
4765
+ let needCallTransitionHooks = false;
4766
+ if (isTemplateNode(el)) {
4767
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
4768
+ const content = el.content.firstChild;
4769
+ if (needCallTransitionHooks) {
4770
+ transition.beforeEnter(content);
4771
+ }
4772
+ replaceNode(content, el, parentComponent);
4773
+ vnode.el = el = content;
4774
+ }
4729
4775
  if (dirs) {
4730
4776
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4731
4777
  }
4732
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
4778
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
4733
4779
  queueEffectWithSuspense(() => {
4734
4780
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
4781
+ needCallTransitionHooks && transition.enter(el);
4735
4782
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4736
4783
  }, parentSuspense);
4737
4784
  }
@@ -4849,7 +4896,7 @@ function createHydrationFunctions(rendererInternals) {
4849
4896
  );
4850
4897
  vnode.el = null;
4851
4898
  if (isFragment) {
4852
- const end = locateClosingAsyncAnchor(node);
4899
+ const end = locateClosingAnchor(node);
4853
4900
  while (true) {
4854
4901
  const next2 = nextSibling(node);
4855
4902
  if (next2 && next2 !== end) {
@@ -4874,14 +4921,14 @@ function createHydrationFunctions(rendererInternals) {
4874
4921
  );
4875
4922
  return next;
4876
4923
  };
4877
- const locateClosingAsyncAnchor = (node) => {
4924
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
4878
4925
  let match = 0;
4879
4926
  while (node) {
4880
4927
  node = nextSibling(node);
4881
4928
  if (node && isComment(node)) {
4882
- if (node.data === "[")
4929
+ if (node.data === open)
4883
4930
  match++;
4884
- if (node.data === "]") {
4931
+ if (node.data === close) {
4885
4932
  if (match === 0) {
4886
4933
  return nextSibling(node);
4887
4934
  } else {
@@ -4892,6 +4939,23 @@ function createHydrationFunctions(rendererInternals) {
4892
4939
  }
4893
4940
  return node;
4894
4941
  };
4942
+ const replaceNode = (newNode, oldNode, parentComponent) => {
4943
+ const parentNode2 = oldNode.parentNode;
4944
+ if (parentNode2) {
4945
+ parentNode2.replaceChild(newNode, oldNode);
4946
+ }
4947
+ let parent = parentComponent;
4948
+ while (parent) {
4949
+ if (parent.vnode.el === oldNode) {
4950
+ parent.vnode.el = newNode;
4951
+ parent.subTree.el = newNode;
4952
+ }
4953
+ parent = parent.parent;
4954
+ }
4955
+ };
4956
+ const isTemplateNode = (node) => {
4957
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
4958
+ };
4895
4959
  return [hydrate, hydrateNode];
4896
4960
  }
4897
4961
 
@@ -5242,7 +5306,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5242
5306
  if (dirs) {
5243
5307
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
5244
5308
  }
5245
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5309
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
5246
5310
  if (needCallTransitionHooks) {
5247
5311
  transition.beforeEnter(el);
5248
5312
  }
@@ -5641,6 +5705,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5641
5705
  } else {
5642
5706
  instance.next = n2;
5643
5707
  invalidateJob(instance.update);
5708
+ instance.effect.dirty = true;
5644
5709
  instance.update();
5645
5710
  }
5646
5711
  } else {
@@ -5810,11 +5875,16 @@ function baseCreateRenderer(options, createHydrationFns) {
5810
5875
  };
5811
5876
  const effect = instance.effect = new ReactiveEffect(
5812
5877
  componentUpdateFn,
5878
+ NOOP,
5813
5879
  () => queueJob(update),
5814
5880
  instance.scope
5815
5881
  // track it in component's effect scope
5816
5882
  );
5817
- const update = instance.update = () => effect.run();
5883
+ const update = instance.update = () => {
5884
+ if (effect.dirty) {
5885
+ effect.run();
5886
+ }
5887
+ };
5818
5888
  update.id = instance.uid;
5819
5889
  toggleRecurse(instance, true);
5820
5890
  if (!!(process.env.NODE_ENV !== "production")) {
@@ -6145,8 +6215,8 @@ function baseCreateRenderer(options, createHydrationFns) {
6145
6215
  moveStaticNode(vnode, container, anchor);
6146
6216
  return;
6147
6217
  }
6148
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
6149
- if (needTransition) {
6218
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
6219
+ if (needTransition2) {
6150
6220
  if (moveType === 0) {
6151
6221
  transition.beforeEnter(el);
6152
6222
  hostInsert(el, container, anchor);
@@ -6366,6 +6436,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6366
6436
  function toggleRecurse({ effect, update }, allowed) {
6367
6437
  effect.allowRecurse = update.allowRecurse = allowed;
6368
6438
  }
6439
+ function needTransition(parentSuspense, transition) {
6440
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
6441
+ }
6369
6442
  function traverseStaticChildren(n1, n2, shallow = false) {
6370
6443
  const ch1 = n1.children;
6371
6444
  const ch2 = n2.children;
@@ -7733,7 +7806,8 @@ function isMemoSame(cached, memo) {
7733
7806
  return true;
7734
7807
  }
7735
7808
 
7736
- const version = "3.3.6";
7809
+ const version = "3.4.0-alpha.1";
7810
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
7737
7811
  const _ssrUtils = {
7738
7812
  createComponentInstance,
7739
7813
  setupComponent,
@@ -7746,4 +7820,4 @@ const ssrUtils = _ssrUtils ;
7746
7820
  const resolveFilter = null;
7747
7821
  const compatUtils = null;
7748
7822
 
7749
- export { BaseTransition, BaseTransitionPropsValidators, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, initCustomFormatter, inject, isMemoSame, isRuntimeOnly, isVNode, mergeDefaults, mergeModels, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useAttrs, useModel, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withMemo, withScopeId };
7823
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, ErrorTypeStrings, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, initCustomFormatter, inject, isMemoSame, isRuntimeOnly, isVNode, mergeDefaults, mergeModels, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useAttrs, useModel, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withMemo, withScopeId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.3.6",
3
+ "version": "3.4.0-alpha.1",
4
4
  "description": "@vue/runtime-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.3.6",
36
- "@vue/reactivity": "3.3.6"
35
+ "@vue/shared": "3.4.0-alpha.1",
36
+ "@vue/reactivity": "3.4.0-alpha.1"
37
37
  }
38
38
  }