@vue/runtime-core 3.5.0-beta.1 → 3.5.0-beta.3

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.1
2
+ * @vue/runtime-core v3.5.0-beta.3
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++) {
@@ -1568,6 +1543,7 @@ const logMismatchError = () => {
1568
1543
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
1569
1544
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
1570
1545
  const getContainerType = (container) => {
1546
+ if (container.nodeType !== 1) return void 0;
1571
1547
  if (isSVGContainer(container)) return "svg";
1572
1548
  if (isMathMLContainer(container)) return "mathml";
1573
1549
  return void 0;
@@ -2507,7 +2483,7 @@ const KeepAliveImpl = {
2507
2483
  function pruneCache(filter) {
2508
2484
  cache.forEach((vnode, key) => {
2509
2485
  const name = getComponentName(vnode.type);
2510
- if (name && (!filter || !filter(name))) {
2486
+ if (name && !filter(name)) {
2511
2487
  pruneCacheEntry(key);
2512
2488
  }
2513
2489
  });
@@ -2626,6 +2602,7 @@ function matches(pattern, name) {
2626
2602
  } else if (isString(pattern)) {
2627
2603
  return pattern.split(",").includes(name);
2628
2604
  } else if (isRegExp(pattern)) {
2605
+ pattern.lastIndex = 0;
2629
2606
  return pattern.test(name);
2630
2607
  }
2631
2608
  return false;
@@ -3522,16 +3499,20 @@ function callHook(hook, instance, type) {
3522
3499
  );
3523
3500
  }
3524
3501
  function createWatcher(raw, ctx, publicThis, key) {
3525
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
3502
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
3526
3503
  if (isString(raw)) {
3527
3504
  const handler = ctx[raw];
3528
3505
  if (isFunction(handler)) {
3529
- watch(getter, handler);
3506
+ {
3507
+ watch(getter, handler);
3508
+ }
3530
3509
  } else if (!!(process.env.NODE_ENV !== "production")) {
3531
3510
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
3532
3511
  }
3533
3512
  } else if (isFunction(raw)) {
3534
- watch(getter, raw.bind(publicThis));
3513
+ {
3514
+ watch(getter, raw.bind(publicThis));
3515
+ }
3535
3516
  } else if (isObject(raw)) {
3536
3517
  if (isArray(raw)) {
3537
3518
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -4798,7 +4779,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4798
4779
  if (!!(process.env.NODE_ENV !== "production") && subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
4799
4780
  subTree = filterSingleRoot(subTree.children) || subTree;
4800
4781
  }
4801
- if (vnode === subTree) {
4782
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
4802
4783
  const parentVNode = parentComponent.vnode;
4803
4784
  setScopeId(
4804
4785
  el,
@@ -5138,7 +5119,6 @@ function baseCreateRenderer(options, createHydrationFns) {
5138
5119
  return;
5139
5120
  } else {
5140
5121
  instance.next = n2;
5141
- invalidateJob(instance.update);
5142
5122
  instance.update();
5143
5123
  }
5144
5124
  } else {
@@ -6029,7 +6009,6 @@ function watchSyncEffect(effect, options) {
6029
6009
  !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
6030
6010
  );
6031
6011
  }
6032
- const INITIAL_WATCHER_VALUE = {};
6033
6012
  function watch(source, cb, options) {
6034
6013
  if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
6035
6014
  warn$1(
@@ -6038,21 +6017,8 @@ function watch(source, cb, options) {
6038
6017
  }
6039
6018
  return doWatch(source, cb, options);
6040
6019
  }
6041
- function doWatch(source, cb, {
6042
- immediate,
6043
- deep,
6044
- flush,
6045
- once,
6046
- onTrack,
6047
- onTrigger
6048
- } = EMPTY_OBJ) {
6049
- if (cb && once) {
6050
- const _cb = cb;
6051
- cb = (...args) => {
6052
- _cb(...args);
6053
- watchHandle();
6054
- };
6055
- }
6020
+ function doWatch(source, cb, options = EMPTY_OBJ) {
6021
+ const { immediate, deep, flush, once } = options;
6056
6022
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
6057
6023
  if (immediate !== void 0) {
6058
6024
  warn$1(
@@ -6070,164 +6036,53 @@ function doWatch(source, cb, {
6070
6036
  );
6071
6037
  }
6072
6038
  }
6073
- const warnInvalidSource = (s) => {
6074
- warn$1(
6075
- `Invalid watch source: `,
6076
- s,
6077
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
6078
- );
6079
- };
6080
- const instance = currentInstance;
6081
- const reactiveGetter = (source2) => {
6082
- if (deep) return source2;
6083
- if (isShallow(source2) || deep === false || deep === 0)
6084
- return traverse(source2, 1);
6085
- return traverse(source2);
6086
- };
6087
- let getter;
6088
- let forceTrigger = false;
6089
- let isMultiSource = false;
6090
- if (isRef(source)) {
6091
- getter = () => source.value;
6092
- forceTrigger = isShallow(source);
6093
- } else if (isReactive(source)) {
6094
- getter = () => reactiveGetter(source);
6095
- forceTrigger = true;
6096
- } else if (isArray(source)) {
6097
- isMultiSource = true;
6098
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
6099
- getter = () => source.map((s) => {
6100
- if (isRef(s)) {
6101
- return s.value;
6102
- } else if (isReactive(s)) {
6103
- return reactiveGetter(s);
6104
- } else if (isFunction(s)) {
6105
- return callWithErrorHandling(s, instance, 2);
6106
- } else {
6107
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
6108
- }
6109
- });
6110
- } else if (isFunction(source)) {
6111
- if (cb) {
6112
- getter = () => callWithErrorHandling(source, instance, 2);
6113
- } else {
6114
- getter = () => {
6115
- if (cleanup) {
6116
- cleanup();
6117
- }
6118
- return callWithAsyncErrorHandling(
6119
- source,
6120
- instance,
6121
- 3,
6122
- [onCleanup]
6123
- );
6124
- };
6125
- }
6126
- } else {
6127
- getter = NOOP;
6128
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
6129
- }
6130
- if (cb && deep) {
6131
- const baseGetter = getter;
6132
- const depth = deep === true ? Infinity : deep;
6133
- getter = () => traverse(baseGetter(), depth);
6134
- }
6135
- let cleanup;
6136
- let onCleanup = (fn) => {
6137
- cleanup = effect.onStop = () => {
6138
- callWithErrorHandling(fn, instance, 4);
6139
- cleanup = effect.onStop = void 0;
6140
- };
6141
- };
6039
+ const baseWatchOptions = extend({}, options);
6040
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn$1;
6142
6041
  let ssrCleanup;
6143
6042
  if (isInSSRComponentSetup) {
6144
- onCleanup = NOOP;
6145
- if (!cb) {
6146
- getter();
6147
- } else if (immediate) {
6148
- callWithAsyncErrorHandling(cb, instance, 3, [
6149
- getter(),
6150
- isMultiSource ? [] : void 0,
6151
- onCleanup
6152
- ]);
6153
- }
6154
6043
  if (flush === "sync") {
6155
6044
  const ctx = useSSRContext();
6156
6045
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
6046
+ } else if (!cb || immediate) {
6047
+ baseWatchOptions.once = true;
6157
6048
  } else {
6158
- const watchHandle2 = () => {
6049
+ return {
6050
+ stop: NOOP,
6051
+ resume: NOOP,
6052
+ pause: NOOP
6159
6053
  };
6160
- watchHandle2.stop = NOOP;
6161
- watchHandle2.resume = NOOP;
6162
- watchHandle2.pause = NOOP;
6163
- return watchHandle2;
6164
6054
  }
6165
6055
  }
6166
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
6167
- const job = (immediateFirstRun) => {
6168
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
6169
- return;
6170
- }
6171
- if (cb) {
6172
- const newValue = effect.run();
6173
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
6174
- if (cleanup) {
6175
- cleanup();
6176
- }
6177
- callWithAsyncErrorHandling(cb, instance, 3, [
6178
- newValue,
6179
- // pass undefined as the old value when it's changed for the first time
6180
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
6181
- onCleanup
6182
- ]);
6183
- oldValue = newValue;
6056
+ const instance = currentInstance;
6057
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
6058
+ let isPre = false;
6059
+ if (flush === "post") {
6060
+ baseWatchOptions.scheduler = (job) => {
6061
+ queuePostRenderEffect(job, instance && instance.suspense);
6062
+ };
6063
+ } else if (flush !== "sync") {
6064
+ isPre = true;
6065
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
6066
+ if (isFirstRun) {
6067
+ job();
6068
+ } else {
6069
+ queueJob(job);
6184
6070
  }
6185
- } else {
6186
- effect.run();
6187
- }
6188
- };
6189
- if (cb) job.flags |= 4;
6190
- const effect = new ReactiveEffect(getter);
6191
- let scheduler;
6192
- if (flush === "sync") {
6193
- effect.flags |= 64;
6194
- scheduler = job;
6195
- } else if (flush === "post") {
6196
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
6197
- } else {
6198
- job.flags |= 2;
6199
- if (instance) job.id = instance.uid;
6200
- scheduler = () => queueJob(job);
6071
+ };
6201
6072
  }
6202
- effect.scheduler = scheduler;
6203
- const scope = getCurrentScope();
6204
- const watchHandle = () => {
6205
- effect.stop();
6206
- if (scope) {
6207
- remove(scope.effects, effect);
6073
+ baseWatchOptions.augmentJob = (job) => {
6074
+ if (cb) {
6075
+ job.flags |= 4;
6208
6076
  }
6209
- };
6210
- watchHandle.pause = effect.pause.bind(effect);
6211
- watchHandle.resume = effect.resume.bind(effect);
6212
- watchHandle.stop = watchHandle;
6213
- if (!!(process.env.NODE_ENV !== "production")) {
6214
- effect.onTrack = onTrack;
6215
- effect.onTrigger = onTrigger;
6216
- }
6217
- if (cb) {
6218
- if (immediate) {
6219
- job(true);
6220
- } else {
6221
- oldValue = effect.run();
6077
+ if (isPre) {
6078
+ job.flags |= 2;
6079
+ if (instance) {
6080
+ job.id = instance.uid;
6081
+ job.i = instance;
6082
+ }
6222
6083
  }
6223
- } else if (flush === "post") {
6224
- queuePostRenderEffect(
6225
- effect.run.bind(effect),
6226
- instance && instance.suspense
6227
- );
6228
- } else {
6229
- effect.run();
6230
- }
6084
+ };
6085
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
6231
6086
  if (ssrCleanup) ssrCleanup.push(watchHandle);
6232
6087
  return watchHandle;
6233
6088
  }
@@ -6256,38 +6111,6 @@ function createPathGetter(ctx, path) {
6256
6111
  return cur;
6257
6112
  };
6258
6113
  }
6259
- function traverse(value, depth = Infinity, seen) {
6260
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
6261
- return value;
6262
- }
6263
- seen = seen || /* @__PURE__ */ new Set();
6264
- if (seen.has(value)) {
6265
- return value;
6266
- }
6267
- seen.add(value);
6268
- depth--;
6269
- if (isRef(value)) {
6270
- traverse(value.value, depth, seen);
6271
- } else if (isArray(value)) {
6272
- for (let i = 0; i < value.length; i++) {
6273
- traverse(value[i], depth, seen);
6274
- }
6275
- } else if (isSet(value) || isMap(value)) {
6276
- value.forEach((v) => {
6277
- traverse(v, depth, seen);
6278
- });
6279
- } else if (isPlainObject(value)) {
6280
- for (const key in value) {
6281
- traverse(value[key], depth, seen);
6282
- }
6283
- for (const key of Object.getOwnPropertySymbols(value)) {
6284
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
6285
- traverse(value[key], depth, seen);
6286
- }
6287
- }
6288
- }
6289
- return value;
6290
- }
6291
6114
 
6292
6115
  function useModel(props, name, options = EMPTY_OBJ) {
6293
6116
  const i = getCurrentInstance();
@@ -8449,7 +8272,7 @@ function isMemoSame(cached, memo) {
8449
8272
  return true;
8450
8273
  }
8451
8274
 
8452
- const version = "3.5.0-beta.1";
8275
+ const version = "3.5.0-beta.3";
8453
8276
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
8454
8277
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8455
8278
  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.1",
3
+ "version": "3.5.0-beta.3",
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.5.0-beta.1",
50
- "@vue/reactivity": "3.5.0-beta.1"
49
+ "@vue/shared": "3.5.0-beta.3",
50
+ "@vue/reactivity": "3.5.0-beta.3"
51
51
  }
52
52
  }