@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
  **/
@@ -468,11 +468,11 @@ var VueRuntimeDOM = (function (exports) {
468
468
  }
469
469
  }
470
470
  pause() {
471
- this.flags |= 128;
471
+ this.flags |= 64;
472
472
  }
473
473
  resume() {
474
- if (this.flags & 128) {
475
- this.flags &= ~128;
474
+ if (this.flags & 64) {
475
+ this.flags &= ~64;
476
476
  if (pausedQueueEffects.has(this)) {
477
477
  pausedQueueEffects.delete(this);
478
478
  this.trigger();
@@ -486,9 +486,6 @@ var VueRuntimeDOM = (function (exports) {
486
486
  if (this.flags & 2 && !(this.flags & 32)) {
487
487
  return;
488
488
  }
489
- if (this.flags & 64) {
490
- return this.trigger();
491
- }
492
489
  if (!(this.flags & 8)) {
493
490
  this.flags |= 8;
494
491
  this.nextEffect = batchedEffect;
@@ -532,7 +529,7 @@ var VueRuntimeDOM = (function (exports) {
532
529
  }
533
530
  }
534
531
  trigger() {
535
- if (this.flags & 128) {
532
+ if (this.flags & 64) {
536
533
  pausedQueueEffects.add(this);
537
534
  } else if (this.scheduler) {
538
535
  this.scheduler();
@@ -562,6 +559,7 @@ var VueRuntimeDOM = (function (exports) {
562
559
  batchDepth--;
563
560
  return;
564
561
  }
562
+ batchDepth--;
565
563
  let error;
566
564
  while (batchedEffect) {
567
565
  let e = batchedEffect;
@@ -580,7 +578,6 @@ var VueRuntimeDOM = (function (exports) {
580
578
  e = next;
581
579
  }
582
580
  }
583
- batchDepth--;
584
581
  if (error) throw error;
585
582
  }
586
583
  function prepareDeps(sub) {
@@ -983,26 +980,26 @@ var VueRuntimeDOM = (function (exports) {
983
980
  });
984
981
  },
985
982
  every(fn, thisArg) {
986
- return apply(this, "every", fn, thisArg);
983
+ return apply(this, "every", fn, thisArg, void 0, arguments);
987
984
  },
988
985
  filter(fn, thisArg) {
989
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
986
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
990
987
  },
991
988
  find(fn, thisArg) {
992
- return apply(this, "find", fn, thisArg, toReactive);
989
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
993
990
  },
994
991
  findIndex(fn, thisArg) {
995
- return apply(this, "findIndex", fn, thisArg);
992
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
996
993
  },
997
994
  findLast(fn, thisArg) {
998
- return apply(this, "findLast", fn, thisArg, toReactive);
995
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
999
996
  },
1000
997
  findLastIndex(fn, thisArg) {
1001
- return apply(this, "findLastIndex", fn, thisArg);
998
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
1002
999
  },
1003
1000
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1004
1001
  forEach(fn, thisArg) {
1005
- return apply(this, "forEach", fn, thisArg);
1002
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
1006
1003
  },
1007
1004
  includes(...args) {
1008
1005
  return searchProxy(this, "includes", args);
@@ -1018,7 +1015,7 @@ var VueRuntimeDOM = (function (exports) {
1018
1015
  return searchProxy(this, "lastIndexOf", args);
1019
1016
  },
1020
1017
  map(fn, thisArg) {
1021
- return apply(this, "map", fn, thisArg);
1018
+ return apply(this, "map", fn, thisArg, void 0, arguments);
1022
1019
  },
1023
1020
  pop() {
1024
1021
  return noTracking(this, "pop");
@@ -1037,7 +1034,7 @@ var VueRuntimeDOM = (function (exports) {
1037
1034
  },
1038
1035
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1039
1036
  some(fn, thisArg) {
1040
- return apply(this, "some", fn, thisArg);
1037
+ return apply(this, "some", fn, thisArg, void 0, arguments);
1041
1038
  },
1042
1039
  splice(...args) {
1043
1040
  return noTracking(this, "splice", args);
@@ -1073,12 +1070,17 @@ var VueRuntimeDOM = (function (exports) {
1073
1070
  }
1074
1071
  return iter;
1075
1072
  }
1076
- function apply(self, method, fn, thisArg, wrappedRetFn) {
1073
+ const arrayProto = Array.prototype;
1074
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1077
1075
  const arr = shallowReadArray(self);
1078
- let needsWrap = false;
1076
+ const needsWrap = arr !== self && !isShallow(self);
1077
+ const methodFn = arr[method];
1078
+ if (methodFn !== arrayProto[method]) {
1079
+ const result2 = methodFn.apply(arr, args);
1080
+ return needsWrap ? toReactive(result2) : result2;
1081
+ }
1079
1082
  let wrappedFn = fn;
1080
1083
  if (arr !== self) {
1081
- needsWrap = !isShallow(self);
1082
1084
  if (needsWrap) {
1083
1085
  wrappedFn = function(item, index) {
1084
1086
  return fn.call(this, toReactive(item), index, self);
@@ -1089,7 +1091,7 @@ var VueRuntimeDOM = (function (exports) {
1089
1091
  };
1090
1092
  }
1091
1093
  }
1092
- const result = arr[method](wrappedFn, thisArg);
1094
+ const result = methodFn.call(arr, wrappedFn, thisArg);
1093
1095
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
1094
1096
  }
1095
1097
  function reduce(self, method, fn, args) {
@@ -1940,6 +1942,220 @@ var VueRuntimeDOM = (function (exports) {
1940
1942
  "CLEAR": "clear"
1941
1943
  };
1942
1944
 
1945
+ const INITIAL_WATCHER_VALUE = {};
1946
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1947
+ let activeWatcher = void 0;
1948
+ function getCurrentWatcher() {
1949
+ return activeWatcher;
1950
+ }
1951
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1952
+ if (owner) {
1953
+ let cleanups = cleanupMap.get(owner);
1954
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1955
+ cleanups.push(cleanupFn);
1956
+ } else if (!failSilently) {
1957
+ warn$2(
1958
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1959
+ );
1960
+ }
1961
+ }
1962
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1963
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1964
+ const warnInvalidSource = (s) => {
1965
+ (options.onWarn || warn$2)(
1966
+ `Invalid watch source: `,
1967
+ s,
1968
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1969
+ );
1970
+ };
1971
+ const reactiveGetter = (source2) => {
1972
+ if (deep) return source2;
1973
+ if (isShallow(source2) || deep === false || deep === 0)
1974
+ return traverse(source2, 1);
1975
+ return traverse(source2);
1976
+ };
1977
+ let effect;
1978
+ let getter;
1979
+ let cleanup;
1980
+ let boundCleanup;
1981
+ let forceTrigger = false;
1982
+ let isMultiSource = false;
1983
+ if (isRef(source)) {
1984
+ getter = () => source.value;
1985
+ forceTrigger = isShallow(source);
1986
+ } else if (isReactive(source)) {
1987
+ getter = () => reactiveGetter(source);
1988
+ forceTrigger = true;
1989
+ } else if (isArray(source)) {
1990
+ isMultiSource = true;
1991
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1992
+ getter = () => source.map((s) => {
1993
+ if (isRef(s)) {
1994
+ return s.value;
1995
+ } else if (isReactive(s)) {
1996
+ return reactiveGetter(s);
1997
+ } else if (isFunction(s)) {
1998
+ return call ? call(s, 2) : s();
1999
+ } else {
2000
+ warnInvalidSource(s);
2001
+ }
2002
+ });
2003
+ } else if (isFunction(source)) {
2004
+ if (cb) {
2005
+ getter = call ? () => call(source, 2) : source;
2006
+ } else {
2007
+ getter = () => {
2008
+ if (cleanup) {
2009
+ pauseTracking();
2010
+ try {
2011
+ cleanup();
2012
+ } finally {
2013
+ resetTracking();
2014
+ }
2015
+ }
2016
+ const currentEffect = activeWatcher;
2017
+ activeWatcher = effect;
2018
+ try {
2019
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2020
+ } finally {
2021
+ activeWatcher = currentEffect;
2022
+ }
2023
+ };
2024
+ }
2025
+ } else {
2026
+ getter = NOOP;
2027
+ warnInvalidSource(source);
2028
+ }
2029
+ if (cb && deep) {
2030
+ const baseGetter = getter;
2031
+ const depth = deep === true ? Infinity : deep;
2032
+ getter = () => traverse(baseGetter(), depth);
2033
+ }
2034
+ if (once) {
2035
+ if (cb) {
2036
+ const _cb = cb;
2037
+ cb = (...args) => {
2038
+ _cb(...args);
2039
+ effect.stop();
2040
+ };
2041
+ } else {
2042
+ const _getter = getter;
2043
+ getter = () => {
2044
+ _getter();
2045
+ effect.stop();
2046
+ };
2047
+ }
2048
+ }
2049
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2050
+ const job = (immediateFirstRun) => {
2051
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2052
+ return;
2053
+ }
2054
+ if (cb) {
2055
+ const newValue = effect.run();
2056
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2057
+ if (cleanup) {
2058
+ cleanup();
2059
+ }
2060
+ const currentWatcher = activeWatcher;
2061
+ activeWatcher = effect;
2062
+ try {
2063
+ const args = [
2064
+ newValue,
2065
+ // pass undefined as the old value when it's changed for the first time
2066
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2067
+ boundCleanup
2068
+ ];
2069
+ call ? call(cb, 3, args) : (
2070
+ // @ts-expect-error
2071
+ cb(...args)
2072
+ );
2073
+ oldValue = newValue;
2074
+ } finally {
2075
+ activeWatcher = currentWatcher;
2076
+ }
2077
+ }
2078
+ } else {
2079
+ effect.run();
2080
+ }
2081
+ };
2082
+ if (augmentJob) {
2083
+ augmentJob(job);
2084
+ }
2085
+ effect = new ReactiveEffect(getter);
2086
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2087
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2088
+ cleanup = effect.onStop = () => {
2089
+ const cleanups = cleanupMap.get(effect);
2090
+ if (cleanups) {
2091
+ if (call) {
2092
+ call(cleanups, 4);
2093
+ } else {
2094
+ for (const cleanup2 of cleanups) cleanup2();
2095
+ }
2096
+ cleanupMap.delete(effect);
2097
+ }
2098
+ };
2099
+ {
2100
+ effect.onTrack = options.onTrack;
2101
+ effect.onTrigger = options.onTrigger;
2102
+ }
2103
+ if (cb) {
2104
+ if (immediate) {
2105
+ job(true);
2106
+ } else {
2107
+ oldValue = effect.run();
2108
+ }
2109
+ } else if (scheduler) {
2110
+ scheduler(job.bind(null, true), true);
2111
+ } else {
2112
+ effect.run();
2113
+ }
2114
+ const scope = getCurrentScope();
2115
+ const watchHandle = () => {
2116
+ effect.stop();
2117
+ if (scope) {
2118
+ remove(scope.effects, effect);
2119
+ }
2120
+ };
2121
+ watchHandle.pause = effect.pause.bind(effect);
2122
+ watchHandle.resume = effect.resume.bind(effect);
2123
+ watchHandle.stop = watchHandle;
2124
+ return watchHandle;
2125
+ }
2126
+ function traverse(value, depth = Infinity, seen) {
2127
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2128
+ return value;
2129
+ }
2130
+ seen = seen || /* @__PURE__ */ new Set();
2131
+ if (seen.has(value)) {
2132
+ return value;
2133
+ }
2134
+ seen.add(value);
2135
+ depth--;
2136
+ if (isRef(value)) {
2137
+ traverse(value.value, depth, seen);
2138
+ } else if (isArray(value)) {
2139
+ for (let i = 0; i < value.length; i++) {
2140
+ traverse(value[i], depth, seen);
2141
+ }
2142
+ } else if (isSet(value) || isMap(value)) {
2143
+ value.forEach((v) => {
2144
+ traverse(v, depth, seen);
2145
+ });
2146
+ } else if (isPlainObject(value)) {
2147
+ for (const key in value) {
2148
+ traverse(value[key], depth, seen);
2149
+ }
2150
+ for (const key of Object.getOwnPropertySymbols(value)) {
2151
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2152
+ traverse(value[key], depth, seen);
2153
+ }
2154
+ }
2155
+ }
2156
+ return value;
2157
+ }
2158
+
1943
2159
  const stack = [];
1944
2160
  function pushWarningContext(vnode) {
1945
2161
  stack.push(vnode);
@@ -2067,12 +2283,6 @@ var VueRuntimeDOM = (function (exports) {
2067
2283
  "0": "SETUP_FUNCTION",
2068
2284
  "RENDER_FUNCTION": 1,
2069
2285
  "1": "RENDER_FUNCTION",
2070
- "WATCH_GETTER": 2,
2071
- "2": "WATCH_GETTER",
2072
- "WATCH_CALLBACK": 3,
2073
- "3": "WATCH_CALLBACK",
2074
- "WATCH_CLEANUP": 4,
2075
- "4": "WATCH_CLEANUP",
2076
2286
  "NATIVE_EVENT_HANDLER": 5,
2077
2287
  "5": "NATIVE_EVENT_HANDLER",
2078
2288
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2224,7 +2434,7 @@ var VueRuntimeDOM = (function (exports) {
2224
2434
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2225
2435
  }
2226
2436
  function findInsertionIndex(id) {
2227
- let start = flushIndex + 1;
2437
+ let start = isFlushing ? flushIndex + 1 : 0;
2228
2438
  let end = queue.length;
2229
2439
  while (start < end) {
2230
2440
  const middle = start + end >>> 1;
@@ -2240,15 +2450,13 @@ var VueRuntimeDOM = (function (exports) {
2240
2450
  }
2241
2451
  function queueJob(job) {
2242
2452
  if (!(job.flags & 1)) {
2243
- if (job.id == null) {
2244
- queue.push(job);
2245
- } else if (
2246
- // fast path when the job id is larger than the tail
2247
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2248
- ) {
2453
+ const jobId = getId(job);
2454
+ const lastJob = queue[queue.length - 1];
2455
+ if (!lastJob || // fast path when the job id is larger than the tail
2456
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2249
2457
  queue.push(job);
2250
2458
  } else {
2251
- queue.splice(findInsertionIndex(job.id), 0, job);
2459
+ queue.splice(findInsertionIndex(jobId), 0, job);
2252
2460
  }
2253
2461
  if (!(job.flags & 4)) {
2254
2462
  job.flags |= 1;
@@ -2262,12 +2470,6 @@ var VueRuntimeDOM = (function (exports) {
2262
2470
  currentFlushPromise = resolvedPromise.then(flushJobs);
2263
2471
  }
2264
2472
  }
2265
- function invalidateJob(job) {
2266
- const i = queue.indexOf(job);
2267
- if (i > flushIndex) {
2268
- queue.splice(i, 1);
2269
- }
2270
- }
2271
2473
  function queuePostFlushCb(cb) {
2272
2474
  if (!isArray(cb)) {
2273
2475
  if (activePostFlushCbs && cb.id === -1) {
@@ -2329,24 +2531,13 @@ var VueRuntimeDOM = (function (exports) {
2329
2531
  postFlushIndex = 0;
2330
2532
  }
2331
2533
  }
2332
- const getId = (job) => job.id == null ? Infinity : job.id;
2333
- const comparator = (a, b) => {
2334
- const diff = getId(a) - getId(b);
2335
- if (diff === 0) {
2336
- const isAPre = a.flags & 2;
2337
- const isBPre = b.flags & 2;
2338
- if (isAPre && !isBPre) return -1;
2339
- if (isBPre && !isAPre) return 1;
2340
- }
2341
- return diff;
2342
- };
2534
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2343
2535
  function flushJobs(seen) {
2344
2536
  isFlushPending = false;
2345
2537
  isFlushing = true;
2346
2538
  {
2347
2539
  seen = seen || /* @__PURE__ */ new Map();
2348
2540
  }
2349
- queue.sort(comparator);
2350
2541
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2351
2542
  try {
2352
2543
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3494,6 +3685,7 @@ var VueRuntimeDOM = (function (exports) {
3494
3685
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
3495
3686
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
3496
3687
  const getContainerType = (container) => {
3688
+ if (container.nodeType !== 1) return void 0;
3497
3689
  if (isSVGContainer(container)) return "svg";
3498
3690
  if (isMathMLContainer(container)) return "mathml";
3499
3691
  return void 0;
@@ -4416,7 +4608,7 @@ Server rendered element contains fewer child nodes than client vdom.`
4416
4608
  function pruneCache(filter) {
4417
4609
  cache.forEach((vnode, key) => {
4418
4610
  const name = getComponentName(vnode.type);
4419
- if (name && (!filter || !filter(name))) {
4611
+ if (name && !filter(name)) {
4420
4612
  pruneCacheEntry(key);
4421
4613
  }
4422
4614
  });
@@ -4535,6 +4727,7 @@ Server rendered element contains fewer child nodes than client vdom.`
4535
4727
  } else if (isString(pattern)) {
4536
4728
  return pattern.split(",").includes(name);
4537
4729
  } else if (isRegExp(pattern)) {
4730
+ pattern.lastIndex = 0;
4538
4731
  return pattern.test(name);
4539
4732
  }
4540
4733
  return false;
@@ -5426,16 +5619,20 @@ If this is a native custom element, make sure to exclude it from component resol
5426
5619
  );
5427
5620
  }
5428
5621
  function createWatcher(raw, ctx, publicThis, key) {
5429
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5622
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5430
5623
  if (isString(raw)) {
5431
5624
  const handler = ctx[raw];
5432
5625
  if (isFunction(handler)) {
5433
- watch(getter, handler);
5626
+ {
5627
+ watch(getter, handler);
5628
+ }
5434
5629
  } else {
5435
5630
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5436
5631
  }
5437
5632
  } else if (isFunction(raw)) {
5438
- watch(getter, raw.bind(publicThis));
5633
+ {
5634
+ watch(getter, raw.bind(publicThis));
5635
+ }
5439
5636
  } else if (isObject(raw)) {
5440
5637
  if (isArray(raw)) {
5441
5638
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -6673,7 +6870,7 @@ If you want to remount the same app, move your app creation logic into a factory
6673
6870
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
6674
6871
  subTree = filterSingleRoot(subTree.children) || subTree;
6675
6872
  }
6676
- if (vnode === subTree) {
6873
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
6677
6874
  const parentVNode = parentComponent.vnode;
6678
6875
  setScopeId(
6679
6876
  el,
@@ -7002,7 +7199,6 @@ If you want to remount the same app, move your app creation logic into a factory
7002
7199
  return;
7003
7200
  } else {
7004
7201
  instance.next = n2;
7005
- invalidateJob(instance.update);
7006
7202
  instance.update();
7007
7203
  }
7008
7204
  } else {
@@ -7887,7 +8083,6 @@ If you want to remount the same app, move your app creation logic into a factory
7887
8083
  extend({}, options, { flush: "sync" })
7888
8084
  );
7889
8085
  }
7890
- const INITIAL_WATCHER_VALUE = {};
7891
8086
  function watch(source, cb, options) {
7892
8087
  if (!isFunction(cb)) {
7893
8088
  warn$1(
@@ -7896,21 +8091,8 @@ If you want to remount the same app, move your app creation logic into a factory
7896
8091
  }
7897
8092
  return doWatch(source, cb, options);
7898
8093
  }
7899
- function doWatch(source, cb, {
7900
- immediate,
7901
- deep,
7902
- flush,
7903
- once,
7904
- onTrack,
7905
- onTrigger
7906
- } = EMPTY_OBJ) {
7907
- if (cb && once) {
7908
- const _cb = cb;
7909
- cb = (...args) => {
7910
- _cb(...args);
7911
- watchHandle();
7912
- };
7913
- }
8094
+ function doWatch(source, cb, options = EMPTY_OBJ) {
8095
+ const { immediate, deep, flush, once } = options;
7914
8096
  if (!cb) {
7915
8097
  if (immediate !== void 0) {
7916
8098
  warn$1(
@@ -7928,140 +8110,38 @@ If you want to remount the same app, move your app creation logic into a factory
7928
8110
  );
7929
8111
  }
7930
8112
  }
7931
- const warnInvalidSource = (s) => {
7932
- warn$1(
7933
- `Invalid watch source: `,
7934
- s,
7935
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
7936
- );
7937
- };
8113
+ const baseWatchOptions = extend({}, options);
8114
+ baseWatchOptions.onWarn = warn$1;
7938
8115
  const instance = currentInstance;
7939
- const reactiveGetter = (source2) => {
7940
- if (deep) return source2;
7941
- if (isShallow(source2) || deep === false || deep === 0)
7942
- return traverse(source2, 1);
7943
- return traverse(source2);
7944
- };
7945
- let getter;
7946
- let forceTrigger = false;
7947
- let isMultiSource = false;
7948
- if (isRef(source)) {
7949
- getter = () => source.value;
7950
- forceTrigger = isShallow(source);
7951
- } else if (isReactive(source)) {
7952
- getter = () => reactiveGetter(source);
7953
- forceTrigger = true;
7954
- } else if (isArray(source)) {
7955
- isMultiSource = true;
7956
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
7957
- getter = () => source.map((s) => {
7958
- if (isRef(s)) {
7959
- return s.value;
7960
- } else if (isReactive(s)) {
7961
- return reactiveGetter(s);
7962
- } else if (isFunction(s)) {
7963
- return callWithErrorHandling(s, instance, 2);
8116
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
8117
+ let isPre = false;
8118
+ if (flush === "post") {
8119
+ baseWatchOptions.scheduler = (job) => {
8120
+ queuePostRenderEffect(job, instance && instance.suspense);
8121
+ };
8122
+ } else if (flush !== "sync") {
8123
+ isPre = true;
8124
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
8125
+ if (isFirstRun) {
8126
+ job();
7964
8127
  } else {
7965
- warnInvalidSource(s);
8128
+ queueJob(job);
7966
8129
  }
7967
- });
7968
- } else if (isFunction(source)) {
7969
- if (cb) {
7970
- getter = () => callWithErrorHandling(source, instance, 2);
7971
- } else {
7972
- getter = () => {
7973
- if (cleanup) {
7974
- cleanup();
7975
- }
7976
- return callWithAsyncErrorHandling(
7977
- source,
7978
- instance,
7979
- 3,
7980
- [onCleanup]
7981
- );
7982
- };
7983
- }
7984
- } else {
7985
- getter = NOOP;
7986
- warnInvalidSource(source);
7987
- }
7988
- if (cb && deep) {
7989
- const baseGetter = getter;
7990
- const depth = deep === true ? Infinity : deep;
7991
- getter = () => traverse(baseGetter(), depth);
7992
- }
7993
- let cleanup;
7994
- let onCleanup = (fn) => {
7995
- cleanup = effect.onStop = () => {
7996
- callWithErrorHandling(fn, instance, 4);
7997
- cleanup = effect.onStop = void 0;
7998
8130
  };
7999
- };
8000
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
8001
- const job = (immediateFirstRun) => {
8002
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
8003
- return;
8004
- }
8131
+ }
8132
+ baseWatchOptions.augmentJob = (job) => {
8005
8133
  if (cb) {
8006
- const newValue = effect.run();
8007
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
8008
- if (cleanup) {
8009
- cleanup();
8010
- }
8011
- callWithAsyncErrorHandling(cb, instance, 3, [
8012
- newValue,
8013
- // pass undefined as the old value when it's changed for the first time
8014
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
8015
- onCleanup
8016
- ]);
8017
- oldValue = newValue;
8018
- }
8019
- } else {
8020
- effect.run();
8134
+ job.flags |= 4;
8021
8135
  }
8022
- };
8023
- if (cb) job.flags |= 4;
8024
- const effect = new ReactiveEffect(getter);
8025
- let scheduler;
8026
- if (flush === "sync") {
8027
- effect.flags |= 64;
8028
- scheduler = job;
8029
- } else if (flush === "post") {
8030
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
8031
- } else {
8032
- job.flags |= 2;
8033
- if (instance) job.id = instance.uid;
8034
- scheduler = () => queueJob(job);
8035
- }
8036
- effect.scheduler = scheduler;
8037
- const scope = getCurrentScope();
8038
- const watchHandle = () => {
8039
- effect.stop();
8040
- if (scope) {
8041
- remove(scope.effects, effect);
8136
+ if (isPre) {
8137
+ job.flags |= 2;
8138
+ if (instance) {
8139
+ job.id = instance.uid;
8140
+ job.i = instance;
8141
+ }
8042
8142
  }
8043
8143
  };
8044
- watchHandle.pause = effect.pause.bind(effect);
8045
- watchHandle.resume = effect.resume.bind(effect);
8046
- watchHandle.stop = watchHandle;
8047
- {
8048
- effect.onTrack = onTrack;
8049
- effect.onTrigger = onTrigger;
8050
- }
8051
- if (cb) {
8052
- if (immediate) {
8053
- job(true);
8054
- } else {
8055
- oldValue = effect.run();
8056
- }
8057
- } else if (flush === "post") {
8058
- queuePostRenderEffect(
8059
- effect.run.bind(effect),
8060
- instance && instance.suspense
8061
- );
8062
- } else {
8063
- effect.run();
8064
- }
8144
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
8065
8145
  return watchHandle;
8066
8146
  }
8067
8147
  function instanceWatch(source, value, options) {
@@ -8089,38 +8169,6 @@ If you want to remount the same app, move your app creation logic into a factory
8089
8169
  return cur;
8090
8170
  };
8091
8171
  }
8092
- function traverse(value, depth = Infinity, seen) {
8093
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
8094
- return value;
8095
- }
8096
- seen = seen || /* @__PURE__ */ new Set();
8097
- if (seen.has(value)) {
8098
- return value;
8099
- }
8100
- seen.add(value);
8101
- depth--;
8102
- if (isRef(value)) {
8103
- traverse(value.value, depth, seen);
8104
- } else if (isArray(value)) {
8105
- for (let i = 0; i < value.length; i++) {
8106
- traverse(value[i], depth, seen);
8107
- }
8108
- } else if (isSet(value) || isMap(value)) {
8109
- value.forEach((v) => {
8110
- traverse(v, depth, seen);
8111
- });
8112
- } else if (isPlainObject(value)) {
8113
- for (const key in value) {
8114
- traverse(value[key], depth, seen);
8115
- }
8116
- for (const key of Object.getOwnPropertySymbols(value)) {
8117
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
8118
- traverse(value[key], depth, seen);
8119
- }
8120
- }
8121
- }
8122
- return value;
8123
- }
8124
8172
 
8125
8173
  function useModel(props, name, options = EMPTY_OBJ) {
8126
8174
  const i = getCurrentInstance();
@@ -10254,7 +10302,7 @@ Component that was made reactive: `,
10254
10302
  return true;
10255
10303
  }
10256
10304
 
10257
- const version = "3.5.0-beta.1";
10305
+ const version = "3.5.0-beta.3";
10258
10306
  const warn = warn$1 ;
10259
10307
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10260
10308
  const devtools = devtools$1 ;
@@ -11106,7 +11154,6 @@ Expected function or array of functions, received type ${typeof value}.`
11106
11154
  this._ob = null;
11107
11155
  if (this.shadowRoot && _createApp !== createApp) {
11108
11156
  this._root = this.shadowRoot;
11109
- this._mount(_def);
11110
11157
  } else {
11111
11158
  if (this.shadowRoot) {
11112
11159
  warn(
@@ -11119,9 +11166,9 @@ Expected function or array of functions, received type ${typeof value}.`
11119
11166
  } else {
11120
11167
  this._root = this;
11121
11168
  }
11122
- if (!this._def.__asyncLoader) {
11123
- this._resolveProps(this._def);
11124
- }
11169
+ }
11170
+ if (!this._def.__asyncLoader) {
11171
+ this._resolveProps(this._def);
11125
11172
  }
11126
11173
  }
11127
11174
  connectedCallback() {
@@ -11321,6 +11368,7 @@ Expected function or array of functions, received type ${typeof value}.`
11321
11368
  vnode.ce = (instance) => {
11322
11369
  this._instance = instance;
11323
11370
  instance.ce = this;
11371
+ instance.isCE = true;
11324
11372
  {
11325
11373
  instance.ceReload = (newStyles) => {
11326
11374
  if (this._styles) {
@@ -12079,6 +12127,7 @@ Expected function or array of functions, received type ${typeof value}.`
12079
12127
  exports.effectScope = effectScope;
12080
12128
  exports.getCurrentInstance = getCurrentInstance;
12081
12129
  exports.getCurrentScope = getCurrentScope;
12130
+ exports.getCurrentWatcher = getCurrentWatcher;
12082
12131
  exports.getTransitionRawChildren = getTransitionRawChildren;
12083
12132
  exports.guardReactiveProps = guardReactiveProps;
12084
12133
  exports.h = h;
@@ -12121,6 +12170,7 @@ Expected function or array of functions, received type ${typeof value}.`
12121
12170
  exports.onServerPrefetch = onServerPrefetch;
12122
12171
  exports.onUnmounted = onUnmounted;
12123
12172
  exports.onUpdated = onUpdated;
12173
+ exports.onWatcherCleanup = onWatcherCleanup;
12124
12174
  exports.openBlock = openBlock;
12125
12175
  exports.popScopeId = popScopeId;
12126
12176
  exports.provide = provide;