@vue/runtime-core 3.5.0-beta.2 → 3.5.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @vue/runtime-core v3.5.0-beta.2
2
+ * @vue/runtime-core v3.5.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- import { pauseTracking, resetTracking, isRef, toRaw, isReactive, ref, shallowReadArray, toReactive, shallowReadonly, track, reactive, shallowReactive, trigger, ReactiveEffect, isShallow, getCurrentScope, customRef, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, shallowRef, readonly, isReadonly } from '@vue/reactivity';
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
- import { isString, isFunction, isPromise, isArray, EMPTY_OBJ, NOOP, getGlobalThis, extend, isBuiltInDirective, hasOwn, remove, def, isOn, isReservedProp, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr, isRenderableAttrValue, isObject, isRegExp, invokeArrayFns, toHandlerKey, capitalize, camelize, isGloballyAllowed, NO, hyphenate, EMPTY_ARR, toRawType, makeMap, hasChanged, isSet, isMap, isPlainObject, looseToNumber, isModelListener, toNumber } from '@vue/shared';
6
+ import { pauseTracking, resetTracking, isRef, toRaw, traverse, isReactive, ref, shallowReadArray, toReactive, shallowReadonly, track, reactive, shallowReactive, trigger, ReactiveEffect, watch as watch$1, customRef, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, shallowRef, readonly, isShallow, isReadonly } from '@vue/reactivity';
7
+ export { EffectScope, ReactiveEffect, TrackOpTypes, TriggerOpTypes, customRef, effect, effectScope, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, onWatcherCleanup, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
8
+ import { isString, isFunction, isPromise, isArray, EMPTY_OBJ, NOOP, getGlobalThis, extend, isBuiltInDirective, hasOwn, remove, def, isOn, isReservedProp, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr, isRenderableAttrValue, isObject, isRegExp, invokeArrayFns, toHandlerKey, capitalize, camelize, isGloballyAllowed, NO, hyphenate, EMPTY_ARR, toRawType, makeMap, hasChanged, looseToNumber, isModelListener, toNumber } from '@vue/shared';
9
9
  export { camelize, capitalize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
10
10
 
11
11
  const stack = [];
@@ -136,12 +136,6 @@ const ErrorCodes = {
136
136
  "0": "SETUP_FUNCTION",
137
137
  "RENDER_FUNCTION": 1,
138
138
  "1": "RENDER_FUNCTION",
139
- "WATCH_GETTER": 2,
140
- "2": "WATCH_GETTER",
141
- "WATCH_CALLBACK": 3,
142
- "3": "WATCH_CALLBACK",
143
- "WATCH_CLEANUP": 4,
144
- "4": "WATCH_CLEANUP",
145
139
  "NATIVE_EVENT_HANDLER": 5,
146
140
  "5": "NATIVE_EVENT_HANDLER",
147
141
  "COMPONENT_EVENT_HANDLER": 6,
@@ -297,7 +291,7 @@ function nextTick(fn) {
297
291
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
298
292
  }
299
293
  function findInsertionIndex(id) {
300
- let start = flushIndex + 1;
294
+ let start = isFlushing ? flushIndex + 1 : 0;
301
295
  let end = queue.length;
302
296
  while (start < end) {
303
297
  const middle = start + end >>> 1;
@@ -313,15 +307,13 @@ function findInsertionIndex(id) {
313
307
  }
314
308
  function queueJob(job) {
315
309
  if (!(job.flags & 1)) {
316
- if (job.id == null) {
317
- queue.push(job);
318
- } else if (
319
- // fast path when the job id is larger than the tail
320
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
321
- ) {
310
+ const jobId = getId(job);
311
+ const lastJob = queue[queue.length - 1];
312
+ if (!lastJob || // fast path when the job id is larger than the tail
313
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
322
314
  queue.push(job);
323
315
  } else {
324
- queue.splice(findInsertionIndex(job.id), 0, job);
316
+ queue.splice(findInsertionIndex(jobId), 0, job);
325
317
  }
326
318
  if (!(job.flags & 4)) {
327
319
  job.flags |= 1;
@@ -335,12 +327,6 @@ function queueFlush() {
335
327
  currentFlushPromise = resolvedPromise.then(flushJobs);
336
328
  }
337
329
  }
338
- function invalidateJob(job) {
339
- const i = queue.indexOf(job);
340
- if (i > flushIndex) {
341
- queue.splice(i, 1);
342
- }
343
- }
344
330
  function queuePostFlushCb(cb) {
345
331
  if (!isArray(cb)) {
346
332
  if (activePostFlushCbs && cb.id === -1) {
@@ -402,24 +388,13 @@ function flushPostFlushCbs(seen) {
402
388
  postFlushIndex = 0;
403
389
  }
404
390
  }
405
- const getId = (job) => job.id == null ? Infinity : job.id;
406
- const comparator = (a, b) => {
407
- const diff = getId(a) - getId(b);
408
- if (diff === 0) {
409
- const isAPre = a.flags & 2;
410
- const isBPre = b.flags & 2;
411
- if (isAPre && !isBPre) return -1;
412
- if (isBPre && !isAPre) return 1;
413
- }
414
- return diff;
415
- };
391
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
416
392
  function flushJobs(seen) {
417
393
  isFlushPending = false;
418
394
  isFlushing = true;
419
395
  if (!!(process.env.NODE_ENV !== "production")) {
420
396
  seen = seen || /* @__PURE__ */ new Map();
421
397
  }
422
- queue.sort(comparator);
423
398
  const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
424
399
  try {
425
400
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -1449,7 +1424,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
1449
1424
  // @__NO_SIDE_EFFECTS__
1450
1425
  function defineComponent(options, extraOptions) {
1451
1426
  return isFunction(options) ? (
1452
- // #8326: extend call and options.name access are considered side-effects
1427
+ // #8236: extend call and options.name access are considered side-effects
1453
1428
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1454
1429
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
1455
1430
  ) : options;
@@ -2587,6 +2562,7 @@ const KeepAliveImpl = {
2587
2562
  );
2588
2563
  const { include, exclude, max } = props;
2589
2564
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
2565
+ vnode.shapeFlag &= ~256;
2590
2566
  current = vnode;
2591
2567
  return rawVNode;
2592
2568
  }
@@ -3524,16 +3500,20 @@ function callHook(hook, instance, type) {
3524
3500
  );
3525
3501
  }
3526
3502
  function createWatcher(raw, ctx, publicThis, key) {
3527
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
3503
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
3528
3504
  if (isString(raw)) {
3529
3505
  const handler = ctx[raw];
3530
3506
  if (isFunction(handler)) {
3531
- watch(getter, handler);
3507
+ {
3508
+ watch(getter, handler);
3509
+ }
3532
3510
  } else if (!!(process.env.NODE_ENV !== "production")) {
3533
3511
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
3534
3512
  }
3535
3513
  } else if (isFunction(raw)) {
3536
- watch(getter, raw.bind(publicThis));
3514
+ {
3515
+ watch(getter, raw.bind(publicThis));
3516
+ }
3537
3517
  } else if (isObject(raw)) {
3538
3518
  if (isArray(raw)) {
3539
3519
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -4800,7 +4780,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4800
4780
  if (!!(process.env.NODE_ENV !== "production") && subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
4801
4781
  subTree = filterSingleRoot(subTree.children) || subTree;
4802
4782
  }
4803
- if (vnode === subTree) {
4783
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
4804
4784
  const parentVNode = parentComponent.vnode;
4805
4785
  setScopeId(
4806
4786
  el,
@@ -5140,7 +5120,6 @@ function baseCreateRenderer(options, createHydrationFns) {
5140
5120
  return;
5141
5121
  } else {
5142
5122
  instance.next = n2;
5143
- invalidateJob(instance.update);
5144
5123
  instance.update();
5145
5124
  }
5146
5125
  } else {
@@ -6031,7 +6010,6 @@ function watchSyncEffect(effect, options) {
6031
6010
  !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
6032
6011
  );
6033
6012
  }
6034
- const INITIAL_WATCHER_VALUE = {};
6035
6013
  function watch(source, cb, options) {
6036
6014
  if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
6037
6015
  warn$1(
@@ -6040,21 +6018,8 @@ function watch(source, cb, options) {
6040
6018
  }
6041
6019
  return doWatch(source, cb, options);
6042
6020
  }
6043
- function doWatch(source, cb, {
6044
- immediate,
6045
- deep,
6046
- flush,
6047
- once,
6048
- onTrack,
6049
- onTrigger
6050
- } = EMPTY_OBJ) {
6051
- if (cb && once) {
6052
- const _cb = cb;
6053
- cb = (...args) => {
6054
- _cb(...args);
6055
- watchHandle();
6056
- };
6057
- }
6021
+ function doWatch(source, cb, options = EMPTY_OBJ) {
6022
+ const { immediate, deep, flush, once } = options;
6058
6023
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
6059
6024
  if (immediate !== void 0) {
6060
6025
  warn$1(
@@ -6072,163 +6037,53 @@ function doWatch(source, cb, {
6072
6037
  );
6073
6038
  }
6074
6039
  }
6075
- const warnInvalidSource = (s) => {
6076
- warn$1(
6077
- `Invalid watch source: `,
6078
- s,
6079
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
6080
- );
6081
- };
6082
- const instance = currentInstance;
6083
- const reactiveGetter = (source2) => {
6084
- if (deep) return source2;
6085
- if (isShallow(source2) || deep === false || deep === 0)
6086
- return traverse(source2, 1);
6087
- return traverse(source2);
6088
- };
6089
- let getter;
6090
- let forceTrigger = false;
6091
- let isMultiSource = false;
6092
- if (isRef(source)) {
6093
- getter = () => source.value;
6094
- forceTrigger = isShallow(source);
6095
- } else if (isReactive(source)) {
6096
- getter = () => reactiveGetter(source);
6097
- forceTrigger = true;
6098
- } else if (isArray(source)) {
6099
- isMultiSource = true;
6100
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
6101
- getter = () => source.map((s) => {
6102
- if (isRef(s)) {
6103
- return s.value;
6104
- } else if (isReactive(s)) {
6105
- return reactiveGetter(s);
6106
- } else if (isFunction(s)) {
6107
- return callWithErrorHandling(s, instance, 2);
6108
- } else {
6109
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
6110
- }
6111
- });
6112
- } else if (isFunction(source)) {
6113
- if (cb) {
6114
- getter = () => callWithErrorHandling(source, instance, 2);
6115
- } else {
6116
- getter = () => {
6117
- if (cleanup) {
6118
- cleanup();
6119
- }
6120
- return callWithAsyncErrorHandling(
6121
- source,
6122
- instance,
6123
- 3,
6124
- [onCleanup]
6125
- );
6126
- };
6127
- }
6128
- } else {
6129
- getter = NOOP;
6130
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
6131
- }
6132
- if (cb && deep) {
6133
- const baseGetter = getter;
6134
- const depth = deep === true ? Infinity : deep;
6135
- getter = () => traverse(baseGetter(), depth);
6136
- }
6137
- let cleanup;
6138
- let onCleanup = (fn) => {
6139
- cleanup = effect.onStop = () => {
6140
- callWithErrorHandling(fn, instance, 4);
6141
- cleanup = effect.onStop = void 0;
6142
- };
6143
- };
6040
+ const baseWatchOptions = extend({}, options);
6041
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn$1;
6144
6042
  let ssrCleanup;
6145
6043
  if (isInSSRComponentSetup) {
6146
- onCleanup = NOOP;
6147
- if (!cb) {
6148
- getter();
6149
- } else if (immediate) {
6150
- callWithAsyncErrorHandling(cb, instance, 3, [
6151
- getter(),
6152
- isMultiSource ? [] : void 0,
6153
- onCleanup
6154
- ]);
6155
- }
6156
6044
  if (flush === "sync") {
6157
6045
  const ctx = useSSRContext();
6158
6046
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
6047
+ } else if (!cb || immediate) {
6048
+ baseWatchOptions.once = true;
6159
6049
  } else {
6160
- const watchHandle2 = () => {
6050
+ return {
6051
+ stop: NOOP,
6052
+ resume: NOOP,
6053
+ pause: NOOP
6161
6054
  };
6162
- watchHandle2.stop = NOOP;
6163
- watchHandle2.resume = NOOP;
6164
- watchHandle2.pause = NOOP;
6165
- return watchHandle2;
6166
6055
  }
6167
6056
  }
6168
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
6169
- const job = (immediateFirstRun) => {
6170
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
6171
- return;
6172
- }
6173
- if (cb) {
6174
- const newValue = effect.run();
6175
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
6176
- if (cleanup) {
6177
- cleanup();
6178
- }
6179
- callWithAsyncErrorHandling(cb, instance, 3, [
6180
- newValue,
6181
- // pass undefined as the old value when it's changed for the first time
6182
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
6183
- onCleanup
6184
- ]);
6185
- oldValue = newValue;
6057
+ const instance = currentInstance;
6058
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
6059
+ let isPre = false;
6060
+ if (flush === "post") {
6061
+ baseWatchOptions.scheduler = (job) => {
6062
+ queuePostRenderEffect(job, instance && instance.suspense);
6063
+ };
6064
+ } else if (flush !== "sync") {
6065
+ isPre = true;
6066
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
6067
+ if (isFirstRun) {
6068
+ job();
6069
+ } else {
6070
+ queueJob(job);
6186
6071
  }
6187
- } else {
6188
- effect.run();
6189
- }
6190
- };
6191
- if (cb) job.flags |= 4;
6192
- const effect = new ReactiveEffect(getter);
6193
- let scheduler;
6194
- if (flush === "sync") {
6195
- scheduler = job;
6196
- } else if (flush === "post") {
6197
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
6198
- } else {
6199
- job.flags |= 2;
6200
- if (instance) job.id = instance.uid;
6201
- scheduler = () => queueJob(job);
6072
+ };
6202
6073
  }
6203
- effect.scheduler = scheduler;
6204
- const scope = getCurrentScope();
6205
- const watchHandle = () => {
6206
- effect.stop();
6207
- if (scope) {
6208
- remove(scope.effects, effect);
6074
+ baseWatchOptions.augmentJob = (job) => {
6075
+ if (cb) {
6076
+ job.flags |= 4;
6209
6077
  }
6210
- };
6211
- watchHandle.pause = effect.pause.bind(effect);
6212
- watchHandle.resume = effect.resume.bind(effect);
6213
- watchHandle.stop = watchHandle;
6214
- if (!!(process.env.NODE_ENV !== "production")) {
6215
- effect.onTrack = onTrack;
6216
- effect.onTrigger = onTrigger;
6217
- }
6218
- if (cb) {
6219
- if (immediate) {
6220
- job(true);
6221
- } else {
6222
- oldValue = effect.run();
6078
+ if (isPre) {
6079
+ job.flags |= 2;
6080
+ if (instance) {
6081
+ job.id = instance.uid;
6082
+ job.i = instance;
6083
+ }
6223
6084
  }
6224
- } else if (flush === "post") {
6225
- queuePostRenderEffect(
6226
- effect.run.bind(effect),
6227
- instance && instance.suspense
6228
- );
6229
- } else {
6230
- effect.run();
6231
- }
6085
+ };
6086
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
6232
6087
  if (ssrCleanup) ssrCleanup.push(watchHandle);
6233
6088
  return watchHandle;
6234
6089
  }
@@ -6257,38 +6112,6 @@ function createPathGetter(ctx, path) {
6257
6112
  return cur;
6258
6113
  };
6259
6114
  }
6260
- function traverse(value, depth = Infinity, seen) {
6261
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
6262
- return value;
6263
- }
6264
- seen = seen || /* @__PURE__ */ new Set();
6265
- if (seen.has(value)) {
6266
- return value;
6267
- }
6268
- seen.add(value);
6269
- depth--;
6270
- if (isRef(value)) {
6271
- traverse(value.value, depth, seen);
6272
- } else if (isArray(value)) {
6273
- for (let i = 0; i < value.length; i++) {
6274
- traverse(value[i], depth, seen);
6275
- }
6276
- } else if (isSet(value) || isMap(value)) {
6277
- value.forEach((v) => {
6278
- traverse(v, depth, seen);
6279
- });
6280
- } else if (isPlainObject(value)) {
6281
- for (const key in value) {
6282
- traverse(value[key], depth, seen);
6283
- }
6284
- for (const key of Object.getOwnPropertySymbols(value)) {
6285
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
6286
- traverse(value[key], depth, seen);
6287
- }
6288
- }
6289
- }
6290
- return value;
6291
- }
6292
6115
 
6293
6116
  function useModel(props, name, options = EMPTY_OBJ) {
6294
6117
  const i = getCurrentInstance();
@@ -8450,7 +8273,7 @@ function isMemoSame(cached, memo) {
8450
8273
  return true;
8451
8274
  }
8452
8275
 
8453
- const version = "3.5.0-beta.2";
8276
+ const version = "3.5.0-rc.1";
8454
8277
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
8455
8278
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8456
8279
  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.5.0-beta.2",
3
+ "version": "3.5.0-rc.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/reactivity": "3.5.0-beta.2",
50
- "@vue/shared": "3.5.0-beta.2"
49
+ "@vue/reactivity": "3.5.0-rc.1",
50
+ "@vue/shared": "3.5.0-rc.1"
51
51
  }
52
52
  }