@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;
@@ -1074,14 +1074,14 @@ function iterator(self, method, wrapValue) {
1074
1074
  const arrayProto = Array.prototype;
1075
1075
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1076
1076
  const arr = shallowReadArray(self);
1077
- let methodFn;
1078
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1079
- return methodFn.apply(arr, args);
1077
+ const needsWrap = arr !== self && !isShallow(self);
1078
+ const methodFn = arr[method];
1079
+ if (methodFn !== arrayProto[method]) {
1080
+ const result2 = methodFn.apply(arr, args);
1081
+ return needsWrap ? toReactive(result2) : result2;
1080
1082
  }
1081
- let needsWrap = false;
1082
1083
  let wrappedFn = fn;
1083
1084
  if (arr !== self) {
1084
- needsWrap = !isShallow(self);
1085
1085
  if (needsWrap) {
1086
1086
  wrappedFn = function(item, index) {
1087
1087
  return fn.call(this, toReactive(item), index, self);
@@ -1219,7 +1219,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1219
1219
  }
1220
1220
  }
1221
1221
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1222
- const result = Reflect.set(target, key, value, receiver);
1222
+ const result = Reflect.set(
1223
+ target,
1224
+ key,
1225
+ value,
1226
+ isRef(target) ? target : receiver
1227
+ );
1223
1228
  if (target === toRaw(receiver)) {
1224
1229
  if (!hadKey) {
1225
1230
  trigger(target, "add", key, value);
@@ -1949,6 +1954,220 @@ const TriggerOpTypes = {
1949
1954
  "CLEAR": "clear"
1950
1955
  };
1951
1956
 
1957
+ const INITIAL_WATCHER_VALUE = {};
1958
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1959
+ let activeWatcher = void 0;
1960
+ function getCurrentWatcher() {
1961
+ return activeWatcher;
1962
+ }
1963
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1964
+ if (owner) {
1965
+ let cleanups = cleanupMap.get(owner);
1966
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1967
+ cleanups.push(cleanupFn);
1968
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
1969
+ warn$2(
1970
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1971
+ );
1972
+ }
1973
+ }
1974
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1975
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1976
+ const warnInvalidSource = (s) => {
1977
+ (options.onWarn || warn$2)(
1978
+ `Invalid watch source: `,
1979
+ s,
1980
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1981
+ );
1982
+ };
1983
+ const reactiveGetter = (source2) => {
1984
+ if (deep) return source2;
1985
+ if (isShallow(source2) || deep === false || deep === 0)
1986
+ return traverse(source2, 1);
1987
+ return traverse(source2);
1988
+ };
1989
+ let effect;
1990
+ let getter;
1991
+ let cleanup;
1992
+ let boundCleanup;
1993
+ let forceTrigger = false;
1994
+ let isMultiSource = false;
1995
+ if (isRef(source)) {
1996
+ getter = () => source.value;
1997
+ forceTrigger = isShallow(source);
1998
+ } else if (isReactive(source)) {
1999
+ getter = () => reactiveGetter(source);
2000
+ forceTrigger = true;
2001
+ } else if (isArray(source)) {
2002
+ isMultiSource = true;
2003
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2004
+ getter = () => source.map((s) => {
2005
+ if (isRef(s)) {
2006
+ return s.value;
2007
+ } else if (isReactive(s)) {
2008
+ return reactiveGetter(s);
2009
+ } else if (isFunction(s)) {
2010
+ return call ? call(s, 2) : s();
2011
+ } else {
2012
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
2013
+ }
2014
+ });
2015
+ } else if (isFunction(source)) {
2016
+ if (cb) {
2017
+ getter = call ? () => call(source, 2) : source;
2018
+ } else {
2019
+ getter = () => {
2020
+ if (cleanup) {
2021
+ pauseTracking();
2022
+ try {
2023
+ cleanup();
2024
+ } finally {
2025
+ resetTracking();
2026
+ }
2027
+ }
2028
+ const currentEffect = activeWatcher;
2029
+ activeWatcher = effect;
2030
+ try {
2031
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2032
+ } finally {
2033
+ activeWatcher = currentEffect;
2034
+ }
2035
+ };
2036
+ }
2037
+ } else {
2038
+ getter = NOOP;
2039
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
2040
+ }
2041
+ if (cb && deep) {
2042
+ const baseGetter = getter;
2043
+ const depth = deep === true ? Infinity : deep;
2044
+ getter = () => traverse(baseGetter(), depth);
2045
+ }
2046
+ const scope = getCurrentScope();
2047
+ const watchHandle = () => {
2048
+ effect.stop();
2049
+ if (scope) {
2050
+ remove(scope.effects, effect);
2051
+ }
2052
+ };
2053
+ if (once) {
2054
+ if (cb) {
2055
+ const _cb = cb;
2056
+ cb = (...args) => {
2057
+ _cb(...args);
2058
+ watchHandle();
2059
+ };
2060
+ } else {
2061
+ const _getter = getter;
2062
+ getter = () => {
2063
+ _getter();
2064
+ watchHandle();
2065
+ };
2066
+ }
2067
+ }
2068
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2069
+ const job = (immediateFirstRun) => {
2070
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2071
+ return;
2072
+ }
2073
+ if (cb) {
2074
+ const newValue = effect.run();
2075
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2076
+ if (cleanup) {
2077
+ cleanup();
2078
+ }
2079
+ const currentWatcher = activeWatcher;
2080
+ activeWatcher = effect;
2081
+ try {
2082
+ const args = [
2083
+ newValue,
2084
+ // pass undefined as the old value when it's changed for the first time
2085
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2086
+ boundCleanup
2087
+ ];
2088
+ call ? call(cb, 3, args) : (
2089
+ // @ts-expect-error
2090
+ cb(...args)
2091
+ );
2092
+ oldValue = newValue;
2093
+ } finally {
2094
+ activeWatcher = currentWatcher;
2095
+ }
2096
+ }
2097
+ } else {
2098
+ effect.run();
2099
+ }
2100
+ };
2101
+ if (augmentJob) {
2102
+ augmentJob(job);
2103
+ }
2104
+ effect = new ReactiveEffect(getter);
2105
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2106
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2107
+ cleanup = effect.onStop = () => {
2108
+ const cleanups = cleanupMap.get(effect);
2109
+ if (cleanups) {
2110
+ if (call) {
2111
+ call(cleanups, 4);
2112
+ } else {
2113
+ for (const cleanup2 of cleanups) cleanup2();
2114
+ }
2115
+ cleanupMap.delete(effect);
2116
+ }
2117
+ };
2118
+ if (!!(process.env.NODE_ENV !== "production")) {
2119
+ effect.onTrack = options.onTrack;
2120
+ effect.onTrigger = options.onTrigger;
2121
+ }
2122
+ if (cb) {
2123
+ if (immediate) {
2124
+ job(true);
2125
+ } else {
2126
+ oldValue = effect.run();
2127
+ }
2128
+ } else if (scheduler) {
2129
+ scheduler(job.bind(null, true), true);
2130
+ } else {
2131
+ effect.run();
2132
+ }
2133
+ watchHandle.pause = effect.pause.bind(effect);
2134
+ watchHandle.resume = effect.resume.bind(effect);
2135
+ watchHandle.stop = watchHandle;
2136
+ return watchHandle;
2137
+ }
2138
+ function traverse(value, depth = Infinity, seen) {
2139
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2140
+ return value;
2141
+ }
2142
+ seen = seen || /* @__PURE__ */ new Set();
2143
+ if (seen.has(value)) {
2144
+ return value;
2145
+ }
2146
+ seen.add(value);
2147
+ depth--;
2148
+ if (isRef(value)) {
2149
+ traverse(value.value, depth, seen);
2150
+ } else if (isArray(value)) {
2151
+ for (let i = 0; i < value.length; i++) {
2152
+ traverse(value[i], depth, seen);
2153
+ }
2154
+ } else if (isSet(value) || isMap(value)) {
2155
+ value.forEach((v) => {
2156
+ traverse(v, depth, seen);
2157
+ });
2158
+ } else if (isPlainObject(value)) {
2159
+ for (const key in value) {
2160
+ traverse(value[key], depth, seen);
2161
+ }
2162
+ for (const key of Object.getOwnPropertySymbols(value)) {
2163
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2164
+ traverse(value[key], depth, seen);
2165
+ }
2166
+ }
2167
+ }
2168
+ return value;
2169
+ }
2170
+
1952
2171
  const stack = [];
