@vue/runtime-dom 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/runtime-dom v3.5.0-beta.1
2
+ * @vue/runtime-dom 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++) {
@@ -3491,6 +3682,7 @@ const logMismatchError = () => {
3491
3682
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
3492
3683
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
3493
3684
  const getContainerType = (container) => {
3685
+ if (container.nodeType !== 1) return void 0;
3494
3686
  if (isSVGContainer(container)) return "svg";
3495
3687
  if (isMathMLContainer(container)) return "mathml";
3496
3688
  return void 0;
@@ -4419,7 +4611,7 @@ const KeepAliveImpl = {
4419
4611
  function pruneCache(filter) {
4420
4612
  cache.forEach((vnode, key) => {
4421
4613
  const name = getComponentName(vnode.type);
4422
- if (name && (!filter || !filter(name))) {
4614
+ if (name && !filter(name)) {
4423
4615
  pruneCacheEntry(key);
4424
4616
  }
4425
4617
  });
@@ -4538,6 +4730,7 @@ function matches(pattern, name) {
4538
4730
  } else if (isString(pattern)) {
4539
4731
  return pattern.split(",").includes(name);
4540
4732
  } else if (isRegExp(pattern)) {
4733
+ pattern.lastIndex = 0;
4541
4734
  return pattern.test(name);
4542
4735
  }
4543
4736
  return false;
@@ -5432,16 +5625,20 @@ function callHook$1(hook, instance, type) {
5432
5625
  );
5433
5626
  }
5434
5627
  function createWatcher(raw, ctx, publicThis, key) {
5435
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5628
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5436
5629
  if (isString(raw)) {
5437
5630
  const handler = ctx[raw];
5438
5631
  if (isFunction(handler)) {
5439
- watch(getter, handler);
5632
+ {
5633
+ watch(getter, handler);
5634
+ }
5440
5635
  } else {
5441
5636
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5442
5637
  }
5443
5638
  } else if (isFunction(raw)) {
5444
- watch(getter, raw.bind(publicThis));
5639
+ {
5640
+ watch(getter, raw.bind(publicThis));
5641
+ }
5445
5642
  } else if (isObject(raw)) {
5446
5643
  if (isArray(raw)) {
5447
5644
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -6679,7 +6876,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6679
6876
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
6680
6877
  subTree = filterSingleRoot(subTree.children) || subTree;
6681
6878
  }
6682
- if (vnode === subTree) {
6879
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
6683
6880
  const parentVNode = parentComponent.vnode;
6684
6881
  setScopeId(
6685
6882
  el,
@@ -7008,7 +7205,6 @@ function baseCreateRenderer(options, createHydrationFns) {
7008
7205
  return;
7009
7206
  } else {
7010
7207
  instance.next = n2;
7011
- invalidateJob(instance.update);
7012
7208
  instance.update();
7013
7209
  }
7014
7210
  } else {
@@ -7899,7 +8095,6 @@ function watchSyncEffect(effect, options) {
7899
8095
  extend({}, options, { flush: "sync" })
7900
8096
  );
7901
8097
  }
7902
- const INITIAL_WATCHER_VALUE = {};
7903
8098
  function watch(source, cb, options) {
7904
8099
  if (!isFunction(cb)) {
7905
8100
  warn$1(
@@ -7908,21 +8103,8 @@ function watch(source, cb, options) {
7908
8103
  }
7909
8104
  return doWatch(source, cb, options);
7910
8105
  }
7911
- function doWatch(source, cb, {
7912
- immediate,
7913
- deep,
7914
- flush,
7915
- once,
7916
- onTrack,
7917
- onTrigger
7918
- } = EMPTY_OBJ) {
7919
- if (cb && once) {
7920
- const _cb = cb;
7921
- cb = (...args) => {
7922
- _cb(...args);
7923
- watchHandle();
7924
- };
7925
- }
8106
+ function doWatch(source, cb, options = EMPTY_OBJ) {
8107
+ const { immediate, deep, flush, once } = options;
7926
8108
  if (!cb) {
7927
8109
  if (immediate !== void 0) {
7928
8110
  warn$1(
@@ -7940,164 +8122,53 @@ function doWatch(source, cb, {
7940
8122
  );
7941
8123
  }
7942
8124
  }
7943
- const warnInvalidSource = (s) => {
7944
- warn$1(
7945
- `Invalid watch source: `,
7946
- s,
7947
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
7948
- );
7949
- };
7950
- const instance = currentInstance;
7951
- const reactiveGetter = (source2) => {
7952
- if (deep) return source2;
7953
- if (isShallow(source2) || deep === false || deep === 0)
7954
- return traverse(source2, 1);
7955
- return traverse(source2);
7956
- };
7957
- let getter;
7958
- let forceTrigger = false;
7959
- let isMultiSource = false;
7960
- if (isRef(source)) {
7961
- getter = () => source.value;
7962
- forceTrigger = isShallow(source);
7963
- } else if (isReactive(source)) {
7964
- getter = () => reactiveGetter(source);
7965
- forceTrigger = true;
7966
- } else if (isArray(source)) {
7967
- isMultiSource = true;
7968
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
7969
- getter = () => source.map((s) => {
7970
- if (isRef(s)) {
7971
- return s.value;
7972
- } else if (isReactive(s)) {
7973
- return reactiveGetter(s);
7974
- } else if (isFunction(s)) {
7975
- return callWithErrorHandling(s, instance, 2);
7976
- } else {
7977
- warnInvalidSource(s);
7978
- }
7979
- });
7980
- } else if (isFunction(source)) {
7981
- if (cb) {
7982
- getter = () => callWithErrorHandling(source, instance, 2);
7983
- } else {
7984
- getter = () => {
7985
- if (cleanup) {
7986
- cleanup();
7987
- }
7988
- return callWithAsyncErrorHandling(
7989
- source,
7990
- instance,
7991
- 3,
7992
- [onCleanup]
7993
- );
7994
- };
7995
- }
7996
- } else {
7997
- getter = NOOP;
7998
- warnInvalidSource(source);
7999
- }
8000
- if (cb && deep) {
8001
- const baseGetter = getter;
8002
- const depth = deep === true ? Infinity : deep;
8003
- getter = () => traverse(baseGetter(), depth);
8004
- }
8005
- let cleanup;
8006
- let onCleanup = (fn) => {
8007
- cleanup = effect.onStop = () => {
8008
- callWithErrorHandling(fn, instance, 4);
8009
- cleanup = effect.onStop = void 0;
8010
- };
8011
- };
8125
+ const baseWatchOptions = extend({}, options);
8126
+ baseWatchOptions.onWarn = warn$1;
8012
8127
  let ssrCleanup;
8013
8128
  if (isInSSRComponentSetup) {
8014
- onCleanup = NOOP;
8015
- if (!cb) {
8016
- getter();
8017
- } else if (immediate) {
8018
- callWithAsyncErrorHandling(cb, instance, 3, [
8019
- getter(),
8020
- isMultiSource ? [] : void 0,
8021
- onCleanup
8022
- ]);
8023
- }
8024
8129
  if (flush === "sync") {
8025
8130
  const ctx = useSSRContext();
8026
8131
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
8132
+ } else if (!cb || immediate) {
8133
+ baseWatchOptions.once = true;
8027
8134
  } else {
8028
- const watchHandle2 = () => {
8135
+ return {
8136
+ stop: NOOP,
8137
+ resume: NOOP,
8138
+ pause: NOOP
8029
8139
  };
8030
- watchHandle2.stop = NOOP;
8031
- watchHandle2.resume = NOOP;
8032
- watchHandle2.pause = NOOP;
8033
- return watchHandle2;
8034
8140
  }
8035
8141
  }
8036
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
8037
- const job = (immediateFirstRun) => {
8038
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
8039
- return;
8040
- }
8041
- if (cb) {
8042
- const newValue = effect.run();
8043
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
8044
- if (cleanup) {
8045
- cleanup();
8046
- }
8047
- callWithAsyncErrorHandling(cb, instance, 3, [
8048
- newValue,
8049
- // pass undefined as the old value when it's changed for the first time
8050
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
8051
- onCleanup
8052
- ]);
8053
- oldValue = newValue;
8142
+ const instance = currentInstance;
8143
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
8144
+ let isPre = false;
8145
+ if (flush === "post") {
8146
+ baseWatchOptions.scheduler = (job) => {
8147
+ queuePostRenderEffect(job, instance && instance.suspense);
8148
+ };
8149
+ } else if (flush !== "sync") {
8150
+ isPre = true;
8151
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
8152
+ if (isFirstRun) {
8153
+ job();
8154
+ } else {
8155
+ queueJob(job);
8054
8156
  }
8055
- } else {
8056
- effect.run();
8057
- }
8058
- };
8059
- if (cb) job.flags |= 4;
8060
- const effect = new ReactiveEffect(getter);
8061
- let scheduler;
8062
- if (flush === "sync") {
8063
- effect.flags |= 64;
8064
- scheduler = job;
8065
- } else if (flush === "post") {
8066
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
8067
- } else {
8068
- job.flags |= 2;
8069
- if (instance) job.id = instance.uid;
8070
- scheduler = () => queueJob(job);
8157
+ };
8071
8158
  }
8072
- effect.scheduler = scheduler;
8073
- const scope = getCurrentScope();
8074
- const watchHandle = () => {
8075
- effect.stop();
8076
- if (scope) {
8077
- remove(scope.effects, effect);
8159
+ baseWatchOptions.augmentJob = (job) => {
8160
+ if (cb) {
8161
+ job.flags |= 4;
8078
8162
  }
8079
- };
8080
- watchHandle.pause = effect.pause.bind(effect);
8081
- watchHandle.resume = effect.resume.bind(effect);
8082
- watchHandle.stop = watchHandle;
8083
- {
8084
- effect.onTrack = onTrack;
8085
- effect.onTrigger = onTrigger;
8086
- }
8087
- if (cb) {
8088
- if (immediate) {
8089
- job(true);
8090
- } else {
8091
- oldValue = effect.run();
8163
+ if (isPre) {
8164
+ job.flags |= 2;
8165
+ if (instance) {
8166
+ job.id = instance.uid;
8167
+ job.i = instance;
8168
+ }
8092
8169
  }
8093
- } else if (flush === "post") {
8094
- queuePostRenderEffect(
8095
- effect.run.bind(effect),
8096
- instance && instance.suspense
8097
- );
8098
- } else {
8099
- effect.run();
8100
- }
8170
+ };
8171
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
8101
8172
  if (ssrCleanup) ssrCleanup.push(watchHandle);
8102
8173
  return watchHandle;
8103
8174
  }
@@ -8126,38 +8197,6 @@ function createPathGetter(ctx, path) {
8126
8197
  return cur;
8127
8198
  };
8128
8199
  }
8129
- function traverse(value, depth = Infinity, seen) {
8130
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
8131
- return value;
8132
- }
8133
- seen = seen || /* @__PURE__ */ new Set();
8134
- if (seen.has(value)) {
8135
- return value;
8136
- }
8137
- seen.add(value);
8138
- depth--;
8139
- if (isRef(value)) {
8140
- traverse(value.value, depth, seen);
8141
- } else if (isArray(value)) {
8142
- for (let i = 0; i < value.length; i++) {
8143
- traverse(value[i], depth, seen);
8144
- }
8145
- } else if (isSet(value) || isMap(value)) {
8146
- value.forEach((v) => {
8147
- traverse(v, depth, seen);
8148
- });
8149
- } else if (isPlainObject(value)) {
8150
- for (const key in value) {
8151
- traverse(value[key], depth, seen);
8152
- }
8153
- for (const key of Object.getOwnPropertySymbols(value)) {
8154
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
8155
- traverse(value[key], depth, seen);
8156
- }
8157
- }
8158
- }
8159
- return value;
8160
- }
8161
8200
 
8162
8201
  function useModel(props, name, options = EMPTY_OBJ) {
8163
8202
  const i = getCurrentInstance();
@@ -10305,7 +10344,7 @@ function isMemoSame(cached, memo) {
10305
10344
  return true;
10306
10345
  }
10307
10346
 
10308
- const version = "3.5.0-beta.1";
10347
+ const version = "3.5.0-beta.3";
10309
10348
  const warn = warn$1 ;
10310
10349
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10311
10350
  const devtools = devtools$1 ;
@@ -11174,7 +11213,6 @@ class VueElement extends BaseClass {
11174
11213
  this._ob = null;
11175
11214
  if (this.shadowRoot && _createApp !== createApp) {
11176
11215
  this._root = this.shadowRoot;
11177
- this._mount(_def);
11178
11216
  } else {
11179
11217
  if (this.shadowRoot) {
11180
11218
  warn(
@@ -11187,9 +11225,9 @@ class VueElement extends BaseClass {
11187
11225
  } else {
11188
11226
  this._root = this;
11189
11227
  }
11190
- if (!this._def.__asyncLoader) {
11191
- this._resolveProps(this._def);
11192
- }
11228
+ }
11229
+ if (!this._def.__asyncLoader) {
11230
+ this._resolveProps(this._def);
11193
11231
  }
11194
11232
  }
11195
11233
  connectedCallback() {
@@ -11389,6 +11427,7 @@ class VueElement extends BaseClass {
11389
11427
  vnode.ce = (instance) => {
11390
11428
  this._instance = instance;
11391
11429
  instance.ce = this;
11430
+ instance.isCE = true;
11392
11431
  {
11393
11432
  instance.ceReload = (newStyles) => {
11394
11433
  if (this._styles) {
@@ -12144,4 +12183,4 @@ const initDirectivesForSSR = () => {
12144
12183
  }
12145
12184
  } ;
12146
12185
 
12147
- 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, 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 };
12186
+ 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, 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 };