vue 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 v3.5.0-beta.1
2
+ * vue v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -532,11 +532,11 @@ class ReactiveEffect {
532
532
  }
533
533
  }
534
534
  pause() {
535
- this.flags |= 128;
535
+ this.flags |= 64;
536
536
  }
537
537
  resume() {
538
- if (this.flags & 128) {
539
- this.flags &= ~128;
538
+ if (this.flags & 64) {
539
+ this.flags &= ~64;
540
540
  if (pausedQueueEffects.has(this)) {
541
541
  pausedQueueEffects.delete(this);
542
542
  this.trigger();
@@ -550,9 +550,6 @@ class ReactiveEffect {
550
550
  if (this.flags & 2 && !(this.flags & 32)) {
551
551
  return;
552
552
  }
553
- if (this.flags & 64) {
554
- return this.trigger();
555
- }
556
553
  if (!(this.flags & 8)) {
557
554
  this.flags |= 8;
558
555
  this.nextEffect = batchedEffect;
@@ -596,7 +593,7 @@ class ReactiveEffect {
596
593
  }
597
594
  }
598
595
  trigger() {
599
- if (this.flags & 128) {
596
+ if (this.flags & 64) {
600
597
  pausedQueueEffects.add(this);
601
598
  } else if (this.scheduler) {
602
599
  this.scheduler();
@@ -626,6 +623,7 @@ function endBatch() {
626
623
  batchDepth--;
627
624
  return;
628
625
  }
626
+ batchDepth--;
629
627
  let error;
630
628
  while (batchedEffect) {
631
629
  let e = batchedEffect;
@@ -644,7 +642,6 @@ function endBatch() {
644
642
  e = next;
645
643
  }
646
644
  }
647
- batchDepth--;
648
645
  if (error) throw error;
649
646
  }
650
647
  function prepareDeps(sub) {
@@ -1047,26 +1044,26 @@ const arrayInstrumentations = {
1047
1044
  });
1048
1045
  },
1049
1046
  every(fn, thisArg) {
1050
- return apply(this, "every", fn, thisArg);
1047
+ return apply(this, "every", fn, thisArg, void 0, arguments);
1051
1048
  },
1052
1049
  filter(fn, thisArg) {
1053
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
1050
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
1054
1051
  },
1055
1052
  find(fn, thisArg) {
1056
- return apply(this, "find", fn, thisArg, toReactive);
1053
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
1057
1054
  },
1058
1055
  findIndex(fn, thisArg) {
1059
- return apply(this, "findIndex", fn, thisArg);
1056
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
1060
1057
  },
1061
1058
  findLast(fn, thisArg) {
1062
- return apply(this, "findLast", fn, thisArg, toReactive);
1059
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
1063
1060
  },
1064
1061
  findLastIndex(fn, thisArg) {
1065
- return apply(this, "findLastIndex", fn, thisArg);
1062
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
1066
1063
  },
1067
1064
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1068
1065
  forEach(fn, thisArg) {
1069
- return apply(this, "forEach", fn, thisArg);
1066
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
1070
1067
  },
1071
1068
  includes(...args) {
1072
1069
  return searchProxy(this, "includes", args);
@@ -1082,7 +1079,7 @@ const arrayInstrumentations = {
1082
1079
  return searchProxy(this, "lastIndexOf", args);
1083
1080
  },
1084
1081
  map(fn, thisArg) {
1085
- return apply(this, "map", fn, thisArg);
1082
+ return apply(this, "map", fn, thisArg, void 0, arguments);
1086
1083
  },
1087
1084
  pop() {
1088
1085
  return noTracking(this, "pop");
@@ -1101,7 +1098,7 @@ const arrayInstrumentations = {
1101
1098
  },
1102
1099
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1103
1100
  some(fn, thisArg) {
1104
- return apply(this, "some", fn, thisArg);
1101
+ return apply(this, "some", fn, thisArg, void 0, arguments);
1105
1102
  },
1106
1103
  splice(...args) {
1107
1104
  return noTracking(this, "splice", args);
@@ -1137,12 +1134,17 @@ function iterator(self, method, wrapValue) {
1137
1134
  }
1138
1135
  return iter;
1139
1136
  }
1140
- function apply(self, method, fn, thisArg, wrappedRetFn) {
1137
+ const arrayProto = Array.prototype;
1138
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1141
1139
  const arr = shallowReadArray(self);
1142
- let needsWrap = false;
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;
1145
+ }
1143
1146
  let wrappedFn = fn;
1144
1147
  if (arr !== self) {
1145
- needsWrap = !isShallow(self);
1146
1148
  if (needsWrap) {
1147
1149
  wrappedFn = function(item, index) {
1148
1150
  return fn.call(this, toReactive(item), index, self);
@@ -1153,7 +1155,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn) {
1153
1155
  };
1154
1156
  }
1155
1157
  }
1156
- const result = arr[method](wrappedFn, thisArg);
1158
+ const result = methodFn.call(arr, wrappedFn, thisArg);
1157
1159
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
1158
1160
  }
1159
1161
  function reduce(self, method, fn, args) {
@@ -2004,6 +2006,220 @@ const TriggerOpTypes = {
2004
2006
  "CLEAR": "clear"
2005
2007
  };
2006
2008
 
2009
+ const INITIAL_WATCHER_VALUE = {};
2010
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
2011
+ let activeWatcher = void 0;
2012
+ function getCurrentWatcher() {
2013
+ return activeWatcher;
2014
+ }
2015
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2016
+ if (owner) {
2017
+ let cleanups = cleanupMap.get(owner);
2018
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
2019
+ cleanups.push(cleanupFn);
2020
+ } else if (!failSilently) {
2021
+ warn$2(
2022
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
2023
+ );
2024
+ }
2025
+ }
2026
+ function watch$1(source, cb, options = EMPTY_OBJ) {
2027
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
2028
+ const warnInvalidSource = (s) => {
2029
+ (options.onWarn || warn$2)(
2030
+ `Invalid watch source: `,
2031
+ s,
2032
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
2033
+ );
2034
+ };
2035
+ const reactiveGetter = (source2) => {
2036
+ if (deep) return source2;
2037
+ if (isShallow(source2) || deep === false || deep === 0)
2038
+ return traverse(source2, 1);
2039
+ return traverse(source2);
2040
+ };
2041
+ let effect;
2042
+ let getter;
2043
+ let cleanup;
2044
+ let boundCleanup;
2045
+ let forceTrigger = false;
2046
+ let isMultiSource = false;
2047
+ if (isRef(source)) {
2048
+ getter = () => source.value;
2049
+ forceTrigger = isShallow(source);
2050
+ } else if (isReactive(source)) {
2051
+ getter = () => reactiveGetter(source);
2052
+ forceTrigger = true;
2053
+ } else if (isArray(source)) {
2054
+ isMultiSource = true;
2055
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2056
+ getter = () => source.map((s) => {
2057
+ if (isRef(s)) {
2058
+ return s.value;
2059
+ } else if (isReactive(s)) {
2060
+ return reactiveGetter(s);
2061
+ } else if (isFunction(s)) {
2062
+ return call ? call(s, 2) : s();
2063
+ } else {
2064
+ warnInvalidSource(s);
2065
+ }
2066
+ });
2067
+ } else if (isFunction(source)) {
2068
+ if (cb) {
2069
+ getter = call ? () => call(source, 2) : source;
2070
+ } else {
2071
+ getter = () => {
2072
+ if (cleanup) {
2073
+ pauseTracking();
2074
+ try {
2075
+ cleanup();
2076
+ } finally {
2077
+ resetTracking();
2078
+ }
2079
+ }
2080
+ const currentEffect = activeWatcher;
2081
+ activeWatcher = effect;
2082
+ try {
2083
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2084
+ } finally {
2085
+ activeWatcher = currentEffect;
2086
+ }
2087
+ };
2088
+ }
2089
+ } else {
2090
+ getter = NOOP;
2091
+ warnInvalidSource(source);
2092
+ }
2093
+ if (cb && deep) {
2094
+ const baseGetter = getter;
2095
+ const depth = deep === true ? Infinity : deep;
2096
+ getter = () => traverse(baseGetter(), depth);
2097
+ }
2098
+ if (once) {
2099
+ if (cb) {
2100
+ const _cb = cb;
2101
+ cb = (...args) => {
2102
+ _cb(...args);
2103
+ effect.stop();
2104
+ };
2105
+ } else {
2106
+ const _getter = getter;
2107
+ getter = () => {
2108
+ _getter();
2109
+ effect.stop();
2110
+ };
2111
+ }
2112
+ }
2113
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2114
+ const job = (immediateFirstRun) => {
2115
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2116
+ return;
2117
+ }
2118
+ if (cb) {
2119
+ const newValue = effect.run();
2120
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2121
+ if (cleanup) {
2122
+ cleanup();
2123
+ }
2124
+ const currentWatcher = activeWatcher;
2125
+ activeWatcher = effect;
2126
+ try {
2127
+ const args = [
2128
+ newValue,
2129
+ // pass undefined as the old value when it's changed for the first time
2130
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2131
+ boundCleanup
2132
+ ];
2133
+ call ? call(cb, 3, args) : (
2134
+ // @ts-expect-error
2135
+ cb(...args)
2136
+ );
2137
+ oldValue = newValue;
2138
+ } finally {
2139
+ activeWatcher = currentWatcher;
2140
+ }
2141
+ }
2142
+ } else {
2143
+ effect.run();
2144
+ }
2145
+ };
2146
+ if (augmentJob) {
2147
+ augmentJob(job);
2148
+ }
2149
+ effect = new ReactiveEffect(getter);
2150
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2151
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2152
+ cleanup = effect.onStop = () => {
2153
+ const cleanups = cleanupMap.get(effect);
2154
+ if (cleanups) {
2155
+ if (call) {
2156
+ call(cleanups, 4);
2157
+ } else {
2158
+ for (const cleanup2 of cleanups) cleanup2();
2159
+ }
2160
+ cleanupMap.delete(effect);
2161
+ }
2162
+ };
2163
+ {
2164
+ effect.onTrack = options.onTrack;
2165
+ effect.onTrigger = options.onTrigger;
2166
+ }
2167
+ if (cb) {
2168
+ if (immediate) {
2169
+ job(true);
2170
+ } else {
2171
+ oldValue = effect.run();
2172
+ }
2173
+ } else if (scheduler) {
2174
+ scheduler(job.bind(null, true), true);
2175
+ } else {
2176
+ effect.run();
2177
+ }
2178
+ const scope = getCurrentScope();
2179
+ const watchHandle = () => {
2180
+ effect.stop();
2181
+ if (scope) {
2182
+ remove(scope.effects, effect);
2183
+ }
2184
+ };
2185
+ watchHandle.pause = effect.pause.bind(effect);
2186
+ watchHandle.resume = effect.resume.bind(effect);
2187
+ watchHandle.stop = watchHandle;
2188
+ return watchHandle;
2189
+ }
2190
+ function traverse(value, depth = Infinity, seen) {
2191
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2192
+ return value;
2193
+ }
2194
+ seen = seen || /* @__PURE__ */ new Set();
2195
+ if (seen.has(value)) {
2196
+ return value;
2197
+ }
2198
+ seen.add(value);
2199
+ depth--;
2200
+ if (isRef(value)) {
2201
+ traverse(value.value, depth, seen);
2202
+ } else if (isArray(value)) {
2203
+ for (let i = 0; i < value.length; i++) {
2204
+ traverse(value[i], depth, seen);
2205
+ }
2206
+ } else if (isSet(value) || isMap(value)) {
2207
+ value.forEach((v) => {
2208
+ traverse(v, depth, seen);
2209
+ });
2210
+ } else if (isPlainObject(value)) {
2211
+ for (const key in value) {
2212
+ traverse(value[key], depth, seen);
2213
+ }
2214
+ for (const key of Object.getOwnPropertySymbols(value)) {
2215
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2216
+ traverse(value[key], depth, seen);
2217
+ }
2218
+ }
2219
+ }
2220
+ return value;
2221
+ }
2222
+
2007
2223
  const stack$1 = [];
2008
2224
  function pushWarningContext(vnode) {
2009
2225
  stack$1.push(vnode);
@@ -2131,12 +2347,6 @@ const ErrorCodes = {
2131
2347
  "0": "SETUP_FUNCTION",
2132
2348
  "RENDER_FUNCTION": 1,
2133
2349
  "1": "RENDER_FUNCTION",
2134
- "WATCH_GETTER": 2,
2135
- "2": "WATCH_GETTER",
2136
- "WATCH_CALLBACK": 3,
2137
- "3": "WATCH_CALLBACK",
2138
- "WATCH_CLEANUP": 4,
2139
- "4": "WATCH_CLEANUP",
2140
2350
  "NATIVE_EVENT_HANDLER": 5,
2141
2351
  "5": "NATIVE_EVENT_HANDLER",
2142
2352
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2288,7 +2498,7 @@ function nextTick(fn) {
2288
2498
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2289
2499
  }
2290
2500
  function findInsertionIndex(id) {
2291
- let start = flushIndex + 1;
2501
+ let start = isFlushing ? flushIndex + 1 : 0;
2292
2502
  let end = queue.length;
2293
2503
  while (start < end) {
2294
2504
  const middle = start + end >>> 1;
@@ -2304,15 +2514,13 @@ function findInsertionIndex(id) {
2304
2514
  }
2305
2515
  function queueJob(job) {
2306
2516
  if (!(job.flags & 1)) {
2307
- if (job.id == null) {
2308
- queue.push(job);
2309
- } else if (
2310
- // fast path when the job id is larger than the tail
2311
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2312
- ) {
2517
+ const jobId = getId(job);
2518
+ const lastJob = queue[queue.length - 1];
2519
+ if (!lastJob || // fast path when the job id is larger than the tail
2520
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2313
2521
  queue.push(job);
2314
2522
  } else {
2315
- queue.splice(findInsertionIndex(job.id), 0, job);
2523
+ queue.splice(findInsertionIndex(jobId), 0, job);
2316
2524
  }
2317
2525
  if (!(job.flags & 4)) {
2318
2526
  job.flags |= 1;
@@ -2326,12 +2534,6 @@ function queueFlush() {
2326
2534
  currentFlushPromise = resolvedPromise.then(flushJobs);
2327
2535
  }
2328
2536
  }
2329
- function invalidateJob(job) {
2330
- const i = queue.indexOf(job);
2331
- if (i > flushIndex) {
2332
- queue.splice(i, 1);
2333
- }
2334
- }
2335
2537
  function queuePostFlushCb(cb) {
2336
2538
  if (!isArray(cb)) {
2337
2539
  if (activePostFlushCbs && cb.id === -1) {
@@ -2393,24 +2595,13 @@ function flushPostFlushCbs(seen) {
2393
2595
  postFlushIndex = 0;
2394
2596
  }
2395
2597
  }
2396
- const getId = (job) => job.id == null ? Infinity : job.id;
2397
- const comparator = (a, b) => {
2398
- const diff = getId(a) - getId(b);
2399
- if (diff === 0) {
2400
- const isAPre = a.flags & 2;
2401
- const isBPre = b.flags & 2;
2402
- if (isAPre && !isBPre) return -1;
2403
- if (isBPre && !isAPre) return 1;
2404
- }
2405
- return diff;
2406
- };
2598
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2407
2599
  function flushJobs(seen) {
2408
2600
  isFlushPending = false;
2409
2601
  isFlushing = true;
2410
2602
  {
2411
2603
  seen = seen || /* @__PURE__ */ new Map();
2412
2604
  }
2413
- queue.sort(comparator);
2414
2605
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2415
2606
  try {
2416
2607
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3558,6 +3749,7 @@ const logMismatchError = () => {
3558
3749
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
3559
3750
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
3560
3751
  const getContainerType = (container) => {
3752
+ if (container.nodeType !== 1) return void 0;
3561
3753
  if (isSVGContainer(container)) return "svg";
3562
3754
  if (isMathMLContainer(container)) return "mathml";
3563
3755
  return void 0;
@@ -4486,7 +4678,7 @@ const KeepAliveImpl = {
4486
4678
  function pruneCache(filter) {
4487
4679
  cache.forEach((vnode, key) => {
4488
4680
  const name = getComponentName(vnode.type);
4489
- if (name && (!filter || !filter(name))) {
4681
+ if (name && !filter(name)) {
4490
4682
  pruneCacheEntry(key);
4491
4683
  }
4492
4684
  });
@@ -4605,6 +4797,7 @@ function matches(pattern, name) {
4605
4797
  } else if (isString(pattern)) {
4606
4798
  return pattern.split(",").includes(name);
4607
4799
  } else if (isRegExp(pattern)) {
4800
+ pattern.lastIndex = 0;
4608
4801
  return pattern.test(name);
4609
4802
  }
4610
4803
  return false;
@@ -5499,16 +5692,20 @@ function callHook$1(hook, instance, type) {
5499
5692
  );
5500
5693
  }
5501
5694
  function createWatcher(raw, ctx, publicThis, key) {
5502
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5695
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5503
5696
  if (isString(raw)) {
5504
5697
  const handler = ctx[raw];
5505
5698
  if (isFunction(handler)) {
5506
- watch(getter, handler);
5699
+ {
5700
+ watch(getter, handler);
5701
+ }
5507
5702
  } else {
5508
5703
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5509
5704
  }
5510
5705
  } else if (isFunction(raw)) {
5511
- watch(getter, raw.bind(publicThis));
5706
+ {
5707
+ watch(getter, raw.bind(publicThis));
5708
+ }
5512
5709
  } else if (isObject(raw)) {
5513
5710
  if (isArray(raw)) {
5514
5711
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -6746,7 +6943,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6746
6943
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
6747
6944
  subTree = filterSingleRoot(subTree.children) || subTree;
6748
6945
  }
6749
- if (vnode === subTree) {
6946
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
6750
6947
  const parentVNode = parentComponent.vnode;
6751
6948
  setScopeId(
6752
6949
  el,
@@ -7075,7 +7272,6 @@ function baseCreateRenderer(options, createHydrationFns) {
7075
7272
  return;
7076
7273
  } else {
7077
7274
  instance.next = n2;
7078
- invalidateJob(instance.update);
7079
7275
  instance.update();
7080
7276
  }
7081
7277
  } else {
@@ -7966,7 +8162,6 @@ function watchSyncEffect(effect, options) {
7966
8162
  extend({}, options, { flush: "sync" })
7967
8163
  );
7968
8164
  }
7969
- const INITIAL_WATCHER_VALUE = {};
7970
8165
  function watch(source, cb, options) {
7971
8166
  if (!isFunction(cb)) {
7972
8167
  warn$1(
@@ -7975,21 +8170,8 @@ function watch(source, cb, options) {
7975
8170
  }
7976
8171
  return doWatch(source, cb, options);
7977
8172
  }
7978
- function doWatch(source, cb, {
7979
- immediate,
7980
- deep,
7981
- flush,
7982
- once,
7983
- onTrack,
7984
- onTrigger
7985
- } = EMPTY_OBJ) {
7986
- if (cb && once) {
7987
- const _cb = cb;
7988
- cb = (...args) => {
7989
- _cb(...args);
7990
- watchHandle();
7991
- };
7992
- }
8173
+ function doWatch(source, cb, options = EMPTY_OBJ) {
8174
+ const { immediate, deep, flush, once } = options;
7993
8175
  if (!cb) {
7994
8176
  if (immediate !== void 0) {
7995
8177
  warn$1(
@@ -8007,164 +8189,53 @@ function doWatch(source, cb, {
8007
8189
  );
8008
8190
  }
8009
8191
  }
8010
- const warnInvalidSource = (s) => {
8011
- warn$1(
8012
- `Invalid watch source: `,
8013
- s,
8014
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
8015
- );
8016
- };
8017
- const instance = currentInstance;
8018
- const reactiveGetter = (source2) => {
8019
- if (deep) return source2;
8020
- if (isShallow(source2) || deep === false || deep === 0)
8021
- return traverse(source2, 1);
8022
- return traverse(source2);
8023
- };
8024
- let getter;
8025
- let forceTrigger = false;
8026
- let isMultiSource = false;
8027
- if (isRef(source)) {
8028
- getter = () => source.value;
8029
- forceTrigger = isShallow(source);
8030
- } else if (isReactive(source)) {
8031
- getter = () => reactiveGetter(source);
8032
- forceTrigger = true;
8033
- } else if (isArray(source)) {
8034
- isMultiSource = true;
8035
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
8036
- getter = () => source.map((s) => {
8037
- if (isRef(s)) {
8038
- return s.value;
8039
- } else if (isReactive(s)) {
8040
- return reactiveGetter(s);
8041
- } else if (isFunction(s)) {
8042
- return callWithErrorHandling(s, instance, 2);
8043
- } else {
8044
- warnInvalidSource(s);
8045
- }
8046
- });
8047
- } else if (isFunction(source)) {
8048
- if (cb) {
8049
- getter = () => callWithErrorHandling(source, instance, 2);
8050
- } else {
8051
- getter = () => {
8052
- if (cleanup) {
8053
- cleanup();
8054
- }
8055
- return callWithAsyncErrorHandling(
8056
- source,
8057
- instance,
8058
- 3,
8059
- [onCleanup]
8060
- );
8061
- };
8062
- }
8063
- } else {
8064
- getter = NOOP;
8065
- warnInvalidSource(source);
8066
- }
8067
- if (cb && deep) {
8068
- const baseGetter = getter;
8069
- const depth = deep === true ? Infinity : deep;
8070
- getter = () => traverse(baseGetter(), depth);
8071
- }
8072
- let cleanup;
8073
- let onCleanup = (fn) => {
8074
- cleanup = effect.onStop = () => {
8075
- callWithErrorHandling(fn, instance, 4);
8076
- cleanup = effect.onStop = void 0;
8077
- };
8078
- };
8192
+ const baseWatchOptions = extend({}, options);
8193
+ baseWatchOptions.onWarn = warn$1;
8079
8194
  let ssrCleanup;
8080
8195
  if (isInSSRComponentSetup) {
8081
- onCleanup = NOOP;
8082
- if (!cb) {
8083
- getter();
8084
- } else if (immediate) {
8085
- callWithAsyncErrorHandling(cb, instance, 3, [
8086
- getter(),
8087
- isMultiSource ? [] : void 0,
8088
- onCleanup
8089
- ]);
8090
- }
8091
8196
  if (flush === "sync") {
8092
8197
  const ctx = useSSRContext();
8093
8198
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
8199
+ } else if (!cb || immediate) {
8200
+ baseWatchOptions.once = true;
8094
8201
  } else {
8095
- const watchHandle2 = () => {
8202
+ return {
8203
+ stop: NOOP,
8204
+ resume: NOOP,
8205
+ pause: NOOP
8096
8206
  };
8097
- watchHandle2.stop = NOOP;
8098
- watchHandle2.resume = NOOP;
8099
- watchHandle2.pause = NOOP;
8100
- return watchHandle2;
8101
8207
  }
8102
8208
  }
8103
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
8104
- const job = (immediateFirstRun) => {
8105
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
8106
- return;
8107
- }
8108
- if (cb) {
8109
- const newValue = effect.run();
8110
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
8111
- if (cleanup) {
8112
- cleanup();
8113
- }
8114
- callWithAsyncErrorHandling(cb, instance, 3, [
8115
- newValue,
8116
- // pass undefined as the old value when it's changed for the first time
8117
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
8118
- onCleanup
8119
- ]);
8120
- oldValue = newValue;
8209
+ const instance = currentInstance;
8210
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
8211
+ let isPre = false;
8212
+ if (flush === "post") {
8213
+ baseWatchOptions.scheduler = (job) => {
8214
+ queuePostRenderEffect(job, instance && instance.suspense);
8215
+ };
8216
+ } else if (flush !== "sync") {
8217
+ isPre = true;
8218
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
8219
+ if (isFirstRun) {
8220
+ job();
8221
+ } else {
8222
+ queueJob(job);
8121
8223
  }
8122
- } else {
8123
- effect.run();
8124
- }
8125
- };
8126
- if (cb) job.flags |= 4;
8127
- const effect = new ReactiveEffect(getter);
8128
- let scheduler;
8129
- if (flush === "sync") {
8130
- effect.flags |= 64;
8131
- scheduler = job;
8132
- } else if (flush === "post") {
8133
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
8134
- } else {
8135
- job.flags |= 2;
8136
- if (instance) job.id = instance.uid;
8137
- scheduler = () => queueJob(job);
8224
+ };
8138
8225
  }
8139
- effect.scheduler = scheduler;
8140
- const scope = getCurrentScope();
8141
- const watchHandle = () => {
8142
- effect.stop();
8143
- if (scope) {
8144
- remove(scope.effects, effect);
8226
+ baseWatchOptions.augmentJob = (job) => {
8227
+ if (cb) {
8228
+ job.flags |= 4;
8145
8229
  }
8146
- };
8147
- watchHandle.pause = effect.pause.bind(effect);
8148
- watchHandle.resume = effect.resume.bind(effect);
8149
- watchHandle.stop = watchHandle;
8150
- {
8151
- effect.onTrack = onTrack;
8152
- effect.onTrigger = onTrigger;
8153
- }
8154
- if (cb) {
8155
- if (immediate) {
8156
- job(true);
8157
- } else {
8158
- oldValue = effect.run();
8230
+ if (isPre) {
8231
+ job.flags |= 2;
8232
+ if (instance) {
8233
+ job.id = instance.uid;
8234
+ job.i = instance;
8235
+ }
8159
8236
  }
8160
- } else if (flush === "post") {
8161
- queuePostRenderEffect(
8162
- effect.run.bind(effect),
8163
- instance && instance.suspense
8164
- );
8165
- } else {
8166
- effect.run();
8167
- }
8237
+ };
8238
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
8168
8239
  if (ssrCleanup) ssrCleanup.push(watchHandle);
8169
8240
  return watchHandle;
8170
8241
  }
@@ -8193,38 +8264,6 @@ function createPathGetter(ctx, path) {
8193
8264
  return cur;
8194
8265
  };
8195
8266
  }
8196
- function traverse(value, depth = Infinity, seen) {
8197
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
8198
- return value;
8199
- }
8200
- seen = seen || /* @__PURE__ */ new Set();
8201
- if (seen.has(value)) {
8202
- return value;
8203
- }
8204
- seen.add(value);
8205
- depth--;
8206
- if (isRef(value)) {
8207
- traverse(value.value, depth, seen);
8208
- } else if (isArray(value)) {
8209
- for (let i = 0; i < value.length; i++) {
8210
- traverse(value[i], depth, seen);
8211
- }
8212
- } else if (isSet(value) || isMap(value)) {
8213
- value.forEach((v) => {
8214
- traverse(v, depth, seen);
8215
- });
8216
- } else if (isPlainObject(value)) {
8217
- for (const key in value) {
8218
- traverse(value[key], depth, seen);
8219
- }
8220
- for (const key of Object.getOwnPropertySymbols(value)) {
8221
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
8222
- traverse(value[key], depth, seen);
8223
- }
8224
- }
8225
- }
8226
- return value;
8227
- }
8228
8267
 
8229
8268
  function useModel(props, name, options = EMPTY_OBJ) {
8230
8269
  const i = getCurrentInstance();
@@ -10372,7 +10411,7 @@ function isMemoSame(cached, memo) {
10372
10411
  return true;
10373
10412
  }
10374
10413
 
10375
- const version = "3.5.0-beta.1";
10414
+ const version = "3.5.0-beta.3";
10376
10415
  const warn = warn$1 ;
10377
10416
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10378
10417
  const devtools = devtools$1 ;
@@ -11241,7 +11280,6 @@ class VueElement extends BaseClass {
11241
11280
  this._ob = null;
11242
11281
  if (this.shadowRoot && _createApp !== createApp) {
11243
11282
  this._root = this.shadowRoot;
11244
- this._mount(_def);
11245
11283
  } else {
11246
11284
  if (this.shadowRoot) {
11247
11285
  warn(
@@ -11254,9 +11292,9 @@ class VueElement extends BaseClass {
11254
11292
  } else {
11255
11293
  this._root = this;
11256
11294
  }
11257
- if (!this._def.__asyncLoader) {
11258
- this._resolveProps(this._def);
11259
- }
11295
+ }
11296
+ if (!this._def.__asyncLoader) {
11297
+ this._resolveProps(this._def);
11260
11298
  }
11261
11299
  }
11262
11300
  connectedCallback() {
@@ -11456,6 +11494,7 @@ class VueElement extends BaseClass {
11456
11494
  vnode.ce = (instance) => {
11457
11495
  this._instance = instance;
11458
11496
  instance.ce = this;
11497
+ instance.isCE = true;
11459
11498
  {
11460
11499
  instance.ceReload = (newStyles) => {
11461
11500
  if (this._styles) {
@@ -12269,6 +12308,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12269
12308
  effectScope: effectScope,
12270
12309
  getCurrentInstance: getCurrentInstance,
12271
12310
  getCurrentScope: getCurrentScope,
12311
+ getCurrentWatcher: getCurrentWatcher,
12272
12312
  getTransitionRawChildren: getTransitionRawChildren,
12273
12313
  guardReactiveProps: guardReactiveProps,
12274
12314
  h: h,
@@ -12311,6 +12351,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12311
12351
  onServerPrefetch: onServerPrefetch,
12312
12352
  onUnmounted: onUnmounted,
12313
12353
  onUpdated: onUpdated,
12354
+ onWatcherCleanup: onWatcherCleanup,
12314
12355
  openBlock: openBlock,
12315
12356
  popScopeId: popScopeId,
12316
12357
  provide: provide,
@@ -13562,8 +13603,9 @@ const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13562
13603
  const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
13563
13604
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
13564
13605
  const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
13565
- const isMemberExpressionBrowser = (path) => {
13566
- path = path.trim().replace(whitespaceRE, (s) => s.trim());
13606
+ const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
13607
+ const isMemberExpressionBrowser = (exp) => {
13608
+ const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
13567
13609
  let state = 0 /* inMemberExp */;
13568
13610
  let stateStack = [];
13569
13611
  let currentOpenBracketCount = 0;
@@ -13625,6 +13667,9 @@ const isMemberExpressionBrowser = (path) => {
13625
13667
  return !currentOpenBracketCount && !currentOpenParensCount;
13626
13668
  };
13627
13669
  const isMemberExpression = isMemberExpressionBrowser ;
13670
+ const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
13671
+ const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
13672
+ const isFnExpression = isFnExpressionBrowser ;
13628
13673
  function assert(condition, msg) {
13629
13674
  if (!condition) {
13630
13675
  throw new Error(msg || `unexpected compiler condition`);
@@ -14061,7 +14106,9 @@ const tokenizer = new Tokenizer(stack, {
14061
14106
  case 17:
14062
14107
  case 18:
14063
14108
  case 19:
14109
+ // "
14064
14110
  case 20:
14111
+ // '
14065
14112
  case 21:
14066
14113
  emitError(9, end);
14067
14114
  break;
@@ -14966,6 +15013,7 @@ function traverseNode(node, context) {
14966
15013
  context.helper(TO_DISPLAY_STRING);
14967
15014
  }
14968
15015
  break;
15016
+ // for container types, further traverse downwards
14969
15017
  case 9:
14970
15018
  for (let i2 = 0; i2 < node.branches.length; i2++) {
14971
15019
  traverseNode(node.branches[i2], context);
@@ -15313,6 +15361,7 @@ function genNode(node, context) {
15313
15361
  case 21:
15314
15362
  genNodeList(node.body, context, true, false);
15315
15363
  break;
15364
+ // SSR only types
15316
15365
  case 22:
15317
15366
  break;
15318
15367
  case 23:
@@ -15323,6 +15372,7 @@ function genNode(node, context) {
15323
15372
  break;
15324
15373
  case 26:
15325
15374
  break;
15375
+ /* istanbul ignore next */
15326
15376
  case 10:
15327
15377
  break;
15328
15378
  default:
@@ -16982,7 +17032,6 @@ function processSlotOutlet(node, context) {
16982
17032
  };
16983
17033
  }
16984
17034
 
16985
- const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
16986
17035
  const transformOn$1 = (dir, node, context, augmentor) => {
16987
17036
  const { loc, modifiers, arg } = dir;
16988
17037
  if (!dir.exp && !modifiers.length) {
@@ -17026,8 +17075,8 @@ const transformOn$1 = (dir, node, context, augmentor) => {
17026
17075
  }
17027
17076
  let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
17028
17077
  if (exp) {
17029
- const isMemberExp = isMemberExpression(exp.content);
17030
- const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
17078
+ const isMemberExp = isMemberExpression(exp);
17079
+ const isInlineStatement = !(isMemberExp || isFnExpression(exp));
17031
17080
  const hasMultipleStatements = exp.content.includes(`;`);
17032
17081
  {
17033
17082
  validateBrowserExpression(
@@ -17175,7 +17224,7 @@ const transformModel$1 = (dir, node, context) => {
17175
17224
  return createTransformProps();
17176
17225
  }
17177
17226
  const maybeRef = false;
17178
- if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
17227
+ if (!expString.trim() || !isMemberExpression(exp) && !maybeRef) {
17179
17228
  context.onError(
17180
17229
  createCompilerError(42, exp.loc)
17181
17230
  );
@@ -18015,4 +18064,4 @@ ${codeFrame}` : message);
18015
18064
  }
18016
18065
  registerRuntimeCompiler(compileToFunction);
18017
18066
 
18018
- 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, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, 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 };
18067
+ 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, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, 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 };