@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;
@@ -1137,14 +1137,14 @@ function iterator(self, method, wrapValue) {
1137
1137
  const arrayProto = Array.prototype;
1138
1138
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1139
1139
  const arr = shallowReadArray(self);
1140
- let methodFn;
1141
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1142
- return methodFn.apply(arr, args);
1140
+ const needsWrap = arr !== self && !isShallow(self);
1141
+ const methodFn = arr[method];
1142
+ if (methodFn !== arrayProto[method]) {
1143
+ const result2 = methodFn.apply(arr, args);
1144
+ return needsWrap ? toReactive(result2) : result2;
1143
1145
  }
1144
- let needsWrap = false;
1145
1146
  let wrappedFn = fn;
1146
1147
  if (arr !== self) {
1147
- needsWrap = !isShallow(self);
1148
1148
  if (needsWrap) {
1149
1149
  wrappedFn = function(item, index) {
1150
1150
  return fn.call(this, toReactive(item), index, self);
@@ -1282,7 +1282,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1282
1282
  }
1283
1283
  }
1284
1284
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1285
- const result = Reflect.set(target, key, value, receiver);
1285
+ const result = Reflect.set(
1286
+ target,
1287
+ key,
1288
+ value,
1289
+ isRef(target) ? target : receiver
1290
+ );
1286
1291
  if (target === toRaw(receiver)) {
1287
1292
  if (!hadKey) {
1288
1293
  trigger(target, "add", key, value);
@@ -2006,6 +2011,220 @@ const TriggerOpTypes = {
2006
2011
  "CLEAR": "clear"
2007
2012
  };
2008
2013
 
2014
+ const INITIAL_WATCHER_VALUE = {};
2015
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
2016
+ let activeWatcher = void 0;
2017
+ function getCurrentWatcher() {
2018
+ return activeWatcher;
2019
+ }
2020
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2021
+ if (owner) {
2022
+ let cleanups = cleanupMap.get(owner);
2023
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
2024
+ cleanups.push(cleanupFn);
2025
+ } else if (!failSilently) {
2026
+ warn$2(
2027
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
2028
+ );
2029
+ }
2030
+ }
2031
+ function watch$1(source, cb, options = EMPTY_OBJ) {
2032
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
2033
+ const warnInvalidSource = (s) => {
2034
+ (options.onWarn || warn$2)(
2035
+ `Invalid watch source: `,
2036
+ s,
2037
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
2038
+ );
2039
+ };
2040
+ const reactiveGetter = (source2) => {
2041
+ if (deep) return source2;
2042
+ if (isShallow(source2) || deep === false || deep === 0)
2043
+ return traverse(source2, 1);
2044
+ return traverse(source2);
2045
+ };
2046
+ let effect;
2047
+ let getter;
2048
+ let cleanup;
2049
+ let boundCleanup;
2050
+ let forceTrigger = false;
2051
+ let isMultiSource = false;
2052
+ if (isRef(source)) {
2053
+ getter = () => source.value;
2054
+ forceTrigger = isShallow(source);
2055
+ } else if (isReactive(source)) {
2056
+ getter = () => reactiveGetter(source);
2057
+ forceTrigger = true;
2058
+ } else if (isArray(source)) {
2059
+ isMultiSource = true;
2060
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2061
+ getter = () => source.map((s) => {
2062
+ if (isRef(s)) {
2063
+ return s.value;
2064
+ } else if (isReactive(s)) {
2065
+ return reactiveGetter(s);
2066
+ } else if (isFunction(s)) {
2067
+ return call ? call(s, 2) : s();
2068
+ } else {
2069
+ warnInvalidSource(s);
2070
+ }
2071
+ });
2072
+ } else if (isFunction(source)) {
2073
+ if (cb) {
2074
+ getter = call ? () => call(source, 2) : source;
2075
+ } else {
2076
+ getter = () => {
2077
+ if (cleanup) {
2078
+ pauseTracking();
2079
+ try {
2080
+ cleanup();
2081
+ } finally {
2082
+ resetTracking();
2083
+ }
2084
+ }
2085
+ const currentEffect = activeWatcher;
2086
+ activeWatcher = effect;
2087
+ try {
2088
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2089
+ } finally {
2090
+ activeWatcher = currentEffect;
2091
+ }
2092
+ };
2093
+ }
2094
+ } else {
2095
+ getter = NOOP;
2096
+ warnInvalidSource(source);
2097
+ }
2098
+ if (cb && deep) {
2099
+ const baseGetter = getter;
2100
+ const depth = deep === true ? Infinity : deep;
2101
+ getter = () => traverse(baseGetter(), depth);
2102
+ }
2103
+ const scope = getCurrentScope();
2104
+ const watchHandle = () => {
2105
+ effect.stop();
2106
+ if (scope) {
2107
+ remove(scope.effects, effect);
2108
+ }
2109
+ };
2110
+ if (once) {
2111
+ if (cb) {
2112
+ const _cb = cb;
2113
+ cb = (...args) => {
2114
+ _cb(...args);
2115
+ watchHandle();
2116
+ };
2117
+ } else {
2118
+ const _getter = getter;
2119
+ getter = () => {
2120
+ _getter();
2121
+ watchHandle();
2122
+ };
2123
+ }
2124
+ }
2125
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2126
+ const job = (immediateFirstRun) => {
2127
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2128
+ return;
2129
+ }
2130
+ if (cb) {
2131
+ const newValue = effect.run();
2132
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2133
+ if (cleanup) {
2134
+ cleanup();
2135
+ }
2136
+ const currentWatcher = activeWatcher;
2137
+ activeWatcher = effect;
2138
+ try {
2139
+ const args = [
2140
+ newValue,
2141
+ // pass undefined as the old value when it's changed for the first time
2142
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2143
+ boundCleanup
2144
+ ];
2145
+ call ? call(cb, 3, args) : (
2146
+ // @ts-expect-error
2147
+ cb(...args)
2148
+ );
2149
+ oldValue = newValue;
2150
+ } finally {
2151
+ activeWatcher = currentWatcher;
2152
+ }
2153
+ }
2154
+ } else {
2155
+ effect.run();
2156
+ }
2157
+ };
2158
+ if (augmentJob) {
2159
+ augmentJob(job);
2160
+ }
2161
+ effect = new ReactiveEffect(getter);
2162
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2163
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2164
+ cleanup = effect.onStop = () => {
2165
+ const cleanups = cleanupMap.get(effect);
2166
+ if (cleanups) {
2167
+ if (call) {
2168
+ call(cleanups, 4);
2169
+ } else {
2170
+ for (const cleanup2 of cleanups) cleanup2();
2171
+ }
2172
+ cleanupMap.delete(effect);
2173
+ }
2174
+ };
2175
+ {
2176
+ effect.onTrack = options.onTrack;
2177
+ effect.onTrigger = options.onTrigger;
2178
+ }
2179
+ if (cb) {
2180
+ if (immediate) {
2181
+ job(true);
2182
+ } else {
2183
+ oldValue = effect.run();
2184
+ }
2185
+ } else if (scheduler) {
2186
+ scheduler(job.bind(null, true), true);
2187
+ } else {
2188
+ effect.run();
2189
+ }
2190
+ watchHandle.pause = effect.pause.bind(effect);
2191
+ watchHandle.resume = effect.resume.bind(effect);
2192
+ watchHandle.stop = watchHandle;
2193
+ return watchHandle;
2194
+ }
2195
+ function traverse(value, depth = Infinity, seen) {
2196
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2197
+ return value;
2198
+ }
2199
+ seen = seen || /* @__PURE__ */ new Set();
2200
+ if (seen.has(value)) {
2201
+ return value;
2202
+ }
2203
+ seen.add(value);
2204
+ depth--;
2205
+ if (isRef(value)) {
2206
+ traverse(value.value, depth, seen);
2207
+ } else if (isArray(value)) {
2208
+ for (let i = 0; i < value.length; i++) {
2209
+ traverse(value[i], depth, seen);
2210
+ }
2211
+ } else if (isSet(value) || isMap(value)) {
2212
+ value.forEach((v) => {
2213
+ traverse(v, depth, seen);
2214
+ });
2215
+ } else if (isPlainObject(value)) {
2216
+ for (const key in value) {
2217
+ traverse(value[key], depth, seen);
2218
+ }
2219
+ for (const key of Object.getOwnPropertySymbols(value)) {
2220
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2221
+ traverse(value[key], depth, seen);
2222
+ }
2223
+ }
2224
+ }
2225
+ return value;
2226
+ }
2227
+
2009
2228
  const stack$1 = [];
