@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
  **/
@@ -379,12 +379,13 @@ class EffectScope {
379
379
  pause() {
380
380
  if (this._active) {
381
381
  this._isPaused = true;
382
+ let i, l;
382
383
  if (this.scopes) {
383
- for (let i = 0, l = this.scopes.length; i < l; i++) {
384
+ for (i = 0, l = this.scopes.length; i < l; i++) {
384
385
  this.scopes[i].pause();
385
386
  }
386
387
  }
387
- for (let i = 0, l = this.effects.length; i < l; i++) {
388
+ for (i = 0, l = this.effects.length; i < l; i++) {
388
389
  this.effects[i].pause();
389
390
  }
390
391
  }
@@ -396,12 +397,13 @@ class EffectScope {
396
397
  if (this._active) {
397
398
  if (this._isPaused) {
398
399
  this._isPaused = false;
400
+ let i, l;
399
401
  if (this.scopes) {
400
- for (let i = 0, l = this.scopes.length; i < l; i++) {
402
+ for (i = 0, l = this.scopes.length; i < l; i++) {
401
403
  this.scopes[i].resume();
402
404
  }
403
405
  }
404
- for (let i = 0, l = this.effects.length; i < l; i++) {
406
+ for (i = 0, l = this.effects.length; i < l; i++) {
405
407
  this.effects[i].resume();
406
408
  }
407
409
  }
@@ -583,11 +585,9 @@ function startBatch() {
583
585
  batchDepth++;
584
586
  }
585
587
  function endBatch() {
586
- if (batchDepth > 1) {
587
- batchDepth--;
588
+ if (--batchDepth > 0) {
588
589
  return;
589
590
  }
590
- batchDepth--;
591
591
  let error;
592
592
  while (batchedEffect) {
593
593
  let e = batchedEffect;
@@ -1061,14 +1061,14 @@ function iterator(self, method, wrapValue) {
1061
1061
  const arrayProto = Array.prototype;
1062
1062
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1063
1063
  const arr = shallowReadArray(self);
1064
- let methodFn;
1065
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1066
- return methodFn.apply(arr, args);
1064
+ const needsWrap = arr !== self && !isShallow(self);
1065
+ const methodFn = arr[method];
1066
+ if (methodFn !== arrayProto[method]) {
1067
+ const result2 = methodFn.apply(arr, args);
1068
+ return needsWrap ? toReactive(result2) : result2;
1067
1069
  }
1068
- let needsWrap = false;
1069
1070
  let wrappedFn = fn;
1070
1071
  if (arr !== self) {
1071
- needsWrap = !isShallow(self);
1072
1072
  if (needsWrap) {
1073
1073
  wrappedFn = function(item, index) {
1074
1074
  return fn.call(this, toReactive(item), index, self);
@@ -1206,7 +1206,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1206
1206
  }
1207
1207
  }
1208
1208
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1209
- const result = Reflect.set(target, key, value, receiver);
1209
+ const result = Reflect.set(
1210
+ target,
1211
+ key,
1212
+ value,
1213
+ isRef(target) ? target : receiver
1214
+ );
1210
1215
  if (target === toRaw(receiver)) {
1211
1216
  if (!hadKey) {
1212
1217
  trigger(target, "add", key, value);
@@ -1862,6 +1867,202 @@ const TriggerOpTypes = {
1862
1867
  "CLEAR": "clear"
1863
1868
  };
1864
1869
 
1870
+ const INITIAL_WATCHER_VALUE = {};
1871
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1872
+ let activeWatcher = void 0;
1873
+ function getCurrentWatcher() {
1874
+ return activeWatcher;
1875
+ }
1876
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1877
+ if (owner) {
1878
+ let cleanups = cleanupMap.get(owner);
1879
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1880
+ cleanups.push(cleanupFn);
1881
+ }
1882
+ }
1883
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1884
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1885
+ const reactiveGetter = (source2) => {
1886
+ if (deep) return source2;
1887
+ if (isShallow(source2) || deep === false || deep === 0)
1888
+ return traverse(source2, 1);
1889
+ return traverse(source2);
1890
+ };
1891
+ let effect;
1892
+ let getter;
1893
+ let cleanup;
1894
+ let boundCleanup;
1895
+ let forceTrigger = false;
1896
+ let isMultiSource = false;
1897
+ if (isRef(source)) {
1898
+ getter = () => source.value;
1899
+ forceTrigger = isShallow(source);
1900
+ } else if (isReactive(source)) {
1901
+ getter = () => reactiveGetter(source);
1902
+ forceTrigger = true;
1903
+ } else if (isArray(source)) {
1904
+ isMultiSource = true;
1905
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1906
+ getter = () => source.map((s) => {
1907
+ if (isRef(s)) {
1908
+ return s.value;
1909
+ } else if (isReactive(s)) {
1910
+ return reactiveGetter(s);
1911
+ } else if (isFunction(s)) {
1912
+ return call ? call(s, 2) : s();
1913
+ } else ;
1914
+ });
1915
+ } else if (isFunction(source)) {
1916
+ if (cb) {
1917
+ getter = call ? () => call(source, 2) : source;
1918
+ } else {
1919
+ getter = () => {
1920
+ if (cleanup) {
1921
+ pauseTracking();
1922
+ try {
1923
+ cleanup();
1924
+ } finally {
1925
+ resetTracking();
1926
+ }
1927
+ }
1928
+ const currentEffect = activeWatcher;
1929
+ activeWatcher = effect;
1930
+ try {
1931
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1932
+ } finally {
1933
+ activeWatcher = currentEffect;
1934
+ }
1935
+ };
1936
+ }
1937
+ } else {
1938
+ getter = NOOP;
1939
+ }
1940
+ if (cb && deep) {
1941
+ const baseGetter = getter;
1942
+ const depth = deep === true ? Infinity : deep;
1943
+ getter = () => traverse(baseGetter(), depth);
1944
+ }
1945
+ const scope = getCurrentScope();
1946
+ const watchHandle = () => {
1947
+ effect.stop();
1948
+ if (scope) {
1949
+ remove(scope.effects, effect);
1950
+ }
1951
+ };
1952
+ if (once) {
1953
+ if (cb) {
1954
+ const _cb = cb;
1955
+ cb = (...args) => {
1956
+ _cb(...args);
1957
+ watchHandle();
1958
+ };
1959
+ } else {
1960
+ const _getter = getter;
1961
+ getter = () => {
1962
+ _getter();
1963
+ watchHandle();
1964
+ };
1965
+ }
1966
+ }
1967
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1968
+ const job = (immediateFirstRun) => {
1969
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1970
+ return;
1971
+ }
1972
+ if (cb) {
1973
+ const newValue = effect.run();
1974
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1975
+ if (cleanup) {
1976
+ cleanup();
1977
+ }
1978
+ const currentWatcher = activeWatcher;
1979
+ activeWatcher = effect;
1980
+ try {
1981
+ const args = [
1982
+ newValue,
1983
+ // pass undefined as the old value when it's changed for the first time
1984
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1985
+ boundCleanup
1986
+ ];
1987
+ call ? call(cb, 3, args) : (
1988
+ // @ts-expect-error
1989
+ cb(...args)
1990
+ );
1991
+ oldValue = newValue;
1992
+ } finally {
1993
+ activeWatcher = currentWatcher;
1994
+ }
1995
+ }
1996
+ } else {
1997
+ effect.run();
1998
+ }
1999
+ };
2000
+ if (augmentJob) {
2001
+ augmentJob(job);
2002
+ }
2003
+ effect = new ReactiveEffect(getter);
2004
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2005
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2006
+ cleanup = effect.onStop = () => {
2007
+ const cleanups = cleanupMap.get(effect);
2008
+ if (cleanups) {
2009
+ if (call) {
2010
+ call(cleanups, 4);
2011
+ } else {
2012
+ for (const cleanup2 of cleanups) cleanup2();
2013
+ }
2014
+ cleanupMap.delete(effect);
2015
+ }
2016
+ };
2017
+ if (cb) {
2018
+ if (immediate) {
2019
+ job(true);
2020
+ } else {
2021
+ oldValue = effect.run();
2022
+ }
2023
+ } else if (scheduler) {
2024
+ scheduler(job.bind(null, true), true);
2025
+ } else {
2026
+ effect.run();
2027
+ }
2028
+ watchHandle.pause = effect.pause.bind(effect);
2029
+ watchHandle.resume = effect.resume.bind(effect);
2030
+ watchHandle.stop = watchHandle;
2031
+ return watchHandle;
2032
+ }
2033
+ function traverse(value, depth = Infinity, seen) {
2034
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2035
+ return value;
2036
+ }
2037
+ seen = seen || /* @__PURE__ */ new Set();
2038
+ if (seen.has(value)) {
2039
+ return value;
2040
+ }
2041
+ seen.add(value);
2042
+ depth--;
2043
+ if (isRef(value)) {
2044
+ traverse(value.value, depth, seen);
2045
+ } else if (isArray(value)) {
2046
+ for (let i = 0; i < value.length; i++) {
2047
+ traverse(value[i], depth, seen);
2048
+ }
2049
+ } else if (isSet(value) || isMap(value)) {
2050
+ value.forEach((v) => {
2051
+ traverse(v, depth, seen);
2052
+ });
2053
+ } else if (isPlainObject(value)) {
2054
+ for (const key in value) {
2055
+ traverse(value[key], depth, seen);
2056
+ }
2057
+ for (const key of Object.getOwnPropertySymbols(value)) {
2058
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2059
+ traverse(value[key], depth, seen);
2060
+ }
2061
+ }
2062
+ }
2063
+ return value;
2064
+ }
2065
+
1865
2066
  function assertNumber(val, type) {
1866
2067
  return;
1867
2068
  }
@@ -1871,12 +2072,6 @@ const ErrorCodes = {
1871
2072
  "0": "SETUP_FUNCTION",
1872
2073
  "RENDER_FUNCTION": 1,
1873
2074
  "1": "RENDER_FUNCTION",
1874
- "WATCH_GETTER": 2,
1875
- "2": "WATCH_GETTER",
1876
- "WATCH_CALLBACK": 3,
1877
- "3": "WATCH_CALLBACK",
1878
- "WATCH_CLEANUP": 4,
1879
- "4": "WATCH_CLEANUP",
1880
2075
  "NATIVE_EVENT_HANDLER": 5,
1881
2076
  "5": "NATIVE_EVENT_HANDLER",
1882
2077
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2013,7 +2208,7 @@ function nextTick(fn) {
2013
2208
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2014
2209
  }
2015
2210
  function findInsertionIndex(id) {
2016
- let start = flushIndex + 1;
2211
+ let start = isFlushing ? flushIndex + 1 : 0;
2017
2212
  let end = queue.length;
2018
2213
  while (start < end) {
2019
2214
  const middle = start + end >>> 1;
@@ -2029,15 +2224,13 @@ function findInsertionIndex(id) {
2029
2224
  }
2030
2225
  function queueJob(job) {
2031
2226
  if (!(job.flags & 1)) {
2032
- if (job.id == null) {
2033
- queue.push(job);
2034
- } else if (
2035
- // fast path when the job id is larger than the tail
2036
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2037
- ) {
2227
+ const jobId = getId(job);
2228
+ const lastJob = queue[queue.length - 1];
2229
+ if (!lastJob || // fast path when the job id is larger than the tail
2230
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2038
2231
  queue.push(job);
2039
2232
  } else {
2040
- queue.splice(findInsertionIndex(job.id), 0, job);
2233
+ queue.splice(findInsertionIndex(jobId), 0, job);
2041
2234
  }
2042
2235
  if (!(job.flags & 4)) {
2043
2236
  job.flags |= 1;
@@ -2051,12 +2244,6 @@ function queueFlush() {
2051
2244
  currentFlushPromise = resolvedPromise.then(flushJobs);
2052
2245
  }
2053
2246
  }
2054
- function invalidateJob(job) {
2055
- const i = queue.indexOf(job);
2056
- if (i > flushIndex) {
2057
- queue.splice(i, 1);
2058
- }
2059
- }
2060
2247
  function queuePostFlushCb(cb) {
2061
2248
  if (!isArray(cb)) {
2062
2249
  if (activePostFlushCbs && cb.id === -1) {
@@ -2106,21 +2293,10 @@ function flushPostFlushCbs(seen) {
2106
2293
  postFlushIndex = 0;
2107
2294
  }
2108
2295
  }
2109
- const getId = (job) => job.id == null ? Infinity : job.id;
2110
- const comparator = (a, b) => {
2111
- const diff = getId(a) - getId(b);
2112
- if (diff === 0) {
2113
- const isAPre = a.flags & 2;
2114
- const isBPre = b.flags & 2;
2115
- if (isAPre && !isBPre) return -1;
2116
- if (isBPre && !isAPre) return 1;
2117
- }
2118
- return diff;
2119
- };
2296
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2120
2297
  function flushJobs(seen) {
2121
2298
  isFlushPending = false;
2122
2299
  isFlushing = true;
2123
- queue.sort(comparator);
2124
2300
  try {
2125
2301
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
2126
2302
  const job = queue[flushIndex];
@@ -2263,7 +2439,7 @@ function on(instance, event, fn) {
2263
2439
  function once(instance, event, fn) {
2264
2440
  const wrapped = (...args) => {
2265
2441
  off(instance, event, wrapped);
2266
- fn.call(instance.proxy, ...args);
2442
+ fn.apply(instance.proxy, args);
2267
2443
  };
2268
2444
  wrapped.fn = fn;
2269
2445
  on(instance, event, wrapped);
@@ -3126,7 +3302,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3126
3302
  // @__NO_SIDE_EFFECTS__
3127
3303
  function defineComponent(options, extraOptions) {
3128
3304
  return isFunction(options) ? (
3129
- // #8326: extend call and options.name access are considered side-effects
3305
+ // #8236: extend call and options.name access are considered side-effects
3130
3306
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
3131
3307
  /* @__PURE__ */ (() => extend$1({ name: options.name }, extraOptions, { setup: options }))()
3132
3308
  ) : options;
@@ -4054,6 +4230,7 @@ const KeepAliveImpl = {
4054
4230
  );
4055
4231
  const { include, exclude, max } = props;
4056
4232
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
4233
+ vnode.shapeFlag &= ~256;
4057
4234
  current = vnode;
4058
4235
  return rawVNode;
4059
4236
  }
@@ -5301,21 +5478,41 @@ function callHook$1(hook, instance, type) {
5301
5478
  );
5302
5479
  }
5303
5480
  function createWatcher(raw, ctx, publicThis, key) {
5304
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5481
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5482
+ const options = {};
5483
+ {
5484
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
5485
+ const newValue = getter();
5486
+ if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
5487
+ options.deep = true;
5488
+ }
5489
+ const baseGetter = getter;
5490
+ getter = () => {
5491
+ const val = baseGetter();
5492
+ if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
5493
+ traverse(val);
5494
+ }
5495
+ return val;
5496
+ };
5497
+ }
5305
5498
  if (isString(raw)) {
5306
5499
  const handler = ctx[raw];
5307
5500
  if (isFunction(handler)) {
5308
- watch(getter, handler);
5501
+ {
5502
+ watch(getter, handler, options);
5503
+ }
5309
5504
  }
5310
5505
  } else if (isFunction(raw)) {
5311
- watch(getter, raw.bind(publicThis));
5506
+ {
5507
+ watch(getter, raw.bind(publicThis), options);
5508
+ }
5312
5509
  } else if (isObject(raw)) {
5313
5510
  if (isArray(raw)) {
5314
5511
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
5315
5512
  } else {
5316
5513
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
5317
5514
  if (isFunction(handler)) {
5318
- watch(getter, handler, raw);
5515
+ watch(getter, handler, extend$1(raw, options) );
5319
5516
  }
5320
5517
  }
5321
5518
  } else ;
@@ -5506,7 +5703,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5506
5703
  return vm;
5507
5704
  }
5508
5705
  }
5509
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
5706
+ Vue.version = `2.6.14-compat:${"3.5.0-rc.1"}`;
5510
5707
  Vue.config = singletonApp.config;
5511
5708
  Vue.use = (plugin, ...options) => {
5512
5709
  if (plugin && isFunction(plugin.install)) {
@@ -5800,7 +5997,7 @@ function defineReactive(obj, key, val) {
5800
5997
  if (isArray(val)) {
5801
5998
  methodsToPatch.forEach((m) => {
5802
5999
  val[m] = (...args) => {
5803
- Array.prototype[m].call(reactiveVal, ...args);
6000
+ Array.prototype[m].apply(reactiveVal, args);
5804
6001
  };
5805
6002
  });
5806
6003
  } else {
@@ -6698,7 +6895,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6698
6895
  }
6699
6896
  if (parentComponent) {
6700
6897
  let subTree = parentComponent.subTree;
6701
- if (vnode === subTree) {
6898
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
6702
6899
  const parentVNode = parentComponent.vnode;
6703
6900
  setScopeId(
6704
6901
  el,
@@ -6997,7 +7194,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6997
7194
  return;
6998
7195
  } else {
6999
7196
  instance.next = n2;
7000
- invalidateJob(instance.update);
7001
7197
  instance.update();
7002
7198
  }
7003
7199
  } else {
@@ -7840,178 +8036,57 @@ function watchSyncEffect(effect, options) {
7840
8036
  { flush: "sync" }
7841
8037
  );
7842
8038
  }
7843
- const INITIAL_WATCHER_VALUE = {};
7844
8039
  function watch(source, cb, options) {
7845
8040
  return doWatch(source, cb, options);
7846
8041
  }
7847
- function doWatch(source, cb, {
7848
- immediate,
7849
- deep,
7850
- flush,
7851
- once,
7852
- onTrack,
7853
- onTrigger
7854
- } = EMPTY_OBJ) {
7855
- if (cb && once) {
7856
- const _cb = cb;
7857
- cb = (...args) => {
7858
- _cb(...args);
7859
- watchHandle();
7860
- };
7861
- }
7862
- const instance = currentInstance;
7863
- const reactiveGetter = (source2) => {
7864
- if (deep) return source2;
7865
- if (isShallow(source2) || deep === false || deep === 0)
7866
- return traverse(source2, 1);
7867
- return traverse(source2);
7868
- };
7869
- let getter;
7870
- let forceTrigger = false;
7871
- let isMultiSource = false;
7872
- if (isRef(source)) {
7873
- getter = () => source.value;
7874
- forceTrigger = isShallow(source);
7875
- } else if (isReactive(source)) {
7876
- getter = () => reactiveGetter(source);
7877
- forceTrigger = true;
7878
- } else if (isArray(source)) {
7879
- isMultiSource = true;
7880
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
7881
- getter = () => source.map((s) => {
7882
- if (isRef(s)) {
7883
- return s.value;
7884
- } else if (isReactive(s)) {
7885
- return reactiveGetter(s);
7886
- } else if (isFunction(s)) {
7887
- return callWithErrorHandling(s, instance, 2);
7888
- } else ;
7889
- });
7890
- } else if (isFunction(source)) {
7891
- if (cb) {
7892
- getter = () => callWithErrorHandling(source, instance, 2);
7893
- } else {
7894
- getter = () => {
7895
- if (cleanup) {
7896
- cleanup();
7897
- }
7898
- return callWithAsyncErrorHandling(
7899
- source,
7900
- instance,
7901
- 3,
7902
- [onCleanup]
7903
- );
7904
- };
7905
- }
7906
- } else {
7907
- getter = NOOP;
7908
- }
7909
- if (cb && !deep) {
7910
- const baseGetter = getter;
7911
- getter = () => {
7912
- const val = baseGetter();
7913
- if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
7914
- traverse(val);
7915
- }
7916
- return val;
7917
- };
7918
- }
7919
- if (cb && deep) {
7920
- const baseGetter = getter;
7921
- const depth = deep === true ? Infinity : deep;
7922
- getter = () => traverse(baseGetter(), depth);
7923
- }
7924
- let cleanup;
7925
- let onCleanup = (fn) => {
7926
- cleanup = effect.onStop = () => {
7927
- callWithErrorHandling(fn, instance, 4);
7928
- cleanup = effect.onStop = void 0;
7929
- };
7930
- };
8042
+ function doWatch(source, cb, options = EMPTY_OBJ) {
8043
+ const { immediate, deep, flush, once } = options;
8044
+ const baseWatchOptions = extend$1({}, options);
7931
8045
  let ssrCleanup;
7932
8046
  if (isInSSRComponentSetup) {
7933
- onCleanup = NOOP;
7934
- if (!cb) {
7935
- getter();
7936
- } else if (immediate) {
7937
- callWithAsyncErrorHandling(cb, instance, 3, [
7938
- getter(),
7939
- isMultiSource ? [] : void 0,
7940
- onCleanup
7941
- ]);
7942
- }
7943
8047
  if (flush === "sync") {
7944
8048
  const ctx = useSSRContext();
7945
8049
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
8050
+ } else if (!cb || immediate) {
8051
+ baseWatchOptions.once = true;
7946
8052
  } else {
7947
- const watchHandle2 = () => {
8053
+ return {
8054
+ stop: NOOP,
8055
+ resume: NOOP,
8056
+ pause: NOOP
7948
8057
  };
7949
- watchHandle2.stop = NOOP;
7950
- watchHandle2.resume = NOOP;
7951
- watchHandle2.pause = NOOP;
7952
- return watchHandle2;
7953
8058
  }
7954
8059
  }
7955
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
7956
- const job = (immediateFirstRun) => {
7957
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
7958
- return;
7959
- }
7960
- if (cb) {
7961
- const newValue = effect.run();
7962
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
7963
- if (cleanup) {
7964
- cleanup();
7965
- }
7966
- callWithAsyncErrorHandling(cb, instance, 3, [
7967
- newValue,
7968
- // pass undefined as the old value when it's changed for the first time
7969
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
7970
- onCleanup
7971
- ]);
7972
- oldValue = newValue;
8060
+ const instance = currentInstance;
8061
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
8062
+ let isPre = false;
8063
+ if (flush === "post") {
8064
+ baseWatchOptions.scheduler = (job) => {
8065
+ queuePostRenderEffect(job, instance && instance.suspense);
8066
+ };
8067
+ } else if (flush !== "sync") {
8068
+ isPre = true;
8069
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
8070
+ if (isFirstRun) {
8071
+ job();
8072
+ } else {
8073
+ queueJob(job);
7973
8074
  }
7974
- } else {
7975
- effect.run();
7976
- }
7977
- };
7978
- if (cb) job.flags |= 4;
7979
- const effect = new ReactiveEffect(getter);
7980
- let scheduler;
7981
- if (flush === "sync") {
7982
- scheduler = job;
7983
- } else if (flush === "post") {
7984
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
7985
- } else {
7986
- job.flags |= 2;
7987
- if (instance) job.id = instance.uid;
7988
- scheduler = () => queueJob(job);
8075
+ };
7989
8076
  }
7990
- effect.scheduler = scheduler;
7991
- const scope = getCurrentScope();
7992
- const watchHandle = () => {
7993
- effect.stop();
7994
- if (scope) {
7995
- remove(scope.effects, effect);
8077
+ baseWatchOptions.augmentJob = (job) => {
8078
+ if (cb) {
8079
+ job.flags |= 4;
7996
8080
  }
7997
- };
7998
- watchHandle.pause = effect.pause.bind(effect);
7999
- watchHandle.resume = effect.resume.bind(effect);
8000
- watchHandle.stop = watchHandle;
8001
- if (cb) {
8002
- if (immediate) {
8003
- job(true);
8004
- } else {
8005
- oldValue = effect.run();
8081
+ if (isPre) {
8082
+ job.flags |= 2;
8083
+ if (instance) {
8084
+ job.id = instance.uid;
8085
+ job.i = instance;
8086
+ }
8006
8087
  }
8007
- } else if (flush === "post") {
8008
- queuePostRenderEffect(
8009
- effect.run.bind(effect),
8010
- instance && instance.suspense
8011
- );
8012
- } else {
8013
- effect.run();
8014
- }
8088
+ };
8089
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
8015
8090
  if (ssrCleanup) ssrCleanup.push(watchHandle);
8016
8091
  return watchHandle;
8017
8092
  }
@@ -8040,38 +8115,6 @@ function createPathGetter(ctx, path) {
8040
8115
  return cur;
8041
8116
  };
8042
8117
  }
8043
- function traverse(value, depth = Infinity, seen) {
8044
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
8045
- return value;
8046
- }
8047
- seen = seen || /* @__PURE__ */ new Set();
8048
- if (seen.has(value)) {
8049
- return value;
8050
- }
8051
- seen.add(value);
8052
- depth--;
8053
- if (isRef(value)) {
8054
- traverse(value.value, depth, seen);
8055
- } else if (isArray(value)) {
8056
- for (let i = 0; i < value.length; i++) {
8057
- traverse(value[i], depth, seen);
8058
- }
8059
- } else if (isSet(value) || isMap(value)) {
8060
- value.forEach((v) => {
8061
- traverse(v, depth, seen);
8062
- });
8063
- } else if (isPlainObject(value)) {
8064
- for (const key in value) {
8065
- traverse(value[key], depth, seen);
8066
- }
8067
- for (const key of Object.getOwnPropertySymbols(value)) {
8068
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
8069
- traverse(value[key], depth, seen);
8070
- }
8071
- }
8072
- }
8073
- return value;
8074
- }
8075
8118
 
8076
8119
  function useModel(props, name, options = EMPTY_OBJ) {
8077
8120
  const i = getCurrentInstance();
@@ -9796,7 +9839,7 @@ function isMemoSame(cached, memo) {
9796
9839
  return true;
9797
9840
  }
9798
9841
 
9799
- const version = "3.5.0-beta.2";
9842
+ const version = "3.5.0-rc.1";
9800
9843
  const warn$1 = NOOP;
9801
9844
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9802
9845
  const devtools = void 0;
@@ -10414,8 +10457,9 @@ function compatCoerceAttr(el, key, value, instance = null) {
10414
10457
 
10415
10458
  function patchDOMProp(el, key, value, parentComponent) {
10416
10459
  if (key === "innerHTML" || key === "textContent") {
10417
- if (value == null) return;
10418
- el[key] = value;
10460
+ if (value != null) {
10461
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
10462
+ }
10419
10463
  return;
10420
10464
  }
10421
10465
  const tag = el.tagName;
@@ -10823,6 +10867,9 @@ class VueElement extends BaseClass {
10823
10867
  delete this._props[key];
10824
10868
  } else {
10825
10869
  this._props[key] = val;
10870
+ if (key === "key" && this._app) {
10871
+ this._app._ceVNode.key = val;
10872
+ }
10826
10873
  }
10827
10874
  if (shouldUpdate && this._instance) {
10828
10875
  this._update();
@@ -11598,6 +11645,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
11598
11645
  effectScope: effectScope,
11599
11646
  getCurrentInstance: getCurrentInstance,
11600
11647
  getCurrentScope: getCurrentScope,
11648
+ getCurrentWatcher: getCurrentWatcher,
11601
11649
  getTransitionRawChildren: getTransitionRawChildren,
11602
11650
  guardReactiveProps: guardReactiveProps,
11603
11651
  h: h,
@@ -11640,6 +11688,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
11640
11688
  onServerPrefetch: onServerPrefetch,
11641
11689
  onUnmounted: onUnmounted,
11642
11690
  onUpdated: onUpdated,
11691
+ onWatcherCleanup: onWatcherCleanup,
11643
11692
  openBlock: openBlock,
11644
11693
  popScopeId: popScopeId,
11645
11694
  provide: provide,
@@ -13153,6 +13202,9 @@ const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || no
13153
13202
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
13154
13203
  function isReferenced(node, parent, grandparent) {
13155
13204
  switch (parent.type) {
13205
+ // yes: PARENT[NODE]
13206
+ // yes: NODE.child
13207
+ // no: parent.NODE
13156
13208
  case "MemberExpression":
13157
13209
  case "OptionalMemberExpression":
13158
13210
  if (parent.property === node) {
@@ -13161,12 +13213,23 @@ function isReferenced(node, parent, grandparent) {
13161
13213
  return parent.object === node;
13162
13214
  case "JSXMemberExpression":
13163
13215
  return parent.object === node;
13216
+ // no: let NODE = init;
13217
+ // yes: let id = NODE;
13164
13218
  case "VariableDeclarator":
13165
13219
  return parent.init === node;
13220
+ // yes: () => NODE
13221
+ // no: (NODE) => {}
13166
13222
  case "ArrowFunctionExpression":
13167
13223
  return parent.body === node;
13224
+ // no: class { #NODE; }
13225
+ // no: class { get #NODE() {} }
13226
+ // no: class { #NODE() {} }
13227
+ // no: class { fn() { return this.#NODE; } }
13168
13228
  case "PrivateName":
13169
13229
  return false;
13230
+ // no: class { NODE() {} }
13231
+ // yes: class { [NODE]() {} }
13232
+ // no: class { foo(NODE) {} }
13170
13233
  case "ClassMethod":
13171
13234
  case "ClassPrivateMethod":
13172
13235
  case "ObjectMethod":
@@ -13174,11 +13237,18 @@ function isReferenced(node, parent, grandparent) {
13174
13237
  return !!parent.computed;
13175
13238
  }
13176
13239
  return false;
13240
+ // yes: { [NODE]: "" }
13241
+ // no: { NODE: "" }
13242
+ // depends: { NODE }
13243
+ // depends: { key: NODE }
13177
13244
  case "ObjectProperty":
13178
13245
  if (parent.key === node) {
13179
13246
  return !!parent.computed;
13180
13247
  }
13181
13248
  return !grandparent;
13249
+ // no: class { NODE = value; }
13250
+ // yes: class { [NODE] = value; }
13251
+ // yes: class { key = NODE; }
13182
13252
  case "ClassProperty":
13183
13253
  if (parent.key === node) {
13184
13254
  return !!parent.computed;
@@ -13186,47 +13256,80 @@ function isReferenced(node, parent, grandparent) {
13186
13256
  return true;
13187
13257
  case "ClassPrivateProperty":
13188
13258
  return parent.key !== node;
13259
+ // no: class NODE {}
13260
+ // yes: class Foo extends NODE {}
13189
13261
  case "ClassDeclaration":
13190
13262
  case "ClassExpression":
13191
13263
  return parent.superClass === node;
13264
+ // yes: left = NODE;
13265
+ // no: NODE = right;
13192
13266
  case "AssignmentExpression":
13193
13267
  return parent.right === node;
13268
+ // no: [NODE = foo] = [];
13269
+ // yes: [foo = NODE] = [];
13194
13270
  case "AssignmentPattern":
13195
13271
  return parent.right === node;
13272
+ // no: NODE: for (;;) {}
13196
13273
  case "LabeledStatement":
13197
13274
  return false;
13275
+ // no: try {} catch (NODE) {}
13198
13276
  case "CatchClause":
13199
13277
  return false;
13278
+ // no: function foo(...NODE) {}
13200
13279
  case "RestElement":
13201
13280
  return false;
13202
13281
  case "BreakStatement":
13203
13282
  case "ContinueStatement":
13204
13283
  return false;
13284
+ // no: function NODE() {}
13285
+ // no: function foo(NODE) {}
13205
13286
  case "FunctionDeclaration":
13206
13287
  case "FunctionExpression":
13207
13288
  return false;
13289
+ // no: export NODE from "foo";
13290
+ // no: export * as NODE from "foo";
13208
13291
  case "ExportNamespaceSpecifier":
13209
13292
  case "ExportDefaultSpecifier":
13210
13293
  return false;
13294
+ // no: export { foo as NODE };
13295
+ // yes: export { NODE as foo };
13296
+ // no: export { NODE as foo } from "foo";
13211
13297
  case "ExportSpecifier":
13212
13298
  return parent.local === node;
13299
+ // no: import NODE from "foo";
13300
+ // no: import * as NODE from "foo";
13301
+ // no: import { NODE as foo } from "foo";
13302
+ // no: import { foo as NODE } from "foo";
13303
+ // no: import NODE from "bar";
13213
13304
  case "ImportDefaultSpecifier":
13214
13305
  case "ImportNamespaceSpecifier":
13215
13306
  case "ImportSpecifier":
13216
13307
  return false;
13308
+ // no: import "foo" assert { NODE: "json" }
13217
13309
  case "ImportAttribute":
13218
13310
  return false;
13311
+ // no: <div NODE="foo" />
13219
13312
  case "JSXAttribute":
13220
13313
  return false;
13314
+ // no: [NODE] = [];
13315
+ // no: ({ NODE }) = [];
13221
13316
  case "ObjectPattern":
13222
13317
  case "ArrayPattern":
13223
13318
  return false;
13319
+ // no: new.NODE
13320
+ // no: NODE.target
13224
13321
  case "MetaProperty":
13225
13322
  return false;
13323
+ // yes: type X = { someProperty: NODE }
13324
+ // no: type X = { NODE: OtherType }
13226
13325
  case "ObjectTypeProperty":
13227
13326
  return parent.key !== node;
13327
+ // yes: enum X { Foo = NODE }
13328
+ // no: enum X { NODE }
13228
13329
  case "TSEnumMember":
13229
13330
  return parent.id !== node;
13331
+ // yes: { [NODE]: value }
13332
+ // no: { NODE: value }
13230
13333
  case "TSPropertySignature":
13231
13334
  if (parent.key === node) {
13232
13335
  return !!parent.computed;
@@ -13814,7 +13917,9 @@ const tokenizer = new Tokenizer(stack, {
13814
13917
  case 17:
13815
13918
  case 18:
13816
13919
  case 19:
13920
+ // "
13817
13921
  case 20:
13922
+ // '
13818
13923
  case 21:
13819
13924
  emitError(9, end);
13820
13925
  break;
@@ -14784,6 +14889,7 @@ function traverseNode(node, context) {
14784
14889
  context.helper(TO_DISPLAY_STRING);
14785
14890
  }
14786
14891
  break;
14892
+ // for container types, further traverse downwards
14787
14893
  case 9:
14788
14894
  for (let i2 = 0; i2 < node.branches.length; i2++) {
14789
14895
  traverseNode(node.branches[i2], context);
@@ -15260,6 +15366,7 @@ function genNode(node, context) {
15260
15366
  case 21:
15261
15367
  genNodeList(node.body, context, true, false);
15262
15368
  break;
15369
+ // SSR only types
15263
15370
  case 22:
15264
15371
  genTemplateLiteral(node, context);
15265
15372
  break;
@@ -17633,27 +17740,35 @@ function parseFilter(node, context) {
17633
17740
  case 34:
17634
17741
  inDouble = true;
17635
17742
  break;
17743
+ // "
17636
17744
  case 39:
17637
17745
  inSingle = true;
17638
17746
  break;
17747
+ // '
17639
17748
  case 96:
17640
17749
  inTemplateString = true;
17641
17750
  break;
17751
+ // `
17642
17752
  case 40:
17643
17753
  paren++;
17644
17754
  break;
17755
+ // (
17645
17756
  case 41:
17646
17757
  paren--;
17647
17758
  break;
17759
+ // )
17648
17760
  case 91:
17649
17761
  square++;
17650
17762
  break;
17763
+ // [
17651
17764
  case 93:
17652
17765
  square--;
17653
17766
  break;
17767
+ // ]
17654
17768
  case 123:
17655
17769
  curly++;
17656
17770
  break;
17771
+ // {
17657
17772
  case 125:
17658
17773
  curly--;
17659
17774
  break;