@vue/compat 3.5.0-beta.1 → 3.5.0-beta.3

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.1
2
+ * @vue/compat v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -465,11 +465,11 @@ class ReactiveEffect {
465
465
  }
466
466
  }
467
467
  pause() {
468
- this.flags |= 128;
468
+ this.flags |= 64;
469
469
  }
470
470
  resume() {
471
- if (this.flags & 128) {
472
- this.flags &= ~128;
471
+ if (this.flags & 64) {
472
+ this.flags &= ~64;
473
473
  if (pausedQueueEffects.has(this)) {
474
474
  pausedQueueEffects.delete(this);
475
475
  this.trigger();
@@ -483,9 +483,6 @@ class ReactiveEffect {
483
483
  if (this.flags & 2 && !(this.flags & 32)) {
484
484
  return;
485
485
  }
486
- if (this.flags & 64) {
487
- return this.trigger();
488
- }
489
486
  if (!(this.flags & 8)) {
490
487
  this.flags |= 8;
491
488
  this.nextEffect = batchedEffect;
@@ -529,7 +526,7 @@ class ReactiveEffect {
529
526
  }
530
527
  }
531
528
  trigger() {
532
- if (this.flags & 128) {
529
+ if (this.flags & 64) {
533
530
  pausedQueueEffects.add(this);
534
531
  } else if (this.scheduler) {
535
532
  this.scheduler();
@@ -559,6 +556,7 @@ function endBatch() {
559
556
  batchDepth--;
560
557
  return;
561
558
  }
559
+ batchDepth--;
562
560
  let error;
563
561
  while (batchedEffect) {
564
562
  let e = batchedEffect;
@@ -577,7 +575,6 @@ function endBatch() {
577
575
  e = next;
578
576
  }
579
577
  }
580
- batchDepth--;
581
578
  if (error) throw error;
582
579
  }
583
580
  function prepareDeps(sub) {
@@ -980,26 +977,26 @@ const arrayInstrumentations = {
980
977
  });
981
978
  },
982
979
  every(fn, thisArg) {
983
- return apply(this, "every", fn, thisArg);
980
+ return apply(this, "every", fn, thisArg, void 0, arguments);
984
981
  },
985
982
  filter(fn, thisArg) {
986
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
983
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
987
984
  },
988
985
  find(fn, thisArg) {
989
- return apply(this, "find", fn, thisArg, toReactive);
986
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
990
987
  },
991
988
  findIndex(fn, thisArg) {
992
- return apply(this, "findIndex", fn, thisArg);
989
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
993
990
  },
994
991
  findLast(fn, thisArg) {
995
- return apply(this, "findLast", fn, thisArg, toReactive);
992
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
996
993
  },
997
994
  findLastIndex(fn, thisArg) {
998
- return apply(this, "findLastIndex", fn, thisArg);
995
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
999
996
  },
1000
997
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1001
998
  forEach(fn, thisArg) {
1002
- return apply(this, "forEach", fn, thisArg);
999
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
1003
1000
  },
1004
1001
  includes(...args) {
1005
1002
  return searchProxy(this, "includes", args);
@@ -1015,7 +1012,7 @@ const arrayInstrumentations = {
1015
1012
  return searchProxy(this, "lastIndexOf", args);
1016
1013
  },
1017
1014
  map(fn, thisArg) {
1018
- return apply(this, "map", fn, thisArg);
1015
+ return apply(this, "map", fn, thisArg, void 0, arguments);
1019
1016
  },
1020
1017
  pop() {
1021
1018
  return noTracking(this, "pop");
@@ -1034,7 +1031,7 @@ const arrayInstrumentations = {
1034
1031
  },
1035
1032
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1036
1033
  some(fn, thisArg) {
1037
- return apply(this, "some", fn, thisArg);
1034
+ return apply(this, "some", fn, thisArg, void 0, arguments);
1038
1035
  },
1039
1036
  splice(...args) {
1040
1037
  return noTracking(this, "splice", args);
@@ -1070,12 +1067,17 @@ function iterator(self, method, wrapValue) {
1070
1067
  }
1071
1068
  return iter;
1072
1069
  }
1073
- function apply(self, method, fn, thisArg, wrappedRetFn) {
1070
+ const arrayProto = Array.prototype;
1071
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1074
1072
  const arr = shallowReadArray(self);
1075
- let needsWrap = false;
1073
+ const needsWrap = arr !== self && !isShallow(self);
1074
+ const methodFn = arr[method];
1075
+ if (methodFn !== arrayProto[method]) {
1076
+ const result2 = methodFn.apply(arr, args);
1077
+ return needsWrap ? toReactive(result2) : result2;
1078
+ }
1076
1079
  let wrappedFn = fn;
1077
1080
  if (arr !== self) {
1078
- needsWrap = !isShallow(self);
1079
1081
  if (needsWrap) {
1080
1082
  wrappedFn = function(item, index) {
1081
1083
  return fn.call(this, toReactive(item), index, self);
@@ -1086,7 +1088,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn) {
1086
1088
  };
1087
1089
  }
1088
1090
  }
1089
- const result = arr[method](wrappedFn, thisArg);
1091
+ const result = methodFn.call(arr, wrappedFn, thisArg);
1090
1092
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
1091
1093
  }
1092
1094
  function reduce(self, method, fn, args) {
@@ -1937,6 +1939,220 @@ const TriggerOpTypes = {
1937
1939
  "CLEAR": "clear"
1938
1940
  };
1939
1941
 
1942
+ const INITIAL_WATCHER_VALUE = {};
1943
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1944
+ let activeWatcher = void 0;
1945
+ function getCurrentWatcher() {
1946
+ return activeWatcher;
1947
+ }
1948
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1949
+ if (owner) {
1950
+ let cleanups = cleanupMap.get(owner);
1951
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1952
+ cleanups.push(cleanupFn);
1953
+ } else if (!failSilently) {
1954
+ warn$2(
1955
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1956
+ );
1957
+ }
1958
+ }
1959
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1960
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1961
+ const warnInvalidSource = (s) => {
1962
+ (options.onWarn || warn$2)(
1963
+ `Invalid watch source: `,
1964
+ s,
1965
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1966
+ );
1967
+ };
1968
+ const reactiveGetter = (source2) => {
1969
+ if (deep) return source2;
1970
+ if (isShallow(source2) || deep === false || deep === 0)
1971
+ return traverse(source2, 1);
1972
+ return traverse(source2);
1973
+ };
1974
+ let effect;
1975
+ let getter;
1976
+ let cleanup;
1977
+ let boundCleanup;
1978
+ let forceTrigger = false;
1979
+ let isMultiSource = false;
1980
+ if (isRef(source)) {
1981
+ getter = () => source.value;
1982
+ forceTrigger = isShallow(source);
1983
+ } else if (isReactive(source)) {
1984
+ getter = () => reactiveGetter(source);
1985
+ forceTrigger = true;
1986
+ } else if (isArray(source)) {
1987
+ isMultiSource = true;
1988
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1989
+ getter = () => source.map((s) => {
1990
+ if (isRef(s)) {
1991
+ return s.value;
1992
+ } else if (isReactive(s)) {
1993
+ return reactiveGetter(s);
1994
+ } else if (isFunction(s)) {
1995
+ return call ? call(s, 2) : s();
1996
+ } else {
1997
+ warnInvalidSource(s);
1998
+ }
1999
+ });
2000
+ } else if (isFunction(source)) {
2001
+ if (cb) {
2002
+ getter = call ? () => call(source, 2) : source;
2003
+ } else {
2004
+ getter = () => {
2005
+ if (cleanup) {
2006
+ pauseTracking();
2007
+ try {
2008
+ cleanup();
2009
+ } finally {
2010
+ resetTracking();
2011
+ }
2012
+ }
2013
+ const currentEffect = activeWatcher;
2014
+ activeWatcher = effect;
2015
+ try {
2016
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2017
+ } finally {
2018
+ activeWatcher = currentEffect;
2019
+ }
2020
+ };
2021
+ }
2022
+ } else {
2023
+ getter = NOOP;
2024
+ warnInvalidSource(source);
2025
+ }
2026
+ if (cb && deep) {
2027
+ const baseGetter = getter;
2028
+ const depth = deep === true ? Infinity : deep;
2029
+ getter = () => traverse(baseGetter(), depth);
2030
+ }
2031
+ if (once) {
2032
+ if (cb) {
2033
+ const _cb = cb;
2034
+ cb = (...args) => {
2035
+ _cb(...args);
2036
+ effect.stop();
2037
+ };
2038
+ } else {
2039
+ const _getter = getter;
2040
+ getter = () => {
2041
+ _getter();
2042
+ effect.stop();
2043
+ };
2044
+ }
2045
+ }
2046
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2047
+ const job = (immediateFirstRun) => {
2048
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2049
+ return;
2050
+ }
2051
+ if (cb) {
2052
+ const newValue = effect.run();
2053
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2054
+ if (cleanup) {
2055
+ cleanup();
2056
+ }
2057
+ const currentWatcher = activeWatcher;
2058
+ activeWatcher = effect;
2059
+ try {
2060
+ const args = [
2061
+ newValue,
2062
+ // pass undefined as the old value when it's changed for the first time
2063
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2064
+ boundCleanup
2065
+ ];
2066
+ call ? call(cb, 3, args) : (
2067
+ // @ts-expect-error
2068
+ cb(...args)
2069
+ );
2070
+ oldValue = newValue;
2071
+ } finally {
2072
+ activeWatcher = currentWatcher;
2073
+ }
2074
+ }
2075
+ } else {
2076
+ effect.run();
2077
+ }
2078
+ };
2079
+ if (augmentJob) {
2080
+ augmentJob(job);
2081
+ }
2082
+ effect = new ReactiveEffect(getter);
2083
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2084
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2085
+ cleanup = effect.onStop = () => {
2086
+ const cleanups = cleanupMap.get(effect);
2087
+ if (cleanups) {
2088
+ if (call) {
2089
+ call(cleanups, 4);
2090
+ } else {
2091
+ for (const cleanup2 of cleanups) cleanup2();
2092
+ }
2093
+ cleanupMap.delete(effect);
2094
+ }
2095
+ };
2096
+ {
2097
+ effect.onTrack = options.onTrack;
2098
+ effect.onTrigger = options.onTrigger;
2099
+ }
2100
+ if (cb) {
2101
+ if (immediate) {
2102
+ job(true);
2103
+ } else {
2104
+ oldValue = effect.run();
2105
+ }
2106
+ } else if (scheduler) {
2107
+ scheduler(job.bind(null, true), true);
2108
+ } else {
2109
+ effect.run();
2110
+ }
2111
+ const scope = getCurrentScope();
2112
+ const watchHandle = () => {
2113
+ effect.stop();
2114
+ if (scope) {
2115
+ remove(scope.effects, effect);
2116
+ }
2117
+ };
2118
+ watchHandle.pause = effect.pause.bind(effect);
2119
+ watchHandle.resume = effect.resume.bind(effect);
2120
+ watchHandle.stop = watchHandle;
2121
+ return watchHandle;
2122
+ }
2123
+ function traverse(value, depth = Infinity, seen) {
2124
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2125
+ return value;
2126
+ }
2127
+ seen = seen || /* @__PURE__ */ new Set();
2128
+ if (seen.has(value)) {
2129
+ return value;
2130
+ }
2131
+ seen.add(value);
2132
+ depth--;
2133
+ if (isRef(value)) {
2134
+ traverse(value.value, depth, seen);
2135
+ } else if (isArray(value)) {
2136
+ for (let i = 0; i < value.length; i++) {
2137
+ traverse(value[i], depth, seen);
2138
+ }
2139
+ } else if (isSet(value) || isMap(value)) {
2140
+ value.forEach((v) => {
2141
+ traverse(v, depth, seen);
2142
+ });
2143
+ } else if (isPlainObject(value)) {
2144
+ for (const key in value) {
2145
+ traverse(value[key], depth, seen);
2146
+ }
2147
+ for (const key of Object.getOwnPropertySymbols(value)) {
2148
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2149
+ traverse(value[key], depth, seen);
2150
+ }
2151
+ }
2152
+ }
2153
+ return value;
2154
+ }
2155
+
1940
2156
  const stack = [];
1941
2157
  function pushWarningContext(vnode) {
1942
2158
  stack.push(vnode);
@@ -2064,12 +2280,6 @@ const ErrorCodes = {
2064
2280
  "0": "SETUP_FUNCTION",
2065
2281
  "RENDER_FUNCTION": 1,
2066
2282
  "1": "RENDER_FUNCTION",
2067
- "WATCH_GETTER": 2,
2068
- "2": "WATCH_GETTER",
2069
- "WATCH_CALLBACK": 3,
2070
- "3": "WATCH_CALLBACK",
2071
- "WATCH_CLEANUP": 4,
2072
- "4": "WATCH_CLEANUP",
2073
2283
  "NATIVE_EVENT_HANDLER": 5,
2074
2284
  "5": "NATIVE_EVENT_HANDLER",
2075
2285
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2221,7 +2431,7 @@ function nextTick(fn) {
2221
2431
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2222
2432
  }
2223
2433
  function findInsertionIndex(id) {
2224
- let start = flushIndex + 1;
2434
+ let start = isFlushing ? flushIndex + 1 : 0;
2225
2435
  let end = queue.length;
2226
2436
  while (start < end) {
2227
2437
  const middle = start + end >>> 1;
@@ -2237,15 +2447,13 @@ function findInsertionIndex(id) {
2237
2447
  }
2238
2448
  function queueJob(job) {
2239
2449
  if (!(job.flags & 1)) {
2240
- if (job.id == null) {
2241
- queue.push(job);
2242
- } else if (
2243
- // fast path when the job id is larger than the tail
2244
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2245
- ) {
2450
+ const jobId = getId(job);
2451
+ const lastJob = queue[queue.length - 1];
2452
+ if (!lastJob || // fast path when the job id is larger than the tail
2453
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2246
2454
  queue.push(job);
2247
2455
  } else {
2248
- queue.splice(findInsertionIndex(job.id), 0, job);
2456
+ queue.splice(findInsertionIndex(jobId), 0, job);
2249
2457
  }
2250
2458
  if (!(job.flags & 4)) {
2251
2459
  job.flags |= 1;
@@ -2259,12 +2467,6 @@ function queueFlush() {
2259
2467
  currentFlushPromise = resolvedPromise.then(flushJobs);
2260
2468
  }
2261
2469
  }
2262
- function invalidateJob(job) {
2263
- const i = queue.indexOf(job);
2264
- if (i > flushIndex) {
2265
- queue.splice(i, 1);
2266
- }
2267
- }
2268
2470
  function queuePostFlushCb(cb) {
2269
2471
  if (!isArray(cb)) {
2270
2472
  if (activePostFlushCbs && cb.id === -1) {
@@ -2326,24 +2528,13 @@ function flushPostFlushCbs(seen) {
2326
2528
  postFlushIndex = 0;
2327
2529
  }
2328
2530
  }
2329
- const getId = (job) => job.id == null ? Infinity : job.id;
2330
- const comparator = (a, b) => {
2331
- const diff = getId(a) - getId(b);
2332
- if (diff === 0) {
2333
- const isAPre = a.flags & 2;
2334
- const isBPre = b.flags & 2;
2335
- if (isAPre && !isBPre) return -1;
2336
- if (isBPre && !isAPre) return 1;
2337
- }
2338
- return diff;
2339
- };
2531
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2340
2532
  function flushJobs(seen) {
2341
2533
  isFlushPending = false;
2342
2534
  isFlushing = true;
2343
2535
  {
2344
2536
  seen = seen || /* @__PURE__ */ new Map();
2345
2537
  }
2346
- queue.sort(comparator);
2347
2538
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2348
2539
  try {
2349
2540
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -2984,7 +3175,7 @@ function on(instance, event, fn) {
2984
3175
  function once(instance, event, fn) {
2985
3176
  const wrapped = (...args) => {
2986
3177
  off(instance, event, wrapped);
2987
- fn.call(instance.proxy, ...args);
3178
+ fn.apply(instance.proxy, args);
2988
3179
  };
2989
3180
  wrapped.fn = fn;
2990
3181
  on(instance, event, wrapped);
@@ -4022,6 +4213,7 @@ const logMismatchError = () => {
4022
4213
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
4023
4214
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
4024
4215
  const getContainerType = (container) => {
4216
+ if (container.nodeType !== 1) return void 0;
4025
4217
  if (isSVGContainer(container)) return "svg";
4026
4218
  if (isMathMLContainer(container)) return "mathml";
4027
4219
  return void 0;
@@ -4950,7 +5142,7 @@ const KeepAliveImpl = {
4950
5142
  function pruneCache(filter) {
4951
5143
  cache.forEach((vnode, key) => {
4952
5144
  const name = getComponentName(vnode.type);
4953
- if (name && (!filter || !filter(name))) {
5145
+ if (name && !filter(name)) {
4954
5146
  pruneCacheEntry(key);
4955
5147
  }
4956
5148
  });
@@ -5072,6 +5264,7 @@ function matches(pattern, name) {
5072
5264
  } else if (isString(pattern)) {
5073
5265
  return pattern.split(",").includes(name);
5074
5266
  } else if (isRegExp(pattern)) {
5267
+ pattern.lastIndex = 0;
5075
5268
  return pattern.test(name);
5076
5269
  }
5077
5270
  return false;
@@ -6516,23 +6709,43 @@ function callHook$1(hook, instance, type) {
6516
6709
  );
6517
6710
  }
6518
6711
  function createWatcher(raw, ctx, publicThis, key) {
6519
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6712
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6713
+ const options = {};
6714
+ {
6715
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6716
+ const newValue = getter();
6717
+ if (isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
6718
+ options.deep = true;
6719
+ }
6720
+ const baseGetter = getter;
6721
+ getter = () => {
6722
+ const val = baseGetter();
6723
+ if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
6724
+ traverse(val);
6725
+ }
6726
+ return val;
6727
+ };
6728
+ }
6520
6729
  if (isString(raw)) {
6521
6730
  const handler = ctx[raw];
6522
6731
  if (isFunction(handler)) {
6523
- watch(getter, handler);
6732
+ {
6733
+ watch(getter, handler, options);
6734
+ }
6524
6735
  } else {
6525
6736
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6526
6737
  }
6527
6738
  } else if (isFunction(raw)) {
6528
- watch(getter, raw.bind(publicThis));
6739
+ {
6740
+ watch(getter, raw.bind(publicThis), options);
6741
+ }
6529
6742
  } else if (isObject(raw)) {
6530
6743
  if (isArray(raw)) {
6531
6744
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6532
6745
  } else {
6533
6746
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6534
6747
  if (isFunction(handler)) {
6535
- watch(getter, handler, raw);
6748
+ watch(getter, handler, extend(raw, options) );
6536
6749
  } else {
6537
6750
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6538
6751
  }
@@ -6756,7 +6969,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6756
6969
  return vm;
6757
6970
  }
6758
6971
  }
6759
- Vue.version = `2.6.14-compat:${"3.5.0-beta.1"}`;
6972
+ Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
6760
6973
  Vue.config = singletonApp.config;
6761
6974
  Vue.use = (plugin, ...options) => {
6762
6975
  if (plugin && isFunction(plugin.install)) {
@@ -7088,7 +7301,7 @@ function defineReactive(obj, key, val) {
7088
7301
  if (isArray(val)) {
7089
7302
  methodsToPatch.forEach((m) => {
7090
7303
  val[m] = (...args) => {
7091
- Array.prototype[m].call(reactiveVal, ...args);
7304
+ Array.prototype[m].apply(reactiveVal, args);
7092
7305
  };
7093
7306
  });
7094
7307
  } else {
@@ -8283,7 +8496,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8283
8496
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8284
8497
  subTree = filterSingleRoot(subTree.children) || subTree;
8285
8498
  }
8286
- if (vnode === subTree) {
8499
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8287
8500
  const parentVNode = parentComponent.vnode;
8288
8501
  setScopeId(
8289
8502
  el,
@@ -8613,7 +8826,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8613
8826
  return;
8614
8827
  } else {
8615
8828
  instance.next = n2;
8616
- invalidateJob(instance.update);
8617
8829
  instance.update();
8618
8830
  }
8619
8831
  } else {
@@ -9537,7 +9749,6 @@ function watchSyncEffect(effect, options) {
9537
9749
  extend({}, options, { flush: "sync" })
9538
9750
  );
9539
9751
  }
9540
- const INITIAL_WATCHER_VALUE = {};
9541
9752
  function watch(source, cb, options) {
9542
9753
  if (!isFunction(cb)) {
9543
9754
  warn$1(
@@ -9546,21 +9757,8 @@ function watch(source, cb, options) {
9546
9757
  }
9547
9758
  return doWatch(source, cb, options);
9548
9759
  }
9549
- function doWatch(source, cb, {
9550
- immediate,
9551
- deep,
9552
- flush,
9553
- once,
9554
- onTrack,
9555
- onTrigger
9556
- } = EMPTY_OBJ) {
9557
- if (cb && once) {
9558
- const _cb = cb;
9559
- cb = (...args) => {
9560
- _cb(...args);
9561
- watchHandle();
9562
- };
9563
- }
9760
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9761
+ const { immediate, deep, flush, once } = options;
9564
9762
  if (!cb) {
9565
9763
  if (immediate !== void 0) {
9566
9764
  warn$1(
@@ -9578,174 +9776,53 @@ function doWatch(source, cb, {
9578
9776
  );
9579
9777
  }
9580
9778
  }
9581
- const warnInvalidSource = (s) => {
9582
- warn$1(
9583
- `Invalid watch source: `,
9584
- s,
9585
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9586
- );
9587
- };
9588
- const instance = currentInstance;
9589
- const reactiveGetter = (source2) => {
9590
- if (deep) return source2;
9591
- if (isShallow(source2) || deep === false || deep === 0)
9592
- return traverse(source2, 1);
9593
- return traverse(source2);
9594
- };
9595
- let getter;
9596
- let forceTrigger = false;
9597
- let isMultiSource = false;
9598
- if (isRef(source)) {
9599
- getter = () => source.value;
9600
- forceTrigger = isShallow(source);
9601
- } else if (isReactive(source)) {
9602
- getter = () => reactiveGetter(source);
9603
- forceTrigger = true;
9604
- } else if (isArray(source)) {
9605
- isMultiSource = true;
9606
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9607
- getter = () => source.map((s) => {
9608
- if (isRef(s)) {
9609
- return s.value;
9610
- } else if (isReactive(s)) {
9611
- return reactiveGetter(s);
9612
- } else if (isFunction(s)) {
9613
- return callWithErrorHandling(s, instance, 2);
9614
- } else {
9615
- warnInvalidSource(s);
9616
- }
9617
- });
9618
- } else if (isFunction(source)) {
9619
- if (cb) {
9620
- getter = () => callWithErrorHandling(source, instance, 2);
9621
- } else {
9622
- getter = () => {
9623
- if (cleanup) {
9624
- cleanup();
9625
- }
9626
- return callWithAsyncErrorHandling(
9627
- source,
9628
- instance,
9629
- 3,
9630
- [onCleanup]
9631
- );
9632
- };
9633
- }
9634
- } else {
9635
- getter = NOOP;
9636
- warnInvalidSource(source);
9637
- }
9638
- if (cb && !deep) {
9639
- const baseGetter = getter;
9640
- getter = () => {
9641
- const val = baseGetter();
9642
- if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
9643
- traverse(val);
9644
- }
9645
- return val;
9646
- };
9647
- }
9648
- if (cb && deep) {
9649
- const baseGetter = getter;
9650
- const depth = deep === true ? Infinity : deep;
9651
- getter = () => traverse(baseGetter(), depth);
9652
- }
9653
- let cleanup;
9654
- let onCleanup = (fn) => {
9655
- cleanup = effect.onStop = () => {
9656
- callWithErrorHandling(fn, instance, 4);
9657
- cleanup = effect.onStop = void 0;
9658
- };
9659
- };
9779
+ const baseWatchOptions = extend({}, options);
9780
+ baseWatchOptions.onWarn = warn$1;
9660
9781
  let ssrCleanup;
9661
9782
  if (isInSSRComponentSetup) {
9662
- onCleanup = NOOP;
9663
- if (!cb) {
9664
- getter();
9665
- } else if (immediate) {
9666
- callWithAsyncErrorHandling(cb, instance, 3, [
9667
- getter(),
9668
- isMultiSource ? [] : void 0,
9669
- onCleanup
9670
- ]);
9671
- }
9672
9783
  if (flush === "sync") {
9673
9784
  const ctx = useSSRContext();
9674
9785
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9786
+ } else if (!cb || immediate) {
9787
+ baseWatchOptions.once = true;
9675
9788
  } else {
9676
- const watchHandle2 = () => {
9789
+ return {
9790
+ stop: NOOP,
9791
+ resume: NOOP,
9792
+ pause: NOOP
9677
9793
  };
9678
- watchHandle2.stop = NOOP;
9679
- watchHandle2.resume = NOOP;
9680
- watchHandle2.pause = NOOP;
9681
- return watchHandle2;
9682
9794
  }
9683
9795
  }
9684
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9685
- const job = (immediateFirstRun) => {
9686
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9687
- return;
9688
- }
9689
- if (cb) {
9690
- const newValue = effect.run();
9691
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
9692
- if (cleanup) {
9693
- cleanup();
9694
- }
9695
- callWithAsyncErrorHandling(cb, instance, 3, [
9696
- newValue,
9697
- // pass undefined as the old value when it's changed for the first time
9698
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9699
- onCleanup
9700
- ]);
9701
- oldValue = newValue;
9796
+ const instance = currentInstance;
9797
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9798
+ let isPre = false;
9799
+ if (flush === "post") {
9800
+ baseWatchOptions.scheduler = (job) => {
9801
+ queuePostRenderEffect(job, instance && instance.suspense);
9802
+ };
9803
+ } else if (flush !== "sync") {
9804
+ isPre = true;
9805
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9806
+ if (isFirstRun) {
9807
+ job();
9808
+ } else {
9809
+ queueJob(job);
9702
9810
  }
9703
- } else {
9704
- effect.run();
9705
- }
9706
- };
9707
- if (cb) job.flags |= 4;
9708
- const effect = new ReactiveEffect(getter);
9709
- let scheduler;
9710
- if (flush === "sync") {
9711
- effect.flags |= 64;
9712
- scheduler = job;
9713
- } else if (flush === "post") {
9714
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9715
- } else {
9716
- job.flags |= 2;
9717
- if (instance) job.id = instance.uid;
9718
- scheduler = () => queueJob(job);
9811
+ };
9719
9812
  }
9720
- effect.scheduler = scheduler;
9721
- const scope = getCurrentScope();
9722
- const watchHandle = () => {
9723
- effect.stop();
9724
- if (scope) {
9725
- remove(scope.effects, effect);
9813
+ baseWatchOptions.augmentJob = (job) => {
9814
+ if (cb) {
9815
+ job.flags |= 4;
9726
9816
  }
9727
- };
9728
- watchHandle.pause = effect.pause.bind(effect);
9729
- watchHandle.resume = effect.resume.bind(effect);
9730
- watchHandle.stop = watchHandle;
9731
- {
9732
- effect.onTrack = onTrack;
9733
- effect.onTrigger = onTrigger;
9734
- }
9735
- if (cb) {
9736
- if (immediate) {
9737
- job(true);
9738
- } else {
9739
- oldValue = effect.run();
9817
+ if (isPre) {
9818
+ job.flags |= 2;
9819
+ if (instance) {
9820
+ job.id = instance.uid;
9821
+ job.i = instance;
9822
+ }
9740
9823
  }
9741
- } else if (flush === "post") {
9742
- queuePostRenderEffect(
9743
- effect.run.bind(effect),
9744
- instance && instance.suspense
9745
- );
9746
- } else {
9747
- effect.run();
9748
- }
9824
+ };
9825
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9749
9826
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9750
9827
  return watchHandle;
9751
9828
  }
@@ -9774,38 +9851,6 @@ function createPathGetter(ctx, path) {
9774
9851
  return cur;
9775
9852
  };
9776
9853
  }
9777
- function traverse(value, depth = Infinity, seen) {
9778
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9779
- return value;
9780
- }
9781
- seen = seen || /* @__PURE__ */ new Set();
9782
- if (seen.has(value)) {
9783
- return value;
9784
- }
9785
- seen.add(value);
9786
- depth--;
9787
- if (isRef(value)) {
9788
- traverse(value.value, depth, seen);
9789
- } else if (isArray(value)) {
9790
- for (let i = 0; i < value.length; i++) {
9791
- traverse(value[i], depth, seen);
9792
- }
9793
- } else if (isSet(value) || isMap(value)) {
9794
- value.forEach((v) => {
9795
- traverse(v, depth, seen);
9796
- });
9797
- } else if (isPlainObject(value)) {
9798
- for (const key in value) {
9799
- traverse(value[key], depth, seen);
9800
- }
9801
- for (const key of Object.getOwnPropertySymbols(value)) {
9802
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9803
- traverse(value[key], depth, seen);
9804
- }
9805
- }
9806
- }
9807
- return value;
9808
- }
9809
9854
 
9810
9855
  function useModel(props, name, options = EMPTY_OBJ) {
9811
9856
  const i = getCurrentInstance();
@@ -12060,7 +12105,7 @@ function isMemoSame(cached, memo) {
12060
12105
  return true;
12061
12106
  }
12062
12107
 
12063
- const version = "3.5.0-beta.1";
12108
+ const version = "3.5.0-beta.3";
12064
12109
  const warn = warn$1 ;
12065
12110
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12066
12111
  const devtools = devtools$1 ;
@@ -13017,7 +13062,6 @@ class VueElement extends BaseClass {
13017
13062
  this._ob = null;
13018
13063
  if (this.shadowRoot && _createApp !== createApp) {
13019
13064
  this._root = this.shadowRoot;
13020
- this._mount(_def);
13021
13065
  } else {
13022
13066
  if (this.shadowRoot) {
13023
13067
  warn(
@@ -13030,9 +13074,9 @@ class VueElement extends BaseClass {
13030
13074
  } else {
13031
13075
  this._root = this;
13032
13076
  }
13033
- if (!this._def.__asyncLoader) {
13034
- this._resolveProps(this._def);
13035
- }
13077
+ }
13078
+ if (!this._def.__asyncLoader) {
13079
+ this._resolveProps(this._def);
13036
13080
  }
13037
13081
  }
13038
13082
  connectedCallback() {
@@ -13232,6 +13276,7 @@ class VueElement extends BaseClass {
13232
13276
  vnode.ce = (instance) => {
13233
13277
  this._instance = instance;
13234
13278
  instance.ce = this;
13279
+ instance.isCE = true;
13235
13280
  {
13236
13281
  instance.ceReload = (newStyles) => {
13237
13282
  if (this._styles) {
@@ -14102,6 +14147,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14102
14147
  effectScope: effectScope,
14103
14148
  getCurrentInstance: getCurrentInstance,
14104
14149
  getCurrentScope: getCurrentScope,
14150
+ getCurrentWatcher: getCurrentWatcher,
14105
14151
  getTransitionRawChildren: getTransitionRawChildren,
14106
14152
  guardReactiveProps: guardReactiveProps,
14107
14153
  h: h,
@@ -14144,6 +14190,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14144
14190
  onServerPrefetch: onServerPrefetch,
14145
14191
  onUnmounted: onUnmounted,
14146
14192
  onUpdated: onUpdated,
14193
+ onWatcherCleanup: onWatcherCleanup,
14147
14194
  openBlock: openBlock,
14148
14195
  popScopeId: popScopeId,
14149
14196
  provide: provide,
@@ -14257,4 +14304,4 @@ Vue.compile = () => {
14257
14304
 
14258
14305
  const configureCompat = Vue.configureCompat;
14259
14306
 
14260
- 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 };
14307
+ 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 };