@vue/compat 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,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.0-beta.2
2
+ * @vue/compat v3.5.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -337,12 +337,13 @@ class EffectScope {
337
337
  pause() {
338
338
  if (this._active) {
339
339
  this._isPaused = true;
340
+ let i, l;
340
341
  if (this.scopes) {
341
- for (let i = 0, l = this.scopes.length; i < l; i++) {
342
+ for (i = 0, l = this.scopes.length; i < l; i++) {
342
343
  this.scopes[i].pause();
343
344
  }
344
345
  }
345
- for (let i = 0, l = this.effects.length; i < l; i++) {
346
+ for (i = 0, l = this.effects.length; i < l; i++) {
346
347
  this.effects[i].pause();
347
348
  }
348
349
  }
@@ -354,12 +355,13 @@ class EffectScope {
354
355
  if (this._active) {
355
356
  if (this._isPaused) {
356
357
  this._isPaused = false;
358
+ let i, l;
357
359
  if (this.scopes) {
358
- for (let i = 0, l = this.scopes.length; i < l; i++) {
360
+ for (i = 0, l = this.scopes.length; i < l; i++) {
359
361
  this.scopes[i].resume();
360
362
  }
361
363
  }
362
- for (let i = 0, l = this.effects.length; i < l; i++) {
364
+ for (i = 0, l = this.effects.length; i < l; i++) {
363
365
  this.effects[i].resume();
364
366
  }
365
367
  }
@@ -552,11 +554,9 @@ function startBatch() {
552
554
  batchDepth++;
553
555
  }
554
556
  function endBatch() {
555
- if (batchDepth > 1) {
556
- batchDepth--;
557
+ if (--batchDepth > 0) {
557
558
  return;
558
559
  }
559
- batchDepth--;
560
560
  let error;
561
561
  while (batchedEffect) {
562
562
  let e = batchedEffect;
@@ -1070,14 +1070,14 @@ function iterator(self, method, wrapValue) {
1070
1070
  const arrayProto = Array.prototype;
1071
1071
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1072
1072
  const arr = shallowReadArray(self);
1073
- let methodFn;
1074
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1075
- return methodFn.apply(arr, args);
1073
+ const needsWrap = arr !== self && !isShallow(self);
1074
+ const methodFn = arr[method];
1075
+ if (methodFn !== arrayProto[method]) {
1076
+ const result2 = methodFn.apply(arr, args);
1077
+ return needsWrap ? toReactive(result2) : result2;
1076
1078
  }
1077
- let needsWrap = false;
1078
1079
  let wrappedFn = fn;
1079
1080
  if (arr !== self) {
1080
- needsWrap = !isShallow(self);
1081
1081
  if (needsWrap) {
1082
1082
  wrappedFn = function(item, index) {
1083
1083
  return fn.call(this, toReactive(item), index, self);
@@ -1215,7 +1215,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1215
1215
  }
1216
1216
  }
1217
1217
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1218
- const result = Reflect.set(target, key, value, receiver);
1218
+ const result = Reflect.set(
1219
+ target,
1220
+ key,
1221
+ value,
1222
+ isRef(target) ? target : receiver
1223
+ );
1219
1224
  if (target === toRaw(receiver)) {
1220
1225
  if (!hadKey) {
1221
1226
  trigger(target, "add", key, value);
@@ -1939,6 +1944,220 @@ const TriggerOpTypes = {
1939
1944
  "CLEAR": "clear"
1940
1945
  };
1941
1946
 
1947
+ const INITIAL_WATCHER_VALUE = {};
1948
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1949
+ let activeWatcher = void 0;
1950
+ function getCurrentWatcher() {
1951
+ return activeWatcher;
1952
+ }
1953
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1954
+ if (owner) {
1955
+ let cleanups = cleanupMap.get(owner);
1956
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1957
+ cleanups.push(cleanupFn);
1958
+ } else if (!failSilently) {
1959
+ warn$2(
1960
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1961
+ );
1962
+ }
1963
+ }
1964
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1965
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1966
+ const warnInvalidSource = (s) => {
1967
+ (options.onWarn || warn$2)(
1968
+ `Invalid watch source: `,
1969
+ s,
1970
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1971
+ );
1972
+ };
1973
+ const reactiveGetter = (source2) => {
1974
+ if (deep) return source2;
1975
+ if (isShallow(source2) || deep === false || deep === 0)
1976
+ return traverse(source2, 1);
1977
+ return traverse(source2);
1978
+ };
1979
+ let effect;
1980
+ let getter;
1981
+ let cleanup;
1982
+ let boundCleanup;
1983
+ let forceTrigger = false;
1984
+ let isMultiSource = false;
1985
+ if (isRef(source)) {
1986
+ getter = () => source.value;
1987
+ forceTrigger = isShallow(source);
1988
+ } else if (isReactive(source)) {
1989
+ getter = () => reactiveGetter(source);
1990
+ forceTrigger = true;
1991
+ } else if (isArray(source)) {
1992
+ isMultiSource = true;
1993
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1994
+ getter = () => source.map((s) => {
1995
+ if (isRef(s)) {
1996
+ return s.value;
1997
+ } else if (isReactive(s)) {
1998
+ return reactiveGetter(s);
1999
+ } else if (isFunction(s)) {
2000
+ return call ? call(s, 2) : s();
2001
+ } else {
2002
+ warnInvalidSource(s);
2003
+ }
2004
+ });
2005
+ } else if (isFunction(source)) {
2006
+ if (cb) {
2007
+ getter = call ? () => call(source, 2) : source;
2008
+ } else {
2009
+ getter = () => {
2010
+ if (cleanup) {
2011
+ pauseTracking();
2012
+ try {
2013
+ cleanup();
2014
+ } finally {
2015
+ resetTracking();
2016
+ }
2017
+ }
2018
+ const currentEffect = activeWatcher;
2019
+ activeWatcher = effect;
2020
+ try {
2021
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2022
+ } finally {
2023
+ activeWatcher = currentEffect;
2024
+ }
2025
+ };
2026
+ }
2027
+ } else {
2028
+ getter = NOOP;
2029
+ warnInvalidSource(source);
2030
+ }
2031
+ if (cb && deep) {
2032
+ const baseGetter = getter;
2033
+ const depth = deep === true ? Infinity : deep;
2034
+ getter = () => traverse(baseGetter(), depth);
2035
+ }
2036
+ const scope = getCurrentScope();
2037
+ const watchHandle = () => {
2038
+ effect.stop();
2039
+ if (scope) {
2040
+ remove(scope.effects, effect);
2041
+ }
2042
+ };
2043
+ if (once) {
2044
+ if (cb) {
2045
+ const _cb = cb;
2046
+ cb = (...args) => {
2047
+ _cb(...args);
2048
+ watchHandle();
2049
+ };
2050
+ } else {
2051
+ const _getter = getter;
2052
+ getter = () => {
2053
+ _getter();
2054
+ watchHandle();
2055
+ };
2056
+ }
2057
+ }
2058
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2059
+ const job = (immediateFirstRun) => {
2060
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2061
+ return;
2062
+ }
2063
+ if (cb) {
2064
+ const newValue = effect.run();
2065
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2066
+ if (cleanup) {
2067
+ cleanup();
2068
+ }
2069
+ const currentWatcher = activeWatcher;
2070
+ activeWatcher = effect;
2071
+ try {
2072
+ const args = [
2073
+ newValue,
2074
+ // pass undefined as the old value when it's changed for the first time
2075
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2076
+ boundCleanup
2077
+ ];
2078
+ call ? call(cb, 3, args) : (
2079
+ // @ts-expect-error
2080
+ cb(...args)
2081
+ );
2082
+ oldValue = newValue;
2083
+ } finally {
2084
+ activeWatcher = currentWatcher;
2085
+ }
2086
+ }
2087
+ } else {
2088
+ effect.run();
2089
+ }
2090
+ };
2091
+ if (augmentJob) {
2092
+ augmentJob(job);
2093
+ }
2094
+ effect = new ReactiveEffect(getter);
2095
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2096
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2097
+ cleanup = effect.onStop = () => {
2098
+ const cleanups = cleanupMap.get(effect);
2099
+ if (cleanups) {
2100
+ if (call) {
2101
+ call(cleanups, 4);
2102
+ } else {
2103
+ for (const cleanup2 of cleanups) cleanup2();
2104
+ }
2105
+ cleanupMap.delete(effect);
2106
+ }
2107
+ };
2108
+ {
2109
+ effect.onTrack = options.onTrack;
2110
+ effect.onTrigger = options.onTrigger;
2111
+ }
2112
+ if (cb) {
2113
+ if (immediate) {
2114
+ job(true);
2115
+ } else {
2116
+ oldValue = effect.run();
2117
+ }
2118
+ } else if (scheduler) {
2119
+ scheduler(job.bind(null, true), true);
2120
+ } else {
2121
+ effect.run();
2122
+ }
2123
+ watchHandle.pause = effect.pause.bind(effect);
2124
+ watchHandle.resume = effect.resume.bind(effect);
2125
+ watchHandle.stop = watchHandle;
2126
+ return watchHandle;
2127
+ }
2128
+ function traverse(value, depth = Infinity, seen) {
2129
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2130
+ return value;
2131
+ }
2132
+ seen = seen || /* @__PURE__ */ new Set();
2133
+ if (seen.has(value)) {
2134
+ return value;
2135
+ }
2136
+ seen.add(value);
2137
+ depth--;
2138
+ if (isRef(value)) {
2139
+ traverse(value.value, depth, seen);
2140
+ } else if (isArray(value)) {
2141
+ for (let i = 0; i < value.length; i++) {
2142
+ traverse(value[i], depth, seen);
2143
+ }
2144
+ } else if (isSet(value) || isMap(value)) {
2145
+ value.forEach((v) => {
2146
+ traverse(v, depth, seen);
2147
+ });
2148
+ } else if (isPlainObject(value)) {
2149
+ for (const key in value) {
2150
+ traverse(value[key], depth, seen);
2151
+ }
2152
+ for (const key of Object.getOwnPropertySymbols(value)) {
2153
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2154
+ traverse(value[key], depth, seen);
2155
+ }
2156
+ }
2157
+ }
2158
+ return value;
2159
+ }
2160
+
1942
2161
  const stack = [];
1943
2162
  function pushWarningContext(vnode) {
1944
2163
  stack.push(vnode);
@@ -2066,12 +2285,6 @@ const ErrorCodes = {
2066
2285
  "0": "SETUP_FUNCTION",
2067
2286
  "RENDER_FUNCTION": 1,
2068
2287
  "1": "RENDER_FUNCTION",
2069
- "WATCH_GETTER": 2,
2070
- "2": "WATCH_GETTER",
2071
- "WATCH_CALLBACK": 3,
2072
- "3": "WATCH_CALLBACK",
2073
- "WATCH_CLEANUP": 4,
2074
- "4": "WATCH_CLEANUP",
2075
2288
  "NATIVE_EVENT_HANDLER": 5,
2076
2289
  "5": "NATIVE_EVENT_HANDLER",
2077
2290
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2223,7 +2436,7 @@ function nextTick(fn) {
2223
2436
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2224
2437
  }
2225
2438
  function findInsertionIndex(id) {
2226
- let start = flushIndex + 1;
2439
+ let start = isFlushing ? flushIndex + 1 : 0;
2227
2440
  let end = queue.length;
2228
2441
  while (start < end) {
2229
2442
  const middle = start + end >>> 1;
@@ -2239,15 +2452,13 @@ function findInsertionIndex(id) {
2239
2452
  }
2240
2453
  function queueJob(job) {
2241
2454
  if (!(job.flags & 1)) {
2242
- if (job.id == null) {
2243
- queue.push(job);
2244
- } else if (
2245
- // fast path when the job id is larger than the tail
2246
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2247
- ) {
2455
+ const jobId = getId(job);
2456
+ const lastJob = queue[queue.length - 1];
2457
+ if (!lastJob || // fast path when the job id is larger than the tail
2458
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2248
2459
  queue.push(job);
2249
2460
  } else {
2250
- queue.splice(findInsertionIndex(job.id), 0, job);
2461
+ queue.splice(findInsertionIndex(jobId), 0, job);
2251
2462
  }
2252
2463
  if (!(job.flags & 4)) {
2253
2464
  job.flags |= 1;
@@ -2261,12 +2472,6 @@ function queueFlush() {
2261
2472
  currentFlushPromise = resolvedPromise.then(flushJobs);
2262
2473
  }
2263
2474
  }
2264
- function invalidateJob(job) {
2265
- const i = queue.indexOf(job);
2266
- if (i > flushIndex) {
2267
- queue.splice(i, 1);
2268
- }
2269
- }
2270
2475
  function queuePostFlushCb(cb) {
2271
2476
  if (!isArray(cb)) {
2272
2477
  if (activePostFlushCbs && cb.id === -1) {
@@ -2328,24 +2533,13 @@ function flushPostFlushCbs(seen) {
2328
2533
  postFlushIndex = 0;
2329
2534
  }
2330
2535
  }
2331
- const getId = (job) => job.id == null ? Infinity : job.id;
2332
- const comparator = (a, b) => {
2333
- const diff = getId(a) - getId(b);
2334
- if (diff === 0) {
2335
- const isAPre = a.flags & 2;
2336
- const isBPre = b.flags & 2;
2337
- if (isAPre && !isBPre) return -1;
2338
- if (isBPre && !isAPre) return 1;
2339
- }
2340
- return diff;
2341
- };
2536
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2342
2537
  function flushJobs(seen) {
2343
2538
  isFlushPending = false;
2344
2539
  isFlushing = true;
2345
2540
  {
2346
2541
  seen = seen || /* @__PURE__ */ new Map();
2347
2542
  }
2348
- queue.sort(comparator);
2349
2543
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2350
2544
  try {
2351
2545
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -2986,7 +3180,7 @@ function on(instance, event, fn) {
2986
3180
  function once(instance, event, fn) {
2987
3181
  const wrapped = (...args) => {
2988
3182
  off(instance, event, wrapped);
2989
- fn.call(instance.proxy, ...args);
3183
+ fn.apply(instance.proxy, args);
2990
3184
  };
2991
3185
  wrapped.fn = fn;
2992
3186
  on(instance, event, wrapped);
@@ -3905,7 +4099,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3905
4099
  // @__NO_SIDE_EFFECTS__
3906
4100
  function defineComponent(options, extraOptions) {
3907
4101
  return isFunction(options) ? (
3908
- // #8326: extend call and options.name access are considered side-effects
4102
+ // #8236: extend call and options.name access are considered side-effects
3909
4103
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
3910
4104
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
3911
4105
  ) : options;
@@ -5032,6 +5226,7 @@ const KeepAliveImpl = {
5032
5226
  );
5033
5227
  const { include, exclude, max } = props;
5034
5228
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
5229
+ vnode.shapeFlag &= ~256;
5035
5230
  current = vnode;
5036
5231
  return rawVNode;
5037
5232
  }
@@ -6520,23 +6715,43 @@ function callHook$1(hook, instance, type) {
6520
6715
  );
6521
6716
  }
6522
6717
  function createWatcher(raw, ctx, publicThis, key) {
6523
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6718
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6719
+ const options = {};
6720
+ {
6721
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6722
+ const newValue = getter();
6723
+ if (isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
6724
+ options.deep = true;
6725
+ }
6726
+ const baseGetter = getter;
6727
+ getter = () => {
6728
+ const val = baseGetter();
6729
+ if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
6730
+ traverse(val);
6731
+ }
6732
+ return val;
6733
+ };
6734
+ }
6524
6735
  if (isString(raw)) {
6525
6736
  const handler = ctx[raw];
6526
6737
  if (isFunction(handler)) {
6527
- watch(getter, handler);
6738
+ {
6739
+ watch(getter, handler, options);
6740
+ }
6528
6741
  } else {
6529
6742
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6530
6743
  }
6531
6744
  } else if (isFunction(raw)) {
6532
- watch(getter, raw.bind(publicThis));
6745
+ {
6746
+ watch(getter, raw.bind(publicThis), options);
6747
+ }
6533
6748
  } else if (isObject(raw)) {
6534
6749
  if (isArray(raw)) {
6535
6750
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6536
6751
  } else {
6537
6752
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6538
6753
  if (isFunction(handler)) {
6539
- watch(getter, handler, raw);
6754
+ watch(getter, handler, extend(raw, options) );
6540
6755
  } else {
6541
6756
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6542
6757
  }
@@ -6760,7 +6975,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6760
6975
  return vm;
6761
6976
  }
6762
6977
  }
6763
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
6978
+ Vue.version = `2.6.14-compat:${"3.5.0-rc.1"}`;
6764
6979
  Vue.config = singletonApp.config;
6765
6980
  Vue.use = (plugin, ...options) => {
6766
6981
  if (plugin && isFunction(plugin.install)) {
@@ -7092,7 +7307,7 @@ function defineReactive(obj, key, val) {
7092
7307
  if (isArray(val)) {
7093
7308
  methodsToPatch.forEach((m) => {
7094
7309
  val[m] = (...args) => {
7095
- Array.prototype[m].call(reactiveVal, ...args);
7310
+ Array.prototype[m].apply(reactiveVal, args);
7096
7311
  };
7097
7312
  });
7098
7313
  } else {
@@ -8287,7 +8502,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8287
8502
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8288
8503
  subTree = filterSingleRoot(subTree.children) || subTree;
8289
8504
  }
8290
- if (vnode === subTree) {
8505
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8291
8506
  const parentVNode = parentComponent.vnode;
8292
8507
  setScopeId(
8293
8508
  el,
@@ -8617,7 +8832,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8617
8832
  return;
8618
8833
  } else {
8619
8834
  instance.next = n2;
8620
- invalidateJob(instance.update);
8621
8835
  instance.update();
8622
8836
  }
8623
8837
  } else {
@@ -9541,7 +9755,6 @@ function watchSyncEffect(effect, options) {
9541
9755
  extend({}, options, { flush: "sync" })
9542
9756
  );
9543
9757
  }
9544
- const INITIAL_WATCHER_VALUE = {};
9545
9758
  function watch(source, cb, options) {
9546
9759
  if (!isFunction(cb)) {
9547
9760
  warn$1(
@@ -9550,21 +9763,8 @@ function watch(source, cb, options) {
9550
9763
  }
9551
9764
  return doWatch(source, cb, options);
9552
9765
  }
9553
- function doWatch(source, cb, {
9554
- immediate,
9555
- deep,
9556
- flush,
9557
- once,
9558
- onTrack,
9559
- onTrigger
9560
- } = EMPTY_OBJ) {
9561
- if (cb && once) {
9562
- const _cb = cb;
9563
- cb = (...args) => {
9564
- _cb(...args);
9565
- watchHandle();
9566
- };
9567
- }
9766
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9767
+ const { immediate, deep, flush, once } = options;
9568
9768
  if (!cb) {
9569
9769
  if (immediate !== void 0) {
9570
9770
  warn$1(
@@ -9582,173 +9782,53 @@ function doWatch(source, cb, {
9582
9782
  );
9583
9783
  }
9584
9784
  }
9585
- const warnInvalidSource = (s) => {
9586
- warn$1(
9587
- `Invalid watch source: `,
9588
- s,
9589
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9590
- );
9591
- };
9592
- const instance = currentInstance;
9593
- const reactiveGetter = (source2) => {
9594
- if (deep) return source2;
9595
- if (isShallow(source2) || deep === false || deep === 0)
9596
- return traverse(source2, 1);
9597
- return traverse(source2);
9598
- };
9599
- let getter;
9600
- let forceTrigger = false;
9601
- let isMultiSource = false;
9602
- if (isRef(source)) {
9603
- getter = () => source.value;
9604
- forceTrigger = isShallow(source);
9605
- } else if (isReactive(source)) {
9606
- getter = () => reactiveGetter(source);
9607
- forceTrigger = true;
9608
- } else if (isArray(source)) {
9609
- isMultiSource = true;
9610
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9611
- getter = () => source.map((s) => {
9612
- if (isRef(s)) {
9613
- return s.value;
9614
- } else if (isReactive(s)) {
9615
- return reactiveGetter(s);
9616
- } else if (isFunction(s)) {
9617
- return callWithErrorHandling(s, instance, 2);
9618
- } else {
9619
- warnInvalidSource(s);
9620
- }
9621
- });
9622
- } else if (isFunction(source)) {
9623
- if (cb) {
9624
- getter = () => callWithErrorHandling(source, instance, 2);
9625
- } else {
9626
- getter = () => {
9627
- if (cleanup) {
9628
- cleanup();
9629
- }
9630
- return callWithAsyncErrorHandling(
9631
- source,
9632
- instance,
9633
- 3,
9634
- [onCleanup]
9635
- );
9636
- };
9637
- }
9638
- } else {
9639
- getter = NOOP;
9640
- warnInvalidSource(source);
9641
- }
9642
- if (cb && !deep) {
9643
- const baseGetter = getter;
9644
- getter = () => {
9645
- const val = baseGetter();
9646
- if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
9647
- traverse(val);
9648
- }
9649
- return val;
9650
- };
9651
- }
9652
- if (cb && deep) {
9653
- const baseGetter = getter;
9654
- const depth = deep === true ? Infinity : deep;
9655
- getter = () => traverse(baseGetter(), depth);
9656
- }
9657
- let cleanup;
9658
- let onCleanup = (fn) => {
9659
- cleanup = effect.onStop = () => {
9660
- callWithErrorHandling(fn, instance, 4);
9661
- cleanup = effect.onStop = void 0;
9662
- };
9663
- };
9785
+ const baseWatchOptions = extend({}, options);
9786
+ baseWatchOptions.onWarn = warn$1;
9664
9787
  let ssrCleanup;
9665
9788
  if (isInSSRComponentSetup) {
9666
- onCleanup = NOOP;
9667
- if (!cb) {
9668
- getter();
9669
- } else if (immediate) {
9670
- callWithAsyncErrorHandling(cb, instance, 3, [
9671
- getter(),
9672
- isMultiSource ? [] : void 0,
9673
- onCleanup
9674
- ]);
9675
- }
9676
9789
  if (flush === "sync") {
9677
9790
  const ctx = useSSRContext();
9678
9791
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9792
+ } else if (!cb || immediate) {
9793
+ baseWatchOptions.once = true;
9679
9794
  } else {
9680
- const watchHandle2 = () => {
9795
+ return {
9796
+ stop: NOOP,
9797
+ resume: NOOP,
9798
+ pause: NOOP
9681
9799
  };
9682
- watchHandle2.stop = NOOP;
9683
- watchHandle2.resume = NOOP;
9684
- watchHandle2.pause = NOOP;
9685
- return watchHandle2;
9686
9800
  }
9687
9801
  }
9688
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9689
- const job = (immediateFirstRun) => {
9690
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9691
- return;
9692
- }
9693
- if (cb) {
9694
- const newValue = effect.run();
9695
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
9696
- if (cleanup) {
9697
- cleanup();
9698
- }
9699
- callWithAsyncErrorHandling(cb, instance, 3, [
9700
- newValue,
9701
- // pass undefined as the old value when it's changed for the first time
9702
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9703
- onCleanup
9704
- ]);
9705
- oldValue = newValue;
9802
+ const instance = currentInstance;
9803
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9804
+ let isPre = false;
9805
+ if (flush === "post") {
9806
+ baseWatchOptions.scheduler = (job) => {
9807
+ queuePostRenderEffect(job, instance && instance.suspense);
9808
+ };
9809
+ } else if (flush !== "sync") {
9810
+ isPre = true;
9811
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9812
+ if (isFirstRun) {
9813
+ job();
9814
+ } else {
9815
+ queueJob(job);
9706
9816
  }
9707
- } else {
9708
- effect.run();
9709
- }
9710
- };
9711
- if (cb) job.flags |= 4;
9712
- const effect = new ReactiveEffect(getter);
9713
- let scheduler;
9714
- if (flush === "sync") {
9715
- scheduler = job;
9716
- } else if (flush === "post") {
9717
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9718
- } else {
9719
- job.flags |= 2;
9720
- if (instance) job.id = instance.uid;
9721
- scheduler = () => queueJob(job);
9817
+ };
9722
9818
  }
9723
- effect.scheduler = scheduler;
9724
- const scope = getCurrentScope();
9725
- const watchHandle = () => {
9726
- effect.stop();
9727
- if (scope) {
9728
- remove(scope.effects, effect);
9819
+ baseWatchOptions.augmentJob = (job) => {
9820
+ if (cb) {
9821
+ job.flags |= 4;
9729
9822
  }
9730
- };
9731
- watchHandle.pause = effect.pause.bind(effect);
9732
- watchHandle.resume = effect.resume.bind(effect);
9733
- watchHandle.stop = watchHandle;
9734
- {
9735
- effect.onTrack = onTrack;
9736
- effect.onTrigger = onTrigger;
9737
- }
9738
- if (cb) {
9739
- if (immediate) {
9740
- job(true);
9741
- } else {
9742
- oldValue = effect.run();
9823
+ if (isPre) {
9824
+ job.flags |= 2;
9825
+ if (instance) {
9826
+ job.id = instance.uid;
9827
+ job.i = instance;
9828
+ }
9743
9829
  }
9744
- } else if (flush === "post") {
9745
- queuePostRenderEffect(
9746
- effect.run.bind(effect),
9747
- instance && instance.suspense
9748
- );
9749
- } else {
9750
- effect.run();
9751
- }
9830
+ };
9831
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9752
9832
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9753
9833
  return watchHandle;
9754
9834
  }
@@ -9777,38 +9857,6 @@ function createPathGetter(ctx, path) {
9777
9857
  return cur;
9778
9858
  };
9779
9859
  }
9780
- function traverse(value, depth = Infinity, seen) {
9781
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9782
- return value;
9783
- }
9784
- seen = seen || /* @__PURE__ */ new Set();
9785
- if (seen.has(value)) {
9786
- return value;
9787
- }
9788
- seen.add(value);
9789
- depth--;
9790
- if (isRef(value)) {
9791
- traverse(value.value, depth, seen);
9792
- } else if (isArray(value)) {
9793
- for (let i = 0; i < value.length; i++) {
9794
- traverse(value[i], depth, seen);
9795
- }
9796
- } else if (isSet(value) || isMap(value)) {
9797
- value.forEach((v) => {
9798
- traverse(v, depth, seen);
9799
- });
9800
- } else if (isPlainObject(value)) {
9801
- for (const key in value) {
9802
- traverse(value[key], depth, seen);
9803
- }
9804
- for (const key of Object.getOwnPropertySymbols(value)) {
9805
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9806
- traverse(value[key], depth, seen);
9807
- }
9808
- }
9809
- }
9810
- return value;
9811
- }
9812
9860
 
9813
9861
  function useModel(props, name, options = EMPTY_OBJ) {
9814
9862
  const i = getCurrentInstance();
@@ -12063,7 +12111,7 @@ function isMemoSame(cached, memo) {
12063
12111
  return true;
12064
12112
  }
12065
12113
 
12066
- const version = "3.5.0-beta.2";
12114
+ const version = "3.5.0-rc.1";
12067
12115
  const warn = warn$1 ;
12068
12116
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12069
12117
  const devtools = devtools$1 ;
@@ -12762,8 +12810,9 @@ function compatCoerceAttr(el, key, value, instance = null) {
12762
12810
 
12763
12811
  function patchDOMProp(el, key, value, parentComponent) {
12764
12812
  if (key === "innerHTML" || key === "textContent") {
12765
- if (value == null) return;
12766
- el[key] = value;
12813
+ if (value != null) {
12814
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
12815
+ }
12767
12816
  return;
12768
12817
  }
12769
12818
  const tag = el.tagName;
@@ -13206,6 +13255,9 @@ class VueElement extends BaseClass {
13206
13255
  delete this._props[key];
13207
13256
  } else {
13208
13257
  this._props[key] = val;
13258
+ if (key === "key" && this._app) {
13259
+ this._app._ceVNode.key = val;
13260
+ }
13209
13261
  }
13210
13262
  if (shouldUpdate && this._instance) {
13211
13263
  this._update();
@@ -14105,6 +14157,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14105
14157
  effectScope: effectScope,
14106
14158
  getCurrentInstance: getCurrentInstance,
14107
14159
  getCurrentScope: getCurrentScope,
14160
+ getCurrentWatcher: getCurrentWatcher,
14108
14161
  getTransitionRawChildren: getTransitionRawChildren,
14109
14162
  guardReactiveProps: guardReactiveProps,
14110
14163
  h: h,
@@ -14147,6 +14200,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14147
14200
  onServerPrefetch: onServerPrefetch,
14148
14201
  onUnmounted: onUnmounted,
14149
14202
  onUpdated: onUpdated,
14203
+ onWatcherCleanup: onWatcherCleanup,
14150
14204
  openBlock: openBlock,
14151
14205
  popScopeId: popScopeId,
14152
14206
  provide: provide,
@@ -14260,4 +14314,4 @@ Vue.compile = () => {
14260
14314
 
14261
14315
  const configureCompat = Vue.configureCompat;
14262
14316
 
14263
- export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, hydrateOnIdle, hydrateOnInteraction, hydrateOnMediaQuery, hydrateOnVisible, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useHost, useId, useModel, useSSRContext, useShadowRoot, useSlots, useTemplateRef, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
14317
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getCurrentWatcher, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, hydrateOnIdle, hydrateOnInteraction, hydrateOnMediaQuery, hydrateOnVisible, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, onWatcherCleanup, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useHost, useId, useModel, useSSRContext, useShadowRoot, useSlots, useTemplateRef, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };