@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,9 +1,9 @@
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
  **/
6
- import { pauseTracking, resetTracking, isRef, toRaw, shallowReadonly, isShallow, isReactive, ReactiveEffect, getCurrentScope, ref, track, reactive, shallowReactive, trigger, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, customRef, isReadonly } from '@vue/reactivity';
6
+ import { pauseTracking, resetTracking, isRef, toRaw, shallowReadonly, isShallow, isReactive, ReactiveEffect, getCurrentScope, ref, shallowReadArray, toReactive, track, reactive, shallowReactive, trigger, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, customRef, isReadonly } from '@vue/reactivity';
7
7
  export { EffectScope, ReactiveEffect, TrackOpTypes, TriggerOpTypes, customRef, effect, effectScope, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
8
8
  import { isString, isFunction, isPromise, isArray, NOOP, getGlobalThis, extend, EMPTY_OBJ, toHandlerKey, looseToNumber, hyphenate, camelize, isObject, isOn, hasOwn, isModelListener, capitalize, toNumber, hasChanged, remove, isSet, isMap, isPlainObject, isBuiltInDirective, invokeArrayFns, isRegExp, isGloballyAllowed, NO, isReservedProp, EMPTY_ARR, toRawType, makeMap, def, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr, isRenderableAttrValue } from '@vue/shared';
9
9
  export { camelize, capitalize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
@@ -292,7 +292,7 @@ function findInsertionIndex(id) {
292
292
  const middle = start + end >>> 1;
293
293
  const middleJob = queue[middle];
294
294
  const middleJobId = getId(middleJob);
295
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
295
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
296
296
  start = middle + 1;
297
297
  } else {
298
298
  end = middle;
@@ -301,15 +301,21 @@ function findInsertionIndex(id) {
301
301
  return start;
302
302
  }
303
303
  function queueJob(job) {
304
- if (!queue.length || !queue.includes(
305
- job,
306
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
307
- )) {
304
+ var _a;
305
+ if (!(job.flags & 1)) {
308
306
  if (job.id == null) {
309
307
  queue.push(job);
308
+ } else if (
309
+ // fast path when the job id is larger than the tail
310
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
311
+ ) {
312
+ queue.push(job);
310
313
  } else {
311
314
  queue.splice(findInsertionIndex(job.id), 0, job);
312
315
  }
316
+ if (!(job.flags & 4)) {
317
+ job.flags |= 1;
318
+ }
313
319
  queueFlush();
314
320
  }
315
321
  }
@@ -327,11 +333,11 @@ function invalidateJob(job) {
327
333
  }
328
334
  function queuePostFlushCb(cb) {
329
335
  if (!isArray(cb)) {
330
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
331
- cb,
332
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
333
- )) {
336
+ if (!(cb.flags & 1)) {
334
337
  pendingPostFlushCbs.push(cb);
338
+ if (!(cb.flags & 4)) {
339
+ cb.flags |= 1;
340
+ }
335
341
  }
336
342
  } else {
337
343
  pendingPostFlushCbs.push(...cb);
@@ -344,7 +350,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
344
350
  }
345
351
  for (; i < queue.length; i++) {
346
352
  const cb = queue[i];
347
- if (cb && cb.pre) {
353
+ if (cb && cb.flags & 2) {
348
354
  if (instance && cb.id !== instance.uid) {
349
355
  continue;
350
356
  }
@@ -354,6 +360,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
354
360
  queue.splice(i, 1);
355
361
  i--;
356
362
  cb();
363
+ cb.flags &= ~1;
357
364
  }
358
365
  }
359
366
  }
@@ -376,6 +383,7 @@ function flushPostFlushCbs(seen) {
376
383
  continue;
377
384
  }
378
385
  activePostFlushCbs[postFlushIndex]();
386
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
379
387
  }
380
388
  activePostFlushCbs = null;
381
389
  postFlushIndex = 0;
@@ -385,9 +393,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
385
393
  const comparator = (a, b) => {
386
394
  const diff = getId(a) - getId(b);
387
395
  if (diff === 0) {
388
- if (a.pre && !b.pre)
396
+ const isAPre = a.flags & 2;
397
+ const isBPre = b.flags & 2;
398
+ if (isAPre && !isBPre)
389
399
  return -1;
390
- if (b.pre && !a.pre)
400
+ if (isBPre && !isAPre)
391
401
  return 1;
392
402
  }
393
403
  return diff;
@@ -403,11 +413,12 @@ function flushJobs(seen) {
403
413
  try {
404
414
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
405
415
  const job = queue[flushIndex];
406
- if (job && job.active !== false) {
416
+ if (job && !(job.flags & 8)) {
407
417
  if (!!(process.env.NODE_ENV !== "production") && check(job)) {
408
418
  continue;
409
419
  }
410
420
  callWithErrorHandling(job, null, 14);
421
+ job.flags &= ~1;
411
422
  }
412
423
  }
413
424
  } finally {
@@ -489,7 +500,6 @@ function rerender(id, newRender) {
489
500
  }
490
501
  instance.renderCache = [];
491
502
  isHmrUpdating = true;
492
- instance.effect.dirty = true;
493
503
  instance.update();
494
504
  isHmrUpdating = false;
495
505
  });
@@ -517,7 +527,6 @@ function reload(id, newComp) {
517
527
  instance.ceReload(newComp.styles);
518
528
  hmrDirtyComponents.delete(oldComp);
519
529
  } else if (instance.parent) {
520
- instance.parent.effect.dirty = true;
521
530
  queueJob(instance.parent.update);
522
531
  } else if (instance.appContext.reload) {
523
532
  instance.appContext.reload();
@@ -1942,8 +1951,8 @@ function doWatch(source, cb, {
1942
1951
  }
1943
1952
  }
1944
1953
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1945
- const job = () => {
1946
- if (!effect.active || !effect.dirty) {
1954
+ const job = (immediateFirstRun) => {
1955
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1947
1956
  return;
1948
1957
  }
1949
1958
  if (cb) {
@@ -1964,19 +1973,22 @@ function doWatch(source, cb, {
1964
1973
  effect.run();
1965
1974
  }
1966
1975
  };
1967
- job.allowRecurse = !!cb;
1976
+ if (cb)
1977
+ job.flags |= 4;
1978
+ const effect = new ReactiveEffect(getter);
1968
1979
  let scheduler;
1969
1980
  if (flush === "sync") {
1981
+ effect.flags |= 64;
1970
1982
  scheduler = job;
1971
1983
  } else if (flush === "post") {
1972
1984
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
1973
1985
  } else {
1974
- job.pre = true;
1986
+ job.flags |= 2;
1975
1987
  if (instance)
1976
1988
  job.id = instance.uid;
1977
1989
  scheduler = () => queueJob(job);
1978
1990
  }
1979
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
1991
+ effect.scheduler = scheduler;
1980
1992
  const scope = getCurrentScope();
1981
1993
  const unwatch = () => {
1982
1994
  effect.stop();
@@ -1990,7 +2002,7 @@ function doWatch(source, cb, {
1990
2002
  }
1991
2003
  if (cb) {
1992
2004
  if (immediate) {
1993
- job();
2005
+ job(true);
1994
2006
  } else {
1995
2007
  oldValue = effect.run();
1996
2008
  }
@@ -2171,24 +2183,7 @@ const BaseTransitionImpl = {
2171
2183
  if (!children || !children.length) {
2172
2184
  return;
2173
2185
  }
2174
- let child = children[0];
2175
- if (children.length > 1) {
2176
- let hasFound = false;
2177
- for (const c of children) {
2178
- if (c.type !== Comment) {
2179
- if (!!(process.env.NODE_ENV !== "production") && hasFound) {
2180
- warn$1(
2181
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
2182
- );
2183
- break;
2184
- }
2185
- child = c;
2186
- hasFound = true;
2187
- if (!!!(process.env.NODE_ENV !== "production"))
2188
- break;
2189
- }
2190
- }
2191
- }
2186
+ const child = findNonCommentChild(children);
2192
2187
  const rawProps = toRaw(props);
2193
2188
  const { mode } = rawProps;
2194
2189
  if (!!(process.env.NODE_ENV !== "production") && mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -2197,7 +2192,7 @@ const BaseTransitionImpl = {
2197
2192
  if (state.isLeaving) {
2198
2193
  return emptyPlaceholder(child);
2199
2194
  }
2200
- const innerChild = getKeepAliveChild(child);
2195
+ const innerChild = getInnerChild$1(child);
2201
2196
  if (!innerChild) {
2202
2197
  return emptyPlaceholder(child);
2203
2198
  }
@@ -2209,7 +2204,7 @@ const BaseTransitionImpl = {
2209
2204
  );
2210
2205
  setTransitionHooks(innerChild, enterHooks);
2211
2206
  const oldChild = instance.subTree;
2212
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
2207
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
2213
2208
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
2214
2209
  const leavingHooks = resolveTransitionHooks(
2215
2210
  oldInnerChild,
@@ -2222,8 +2217,7 @@ const BaseTransitionImpl = {
2222
2217
  state.isLeaving = true;
2223
2218
  leavingHooks.afterLeave = () => {
2224
2219
  state.isLeaving = false;
2225
- if (instance.update.active !== false) {
2226
- instance.effect.dirty = true;
2220
+ if (!(instance.job.flags & 8)) {
2227
2221
  instance.update();
2228
2222
  }
2229
2223
  };
@@ -2248,6 +2242,27 @@ const BaseTransitionImpl = {
2248
2242
  };
2249
2243
  }
2250
2244
  };
2245
+ function findNonCommentChild(children) {
2246
+ let child = children[0];
2247
+ if (children.length > 1) {
2248
+ let hasFound = false;
2249
+ for (const c of children) {
2250
+ if (c.type !== Comment) {
2251
+ if (!!(process.env.NODE_ENV !== "production") && hasFound) {
2252
+ warn$1(
2253
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
2254
+ );
2255
+ break;
2256
+ }
2257
+ child = c;
2258
+ hasFound = true;
2259
+ if (!!!(process.env.NODE_ENV !== "production"))
2260
+ break;
2261
+ }
2262
+ }
2263
+ }
2264
+ return child;
2265
+ }
2251
2266
  const BaseTransition = BaseTransitionImpl;
2252
2267
  function getLeavingNodesForType(state, vnode) {
2253
2268
  const { leavingVNodes } = state;
@@ -2402,8 +2417,11 @@ function emptyPlaceholder(vnode) {
2402
2417
  return vnode;
2403
2418
  }
2404
2419
  }
2405
- function getKeepAliveChild(vnode) {
2420
+ function getInnerChild$1(vnode) {
2406
2421
  if (!isKeepAlive(vnode)) {
2422
+ if (isTeleport(vnode.type) && vnode.children) {
2423
+ return findNonCommentChild(vnode.children);
2424
+ }
2407
2425
  return vnode;
2408
2426
  }
2409
2427
  if (!!(process.env.NODE_ENV !== "production") && vnode.component) {
@@ -2572,7 +2590,6 @@ function defineAsyncComponent(source) {
2572
2590
  load().then(() => {
2573
2591
  loaded.value = true;
2574
2592
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2575
- instance.parent.effect.dirty = true;
2576
2593
  queueJob(instance.parent.update);
2577
2594
  }
2578
2595
  }).catch((err) => {
@@ -2903,10 +2920,20 @@ function onErrorCaptured(hook, target = currentInstance) {
2903
2920
  function renderList(source, renderItem, cache, index) {
2904
2921
  let ret;
2905
2922
  const cached = cache && cache[index];
2906
- if (isArray(source) || isString(source)) {
2923
+ const sourceIsArray = isArray(source);
2924
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
2925
+ if (sourceIsArray || isString(source)) {
2926
+ if (sourceIsReactiveArray) {
2927
+ source = shallowReadArray(source);
2928
+ }
2907
2929
  ret = new Array(source.length);
2908
2930
  for (let i = 0, l = source.length; i < l; i++) {
2909
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
2931
+ ret[i] = renderItem(
2932
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
2933
+ i,
2934
+ void 0,
2935
+ cached && cached[i]
2936
+ );
2910
2937
  }
2911
2938
  } else if (typeof source === "number") {
2912
2939
  if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
@@ -3041,7 +3068,6 @@ const publicPropertiesMap = (
3041
3068
  $emit: (i) => i.emit,
3042
3069
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
3043
3070
  $forceUpdate: (i) => i.f || (i.f = () => {
3044
- i.effect.dirty = true;
3045
3071
  queueJob(i.update);
3046
3072
  }),
3047
3073
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -4378,7 +4404,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
4378
4404
  function assertType(value, type) {
4379
4405
  let valid;
4380
4406
  const expectedType = getType(type);
4381
- if (isSimpleType(expectedType)) {
4407
+ if (expectedType === "null") {
4408
+ valid = value === null;
4409
+ } else if (isSimpleType(expectedType)) {
4382
4410
  const t = typeof value;
4383
4411
  valid = t === expectedType.toLowerCase();
4384
4412
  if (!valid && t === "object") {
@@ -4388,8 +4416,6 @@ function assertType(value, type) {
4388
4416
  valid = isObject(value);
4389
4417
  } else if (expectedType === "Array") {
4390
4418
  valid = isArray(value);
4391
- } else if (expectedType === "null") {
4392
- valid = value === null;
4393
4419
  } else {
4394
4420
  valid = value instanceof type;
4395
4421
  }
@@ -5961,7 +5987,6 @@ function baseCreateRenderer(options, createHydrationFns) {
5961
5987
  } else {
5962
5988
  instance.next = n2;
5963
5989
  invalidateJob(instance.update);
5964
- instance.effect.dirty = true;
5965
5990
  instance.update();
5966
5991
  }
5967
5992
  } else {
@@ -6144,24 +6169,18 @@ function baseCreateRenderer(options, createHydrationFns) {
6144
6169
  }
6145
6170
  }
6146
6171
  };
6147
- const effect = instance.effect = new ReactiveEffect(
6148
- componentUpdateFn,
6149
- NOOP,
6150
- () => queueJob(update),
6151
- instance.scope
6152
- // track it in component's effect scope
6153
- );
6154
- const update = instance.update = () => {
6155
- if (effect.dirty) {
6156
- effect.run();
6157
- }
6158
- };
6159
- update.id = instance.uid;
6172
+ instance.scope.on();
6173
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
6174
+ instance.scope.off();
6175
+ const update = instance.update = effect.run.bind(effect);
6176
+ const job = instance.job = effect.runIfDirty.bind(effect);
6177
+ job.id = instance.uid;
6178
+ effect.scheduler = () => queueJob(job);
6160
6179
  toggleRecurse(instance, true);
6161
6180
  if (!!(process.env.NODE_ENV !== "production")) {
6162
6181
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
6163
6182
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
6164
- update.ownerInstance = instance;
6183
+ job.ownerInstance = instance;
6165
6184
  }
6166
6185
  update();
6167
6186
  };
@@ -6628,13 +6647,13 @@ function baseCreateRenderer(options, createHydrationFns) {
6628
6647
  if (!!(process.env.NODE_ENV !== "production") && instance.type.__hmrId) {
6629
6648
  unregisterHMR(instance);
6630
6649
  }
6631
- const { bum, scope, update, subTree, um } = instance;
6650
+ const { bum, scope, job, subTree, um } = instance;
6632
6651
  if (bum) {
6633
6652
  invokeArrayFns(bum);
6634
6653
  }
6635
6654
  scope.stop();
6636
- if (update) {
6637
- update.active = false;
6655
+ if (job) {
6656
+ job.flags |= 8;
6638
6657
  unmount(subTree, instance, parentSuspense, doRemove);
6639
6658
  }
6640
6659
  if (um) {
@@ -6720,8 +6739,14 @@ function baseCreateRenderer(options, createHydrationFns) {
6720
6739
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
6721
6740
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
6722
6741
  }
6723
- function toggleRecurse({ effect, update }, allowed) {
6724
- effect.allowRecurse = update.allowRecurse = allowed;
6742
+ function toggleRecurse({ effect, job }, allowed) {
6743
+ if (allowed) {
6744
+ effect.flags |= 32;
6745
+ job.flags |= 4;
6746
+ } else {
6747
+ effect.flags &= ~32;
6748
+ job.flags &= ~4;
6749
+ }
6725
6750
  }
6726
6751
  function needTransition(parentSuspense, transition) {
6727
6752
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -7458,6 +7483,7 @@ function createComponentInstance(vnode, parent, suspense) {
7458
7483
  effect: null,
7459
7484
  update: null,
7460
7485
  // will be set synchronously right after creation
7486
+ job: null,
7461
7487
  scope: new EffectScope(
7462
7488
  true
7463
7489
  /* detached */
@@ -7982,7 +8008,8 @@ function initCustomFormatter() {
7982
8008
  {},
7983
8009
  ["span", vueStyle, genRefFlag(obj)],
7984
8010
  "<",
7985
- formatValue(obj.value),
8011
+ // avoid debugger accessing value affecting behavior
8012
+ formatValue("_value" in obj ? obj._value : obj),
7986
8013
  `>`
7987
8014
  ];
7988
8015
  } else if (isReactive(obj)) {
@@ -8162,7 +8189,7 @@ function isMemoSame(cached, memo) {
8162
8189
  return true;
8163
8190
  }
8164
8191
 
8165
- const version = "3.4.25";
8192
+ const version = "3.5.0-alpha.1";
8166
8193
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
8167
8194
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8168
8195
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.4.25",
3
+ "version": "3.5.0-alpha.1",
4
4
  "description": "@vue/runtime-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-core.esm-bundler.js",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-core#readme",
48
48
  "dependencies": {
49
- "@vue/shared": "3.4.25",
50
- "@vue/reactivity": "3.4.25"
49
+ "@vue/shared": "3.5.0-alpha.1",
50
+ "@vue/reactivity": "3.5.0-alpha.1"
51
51
  }
52
52
  }