@vue/runtime-core 3.4.25 → 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.25
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
  **/
@@ -290,7 +290,7 @@ function findInsertionIndex(id) {
290
290
  const middle = start + end >>> 1;
291
291
  const middleJob = queue[middle];
292
292
  const middleJobId = getId(middleJob);
293
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
293
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
294
294
  start = middle + 1;
295
295
  } else {
296
296
  end = middle;
@@ -299,15 +299,21 @@ function findInsertionIndex(id) {
299
299
  return start;
300
300
  }
301
301
  function queueJob(job) {
302
- if (!queue.length || !queue.includes(
303
- job,
304
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
305
- )) {
302
+ var _a;
303
+ if (!(job.flags & 1)) {
306
304
  if (job.id == null) {
307
305
  queue.push(job);
306
+ } else if (
307
+ // fast path when the job id is larger than the tail
308
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
309
+ ) {
310
+ queue.push(job);
308
311
  } else {
309
312
  queue.splice(findInsertionIndex(job.id), 0, job);
310
313
  }
314
+ if (!(job.flags & 4)) {
315
+ job.flags |= 1;
316
+ }
311
317
  queueFlush();
312
318
  }
313
319
  }
@@ -325,11 +331,11 @@ function invalidateJob(job) {
325
331
  }
326
332
  function queuePostFlushCb(cb) {
327
333
  if (!shared.isArray(cb)) {
328
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
329
- cb,
330
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
331
- )) {
334
+ if (!(cb.flags & 1)) {
332
335
  pendingPostFlushCbs.push(cb);
336
+ if (!(cb.flags & 4)) {
337
+ cb.flags |= 1;
338
+ }
333
339
  }
334
340
  } else {
335
341
  pendingPostFlushCbs.push(...cb);
@@ -342,7 +348,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
342
348
  }
343
349
  for (; i < queue.length; i++) {
344
350
  const cb = queue[i];
345
- if (cb && cb.pre) {
351
+ if (cb && cb.flags & 2) {
346
352
  if (instance && cb.id !== instance.uid) {
347
353
  continue;
348
354
  }
@@ -352,6 +358,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
352
358
  queue.splice(i, 1);
353
359
  i--;
354
360
  cb();
361
+ cb.flags &= ~1;
355
362
  }
356
363
  }
357
364
  }
@@ -374,6 +381,7 @@ function flushPostFlushCbs(seen) {
374
381
  continue;
375
382
  }
376
383
  activePostFlushCbs[postFlushIndex]();
384
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
377
385
  }
378
386
  activePostFlushCbs = null;
379
387
  postFlushIndex = 0;
@@ -383,9 +391,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
383
391
  const comparator = (a, b) => {
384
392
  const diff = getId(a) - getId(b);
385
393
  if (diff === 0) {
386
- if (a.pre && !b.pre)
394
+ const isAPre = a.flags & 2;
395
+ const isBPre = b.flags & 2;
396
+ if (isAPre && !isBPre)
387
397
  return -1;
388
- if (b.pre && !a.pre)
398
+ if (isBPre && !isAPre)
389
399
  return 1;
390
400
  }
391
401
  return diff;
@@ -401,11 +411,12 @@ function flushJobs(seen) {
401
411
  try {
402
412
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
403
413
  const job = queue[flushIndex];
404
- if (job && job.active !== false) {
414
+ if (job && !(job.flags & 8)) {
405
415
  if (check(job)) {
406
416
  continue;
407
417
  }
408
418
  callWithErrorHandling(job, null, 14);
419
+ job.flags &= ~1;
409
420
  }
410
421
  }
411
422
  } finally {
@@ -487,7 +498,6 @@ function rerender(id, newRender) {
487
498
  }
488
499
  instance.renderCache = [];
489
500
  isHmrUpdating = true;
490
- instance.effect.dirty = true;
491
501
  instance.update();
492
502
  isHmrUpdating = false;
493
503
  });
@@ -515,7 +525,6 @@ function reload(id, newComp) {
515
525
  instance.ceReload(newComp.styles);
516
526
  hmrDirtyComponents.delete(oldComp);
517
527
  } else if (instance.parent) {
518
- instance.parent.effect.dirty = true;
519
528
  queueJob(instance.parent.update);
520
529
  } else if (instance.appContext.reload) {
521
530
  instance.appContext.reload();
@@ -1940,8 +1949,8 @@ function doWatch(source, cb, {
1940
1949
  }
1941
1950
  }
1942
1951
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1943
- const job = () => {
1944
- if (!effect.active || !effect.dirty) {
1952
+ const job = (immediateFirstRun) => {
1953
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1945
1954
  return;
1946
1955
  }
1947
1956
  if (cb) {
@@ -1962,19 +1971,22 @@ function doWatch(source, cb, {
1962
1971
  effect.run();
1963
1972
  }
1964
1973
  };
1965
- job.allowRecurse = !!cb;
1974
+ if (cb)
1975
+ job.flags |= 4;
1976
+ const effect = new reactivity.ReactiveEffect(getter);
1966
1977
  let scheduler;
1967
1978
  if (flush === "sync") {
1979
+ effect.flags |= 64;
1968
1980
  scheduler = job;
1969
1981
  } else if (flush === "post") {
1970
1982
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
1971
1983
  } else {
1972
- job.pre = true;
1984
+ job.flags |= 2;
1973
1985
  if (instance)
1974
1986
  job.id = instance.uid;
1975
1987
  scheduler = () => queueJob(job);
1976
1988
  }
1977
- const effect = new reactivity.ReactiveEffect(getter, shared.NOOP, scheduler);
1989
+ effect.scheduler = scheduler;
1978
1990
  const scope = reactivity.getCurrentScope();
1979
1991
  const unwatch = () => {
1980
1992
  effect.stop();
@@ -1988,7 +2000,7 @@ function doWatch(source, cb, {
1988
2000
  }
1989
2001
  if (cb) {
1990
2002
  if (immediate) {
1991
- job();
2003
+ job(true);
1992
2004
  } else {
1993
2005
  oldValue = effect.run();
1994
2006
  }
@@ -2169,22 +2181,7 @@ const BaseTransitionImpl = {
2169
2181
  if (!children || !children.length) {
2170
2182
  return;
2171
2183
  }
2172
- let child = children[0];
2173
- if (children.length > 1) {
2174
- let hasFound = false;
2175
- for (const c of children) {
2176
- if (c.type !== Comment) {
2177
- if (hasFound) {
2178
- warn$1(
2179
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
2180
- );
2181
- break;
2182
- }
2183
- child = c;
2184
- hasFound = true;
2185
- }
2186
- }
2187
- }
2184
+ const child = findNonCommentChild(children);
2188
2185
  const rawProps = reactivity.toRaw(props);
2189
2186
  const { mode } = rawProps;
2190
2187
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -2193,7 +2190,7 @@ const BaseTransitionImpl = {
2193
2190
  if (state.isLeaving) {
2194
2191
  return emptyPlaceholder(child);
2195
2192
  }
2196
- const innerChild = getKeepAliveChild(child);
2193
+ const innerChild = getInnerChild$1(child);
2197
2194
  if (!innerChild) {
2198
2195
  return emptyPlaceholder(child);
2199
2196
  }
@@ -2205,7 +2202,7 @@ const BaseTransitionImpl = {
2205
2202
  );
2206
2203
  setTransitionHooks(innerChild, enterHooks);
2207
2204
  const oldChild = instance.subTree;
2208
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
2205
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
2209
2206
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
2210
2207
  const leavingHooks = resolveTransitionHooks(
2211
2208
  oldInnerChild,
@@ -2218,8 +2215,7 @@ const BaseTransitionImpl = {
2218
2215
  state.isLeaving = true;
2219
2216
  leavingHooks.afterLeave = () => {
2220
2217
  state.isLeaving = false;
2221
- if (instance.update.active !== false) {
2222
- instance.effect.dirty = true;
2218
+ if (!(instance.job.flags & 8)) {
2223
2219
  instance.update();
2224
2220
  }
2225
2221
  };
@@ -2244,6 +2240,25 @@ const BaseTransitionImpl = {
2244
2240
  };
2245
2241
  }
2246
2242
  };
2243
+ function findNonCommentChild(children) {
2244
+ let child = children[0];
2245
+ if (children.length > 1) {
2246
+ let hasFound = false;
2247
+ for (const c of children) {
2248
+ if (c.type !== Comment) {
2249
+ if (hasFound) {
2250
+ warn$1(
2251
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
2252
+ );
2253
+ break;
2254
+ }
2255
+ child = c;
2256
+ hasFound = true;
2257
+ }
2258
+ }
2259
+ }
2260
+ return child;
2261
+ }
2247
2262
  const BaseTransition = BaseTransitionImpl;
2248
2263
  function getLeavingNodesForType(state, vnode) {
2249
2264
  const { leavingVNodes } = state;
@@ -2398,8 +2413,11 @@ function emptyPlaceholder(vnode) {
2398
2413
  return vnode;
2399
2414
  }
2400
2415
  }
2401
- function getKeepAliveChild(vnode) {
2416
+ function getInnerChild$1(vnode) {
2402
2417
  if (!isKeepAlive(vnode)) {
2418
+ if (isTeleport(vnode.type) && vnode.children) {
2419
+ return findNonCommentChild(vnode.children);
2420
+ }
2403
2421
  return vnode;
2404
2422
  }
2405
2423
  if (vnode.component) {
@@ -2568,7 +2586,6 @@ function defineAsyncComponent(source) {
2568
2586
  load().then(() => {
2569
2587
  loaded.value = true;
2570
2588
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2571
- instance.parent.effect.dirty = true;
2572
2589
  queueJob(instance.parent.update);
2573
2590
  }
2574
2591
  }).catch((err) => {
@@ -2899,10 +2916,20 @@ function onErrorCaptured(hook, target = currentInstance) {
2899
2916
  function renderList(source, renderItem, cache, index) {
2900
2917
  let ret;
2901
2918
  const cached = cache && cache[index];
2902
- if (shared.isArray(source) || shared.isString(source)) {
2919
+ const sourceIsArray = shared.isArray(source);
2920
+ const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
2921
+ if (sourceIsArray || shared.isString(source)) {
2922
+ if (sourceIsReactiveArray) {
2923
+ source = reactivity.shallowReadArray(source);
2924
+ }
2903
2925
  ret = new Array(source.length);
2904
2926
  for (let i = 0, l = source.length; i < l; i++) {
2905
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
2927
+ ret[i] = renderItem(
2928
+ sourceIsReactiveArray ? reactivity.toReactive(source[i]) : source[i],
2929
+ i,
2930
+ void 0,
2931
+ cached && cached[i]
2932
+ );
2906
2933
  }
2907
2934
  } else if (typeof source === "number") {
2908
2935
  if (!Number.isInteger(source)) {
@@ -3037,7 +3064,6 @@ const publicPropertiesMap = (
3037
3064
  $emit: (i) => i.emit,
3038
3065
  $options: (i) => resolveMergedOptions(i) ,
3039
3066
  $forceUpdate: (i) => i.f || (i.f = () => {
3040
- i.effect.dirty = true;
3041
3067
  queueJob(i.update);
3042
3068
  }),
3043
3069
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -4370,7 +4396,9 @@ const isSimpleType = /* @__PURE__ */ shared.makeMap(
4370
4396
  function assertType(value, type) {
4371
4397
  let valid;
4372
4398
  const expectedType = getType(type);
4373
- if (isSimpleType(expectedType)) {
4399
+ if (expectedType === "null") {
4400
+ valid = value === null;
4401
+ } else if (isSimpleType(expectedType)) {
4374
4402
  const t = typeof value;
4375
4403
  valid = t === expectedType.toLowerCase();
4376
4404
  if (!valid && t === "object") {
@@ -4380,8 +4408,6 @@ function assertType(value, type) {
4380
4408
  valid = shared.isObject(value);
4381
4409
  } else if (expectedType === "Array") {
4382
4410
  valid = shared.isArray(value);
4383
- } else if (expectedType === "null") {
4384
- valid = value === null;
4385
4411
  } else {
4386
4412
  valid = value instanceof type;
4387
4413
  }
@@ -5905,7 +5931,6 @@ function baseCreateRenderer(options, createHydrationFns) {
5905
5931
  } else {
5906
5932
  instance.next = n2;
5907
5933
  invalidateJob(instance.update);
5908
- instance.effect.dirty = true;
5909
5934
  instance.update();
5910
5935
  }
5911
5936
  } else {
@@ -6088,24 +6113,18 @@ function baseCreateRenderer(options, createHydrationFns) {
6088
6113
  }
6089
6114
  }
6090
6115
  };
6091
- const effect = instance.effect = new reactivity.ReactiveEffect(
6092
- componentUpdateFn,
6093
- shared.NOOP,
6094
- () => queueJob(update),
6095
- instance.scope
6096
- // track it in component's effect scope
6097
- );
6098
- const update = instance.update = () => {
6099
- if (effect.dirty) {
6100
- effect.run();
6101
- }
6102
- };
6103
- update.id = instance.uid;
6116
+ instance.scope.on();
6117
+ const effect = instance.effect = new reactivity.ReactiveEffect(componentUpdateFn);
6118
+ instance.scope.off();
6119
+ const update = instance.update = effect.run.bind(effect);
6120
+ const job = instance.job = effect.runIfDirty.bind(effect);
6121
+ job.id = instance.uid;
6122
+ effect.scheduler = () => queueJob(job);
6104
6123
  toggleRecurse(instance, true);
6105
6124
  {
6106
6125
  effect.onTrack = instance.rtc ? (e) => shared.invokeArrayFns(instance.rtc, e) : void 0;
6107
6126
  effect.onTrigger = instance.rtg ? (e) => shared.invokeArrayFns(instance.rtg, e) : void 0;
6108
- update.ownerInstance = instance;
6127
+ job.ownerInstance = instance;
6109
6128
  }
6110
6129
  update();
6111
6130
  };
@@ -6572,13 +6591,13 @@ function baseCreateRenderer(options, createHydrationFns) {
6572
6591
  if (instance.type.__hmrId) {
6573
6592
  unregisterHMR(instance);
6574
6593
  }
6575
- const { bum, scope, update, subTree, um } = instance;
6594
+ const { bum, scope, job, subTree, um } = instance;
6576
6595
  if (bum) {
6577
6596
  shared.invokeArrayFns(bum);
6578
6597
  }
6579
6598
  scope.stop();
6580
- if (update) {
6581
- update.active = false;
6599
+ if (job) {
6600
+ job.flags |= 8;
6582
6601
  unmount(subTree, instance, parentSuspense, doRemove);
6583
6602
  }
6584
6603
  if (um) {
@@ -6664,8 +6683,14 @@ function baseCreateRenderer(options, createHydrationFns) {
6664
6683
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
6665
6684
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
6666
6685
  }
6667
- function toggleRecurse({ effect, update }, allowed) {
6668
- effect.allowRecurse = update.allowRecurse = allowed;
6686
+ function toggleRecurse({ effect, job }, allowed) {
6687
+ if (allowed) {
6688
+ effect.flags |= 32;
6689
+ job.flags |= 4;
6690
+ } else {
6691
+ effect.flags &= ~32;
6692
+ job.flags &= ~4;
6693
+ }
6669
6694
  }
6670
6695
  function needTransition(parentSuspense, transition) {
6671
6696
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -7402,6 +7427,7 @@ function createComponentInstance(vnode, parent, suspense) {
7402
7427
  effect: null,
7403
7428
  update: null,
7404
7429
  // will be set synchronously right after creation
7430
+ job: null,
7405
7431
  scope: new reactivity.EffectScope(
7406
7432
  true
7407
7433
  /* detached */
@@ -7912,7 +7938,8 @@ function initCustomFormatter() {
7912
7938
  {},
7913
7939
  ["span", vueStyle, genRefFlag(obj)],
7914
7940
  "<",
7915
- formatValue(obj.value),
7941
+ // avoid debugger accessing value affecting behavior
7942
+ formatValue("_value" in obj ? obj._value : obj),
7916
7943
  `>`
7917
7944
  ];
7918
7945
  } else if (reactivity.isReactive(obj)) {
@@ -8092,7 +8119,7 @@ function isMemoSame(cached, memo) {
8092
8119
  return true;
8093
8120
  }
8094
8121
 
8095
- const version = "3.4.25";
8122
+ const version = "3.5.0-alpha.1";
8096
8123
  const warn = warn$1 ;
8097
8124
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8098
8125
  const devtools = devtools$1 ;