@vue/runtime-core 3.4.26 → 3.5.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.4.26
2
+ * @vue/runtime-core v3.5.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -160,7 +160,7 @@ function findInsertionIndex(id) {
160
160
  const middle = start + end >>> 1;
161
161
  const middleJob = queue[middle];
162
162
  const middleJobId = getId(middleJob);
163
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
163
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
164
164
  start = middle + 1;
165
165
  } else {
166
166
  end = middle;
@@ -169,15 +169,21 @@ function findInsertionIndex(id) {
169
169
  return start;
170
170
  }
171
171
  function queueJob(job) {
172
- if (!queue.length || !queue.includes(
173
- job,
174
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
175
- )) {
172
+ var _a;
173
+ if (!(job.flags & 1)) {
176
174
  if (job.id == null) {
177
175
  queue.push(job);
176
+ } else if (
177
+ // fast path when the job id is larger than the tail
178
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
179
+ ) {
180
+ queue.push(job);
178
181
  } else {
179
182
  queue.splice(findInsertionIndex(job.id), 0, job);
180
183
  }
184
+ if (!(job.flags & 4)) {
185
+ job.flags |= 1;
186
+ }
181
187
  queueFlush();
182
188
  }
183
189
  }
@@ -195,11 +201,11 @@ function invalidateJob(job) {
195
201
  }
196
202
  function queuePostFlushCb(cb) {
197
203
  if (!shared.isArray(cb)) {
198
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
199
- cb,
200
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
201
- )) {
204
+ if (!(cb.flags & 1)) {
202
205
  pendingPostFlushCbs.push(cb);
206
+ if (!(cb.flags & 4)) {
207
+ cb.flags |= 1;
208
+ }
203
209
  }
204
210
  } else {
205
211
  pendingPostFlushCbs.push(...cb);
@@ -209,13 +215,14 @@ function queuePostFlushCb(cb) {
209
215
  function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
210
216
  for (; i < queue.length; i++) {
211
217
  const cb = queue[i];
212
- if (cb && cb.pre) {
218
+ if (cb && cb.flags & 2) {
213
219
  if (instance && cb.id !== instance.uid) {
214
220
  continue;
215
221
  }
216
222
  queue.splice(i, 1);
217
223
  i--;
218
224
  cb();
225
+ cb.flags &= ~1;
219
226
  }
220
227
  }
221
228
  }
@@ -232,6 +239,7 @@ function flushPostFlushCbs(seen) {
232
239
  activePostFlushCbs = deduped;
233
240
  for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
234
241
  activePostFlushCbs[postFlushIndex]();
242
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
235
243
  }
236
244
  activePostFlushCbs = null;
237
245
  postFlushIndex = 0;
@@ -241,9 +249,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
241
249
  const comparator = (a, b) => {
242
250
  const diff = getId(a) - getId(b);
243
251
  if (diff === 0) {
244
- if (a.pre && !b.pre)
252
+ const isAPre = a.flags & 2;
253
+ const isBPre = b.flags & 2;
254
+ if (isAPre && !isBPre)
245
255
  return -1;
246
- if (b.pre && !a.pre)
256
+ if (isBPre && !isAPre)
247
257
  return 1;
248
258
  }
249
259
  return diff;
@@ -255,9 +265,10 @@ function flushJobs(seen) {
255
265
  try {
256
266
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
257
267
  const job = queue[flushIndex];
258
- if (job && job.active !== false) {
268
+ if (job && !(job.flags & 8)) {
259
269
  if (false) ;
260
270
  callWithErrorHandling(job, null, 14);
271
+ job.flags &= ~1;
261
272
  }
262
273
  }
263
274
  } finally {
@@ -470,7 +481,7 @@ function renderComponentRoot(instance) {
470
481
  false ? {
471
482
  get attrs() {
472
483
  markAttrsAccessed();
473
- return shallowReadonly(attrs);
484
+ return attrs;
474
485
  },
475
486
  slots,
476
487
  emit
@@ -499,12 +510,12 @@ function renderComponentRoot(instance) {
499
510
  propsOptions
500
511
  );
501
512
  }
502
- root = cloneVNode(root, fallthroughAttrs, false, true);
513
+ root = cloneVNode(root, fallthroughAttrs);
503
514
  }
504
515
  }
505
516
  }
506
517
  if (vnode.dirs) {
507
- root = cloneVNode(root, null, false, true);
518
+ root = cloneVNode(root);
508
519
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
509
520
  }
510
521
  if (vnode.transition) {
@@ -940,7 +951,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
940
951
  let parentSuspenseId;
941
952
  const isSuspensible = isVNodeSuspensible(vnode);
942
953
  if (isSuspensible) {
943
- if (parentSuspense && parentSuspense.pendingBranch) {
954
+ if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
944
955
  parentSuspenseId = parentSuspense.pendingId;
945
956
  parentSuspense.deps++;
946
957
  }
@@ -1228,8 +1239,8 @@ function setActiveBranch(suspense, branch) {
1228
1239
  }
1229
1240
  }
1230
1241
  function isVNodeSuspensible(vnode) {
1231
- const suspensible = vnode.props && vnode.props.suspensible;
1232
- return suspensible != null && suspensible !== false;
1242
+ var _a;
1243
+ return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
1233
1244
  }
1234
1245
 
1235
1246
  const ssrContextKey = Symbol.for("v-scx");
@@ -1352,8 +1363,8 @@ function doWatch(source, cb, {
1352
1363
  }
1353
1364
  }
1354
1365
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1355
- const job = () => {
1356
- if (!effect.active || !effect.dirty) {
1366
+ const job = (immediateFirstRun) => {
1367
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1357
1368
  return;
1358
1369
  }
1359
1370
  if (cb) {
@@ -1374,19 +1385,22 @@ function doWatch(source, cb, {
1374
1385
  effect.run();
1375
1386
  }
1376
1387
  };
1377
- job.allowRecurse = !!cb;
1388
+ if (cb)
1389
+ job.flags |= 4;
1390
+ const effect = new reactivity.ReactiveEffect(getter);
1378
1391
  let scheduler;
1379
1392
  if (flush === "sync") {
1393
+ effect.flags |= 64;
1380
1394
  scheduler = job;
1381
1395
  } else if (flush === "post") {
1382
1396
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
1383
1397
  } else {
1384
- job.pre = true;
1398
+ job.flags |= 2;
1385
1399
  if (instance)
1386
1400
  job.id = instance.uid;
1387
1401
  scheduler = () => queueJob(job);
1388
1402
  }
1389
- const effect = new reactivity.ReactiveEffect(getter, shared.NOOP, scheduler);
1403
+ effect.scheduler = scheduler;
1390
1404
  const scope = reactivity.getCurrentScope();
1391
1405
  const unwatch = () => {
1392
1406
  effect.stop();
@@ -1396,7 +1410,7 @@ function doWatch(source, cb, {
1396
1410
  };
1397
1411
  if (cb) {
1398
1412
  if (immediate) {
1399
- job();
1413
+ job(true);
1400
1414
  } else {
1401
1415
  oldValue = effect.run();
1402
1416
  }
@@ -1437,29 +1451,34 @@ function createPathGetter(ctx, path) {
1437
1451
  return cur;
1438
1452
  };
1439
1453
  }
1440
- function traverse(value, depth = Infinity, seen) {
1441
- if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
1454
+ function traverse(value, depth, currentDepth = 0, seen) {
1455
+ if (!shared.isObject(value) || value["__v_skip"]) {
1442
1456
  return value;
1443
1457
  }
1458
+ if (depth && depth > 0) {
1459
+ if (currentDepth >= depth) {
1460
+ return value;
1461
+ }
1462
+ currentDepth++;
1463
+ }
1444
1464
  seen = seen || /* @__PURE__ */ new Set();
1445
1465
  if (seen.has(value)) {
1446
1466
  return value;
1447
1467
  }
1448
1468
  seen.add(value);
1449
- depth--;
1450
1469
  if (reactivity.isRef(value)) {
1451
- traverse(value.value, depth, seen);
1470
+ traverse(value.value, depth, currentDepth, seen);
1452
1471
  } else if (shared.isArray(value)) {
1453
1472
  for (let i = 0; i < value.length; i++) {
1454
- traverse(value[i], depth, seen);
1473
+ traverse(value[i], depth, currentDepth, seen);
1455
1474
  }
1456
1475
  } else if (shared.isSet(value) || shared.isMap(value)) {
1457
1476
  value.forEach((v) => {
1458
- traverse(v, depth, seen);
1477
+ traverse(v, depth, currentDepth, seen);
1459
1478
  });
1460
1479
  } else if (shared.isPlainObject(value)) {
1461
1480
  for (const key in value) {
1462
- traverse(value[key], depth, seen);
1481
+ traverse(value[key], depth, currentDepth, seen);
1463
1482
  }
1464
1483
  }
1465
1484
  return value;
@@ -1566,21 +1585,13 @@ const BaseTransitionImpl = {
1566
1585
  if (!children || !children.length) {
1567
1586
  return;
1568
1587
  }
1569
- let child = children[0];
1570
- if (children.length > 1) {
1571
- for (const c of children) {
1572
- if (c.type !== Comment) {
1573
- child = c;
1574
- break;
1575
- }
1576
- }
1577
- }
1588
+ const child = findNonCommentChild(children);
1578
1589
  const rawProps = reactivity.toRaw(props);
1579
1590
  const { mode } = rawProps;
1580
1591
  if (state.isLeaving) {
1581
1592
  return emptyPlaceholder(child);
1582
1593
  }
1583
- const innerChild = getKeepAliveChild(child);
1594
+ const innerChild = getInnerChild$1(child);
1584
1595
  if (!innerChild) {
1585
1596
  return emptyPlaceholder(child);
1586
1597
  }
@@ -1592,7 +1603,7 @@ const BaseTransitionImpl = {
1592
1603
  );
1593
1604
  setTransitionHooks(innerChild, enterHooks);
1594
1605
  const oldChild = instance.subTree;
1595
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
1606
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
1596
1607
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
1597
1608
  const leavingHooks = resolveTransitionHooks(
1598
1609
  oldInnerChild,
@@ -1601,12 +1612,11 @@ const BaseTransitionImpl = {
1601
1612
  instance
1602
1613
  );
1603
1614
  setTransitionHooks(oldInnerChild, leavingHooks);
1604
- if (mode === "out-in" && innerChild.type !== Comment) {
1615
+ if (mode === "out-in") {
1605
1616
  state.isLeaving = true;
1606
1617
  leavingHooks.afterLeave = () => {
1607
1618
  state.isLeaving = false;
1608
- if (instance.update.active !== false) {
1609
- instance.effect.dirty = true;
1619
+ if (!(instance.job.flags & 8)) {
1610
1620
  instance.update();
1611
1621
  }
1612
1622
  };
@@ -1631,6 +1641,18 @@ const BaseTransitionImpl = {
1631
1641
  };
1632
1642
  }
1633
1643
  };
1644
+ function findNonCommentChild(children) {
1645
+ let child = children[0];
1646
+ if (children.length > 1) {
1647
+ for (const c of children) {
1648
+ if (c.type !== Comment) {
1649
+ child = c;
1650
+ break;
1651
+ }
1652
+ }
1653
+ }
1654
+ return child;
1655
+ }
1634
1656
  const BaseTransition = BaseTransitionImpl;
1635
1657
  function getLeavingNodesForType(state, vnode) {
1636
1658
  const { leavingVNodes } = state;
@@ -1785,8 +1807,11 @@ function emptyPlaceholder(vnode) {
1785
1807
  return vnode;
1786
1808
  }
1787
1809
  }
1788
- function getKeepAliveChild(vnode) {
1810
+ function getInnerChild$1(vnode) {
1789
1811
  if (!isKeepAlive(vnode)) {
1812
+ if (isTeleport(vnode.type) && vnode.children) {
1813
+ return findNonCommentChild(vnode.children);
1814
+ }
1790
1815
  return vnode;
1791
1816
  }
1792
1817
  const { shapeFlag, children } = vnode;
@@ -1944,7 +1969,6 @@ function defineAsyncComponent(source) {
1944
1969
  load().then(() => {
1945
1970
  loaded.value = true;
1946
1971
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1947
- instance.parent.effect.dirty = true;
1948
1972
  queueJob(instance.parent.update);
1949
1973
  }
1950
1974
  }).catch((err) => {
@@ -2102,7 +2126,7 @@ const KeepAliveImpl = {
2102
2126
  return () => {
2103
2127
  pendingCacheKey = null;
2104
2128
  if (!slots.default) {
2105
- return null;
2129
+ return current = null;
2106
2130
  }
2107
2131
  const children = slots.default();
2108
2132
  const rawVNode = children[0];
@@ -2258,10 +2282,20 @@ function onErrorCaptured(hook, target = currentInstance) {
2258
2282
  function renderList(source, renderItem, cache, index) {
2259
2283
  let ret;
2260
2284
  const cached = cache && cache[index];
2261
- if (shared.isArray(source) || shared.isString(source)) {
2285
+ const sourceIsArray = shared.isArray(source);
2286
+ const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
2287
+ if (sourceIsArray || shared.isString(source)) {
2288
+ if (sourceIsReactiveArray) {
2289
+ source = reactivity.shallowReadArray(source);
2290
+ }
2262
2291
  ret = new Array(source.length);
2263
2292
  for (let i = 0, l = source.length; i < l; i++) {
2264
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
2293
+ ret[i] = renderItem(
2294
+ sourceIsReactiveArray ? reactivity.toReactive(source[i]) : source[i],
2295
+ i,
2296
+ void 0,
2297
+ cached && cached[i]
2298
+ );
2265
2299
  }
2266
2300
  } else if (typeof source === "number") {
2267
2301
  ret = new Array(source);
@@ -2383,7 +2417,6 @@ const publicPropertiesMap = (
2383
2417
  $emit: (i) => i.emit,
2384
2418
  $options: (i) => resolveMergedOptions(i) ,
2385
2419
  $forceUpdate: (i) => i.f || (i.f = () => {
2386
- i.effect.dirty = true;
2387
2420
  queueJob(i.update);
2388
2421
  }),
2389
2422
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -3396,7 +3429,7 @@ const initSlots = (instance, children) => {
3396
3429
  const type = children._;
3397
3430
  if (type) {
3398
3431
  shared.extend(slots, children);
3399
- shared.def(slots, "_", type, true);
3432
+ shared.def(slots, "_", type);
3400
3433
  } else {
3401
3434
  normalizeObjectSlots(children, slots);
3402
3435
  }
@@ -4544,7 +4577,6 @@ function baseCreateRenderer(options, createHydrationFns) {
4544
4577
  } else {
4545
4578
  instance.next = n2;
4546
4579
  invalidateJob(instance.update);
4547
- instance.effect.dirty = true;
4548
4580
  instance.update();
4549
4581
  }
4550
4582
  } else {
@@ -4679,19 +4711,13 @@ function baseCreateRenderer(options, createHydrationFns) {
4679
4711
  }
4680
4712
  }
4681
4713
  };
4682
- const effect = instance.effect = new reactivity.ReactiveEffect(
4683
- componentUpdateFn,
4684
- shared.NOOP,
4685
- () => queueJob(update),
4686
- instance.scope
4687
- // track it in component's effect scope
4688
- );
4689
- const update = instance.update = () => {
4690
- if (effect.dirty) {
4691
- effect.run();
4692
- }
4693
- };
4694
- update.id = instance.uid;
4714
+ instance.scope.on();
4715
+ const effect = instance.effect = new reactivity.ReactiveEffect(componentUpdateFn);
4716
+ instance.scope.off();
4717
+ const update = instance.update = effect.run.bind(effect);
4718
+ const job = instance.job = effect.runIfDirty.bind(effect);
4719
+ job.id = instance.uid;
4720
+ effect.scheduler = () => queueJob(job);
4695
4721
  toggleRecurse(instance, true);
4696
4722
  update();
4697
4723
  };
@@ -5140,13 +5166,13 @@ function baseCreateRenderer(options, createHydrationFns) {
5140
5166
  hostRemove(end);
5141
5167
  };
5142
5168
  const unmountComponent = (instance, parentSuspense, doRemove) => {
5143
- const { bum, scope, update, subTree, um } = instance;
5169
+ const { bum, scope, job, subTree, um } = instance;
5144
5170
  if (bum) {
5145
5171
  shared.invokeArrayFns(bum);
5146
5172
  }
5147
5173
  scope.stop();
5148
- if (update) {
5149
- update.active = false;
5174
+ if (job) {
5175
+ job.flags |= 8;
5150
5176
  unmount(subTree, instance, parentSuspense, doRemove);
5151
5177
  }
5152
5178
  if (um) {
@@ -5229,8 +5255,14 @@ function baseCreateRenderer(options, createHydrationFns) {
5229
5255
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
5230
5256
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
5231
5257
  }
5232
- function toggleRecurse({ effect, update }, allowed) {
5233
- effect.allowRecurse = update.allowRecurse = allowed;
5258
+ function toggleRecurse({ effect, job }, allowed) {
5259
+ if (allowed) {
5260
+ effect.flags |= 32;
5261
+ job.flags |= 4;
5262
+ } else {
5263
+ effect.flags &= ~32;
5264
+ job.flags &= ~4;
5265
+ }
5234
5266
  }
5235
5267
  function needTransition(parentSuspense, transition) {
5236
5268
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -5735,8 +5767,8 @@ function guardReactiveProps(props) {
5735
5767
  return null;
5736
5768
  return reactivity.isProxy(props) || isInternalObject(props) ? shared.extend({}, props) : props;
5737
5769
  }
5738
- function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
5739
- const { props, ref, patchFlag, children, transition } = vnode;
5770
+ function cloneVNode(vnode, extraProps, mergeRef = false) {
5771
+ const { props, ref, patchFlag, children } = vnode;
5740
5772
  const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
5741
5773
  const cloned = {
5742
5774
  __v_isVNode: true,
@@ -5766,7 +5798,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
5766
5798
  dynamicChildren: vnode.dynamicChildren,
5767
5799
  appContext: vnode.appContext,
5768
5800
  dirs: vnode.dirs,
5769
- transition,
5801
+ transition: vnode.transition,
5770
5802
  // These should technically only be non-null on mounted VNodes. However,
5771
5803
  // they *should* be copied for kept-alive vnodes. So we just always copy
5772
5804
  // them since them being non-null during a mount doesn't affect the logic as
@@ -5780,9 +5812,6 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
5780
5812
  ctx: vnode.ctx,
5781
5813
  ce: vnode.ce
5782
5814
  };
5783
- if (transition && cloneTransition) {
5784
- cloned.transition = transition.clone(cloned);
5785
- }
5786
5815
  return cloned;
5787
5816
  }
5788
5817
  function createTextVNode(text = " ", flag = 0) {
@@ -5910,6 +5939,7 @@ function createComponentInstance(vnode, parent, suspense) {
5910
5939
  effect: null,
5911
5940
  update: null,
5912
5941
  // will be set synchronously right after creation
5942
+ job: null,
5913
5943
  scope: new reactivity.EffectScope(
5914
5944
  true
5915
5945
  /* detached */
@@ -6278,7 +6308,7 @@ function isMemoSame(cached, memo) {
6278
6308
  return true;
6279
6309
  }
6280
6310
 
6281
- const version = "3.4.26";
6311
+ const version = "3.5.0-alpha.1";
6282
6312
  const warn$1 = shared.NOOP;
6283
6313
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
6284
6314
  const devtools = void 0;