1953
2172
  function pushWarningContext(vnode) {
1954
2173
  stack.push(vnode);
@@ -2077,12 +2296,6 @@ const ErrorCodes = {
2077
2296
  "0": "SETUP_FUNCTION",
2078
2297
  "RENDER_FUNCTION": 1,
2079
2298
  "1": "RENDER_FUNCTION",
2080
- "WATCH_GETTER": 2,
2081
- "2": "WATCH_GETTER",
2082
- "WATCH_CALLBACK": 3,
2083
- "3": "WATCH_CALLBACK",
2084
- "WATCH_CLEANUP": 4,
2085
- "4": "WATCH_CLEANUP",
2086
2299
  "NATIVE_EVENT_HANDLER": 5,
2087
2300
  "5": "NATIVE_EVENT_HANDLER",
2088
2301
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2238,7 +2451,7 @@ function nextTick(fn) {
2238
2451
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2239
2452
  }
2240
2453
  function findInsertionIndex(id) {
2241
- let start = flushIndex + 1;
2454
+ let start = isFlushing ? flushIndex + 1 : 0;
2242
2455
  let end = queue.length;
2243
2456
  while (start < end) {
2244
2457
  const middle = start + end >>> 1;
@@ -2254,15 +2467,13 @@ function findInsertionIndex(id) {
2254
2467
  }
2255
2468
  function queueJob(job) {
2256
2469
  if (!(job.flags & 1)) {
2257
- if (job.id == null) {
2258
- queue.push(job);
2259
- } else if (
2260
- // fast path when the job id is larger than the tail
2261
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2262
- ) {
2470
+ const jobId = getId(job);
2471
+ const lastJob = queue[queue.length - 1];
2472
+ if (!lastJob || // fast path when the job id is larger than the tail
2473
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2263
2474
  queue.push(job);
2264
2475
  } else {
2265
- queue.splice(findInsertionIndex(job.id), 0, job);
2476
+ queue.splice(findInsertionIndex(jobId), 0, job);
2266
2477
  }
2267
2478
  if (!(job.flags & 4)) {
2268
2479
  job.flags |= 1;
@@ -2276,12 +2487,6 @@ function queueFlush() {
2276
2487
  currentFlushPromise = resolvedPromise.then(flushJobs);
2277
2488
  }
2278
2489
  }
2279
- function invalidateJob(job) {
2280
- const i = queue.indexOf(job);
2281
- if (i > flushIndex) {
2282
- queue.splice(i, 1);
2283
- }
2284
- }
2285
2490
  function queuePostFlushCb(cb) {
2286
2491
  if (!isArray(cb)) {
2287
2492
  if (activePostFlushCbs && cb.id === -1) {
@@ -2343,24 +2548,13 @@ function flushPostFlushCbs(seen) {
2343
2548
  postFlushIndex = 0;
2344
2549
  }
2345
2550
  }
2346
- const getId = (job) => job.id == null ? Infinity : job.id;
2347
- const comparator = (a, b) => {
2348
- const diff = getId(a) - getId(b);
2349
- if (diff === 0) {
2350
- const isAPre = a.flags & 2;
2351
- const isBPre = b.flags & 2;
2352
- if (isAPre && !isBPre) return -1;
2353
- if (isBPre && !isAPre) return 1;
2354
- }
2355
- return diff;
2356
- };
2551
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2357
2552
  function flushJobs(seen) {
2358
2553
  isFlushPending = false;
2359
2554
  isFlushing = true;
2360
2555
  if (!!(process.env.NODE_ENV !== "production")) {
2361
2556
  seen = seen || /* @__PURE__ */ new Map();
2362
2557
  }
2363
- queue.sort(comparator);
2364
2558
  const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
2365
2559
  try {
2366
2560
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3004,7 +3198,7 @@ function on(instance, event, fn) {
3004
3198
  function once(instance, event, fn) {
3005
3199
  const wrapped = (...args) => {
3006
3200
  off(instance, event, wrapped);
3007
- fn.call(instance.proxy, ...args);
3201
+ fn.apply(instance.proxy, args);
3008
3202
  };
3009
3203
  wrapped.fn = fn;
3010
3204
  on(instance, event, wrapped);
@@ -3924,7 +4118,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3924
4118
  // @__NO_SIDE_EFFECTS__
3925
4119
  function defineComponent(options, extraOptions) {
3926
4120
  return isFunction(options) ? (
3927
- // #8326: extend call and options.name access are considered side-effects
4121
+ // #8236: extend call and options.name access are considered side-effects
3928
4122
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
3929
4123
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
3930
4124
  ) : options;
@@ -5062,6 +5256,7 @@ const KeepAliveImpl = {
5062
5256
  );
5063
5257
  const { include, exclude, max } = props;
5064
5258
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
5259
+ vnode.shapeFlag &= ~256;
5065
5260
  current = vnode;
5066
5261
  return rawVNode;
5067
5262
  }
@@ -6552,23 +6747,43 @@ function callHook$1(hook, instance, type) {
6552
6747
  );
6553
6748
  }
6554
6749
  function createWatcher(raw, ctx, publicThis, key) {
6555
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6750
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6751
+ const options = {};
6752
+ {
6753
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6754
+ const newValue = getter();
6755
+ if (isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
6756
+ options.deep = true;
6757
+ }
6758
+ const baseGetter = getter;
6759
+ getter = () => {
6760
+ const val = baseGetter();
6761
+ if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
6762
+ traverse(val);
6763
+ }
6764
+ return val;
6765
+ };
6766
+ }
6556
6767
  if (isString(raw)) {
6557
6768
  const handler = ctx[raw];
6558
6769
  if (isFunction(handler)) {
6559
- watch(getter, handler);
6770
+ {
6771
+ watch(getter, handler, options);
6772
+ }
6560
6773
  } else if (!!(process.env.NODE_ENV !== "production")) {
6561
6774
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6562
6775
  }
6563
6776
  } else if (isFunction(raw)) {
6564
- watch(getter, raw.bind(publicThis));
6777
+ {
6778
+ watch(getter, raw.bind(publicThis), options);
6779
+ }
6565
6780
  } else if (isObject(raw)) {
6566
6781
  if (isArray(raw)) {
6567
6782
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6568
6783
  } else {
6569
6784
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6570
6785
  if (isFunction(handler)) {
6571
- watch(getter, handler, raw);
6786
+ watch(getter, handler, extend(raw, options) );
6572
6787
  } else if (!!(process.env.NODE_ENV !== "production")) {
6573
6788
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6574
6789
  }
@@ -6792,7 +7007,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6792
7007
  return vm;
6793
7008
  }
6794
7009
  }
6795
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7010
+ Vue.version = `2.6.14-compat:${"3.5.0-rc.1"}`;
6796
7011
  Vue.config = singletonApp.config;
6797
7012
  Vue.use = (plugin, ...options) => {
6798
7013
  if (plugin && isFunction(plugin.install)) {
@@ -7124,7 +7339,7 @@ function defineReactive(obj, key, val) {
7124
7339
  if (isArray(val)) {
7125
7340
  methodsToPatch.forEach((m) => {
7126
7341
  val[m] = (...args) => {
7127
- Array.prototype[m].call(reactiveVal, ...args);
7342
+ Array.prototype[m].apply(reactiveVal, args);
7128
7343
  };
7129
7344
  });
7130
7345
  } else {
@@ -8348,7 +8563,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8348
8563
  if (!!(process.env.NODE_ENV !== "production") && subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8349
8564
  subTree = filterSingleRoot(subTree.children) || subTree;
8350
8565
  }
8351
- if (vnode === subTree) {
8566
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8352
8567
  const parentVNode = parentComponent.vnode;
8353
8568
  setScopeId(
8354
8569
  el,
@@ -8689,7 +8904,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8689
8904
  return;
8690
8905
  } else {
8691
8906
  instance.next = n2;
8692
- invalidateJob(instance.update);
8693
8907
  instance.update();
8694
8908
  }
8695
8909
  } else {
@@ -9613,7 +9827,6 @@ function watchSyncEffect(effect, options) {
9613
9827
  !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
9614
9828
  );
9615
9829
  }
9616
- const INITIAL_WATCHER_VALUE = {};
9617
9830
  function watch(source, cb, options) {
9618
9831
  if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
9619
9832
  warn$1(
@@ -9622,21 +9835,8 @@ function watch(source, cb, options) {
9622
9835
  }
9623
9836
  return doWatch(source, cb, options);
9624
9837
  }
9625
- function doWatch(source, cb, {
9626
- immediate,
9627
- deep,
9628
- flush,
9629
- once,
9630
- onTrack,
9631
- onTrigger
9632
- } = EMPTY_OBJ) {
9633
- if (cb && once) {
9634
- const _cb = cb;
9635
- cb = (...args) => {
9636
- _cb(...args);
9637
- watchHandle();
9638
- };
9639
- }
9838
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9839
+ const { immediate, deep, flush, once } = options;
9640
9840
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
9641
9841
  if (immediate !== void 0) {
9642
9842
  warn$1(
@@ -9654,173 +9854,53 @@ function doWatch(source, cb, {
9654
9854
  );
9655
9855
  }
9656
9856
  }
9657
- const warnInvalidSource = (s) => {
9658
- warn$1(
9659
- `Invalid watch source: `,
9660
- s,
9661
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9662
- );
9663
- };
9664
- const instance = currentInstance;
9665
- const reactiveGetter = (source2) => {
9666
- if (deep) return source2;
9667
- if (isShallow(source2) || deep === false || deep === 0)
9668
- return traverse(source2, 1);
9669
- return traverse(source2);
9670
- };
9671
- let getter;
9672
- let forceTrigger = false;
9673
- let isMultiSource = false;
9674
- if (isRef(source)) {
9675
- getter = () => source.value;
9676
- forceTrigger = isShallow(source);
9677
- } else if (isReactive(source)) {
9678
- getter = () => reactiveGetter(source);
9679
- forceTrigger = true;
9680
- } else if (isArray(source)) {
9681
- isMultiSource = true;
9682
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9683
- getter = () => source.map((s) => {
9684
- if (isRef(s)) {
9685
- return s.value;
9686
- } else if (isReactive(s)) {
9687
- return reactiveGetter(s);
9688
- } else if (isFunction(s)) {
9689
- return callWithErrorHandling(s, instance, 2);
9690
- } else {
9691
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
9692
- }
9693
- });
9694
- } else if (isFunction(source)) {
9695
- if (cb) {
9696
- getter = () => callWithErrorHandling(source, instance, 2);
9697
- } else {
9698
- getter = () => {
9699
- if (cleanup) {
9700
- cleanup();
9701
- }
9702
- return callWithAsyncErrorHandling(
9703
- source,
9704
- instance,
9705
- 3,
9706
- [onCleanup]
9707
- );
9708
- };
9709
- }
9710
- } else {
9711
- getter = NOOP;
9712
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
9713
- }
9714
- if (cb && !deep) {
9715
- const baseGetter = getter;
9716
- getter = () => {
9717
- const val = baseGetter();
9718
- if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
9719
- traverse(val);
9720
- }
9721
- return val;
9722
- };
9723
- }
9724
- if (cb && deep) {
9725
- const baseGetter = getter;
9726
- const depth = deep === true ? Infinity : deep;
9727
- getter = () => traverse(baseGetter(), depth);
9728
- }
9729
- let cleanup;
9730
- let onCleanup = (fn) => {
9731
- cleanup = effect.onStop = () => {
9732
- callWithErrorHandling(fn, instance, 4);
9733
- cleanup = effect.onStop = void 0;
9734
- };
9735
- };
9857
+ const baseWatchOptions = extend({}, options);
9858
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn$1;
9736
9859
  let ssrCleanup;
9737
9860
  if (isInSSRComponentSetup) {
9738
- onCleanup = NOOP;
9739
- if (!cb) {
9740
- getter();
9741
- } else if (immediate) {
9742
- callWithAsyncErrorHandling(cb, instance, 3, [
9743
- getter(),
9744
- isMultiSource ? [] : void 0,
9745
- onCleanup
9746
- ]);
9747
- }
9748
9861
  if (flush === "sync") {
9749
9862
  const ctx = useSSRContext();
9750
9863
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9864
+ } else if (!cb || immediate) {
9865
+ baseWatchOptions.once = true;
9751
9866
  } else {
9752
- const watchHandle2 = () => {
9867
+ return {
9868
+ stop: NOOP,
9869
+ resume: NOOP,
9870
+ pause: NOOP
9753
9871
  };
9754
- watchHandle2.stop = NOOP;
9755
- watchHandle2.resume = NOOP;
9756
- watchHandle2.pause = NOOP;
9757
- return watchHandle2;
9758
9872
  }
9759
9873
  }
9760
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9761
- const job = (immediateFirstRun) => {
9762
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9763
- return;
9764
- }
9765
- if (cb) {
9766
- const newValue = effect.run();
9767
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
9768
- if (cleanup) {
9769
- cleanup();
9770
- }
9771
- callWithAsyncErrorHandling(cb, instance, 3, [
9772
- newValue,
9773
- // pass undefined as the old value when it's changed for the first time
9774
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9775
- onCleanup
9776
- ]);
9777
- oldValue = newValue;
9874
+ const instance = currentInstance;
9875
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9876
+ let isPre = false;
9877
+ if (flush === "post") {
9878
+ baseWatchOptions.scheduler = (job) => {
9879
+ queuePostRenderEffect(job, instance && instance.suspense);
9880
+ };
9881
+ } else if (flush !== "sync") {
9882
+ isPre = true;
9883
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9884
+ if (isFirstRun) {
9885
+ job();
9886
+ } else {
9887
+ queueJob(job);
9778
9888
  }
9779
- } else {
9780
- effect.run();
9781
- }
9782
- };
9783
- if (cb) job.flags |= 4;
9784
- const effect = new ReactiveEffect(getter);
9785
- let scheduler;
9786
- if (flush === "sync") {
9787
- scheduler = job;
9788
- } else if (flush === "post") {
9789
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9790
- } else {
9791
- job.flags |= 2;
9792
- if (instance) job.id = instance.uid;
9793
- scheduler = () => queueJob(job);
9889
+ };
9794
9890
  }
9795
- effect.scheduler = scheduler;
9796
- const scope = getCurrentScope();
9797
- const watchHandle = () => {
9798
- effect.stop();
9799
- if (scope) {
9800
- remove(scope.effects, effect);
9891
+ baseWatchOptions.augmentJob = (job) => {
9892
+ if (cb) {
9893
+ job.flags |= 4;
9801
9894
  }
9802
- };
9803
- watchHandle.pause = effect.pause.bind(effect);
9804
- watchHandle.resume = effect.resume.bind(effect);
9805
- watchHandle.stop = watchHandle;
9806
- if (!!(process.env.NODE_ENV !== "production")) {
9807
- effect.onTrack = onTrack;
9808
- effect.onTrigger = onTrigger;
9809
- }
9810
- if (cb) {
9811
- if (immediate) {
9812
- job(true);
9813
- } else {
9814
- oldValue = effect.run();
9895
+ if (isPre) {
9896
+ job.flags |= 2;
9897
+ if (instance) {
9898
+ job.id = instance.uid;
9899
+ job.i = instance;
9900
+ }
9815
9901
  }
9816
- } else if (flush === "post") {
9817
- queuePostRenderEffect(
9818
- effect.run.bind(effect),
9819
- instance && instance.suspense
9820
- );
9821
- } else {
9822
- effect.run();
9823
- }
9902
+ };
9903
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9824
9904
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9825
9905
  return watchHandle;
9826
9906
  }
@@ -9849,38 +9929,6 @@ function createPathGetter(ctx, path) {
9849
9929
  return cur;
9850
9930
  };
9851
9931
  }
9852
- function traverse(value, depth = Infinity, seen) {
9853
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9854
- return value;
9855
- }
9856
- seen = seen || /* @__PURE__ */ new Set();
9857
- if (seen.has(value)) {
9858
- return value;
9859
- }
9860
- seen.add(value);
9861
- depth--;
9862
- if (isRef(value)) {
9863
- traverse(value.value, depth, seen);
9864
- } else if (isArray(value)) {
9865
- for (let i = 0; i < value.length; i++) {
9866
- traverse(value[i], depth, seen);
9867
- }
9868
- } else if (isSet(value) || isMap(value)) {
9869
- value.forEach((v) => {
9870
- traverse(v, depth, seen);
9871
- });
9872
- } else if (isPlainObject(value)) {
9873
- for (const key in value) {
9874
- traverse(value[key], depth, seen);
9875
- }
9876
- for (const key of Object.getOwnPropertySymbols(value)) {
9877
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9878
- traverse(value[key], depth, seen);
9879
- }
9880
- }
9881
- }
9882
- return value;
9883
- }
9884
9932
 
9885
9933
  function useModel(props, name, options = EMPTY_OBJ) {
9886
9934
  const i = getCurrentInstance();
@@ -12149,7 +12197,7 @@ function isMemoSame(cached, memo) {
12149
12197
  return true;
12150
12198
  }
12151
12199
 
12152
- const version = "3.5.0-beta.2";
12200
+ const version = "3.5.0-rc.1";
12153
12201
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12154
12202
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12155
12203
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -12848,8 +12896,9 @@ function compatCoerceAttr(el, key, value, instance = null) {
12848
12896
 
12849
12897
  function patchDOMProp(el, key, value, parentComponent) {
12850
12898
  if (key === "innerHTML" || key === "textContent") {
12851
- if (value == null) return;
12852
- el[key] = value;
12899
+ if (value != null) {
12900
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
12901
+ }
12853
12902
  return;
12854
12903
  }
12855
12904
  const tag = el.tagName;
@@ -13292,6 +13341,9 @@ class VueElement extends BaseClass {
13292
13341
  delete this._props[key];
13293
13342
  } else {
13294
13343
  this._props[key] = val;
13344
+ if (key === "key" && this._app) {
13345
+ this._app._ceVNode.key = val;
13346
+ }
13295
13347
  }
13296
13348
  if (shouldUpdate && this._instance) {
13297
13349
  this._update();
@@ -14191,6 +14243,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14191
14243
  effectScope: effectScope,
14192
14244
  getCurrentInstance: getCurrentInstance,
14193
14245
  getCurrentScope: getCurrentScope,
14246
+ getCurrentWatcher: getCurrentWatcher,
14194
14247
  getTransitionRawChildren: getTransitionRawChildren,
14195
14248
  guardReactiveProps: guardReactiveProps,
14196
14249
  h: h,
@@ -14233,6 +14286,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14233
14286
  onServerPrefetch: onServerPrefetch,
14234
14287
  onUnmounted: onUnmounted,
14235
14288
  onUpdated: onUpdated,
14289
+ onWatcherCleanup: onWatcherCleanup,
14236
14290
  openBlock: openBlock,
14237
14291
  popScopeId: popScopeId,
14238
14292
  provide: provide,
@@ -14340,4 +14394,4 @@ Vue.compile = () => {
14340
14394
 
14341
14395
  const configureCompat = Vue.configureCompat;
14342
14396
 
14343
- 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 };
14397
+ 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 };