@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
  **/
@@ -404,12 +404,13 @@ class EffectScope {
404
404
  pause() {
405
405
  if (this._active) {
406
406
  this._isPaused = true;
407
+ let i, l;
407
408
  if (this.scopes) {
408
- for (let i = 0, l = this.scopes.length; i < l; i++) {
409
+ for (i = 0, l = this.scopes.length; i < l; i++) {
409
410
  this.scopes[i].pause();
410
411
  }
411
412
  }
412
- for (let i = 0, l = this.effects.length; i < l; i++) {
413
+ for (i = 0, l = this.effects.length; i < l; i++) {
413
414
  this.effects[i].pause();
414
415
  }
415
416
  }
@@ -421,12 +422,13 @@ class EffectScope {
421
422
  if (this._active) {
422
423
  if (this._isPaused) {
423
424
  this._isPaused = false;
425
+ let i, l;
424
426
  if (this.scopes) {
425
- for (let i = 0, l = this.scopes.length; i < l; i++) {
427
+ for (i = 0, l = this.scopes.length; i < l; i++) {
426
428
  this.scopes[i].resume();
427
429
  }
428
430
  }
429
- for (let i = 0, l = this.effects.length; i < l; i++) {
431
+ for (i = 0, l = this.effects.length; i < l; i++) {
430
432
  this.effects[i].resume();
431
433
  }
432
434
  }
@@ -619,11 +621,9 @@ function startBatch() {
619
621
  batchDepth++;
620
622
  }
621
623
  function endBatch() {
622
- if (batchDepth > 1) {
623
- batchDepth--;
624
+ if (--batchDepth > 0) {
624
625
  return;
625
626
  }
626
- batchDepth--;
627
627
  let error;
628
628
  while (batchedEffect) {
629
629
  let e = batchedEffect;
@@ -1141,14 +1141,14 @@ function iterator(self, method, wrapValue) {
1141
1141
  const arrayProto = Array.prototype;
1142
1142
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1143
1143
  const arr = shallowReadArray(self);
1144
- let methodFn;
1145
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1146
- return methodFn.apply(arr, args);
1144
+ const needsWrap = arr !== self && !isShallow(self);
1145
+ const methodFn = arr[method];
1146
+ if (methodFn !== arrayProto[method]) {
1147
+ const result2 = methodFn.apply(arr, args);
1148
+ return needsWrap ? toReactive(result2) : result2;
1147
1149
  }
1148
- let needsWrap = false;
1149
1150
  let wrappedFn = fn;
1150
1151
  if (arr !== self) {
1151
- needsWrap = !isShallow(self);
1152
1152
  if (needsWrap) {
1153
1153
  wrappedFn = function(item, index) {
1154
1154
  return fn.call(this, toReactive(item), index, self);
@@ -1286,7 +1286,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1286
1286
  }
1287
1287
  }
1288
1288
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1289
- const result = Reflect.set(target, key, value, receiver);
1289
+ const result = Reflect.set(
1290
+ target,
1291
+ key,
1292
+ value,
1293
+ isRef(target) ? target : receiver
1294
+ );
1290
1295
  if (target === toRaw(receiver)) {
1291
1296
  if (!hadKey) {
1292
1297
  trigger(target, "add", key, value);
@@ -2016,6 +2021,220 @@ const TriggerOpTypes = {
2016
2021
  "CLEAR": "clear"
2017
2022
  };
2018
2023
 
2024
+ const INITIAL_WATCHER_VALUE = {};
2025
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
2026
+ let activeWatcher = void 0;
2027
+ function getCurrentWatcher() {
2028
+ return activeWatcher;
2029
+ }
2030
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2031
+ if (owner) {
2032
+ let cleanups = cleanupMap.get(owner);
2033
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
2034
+ cleanups.push(cleanupFn);
2035
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
2036
+ warn$2(
2037
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
2038
+ );
2039
+ }
2040
+ }
2041
+ function watch$1(source, cb, options = EMPTY_OBJ) {
2042
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
2043
+ const warnInvalidSource = (s) => {
2044
+ (options.onWarn || warn$2)(
2045
+ `Invalid watch source: `,
2046
+ s,
2047
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
2048
+ );
2049
+ };
2050
+ const reactiveGetter = (source2) => {
2051
+ if (deep) return source2;
2052
+ if (isShallow(source2) || deep === false || deep === 0)
2053
+ return traverse(source2, 1);
2054
+ return traverse(source2);
2055
+ };
2056
+ let effect;
2057
+ let getter;
2058
+ let cleanup;
2059
+ let boundCleanup;
2060
+ let forceTrigger = false;
2061
+ let isMultiSource = false;
2062
+ if (isRef(source)) {
2063
+ getter = () => source.value;
2064
+ forceTrigger = isShallow(source);
2065
+ } else if (isReactive(source)) {
2066
+ getter = () => reactiveGetter(source);
2067
+ forceTrigger = true;
2068
+ } else if (isArray(source)) {
2069
+ isMultiSource = true;
2070
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2071
+ getter = () => source.map((s) => {
2072
+ if (isRef(s)) {
2073
+ return s.value;
2074
+ } else if (isReactive(s)) {
2075
+ return reactiveGetter(s);
2076
+ } else if (isFunction(s)) {
2077
+ return call ? call(s, 2) : s();
2078
+ } else {
2079
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
2080
+ }
2081
+ });
2082
+ } else if (isFunction(source)) {
2083
+ if (cb) {
2084
+ getter = call ? () => call(source, 2) : source;
2085
+ } else {
2086
+ getter = () => {
2087
+ if (cleanup) {
2088
+ pauseTracking();
2089
+ try {
2090
+ cleanup();
2091
+ } finally {
2092
+ resetTracking();
2093
+ }
2094
+ }
2095
+ const currentEffect = activeWatcher;
2096
+ activeWatcher = effect;
2097
+ try {
2098
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2099
+ } finally {
2100
+ activeWatcher = currentEffect;
2101
+ }
2102
+ };
2103
+ }
2104
+ } else {
2105
+ getter = NOOP;
2106
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
2107
+ }
2108
+ if (cb && deep) {
2109
+ const baseGetter = getter;
2110
+ const depth = deep === true ? Infinity : deep;
2111
+ getter = () => traverse(baseGetter(), depth);
2112
+ }
2113
+ const scope = getCurrentScope();
2114
+ const watchHandle = () => {
2115
+ effect.stop();
2116
+ if (scope) {
2117
+ remove(scope.effects, effect);
2118
+ }
2119
+ };
2120
+ if (once) {
2121
+ if (cb) {
2122
+ const _cb = cb;
2123
+ cb = (...args) => {
2124
+ _cb(...args);
2125
+ watchHandle();
2126
+ };
2127
+ } else {
2128
+ const _getter = getter;
2129
+ getter = () => {
2130
+ _getter();
2131
+ watchHandle();
2132
+ };
2133
+ }
2134
+ }
2135
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2136
+ const job = (immediateFirstRun) => {
2137
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2138
+ return;
2139
+ }
2140
+ if (cb) {
2141
+ const newValue = effect.run();
2142
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2143
+ if (cleanup) {
2144
+ cleanup();
2145
+ }
2146
+ const currentWatcher = activeWatcher;
2147
+ activeWatcher = effect;
2148
+ try {
2149
+ const args = [
2150
+ newValue,
2151
+ // pass undefined as the old value when it's changed for the first time
2152
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2153
+ boundCleanup
2154
+ ];
2155
+ call ? call(cb, 3, args) : (
2156
+ // @ts-expect-error
2157
+ cb(...args)
2158
+ );
2159
+ oldValue = newValue;
2160
+ } finally {
2161
+ activeWatcher = currentWatcher;
2162
+ }
2163
+ }
2164
+ } else {
2165
+ effect.run();
2166
+ }
2167
+ };
2168
+ if (augmentJob) {
2169
+ augmentJob(job);
2170
+ }
2171
+ effect = new ReactiveEffect(getter);
2172
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2173
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2174
+ cleanup = effect.onStop = () => {
2175
+ const cleanups = cleanupMap.get(effect);
2176
+ if (cleanups) {
2177
+ if (call) {
2178
+ call(cleanups, 4);
2179
+ } else {
2180
+ for (const cleanup2 of cleanups) cleanup2();
2181
+ }
2182
+ cleanupMap.delete(effect);
2183
+ }
2184
+ };
2185
+ if (!!(process.env.NODE_ENV !== "production")) {
2186
+ effect.onTrack = options.onTrack;
2187
+ effect.onTrigger = options.onTrigger;
2188
+ }
2189
+ if (cb) {
2190
+ if (immediate) {
2191
+ job(true);
2192
+ } else {
2193
+ oldValue = effect.run();
2194
+ }
2195
+ } else if (scheduler) {
2196
+ scheduler(job.bind(null, true), true);
2197
+ } else {
2198
+ effect.run();
2199
+ }
2200
+ watchHandle.pause = effect.pause.bind(effect);
2201
+ watchHandle.resume = effect.resume.bind(effect);
2202
+ watchHandle.stop = watchHandle;
2203
+ return watchHandle;
2204
+ }
2205
+ function traverse(value, depth = Infinity, seen) {
2206
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2207
+ return value;
2208
+ }
2209
+ seen = seen || /* @__PURE__ */ new Set();
2210
+ if (seen.has(value)) {
2211
+ return value;
2212
+ }
2213
+ seen.add(value);
2214
+ depth--;
2215
+ if (isRef(value)) {
2216
+ traverse(value.value, depth, seen);
2217
+ } else if (isArray(value)) {
2218
+ for (let i = 0; i < value.length; i++) {
2219
+ traverse(value[i], depth, seen);
2220
+ }
2221
+ } else if (isSet(value) || isMap(value)) {
2222
+ value.forEach((v) => {
2223
+ traverse(v, depth, seen);
2224
+ });
2225
+ } else if (isPlainObject(value)) {
2226
+ for (const key in value) {
2227
+ traverse(value[key], depth, seen);
2228
+ }
2229
+ for (const key of Object.getOwnPropertySymbols(value)) {
2230
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2231
+ traverse(value[key], depth, seen);
2232
+ }
2233
+ }
2234
+ }
2235
+ return value;
2236
+ }
2237
+
2019
2238
  const stack$1 = [];
2020
2239
  function pushWarningContext(vnode) {
2021
2240
  stack$1.push(vnode);
@@ -2144,12 +2363,6 @@ const ErrorCodes = {
2144
2363
  "0": "SETUP_FUNCTION",
2145
2364
  "RENDER_FUNCTION": 1,
2146
2365
  "1": "RENDER_FUNCTION",
2147
- "WATCH_GETTER": 2,
2148
- "2": "WATCH_GETTER",
2149
- "WATCH_CALLBACK": 3,
2150
- "3": "WATCH_CALLBACK",
2151
- "WATCH_CLEANUP": 4,
2152
- "4": "WATCH_CLEANUP",
2153
2366
  "NATIVE_EVENT_HANDLER": 5,
2154
2367
  "5": "NATIVE_EVENT_HANDLER",
2155
2368
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2305,7 +2518,7 @@ function nextTick(fn) {
2305
2518
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2306
2519
  }
2307
2520
  function findInsertionIndex(id) {
2308
- let start = flushIndex + 1;
2521
+ let start = isFlushing ? flushIndex + 1 : 0;
2309
2522
  let end = queue.length;
2310
2523
  while (start < end) {
2311
2524
  const middle = start + end >>> 1;
@@ -2321,15 +2534,13 @@ function findInsertionIndex(id) {
2321
2534
  }
2322
2535
  function queueJob(job) {
2323
2536
  if (!(job.flags & 1)) {
2324
- if (job.id == null) {
2325
- queue.push(job);
2326
- } else if (
2327
- // fast path when the job id is larger than the tail
2328
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2329
- ) {
2537
+ const jobId = getId(job);
2538
+ const lastJob = queue[queue.length - 1];
2539
+ if (!lastJob || // fast path when the job id is larger than the tail
2540
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2330
2541
  queue.push(job);
2331
2542
  } else {
2332
- queue.splice(findInsertionIndex(job.id), 0, job);
2543
+ queue.splice(findInsertionIndex(jobId), 0, job);
2333
2544
  }
2334
2545
  if (!(job.flags & 4)) {
2335
2546
  job.flags |= 1;
@@ -2343,12 +2554,6 @@ function queueFlush() {
2343
2554
  currentFlushPromise = resolvedPromise.then(flushJobs);
2344
2555
  }
2345
2556
  }
2346
- function invalidateJob(job) {
2347
- const i = queue.indexOf(job);
2348
- if (i > flushIndex) {
2349
- queue.splice(i, 1);
2350
- }
2351
- }
2352
2557
  function queuePostFlushCb(cb) {
2353
2558
  if (!isArray(cb)) {
2354
2559
  if (activePostFlushCbs && cb.id === -1) {
@@ -2410,24 +2615,13 @@ function flushPostFlushCbs(seen) {
2410
2615
  postFlushIndex = 0;
2411
2616
  }
2412
2617
  }
2413
- const getId = (job) => job.id == null ? Infinity : job.id;
2414
- const comparator = (a, b) => {
2415
- const diff = getId(a) - getId(b);
2416
- if (diff === 0) {
2417
- const isAPre = a.flags & 2;
2418
- const isBPre = b.flags & 2;
2419
- if (isAPre && !isBPre) return -1;
2420
- if (isBPre && !isAPre) return 1;
2421
- }
2422
- return diff;
2423
- };
2618
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2424
2619
  function flushJobs(seen) {
2425
2620
  isFlushPending = false;
2426
2621
  isFlushing = true;
2427
2622
  if (!!(process.env.NODE_ENV !== "production")) {
2428
2623
  seen = seen || /* @__PURE__ */ new Map();
2429
2624
  }
2430
- queue.sort(comparator);
2431
2625
  const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
2432
2626
  try {
2433
2627
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3071,7 +3265,7 @@ function on(instance, event, fn) {
3071
3265
  function once(instance, event, fn) {
3072
3266
  const wrapped = (...args) => {
3073
3267
  off(instance, event, wrapped);
3074
- fn.call(instance.proxy, ...args);
3268
+ fn.apply(instance.proxy, args);
3075
3269
  };
3076
3270
  wrapped.fn = fn;
3077
3271
  on(instance, event, wrapped);
@@ -3991,7 +4185,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3991
4185
  // @__NO_SIDE_EFFECTS__
3992
4186
  function defineComponent(options, extraOptions) {
3993
4187
  return isFunction(options) ? (
3994
- // #8326: extend call and options.name access are considered side-effects
4188
+ // #8236: extend call and options.name access are considered side-effects
3995
4189
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
3996
4190
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
3997
4191
  ) : options;
@@ -5129,6 +5323,7 @@ const KeepAliveImpl = {
5129
5323
  );
5130
5324
  const { include, exclude, max } = props;
5131
5325
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
5326
+ vnode.shapeFlag &= ~256;
5132
5327
  current = vnode;
5133
5328
  return rawVNode;
5134
5329
  }
@@ -6619,23 +6814,43 @@ function callHook$1(hook, instance, type) {
6619
6814
  );
6620
6815
  }
6621
6816
  function createWatcher(raw, ctx, publicThis, key) {
6622
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6817
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6818
+ const options = {};
6819
+ {
6820
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6821
+ const newValue = getter();
6822
+ if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
6823
+ options.deep = true;
6824
+ }
6825
+ const baseGetter = getter;
6826
+ getter = () => {
6827
+ const val = baseGetter();
6828
+ if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
6829
+ traverse(val);
6830
+ }
6831
+ return val;
6832
+ };
6833
+ }
6623
6834
  if (isString(raw)) {
6624
6835
  const handler = ctx[raw];
6625
6836
  if (isFunction(handler)) {
6626
- watch(getter, handler);
6837
+ {
6838
+ watch(getter, handler, options);
6839
+ }
6627
6840
  } else if (!!(process.env.NODE_ENV !== "production")) {
6628
6841
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6629
6842
  }
6630
6843
  } else if (isFunction(raw)) {
6631
- watch(getter, raw.bind(publicThis));
6844
+ {
6845
+ watch(getter, raw.bind(publicThis), options);
6846
+ }
6632
6847
  } else if (isObject(raw)) {
6633
6848
  if (isArray(raw)) {
6634
6849
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6635
6850
  } else {
6636
6851
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6637
6852
  if (isFunction(handler)) {
6638
- watch(getter, handler, raw);
6853
+ watch(getter, handler, extend(raw, options) );
6639
6854
  } else if (!!(process.env.NODE_ENV !== "production")) {
6640
6855
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6641
6856
  }
@@ -6859,7 +7074,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6859
7074
  return vm;
6860
7075
  }
6861
7076
  }
6862
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7077
+ Vue.version = `2.6.14-compat:${"3.5.0-rc.1"}`;
6863
7078
  Vue.config = singletonApp.config;
6864
7079
  Vue.use = (plugin, ...options) => {
6865
7080
  if (plugin && isFunction(plugin.install)) {
@@ -7191,7 +7406,7 @@ function defineReactive(obj, key, val) {
7191
7406
  if (isArray(val)) {
7192
7407
  methodsToPatch.forEach((m) => {
7193
7408
  val[m] = (...args) => {
7194
- Array.prototype[m].call(reactiveVal, ...args);
7409
+ Array.prototype[m].apply(reactiveVal, args);
7195
7410
  };
7196
7411
  });
7197
7412
  } else {
@@ -8415,7 +8630,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8415
8630
  if (!!(process.env.NODE_ENV !== "production") && subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8416
8631
  subTree = filterSingleRoot(subTree.children) || subTree;
8417
8632
  }
8418
- if (vnode === subTree) {
8633
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8419
8634
  const parentVNode = parentComponent.vnode;
8420
8635
  setScopeId(
8421
8636
  el,
@@ -8756,7 +8971,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8756
8971
  return;
8757
8972
  } else {
8758
8973
  instance.next = n2;
8759
- invalidateJob(instance.update);
8760
8974
  instance.update();
8761
8975
  }
8762
8976
  } else {
@@ -9680,7 +9894,6 @@ function watchSyncEffect(effect, options) {
9680
9894
  !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
9681
9895
  );
9682
9896
  }
9683
- const INITIAL_WATCHER_VALUE = {};
9684
9897
  function watch(source, cb, options) {
9685
9898
  if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
9686
9899
  warn$1(
@@ -9689,21 +9902,8 @@ function watch(source, cb, options) {
9689
9902
  }
9690
9903
  return doWatch(source, cb, options);
9691
9904
  }
9692
- function doWatch(source, cb, {
9693
- immediate,
9694
- deep,
9695
- flush,
9696
- once,
9697
- onTrack,
9698
- onTrigger
9699
- } = EMPTY_OBJ) {
9700
- if (cb && once) {
9701
- const _cb = cb;
9702
- cb = (...args) => {
9703
- _cb(...args);
9704
- watchHandle();
9705
- };
9706
- }
9905
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9906
+ const { immediate, deep, flush, once } = options;
9707
9907
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
9708
9908
  if (immediate !== void 0) {
9709
9909
  warn$1(
@@ -9721,173 +9921,53 @@ function doWatch(source, cb, {
9721
9921
  );
9722
9922
  }
9723
9923
  }
9724
- const warnInvalidSource = (s) => {
9725
- warn$1(
9726
- `Invalid watch source: `,
9727
- s,
9728
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9729
- );
9730
- };
9731
- const instance = currentInstance;
9732
- const reactiveGetter = (source2) => {
9733
- if (deep) return source2;
9734
- if (isShallow(source2) || deep === false || deep === 0)
9735
- return traverse(source2, 1);
9736
- return traverse(source2);
9737
- };
9738
- let getter;
9739
- let forceTrigger = false;
9740
- let isMultiSource = false;
9741
- if (isRef(source)) {
9742
- getter = () => source.value;
9743
- forceTrigger = isShallow(source);
9744
- } else if (isReactive(source)) {
9745
- getter = () => reactiveGetter(source);
9746
- forceTrigger = true;
9747
- } else if (isArray(source)) {
9748
- isMultiSource = true;
9749
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9750
- getter = () => source.map((s) => {
9751
- if (isRef(s)) {
9752
- return s.value;
9753
- } else if (isReactive(s)) {
9754
- return reactiveGetter(s);
9755
- } else if (isFunction(s)) {
9756
- return callWithErrorHandling(s, instance, 2);
9757
- } else {
9758
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
9759
- }
9760
- });
9761
- } else if (isFunction(source)) {
9762
- if (cb) {
9763
- getter = () => callWithErrorHandling(source, instance, 2);
9764
- } else {
9765
- getter = () => {
9766
- if (cleanup) {
9767
- cleanup();
9768
- }
9769
- return callWithAsyncErrorHandling(
9770
- source,
9771
- instance,
9772
- 3,
9773
- [onCleanup]
9774
- );
9775
- };
9776
- }
9777
- } else {
9778
- getter = NOOP;
9779
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
9780
- }
9781
- if (cb && !deep) {
9782
- const baseGetter = getter;
9783
- getter = () => {
9784
- const val = baseGetter();
9785
- if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
9786
- traverse(val);
9787
- }
9788
- return val;
9789
- };
9790
- }
9791
- if (cb && deep) {
9792
- const baseGetter = getter;
9793
- const depth = deep === true ? Infinity : deep;
9794
- getter = () => traverse(baseGetter(), depth);
9795
- }
9796
- let cleanup;
9797
- let onCleanup = (fn) => {
9798
- cleanup = effect.onStop = () => {
9799
- callWithErrorHandling(fn, instance, 4);
9800
- cleanup = effect.onStop = void 0;
9801
- };
9802
- };
9924
+ const baseWatchOptions = extend({}, options);
9925
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn$1;
9803
9926
  let ssrCleanup;
9804
9927
  if (isInSSRComponentSetup) {
9805
- onCleanup = NOOP;
9806
- if (!cb) {
9807
- getter();
9808
- } else if (immediate) {
9809
- callWithAsyncErrorHandling(cb, instance, 3, [
9810
- getter(),
9811
- isMultiSource ? [] : void 0,
9812
- onCleanup
9813
- ]);
9814
- }
9815
9928
  if (flush === "sync") {
9816
9929
  const ctx = useSSRContext();
9817
9930
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9931
+ } else if (!cb || immediate) {
9932
+ baseWatchOptions.once = true;
9818
9933
  } else {
9819
- const watchHandle2 = () => {
9934
+ return {
9935
+ stop: NOOP,
9936
+ resume: NOOP,
9937
+ pause: NOOP
9820
9938
  };
9821
- watchHandle2.stop = NOOP;
9822
- watchHandle2.resume = NOOP;
9823
- watchHandle2.pause = NOOP;
9824
- return watchHandle2;
9825
9939
  }
9826
9940
  }
9827
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9828
- const job = (immediateFirstRun) => {
9829
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9830
- return;
9831
- }
9832
- if (cb) {
9833
- const newValue = effect.run();
9834
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
9835
- if (cleanup) {
9836
- cleanup();
9837
- }
9838
- callWithAsyncErrorHandling(cb, instance, 3, [
9839
- newValue,
9840
- // pass undefined as the old value when it's changed for the first time
9841
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9842
- onCleanup
9843
- ]);
9844
- oldValue = newValue;
9941
+ const instance = currentInstance;
9942
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9943
+ let isPre = false;
9944
+ if (flush === "post") {
9945
+ baseWatchOptions.scheduler = (job) => {
9946
+ queuePostRenderEffect(job, instance && instance.suspense);
9947
+ };
9948
+ } else if (flush !== "sync") {
9949
+ isPre = true;
9950
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9951
+ if (isFirstRun) {
9952
+ job();
9953
+ } else {
9954
+ queueJob(job);
9845
9955
  }
9846
- } else {
9847
- effect.run();
9848
- }
9849
- };
9850
- if (cb) job.flags |= 4;
9851
- const effect = new ReactiveEffect(getter);
9852
- let scheduler;
9853
- if (flush === "sync") {
9854
- scheduler = job;
9855
- } else if (flush === "post") {
9856
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9857
- } else {
9858
- job.flags |= 2;
9859
- if (instance) job.id = instance.uid;
9860
- scheduler = () => queueJob(job);
9956
+ };
9861
9957
  }
9862
- effect.scheduler = scheduler;
9863
- const scope = getCurrentScope();
9864
- const watchHandle = () => {
9865
- effect.stop();
9866
- if (scope) {
9867
- remove(scope.effects, effect);
9958
+ baseWatchOptions.augmentJob = (job) => {
9959
+ if (cb) {
9960
+ job.flags |= 4;
9868
9961
  }
9869
- };
9870
- watchHandle.pause = effect.pause.bind(effect);
9871
- watchHandle.resume = effect.resume.bind(effect);
9872
- watchHandle.stop = watchHandle;
9873
- if (!!(process.env.NODE_ENV !== "production")) {
9874
- effect.onTrack = onTrack;
9875
- effect.onTrigger = onTrigger;
9876
- }
9877
- if (cb) {
9878
- if (immediate) {
9879
- job(true);
9880
- } else {
9881
- oldValue = effect.run();
9962
+ if (isPre) {
9963
+ job.flags |= 2;
9964
+ if (instance) {
9965
+ job.id = instance.uid;
9966
+ job.i = instance;
9967
+ }
9882
9968
  }
9883
- } else if (flush === "post") {
9884
- queuePostRenderEffect(
9885
- effect.run.bind(effect),
9886
- instance && instance.suspense
9887
- );
9888
- } else {
9889
- effect.run();
9890
- }
9969
+ };
9970
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9891
9971
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9892
9972
  return watchHandle;
9893
9973
  }
@@ -9916,38 +9996,6 @@ function createPathGetter(ctx, path) {
9916
9996
  return cur;
9917
9997
  };
9918
9998
  }
9919
- function traverse(value, depth = Infinity, seen) {
9920
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9921
- return value;
9922
- }
9923
- seen = seen || /* @__PURE__ */ new Set();
9924
- if (seen.has(value)) {
9925
- return value;
9926
- }
9927
- seen.add(value);
9928
- depth--;
9929
- if (isRef(value)) {
9930
- traverse(value.value, depth, seen);
9931
- } else if (isArray(value)) {
9932
- for (let i = 0; i < value.length; i++) {
9933
- traverse(value[i], depth, seen);
9934
- }
9935
- } else if (isSet(value) || isMap(value)) {
9936
- value.forEach((v) => {
9937
- traverse(v, depth, seen);
9938
- });
9939
- } else if (isPlainObject(value)) {
9940
- for (const key in value) {
9941
- traverse(value[key], depth, seen);
9942
- }
9943
- for (const key of Object.getOwnPropertySymbols(value)) {
9944
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9945
- traverse(value[key], depth, seen);
9946
- }
9947
- }
9948
- }
9949
- return value;
9950
- }
9951
9999
 
9952
10000
  function useModel(props, name, options = EMPTY_OBJ) {
9953
10001
  const i = getCurrentInstance();
@@ -12216,7 +12264,7 @@ function isMemoSame(cached, memo) {
12216
12264
  return true;
12217
12265
  }
12218
12266
 
12219
- const version = "3.5.0-beta.2";
12267
+ const version = "3.5.0-rc.1";
12220
12268
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12221
12269
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12222
12270
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -12915,8 +12963,9 @@ function compatCoerceAttr(el, key, value, instance = null) {
12915
12963
 
12916
12964
  function patchDOMProp(el, key, value, parentComponent) {
12917
12965
  if (key === "innerHTML" || key === "textContent") {
12918
- if (value == null) return;
12919
- el[key] = value;
12966
+ if (value != null) {
12967
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
12968
+ }
12920
12969
  return;
12921
12970
  }
12922
12971
  const tag = el.tagName;
@@ -13359,6 +13408,9 @@ class VueElement extends BaseClass {
13359
13408
  delete this._props[key];
13360
13409
  } else {
13361
13410
  this._props[key] = val;
13411
+ if (key === "key" && this._app) {
13412
+ this._app._ceVNode.key = val;
13413
+ }
13362
13414
  }
13363
13415
  if (shouldUpdate && this._instance) {
13364
13416
  this._update();
@@ -14258,6 +14310,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14258
14310
  effectScope: effectScope,
14259
14311
  getCurrentInstance: getCurrentInstance,
14260
14312
  getCurrentScope: getCurrentScope,
14313
+ getCurrentWatcher: getCurrentWatcher,
14261
14314
  getTransitionRawChildren: getTransitionRawChildren,
14262
14315
  guardReactiveProps: guardReactiveProps,
14263
14316
  h: h,
@@ -14300,6 +14353,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14300
14353
  onServerPrefetch: onServerPrefetch,
14301
14354
  onUnmounted: onUnmounted,
14302
14355
  onUpdated: onUpdated,
14356
+ onWatcherCleanup: onWatcherCleanup,
14303
14357
  openBlock: openBlock,
14304
14358
  popScopeId: popScopeId,
14305
14359
  provide: provide,
@@ -16145,7 +16199,9 @@ const tokenizer = new Tokenizer(stack, {
16145
16199
  case 17:
16146
16200
  case 18:
16147
16201
  case 19:
16202
+ // "
16148
16203
  case 20:
16204
+ // '
16149
16205
  case 21:
16150
16206
  emitError(9, end);
16151
16207
  break;
@@ -17128,6 +17184,7 @@ function traverseNode(node, context) {
17128
17184
  context.helper(TO_DISPLAY_STRING);
17129
17185
  }
17130
17186
  break;
17187
+ // for container types, further traverse downwards
17131
17188
  case 9:
17132
17189
  for (let i2 = 0; i2 < node.branches.length; i2++) {
17133
17190
  traverseNode(node.branches[i2], context);
@@ -17480,6 +17537,7 @@ function genNode(node, context) {
17480
17537
  case 21:
17481
17538
  genNodeList(node.body, context, true, false);
17482
17539
  break;
17540
+ // SSR only types
17483
17541
  case 22:
17484
17542
  break;
17485
17543
  case 23:
@@ -17490,6 +17548,7 @@ function genNode(node, context) {
17490
17548
  break;
17491
17549
  case 26:
17492
17550
  break;
17551
+ /* v8 ignore start */
17493
17552
  case 10:
17494
17553
  break;
17495
17554
  default:
@@ -19499,27 +19558,35 @@ function parseFilter(node, context) {
19499
19558
  case 34:
19500
19559
  inDouble = true;
19501
19560
  break;
19561
+ // "
19502
19562
  case 39:
19503
19563
  inSingle = true;
19504
19564
  break;
19565
+ // '
19505
19566
  case 96:
19506
19567
  inTemplateString = true;
19507
19568
  break;
19569
+ // `
19508
19570
  case 40:
19509
19571
  paren++;
19510
19572
  break;
19573
+ // (
19511
19574
  case 41:
19512
19575
  paren--;
19513
19576
  break;
19577
+ // )
19514
19578
  case 91:
19515
19579
  square++;
19516
19580
  break;
19581
+ // [
19517
19582
  case 93:
19518
19583
  square--;
19519
19584
  break;
19585
+ // ]
19520
19586
  case 123:
19521
19587
  curly++;
19522
19588
  break;
19589
+ // {
19523
19590
  case 125:
19524
19591
  curly--;
19525
19592
  break;
@@ -20370,4 +20437,4 @@ Vue.compile = compileToFunction;
20370
20437
 
20371
20438
  const configureCompat = Vue.configureCompat;
20372
20439
 
20373
- 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 };
20440
+ 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 };