2010
2229
  function pushWarningContext(vnode) {
2011
2230
  stack$1.push(vnode);
@@ -2133,12 +2352,6 @@ const ErrorCodes = {
2133
2352
  "0": "SETUP_FUNCTION",
2134
2353
  "RENDER_FUNCTION": 1,
2135
2354
  "1": "RENDER_FUNCTION",
2136
- "WATCH_GETTER": 2,
2137
- "2": "WATCH_GETTER",
2138
- "WATCH_CALLBACK": 3,
2139
- "3": "WATCH_CALLBACK",
2140
- "WATCH_CLEANUP": 4,
2141
- "4": "WATCH_CLEANUP",
2142
2355
  "NATIVE_EVENT_HANDLER": 5,
2143
2356
  "5": "NATIVE_EVENT_HANDLER",
2144
2357
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2290,7 +2503,7 @@ function nextTick(fn) {
2290
2503
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2291
2504
  }
2292
2505
  function findInsertionIndex(id) {
2293
- let start = flushIndex + 1;
2506
+ let start = isFlushing ? flushIndex + 1 : 0;
2294
2507
  let end = queue.length;
2295
2508
  while (start < end) {
2296
2509
  const middle = start + end >>> 1;
@@ -2306,15 +2519,13 @@ function findInsertionIndex(id) {
2306
2519
  }
2307
2520
  function queueJob(job) {
2308
2521
  if (!(job.flags & 1)) {
2309
- if (job.id == null) {
2310
- queue.push(job);
2311
- } else if (
2312
- // fast path when the job id is larger than the tail
2313
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2314
- ) {
2522
+ const jobId = getId(job);
2523
+ const lastJob = queue[queue.length - 1];
2524
+ if (!lastJob || // fast path when the job id is larger than the tail
2525
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2315
2526
  queue.push(job);
2316
2527
  } else {
2317
- queue.splice(findInsertionIndex(job.id), 0, job);
2528
+ queue.splice(findInsertionIndex(jobId), 0, job);
2318
2529
  }
2319
2530
  if (!(job.flags & 4)) {
2320
2531
  job.flags |= 1;
@@ -2328,12 +2539,6 @@ function queueFlush() {
2328
2539
  currentFlushPromise = resolvedPromise.then(flushJobs);
2329
2540
  }
2330
2541
  }
2331
- function invalidateJob(job) {
2332
- const i = queue.indexOf(job);
2333
- if (i > flushIndex) {
2334
- queue.splice(i, 1);
2335
- }
2336
- }
2337
2542
  function queuePostFlushCb(cb) {
2338
2543
  if (!isArray(cb)) {
2339
2544
  if (activePostFlushCbs && cb.id === -1) {
@@ -2395,24 +2600,13 @@ function flushPostFlushCbs(seen) {
2395
2600
  postFlushIndex = 0;
2396
2601
  }
2397
2602
  }
2398
- const getId = (job) => job.id == null ? Infinity : job.id;
2399
- const comparator = (a, b) => {
2400
- const diff = getId(a) - getId(b);
2401
- if (diff === 0) {
2402
- const isAPre = a.flags & 2;
2403
- const isBPre = b.flags & 2;
2404
- if (isAPre && !isBPre) return -1;
2405
- if (isBPre && !isAPre) return 1;
2406
- }
2407
- return diff;
2408
- };
2603
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2409
2604
  function flushJobs(seen) {
2410
2605
  isFlushPending = false;
2411
2606
  isFlushing = true;
2412
2607
  {
2413
2608
  seen = seen || /* @__PURE__ */ new Map();
2414
2609
  }
2415
- queue.sort(comparator);
2416
2610
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2417
2611
  try {
2418
2612
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3053,7 +3247,7 @@ function on(instance, event, fn) {
3053
3247
  function once(instance, event, fn) {
3054
3248
  const wrapped = (...args) => {
3055
3249
  off(instance, event, wrapped);
3056
- fn.call(instance.proxy, ...args);
3250
+ fn.apply(instance.proxy, args);
3057
3251
  };
3058
3252
  wrapped.fn = fn;
3059
3253
  on(instance, event, wrapped);
@@ -3972,7 +4166,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3972
4166
  // @__NO_SIDE_EFFECTS__
3973
4167
  function defineComponent(options, extraOptions) {
3974
4168
  return isFunction(options) ? (
3975
- // #8326: extend call and options.name access are considered side-effects
4169
+ // #8236: extend call and options.name access are considered side-effects
3976
4170
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
3977
4171
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
3978
4172
  ) : options;
@@ -5099,6 +5293,7 @@ const KeepAliveImpl = {
5099
5293
  );
5100
5294
  const { include, exclude, max } = props;
5101
5295
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
5296
+ vnode.shapeFlag &= ~256;
5102
5297
  current = vnode;
5103
5298
  return rawVNode;
5104
5299
  }
@@ -6587,23 +6782,43 @@ function callHook$1(hook, instance, type) {
6587
6782
  );
6588
6783
  }
6589
6784
  function createWatcher(raw, ctx, publicThis, key) {
6590
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6785
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6786
+ const options = {};
6787
+ {
6788
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6789
+ const newValue = getter();
6790
+ if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
6791
+ options.deep = true;
6792
+ }
6793
+ const baseGetter = getter;
6794
+ getter = () => {
6795
+ const val = baseGetter();
6796
+ if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
6797
+ traverse(val);
6798
+ }
6799
+ return val;
6800
+ };
6801
+ }
6591
6802
  if (isString(raw)) {
6592
6803
  const handler = ctx[raw];
6593
6804
  if (isFunction(handler)) {
6594
- watch(getter, handler);
6805
+ {
6806
+ watch(getter, handler, options);
6807
+ }
6595
6808
  } else {
6596
6809
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6597
6810
  }
6598
6811
  } else if (isFunction(raw)) {
6599
- watch(getter, raw.bind(publicThis));
6812
+ {
6813
+ watch(getter, raw.bind(publicThis), options);
6814
+ }
6600
6815
  } else if (isObject(raw)) {
6601
6816
  if (isArray(raw)) {
6602
6817
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6603
6818
  } else {
6604
6819
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6605
6820
  if (isFunction(handler)) {
6606
- watch(getter, handler, raw);
6821
+ watch(getter, handler, extend(raw, options) );
6607
6822
  } else {
6608
6823
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6609
6824
  }
@@ -6827,7 +7042,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6827
7042
  return vm;
6828
7043
  }
6829
7044
  }
6830
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7045
+ Vue.version = `2.6.14-compat:${"3.5.0-rc.1"}`;
6831
7046
  Vue.config = singletonApp.config;
6832
7047
  Vue.use = (plugin, ...options) => {
6833
7048
  if (plugin && isFunction(plugin.install)) {
@@ -7159,7 +7374,7 @@ function defineReactive(obj, key, val) {
7159
7374
  if (isArray(val)) {
7160
7375
  methodsToPatch.forEach((m) => {
7161
7376
  val[m] = (...args) => {
7162
- Array.prototype[m].call(reactiveVal, ...args);
7377
+ Array.prototype[m].apply(reactiveVal, args);
7163
7378
  };
7164
7379
  });
7165
7380
  } else {
@@ -8354,7 +8569,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8354
8569
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8355
8570
  subTree = filterSingleRoot(subTree.children) || subTree;
8356
8571
  }
8357
- if (vnode === subTree) {
8572
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8358
8573
  const parentVNode = parentComponent.vnode;
8359
8574
  setScopeId(
8360
8575
  el,
@@ -8684,7 +8899,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8684
8899
  return;
8685
8900
  } else {
8686
8901
  instance.next = n2;
8687
- invalidateJob(instance.update);
8688
8902
  instance.update();
8689
8903
  }
8690
8904
  } else {
@@ -9608,7 +9822,6 @@ function watchSyncEffect(effect, options) {
9608
9822
  extend({}, options, { flush: "sync" })
9609
9823
  );
9610
9824
  }
9611
- const INITIAL_WATCHER_VALUE = {};
9612
9825
  function watch(source, cb, options) {
9613
9826
  if (!isFunction(cb)) {
9614
9827
  warn$1(
@@ -9617,21 +9830,8 @@ function watch(source, cb, options) {
9617
9830
  }
9618
9831
  return doWatch(source, cb, options);
9619
9832
  }
9620
- function doWatch(source, cb, {
9621
- immediate,
9622
- deep,
9623
- flush,
9624
- once,
9625
- onTrack,
9626
- onTrigger
9627
- } = EMPTY_OBJ) {
9628
- if (cb && once) {
9629
- const _cb = cb;
9630
- cb = (...args) => {
9631
- _cb(...args);
9632
- watchHandle();
9633
- };
9634
- }
9833
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9834
+ const { immediate, deep, flush, once } = options;
9635
9835
  if (!cb) {
9636
9836
  if (immediate !== void 0) {
9637
9837
  warn$1(
@@ -9649,173 +9849,53 @@ function doWatch(source, cb, {
9649
9849
  );
9650
9850
  }
9651
9851
  }
9652
- const warnInvalidSource = (s) => {
9653
- warn$1(
9654
- `Invalid watch source: `,
9655
- s,
9656
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9657
- );
9658
- };
9659
- const instance = currentInstance;
9660
- const reactiveGetter = (source2) => {
9661
- if (deep) return source2;
9662
- if (isShallow(source2) || deep === false || deep === 0)
9663
- return traverse(source2, 1);
9664
- return traverse(source2);
9665
- };
9666
- let getter;
9667
- let forceTrigger = false;
9668
- let isMultiSource = false;
9669
- if (isRef(source)) {
9670
- getter = () => source.value;
9671
- forceTrigger = isShallow(source);
9672
- } else if (isReactive(source)) {
9673
- getter = () => reactiveGetter(source);
9674
- forceTrigger = true;
9675
- } else if (isArray(source)) {
9676
- isMultiSource = true;
9677
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9678
- getter = () => source.map((s) => {
9679
- if (isRef(s)) {
9680
- return s.value;
9681
- } else if (isReactive(s)) {
9682
- return reactiveGetter(s);
9683
- } else if (isFunction(s)) {
9684
- return callWithErrorHandling(s, instance, 2);
9685
- } else {
9686
- warnInvalidSource(s);
9687
- }
9688
- });
9689
- } else if (isFunction(source)) {
9690
- if (cb) {
9691
- getter = () => callWithErrorHandling(source, instance, 2);
9692
- } else {
9693
- getter = () => {
9694
- if (cleanup) {
9695
- cleanup();
9696
- }
9697
- return callWithAsyncErrorHandling(
9698
- source,
9699
- instance,
9700
- 3,
9701
- [onCleanup]
9702
- );
9703
- };
9704
- }
9705
- } else {
9706
- getter = NOOP;
9707
- warnInvalidSource(source);
9708
- }
9709
- if (cb && !deep) {
9710
- const baseGetter = getter;
9711
- getter = () => {
9712
- const val = baseGetter();
9713
- if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
9714
- traverse(val);
9715
- }
9716
- return val;
9717
- };
9718
- }
9719
- if (cb && deep) {
9720
- const baseGetter = getter;
9721
- const depth = deep === true ? Infinity : deep;
9722
- getter = () => traverse(baseGetter(), depth);
9723
- }
9724
- let cleanup;
9725
- let onCleanup = (fn) => {
9726
- cleanup = effect.onStop = () => {
9727
- callWithErrorHandling(fn, instance, 4);
9728
- cleanup = effect.onStop = void 0;
9729
- };
9730
- };
9852
+ const baseWatchOptions = extend({}, options);
9853
+ baseWatchOptions.onWarn = warn$1;
9731
9854
  let ssrCleanup;
9732
9855
  if (isInSSRComponentSetup) {
9733
- onCleanup = NOOP;
9734
- if (!cb) {
9735
- getter();
9736
- } else if (immediate) {
9737
- callWithAsyncErrorHandling(cb, instance, 3, [
9738
- getter(),
9739
- isMultiSource ? [] : void 0,
9740
- onCleanup
9741
- ]);
9742
- }
9743
9856
  if (flush === "sync") {
9744
9857
  const ctx = useSSRContext();
9745
9858
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9859
+ } else if (!cb || immediate) {
9860
+ baseWatchOptions.once = true;
9746
9861
  } else {
9747
- const watchHandle2 = () => {
9862
+ return {
9863
+ stop: NOOP,
9864
+ resume: NOOP,
9865
+ pause: NOOP
9748
9866
  };
9749
- watchHandle2.stop = NOOP;
9750
- watchHandle2.resume = NOOP;
9751
- watchHandle2.pause = NOOP;
9752
- return watchHandle2;
9753
9867
  }
9754
9868
  }
9755
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9756
- const job = (immediateFirstRun) => {
9757
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9758
- return;
9759
- }
9760
- if (cb) {
9761
- const newValue = effect.run();
9762
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
9763
- if (cleanup) {
9764
- cleanup();
9765
- }
9766
- callWithAsyncErrorHandling(cb, instance, 3, [
9767
- newValue,
9768
- // pass undefined as the old value when it's changed for the first time
9769
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9770
- onCleanup
9771
- ]);
9772
- oldValue = newValue;
9869
+ const instance = currentInstance;
9870
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9871
+ let isPre = false;
9872
+ if (flush === "post") {
9873
+ baseWatchOptions.scheduler = (job) => {
9874
+ queuePostRenderEffect(job, instance && instance.suspense);
9875
+ };
9876
+ } else if (flush !== "sync") {
9877
+ isPre = true;
9878
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9879
+ if (isFirstRun) {
9880
+ job();
9881
+ } else {
9882
+ queueJob(job);
9773
9883
  }
9774
- } else {
9775
- effect.run();
9776
- }
9777
- };
9778
- if (cb) job.flags |= 4;
9779
- const effect = new ReactiveEffect(getter);
9780
- let scheduler;
9781
- if (flush === "sync") {
9782
- scheduler = job;
9783
- } else if (flush === "post") {
9784
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9785
- } else {
9786
- job.flags |= 2;
9787
- if (instance) job.id = instance.uid;
9788
- scheduler = () => queueJob(job);
9884
+ };
9789
9885
  }
9790
- effect.scheduler = scheduler;
9791
- const scope = getCurrentScope();
9792
- const watchHandle = () => {
9793
- effect.stop();
9794
- if (scope) {
9795
- remove(scope.effects, effect);
9886
+ baseWatchOptions.augmentJob = (job) => {
9887
+ if (cb) {
9888
+ job.flags |= 4;
9796
9889
  }
9797
- };
9798
- watchHandle.pause = effect.pause.bind(effect);
9799
- watchHandle.resume = effect.resume.bind(effect);
9800
- watchHandle.stop = watchHandle;
9801
- {
9802
- effect.onTrack = onTrack;
9803
- effect.onTrigger = onTrigger;
9804
- }
9805
- if (cb) {
9806
- if (immediate) {
9807
- job(true);
9808
- } else {
9809
- oldValue = effect.run();
9890
+ if (isPre) {
9891
+ job.flags |= 2;
9892
+ if (instance) {
9893
+ job.id = instance.uid;
9894
+ job.i = instance;
9895
+ }
9810
9896
  }
9811
- } else if (flush === "post") {
9812
- queuePostRenderEffect(
9813
- effect.run.bind(effect),
9814
- instance && instance.suspense
9815
- );
9816
- } else {
9817
- effect.run();
9818
- }
9897
+ };
9898
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9819
9899
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9820
9900
  return watchHandle;
9821
9901
  }
@@ -9844,38 +9924,6 @@ function createPathGetter(ctx, path) {
9844
9924
  return cur;
9845
9925
  };
9846
9926
  }
9847
- function traverse(value, depth = Infinity, seen) {
9848
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9849
- return value;
9850
- }
9851
- seen = seen || /* @__PURE__ */ new Set();
9852
- if (seen.has(value)) {
9853
- return value;
9854
- }
9855
- seen.add(value);
9856
- depth--;
9857
- if (isRef(value)) {
9858
- traverse(value.value, depth, seen);
9859
- } else if (isArray(value)) {
9860
- for (let i = 0; i < value.length; i++) {
9861
- traverse(value[i], depth, seen);
9862
- }
9863
- } else if (isSet(value) || isMap(value)) {
9864
- value.forEach((v) => {
9865
- traverse(v, depth, seen);
9866
- });
9867
- } else if (isPlainObject(value)) {
9868
- for (const key in value) {
9869
- traverse(value[key], depth, seen);
9870
- }
9871
- for (const key of Object.getOwnPropertySymbols(value)) {
9872
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9873
- traverse(value[key], depth, seen);
9874
- }
9875
- }
9876
- }
9877
- return value;
9878
- }
9879
9927
 
9880
9928
  function useModel(props, name, options = EMPTY_OBJ) {
9881
9929
  const i = getCurrentInstance();
@@ -12130,7 +12178,7 @@ function isMemoSame(cached, memo) {
12130
12178
  return true;
12131
12179
  }
12132
12180
 
12133
- const version = "3.5.0-beta.2";
12181
+ const version = "3.5.0-rc.1";
12134
12182
  const warn = warn$1 ;
12135
12183
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12136
12184
  const devtools = devtools$1 ;
@@ -12829,8 +12877,9 @@ function compatCoerceAttr(el, key, value, instance = null) {
12829
12877
 
12830
12878
  function patchDOMProp(el, key, value, parentComponent) {
12831
12879
  if (key === "innerHTML" || key === "textContent") {
12832
- if (value == null) return;
12833
- el[key] = value;
12880
+ if (value != null) {
12881
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
12882
+ }
12834
12883
  return;
12835
12884
  }
12836
12885
  const tag = el.tagName;
@@ -13273,6 +13322,9 @@ class VueElement extends BaseClass {
13273
13322
  delete this._props[key];
13274
13323
  } else {
13275
13324
  this._props[key] = val;
13325
+ if (key === "key" && this._app) {
13326
+ this._app._ceVNode.key = val;
13327
+ }
13276
13328
  }
13277
13329
  if (shouldUpdate && this._instance) {
13278
13330
  this._update();
@@ -14172,6 +14224,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14172
14224
  effectScope: effectScope,
14173
14225
  getCurrentInstance: getCurrentInstance,
14174
14226
  getCurrentScope: getCurrentScope,
14227
+ getCurrentWatcher: getCurrentWatcher,
14175
14228
  getTransitionRawChildren: getTransitionRawChildren,
14176
14229
  guardReactiveProps: guardReactiveProps,
14177
14230
  h: h,
@@ -14214,6 +14267,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14214
14267
  onServerPrefetch: onServerPrefetch,
14215
14268
  onUnmounted: onUnmounted,
14216
14269
  onUpdated: onUpdated,
14270
+ onWatcherCleanup: onWatcherCleanup,
14217
14271
  openBlock: openBlock,
14218
14272
  popScopeId: popScopeId,
14219
14273
  provide: provide,
@@ -16065,7 +16119,9 @@ const tokenizer = new Tokenizer(stack, {
16065
16119
  case 17:
16066
16120
  case 18:
16067
16121
  case 19:
16122
+ // "
16068
16123
  case 20:
16124
+ // '
16069
16125
  case 21:
16070
16126
  emitError(9, end);
16071
16127
  break;
@@ -17047,6 +17103,7 @@ function traverseNode(node, context) {
17047
17103
  context.helper(TO_DISPLAY_STRING);
17048
17104
  }
17049
17105
  break;
17106
+ // for container types, further traverse downwards
17050
17107
  case 9:
17051
17108
  for (let i2 = 0; i2 < node.branches.length; i2++) {
17052
17109
  traverseNode(node.branches[i2], context);
@@ -17399,6 +17456,7 @@ function genNode(node, context) {
17399
17456
  case 21:
17400
17457
  genNodeList(node.body, context, true, false);
17401
17458
  break;
17459
+ // SSR only types
17402
17460
  case 22:
17403
17461
  break;
17404
17462
  case 23:
@@ -17409,6 +17467,7 @@ function genNode(node, context) {
17409
17467
  break;
17410
17468
  case 26:
17411
17469
  break;
17470
+ /* v8 ignore start */
17412
17471
  case 10:
17413
17472
  break;
17414
17473
  default:
@@ -19416,27 +19475,35 @@ function parseFilter(node, context) {
19416
19475
  case 34:
19417
19476
  inDouble = true;
19418
19477
  break;
19478
+ // "
19419
19479
  case 39:
19420
19480
  inSingle = true;
19421
19481
  break;
19482
+ // '
19422
19483
  case 96:
19423
19484
  inTemplateString = true;
19424
19485
  break;
19486
+ // `
19425
19487
  case 40:
19426
19488
  paren++;
19427
19489
  break;
19490
+ // (
19428
19491
  case 41:
19429
19492
  paren--;
19430
19493
  break;
19494
+ // )
19431
19495
  case 91:
19432
19496
  square++;
19433
19497
  break;
19498
+ // [
19434
19499
  case 93:
19435
19500
  square--;
19436
19501
  break;
19502
+ // ]
19437
19503
  case 123:
19438
19504
  curly++;
19439
19505
  break;
19506
+ // {
19440
19507
  case 125:
19441
19508
  curly--;
19442
19509
  break;
@@ -20287,4 +20354,4 @@ Vue.compile = compileToFunction;
20287
20354
 
20288
20355
  const configureCompat = Vue.configureCompat;
20289
20356
 
20290
- 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 };
20357
+ 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 };