@vue/compat 3.5.0-beta.2 → 3.5.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.0-beta.2
2
+ * @vue/compat v3.5.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -455,12 +455,13 @@ class EffectScope {
455
455
  pause() {
456
456
  if (this._active) {
457
457
  this._isPaused = true;
458
+ let i, l;
458
459
  if (this.scopes) {
459
- for (let i = 0, l = this.scopes.length; i < l; i++) {
460
+ for (i = 0, l = this.scopes.length; i < l; i++) {
460
461
  this.scopes[i].pause();
461
462
  }
462
463
  }
463
- for (let i = 0, l = this.effects.length; i < l; i++) {
464
+ for (i = 0, l = this.effects.length; i < l; i++) {
464
465
  this.effects[i].pause();
465
466
  }
466
467
  }
@@ -472,12 +473,13 @@ class EffectScope {
472
473
  if (this._active) {
473
474
  if (this._isPaused) {
474
475
  this._isPaused = false;
476
+ let i, l;
475
477
  if (this.scopes) {
476
- for (let i = 0, l = this.scopes.length; i < l; i++) {
478
+ for (i = 0, l = this.scopes.length; i < l; i++) {
477
479
  this.scopes[i].resume();
478
480
  }
479
481
  }
480
- for (let i = 0, l = this.effects.length; i < l; i++) {
482
+ for (i = 0, l = this.effects.length; i < l; i++) {
481
483
  this.effects[i].resume();
482
484
  }
483
485
  }
@@ -670,11 +672,9 @@ function startBatch() {
670
672
  batchDepth++;
671
673
  }
672
674
  function endBatch() {
673
- if (batchDepth > 1) {
674
- batchDepth--;
675
+ if (--batchDepth > 0) {
675
676
  return;
676
677
  }
677
- batchDepth--;
678
678
  let error;
679
679
  while (batchedEffect) {
680
680
  let e = batchedEffect;
@@ -1188,14 +1188,14 @@ function iterator(self, method, wrapValue) {
1188
1188
  const arrayProto = Array.prototype;
1189
1189
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1190
1190
  const arr = shallowReadArray(self);
1191
- let methodFn;
1192
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1193
- return methodFn.apply(arr, args);
1191
+ const needsWrap = arr !== self && !isShallow(self);
1192
+ const methodFn = arr[method];
1193
+ if (methodFn !== arrayProto[method]) {
1194
+ const result2 = methodFn.apply(arr, args);
1195
+ return needsWrap ? toReactive(result2) : result2;
1194
1196
  }
1195
- let needsWrap = false;
1196
1197
  let wrappedFn = fn;
1197
1198
  if (arr !== self) {
1198
- needsWrap = !isShallow(self);
1199
1199
  if (needsWrap) {
1200
1200
  wrappedFn = function(item, index) {
1201
1201
  return fn.call(this, toReactive(item), index, self);
@@ -1333,7 +1333,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1333
1333
  }
1334
1334
  }
1335
1335
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1336
- const result = Reflect.set(target, key, value, receiver);
1336
+ const result = Reflect.set(
1337
+ target,
1338
+ key,
1339
+ value,
1340
+ isRef(target) ? target : receiver
1341
+ );
1337
1342
  if (target === toRaw(receiver)) {
1338
1343
  if (!hadKey) {
1339
1344
  trigger(target, "add", key, value);
@@ -2057,6 +2062,220 @@ const TriggerOpTypes = {
2057
2062
  "CLEAR": "clear"
2058
2063
  };
2059
2064
 
2065
+ const INITIAL_WATCHER_VALUE = {};
2066
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
2067
+ let activeWatcher = void 0;
2068
+ function getCurrentWatcher() {
2069
+ return activeWatcher;
2070
+ }
2071
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2072
+ if (owner) {
2073
+ let cleanups = cleanupMap.get(owner);
2074
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
2075
+ cleanups.push(cleanupFn);
2076
+ } else if (!failSilently) {
2077
+ warn$2(
2078
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
2079
+ );
2080
+ }
2081
+ }
2082
+ function watch$1(source, cb, options = EMPTY_OBJ) {
2083
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
2084
+ const warnInvalidSource = (s) => {
2085
+ (options.onWarn || warn$2)(
2086
+ `Invalid watch source: `,
2087
+ s,
2088
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
2089
+ );
2090
+ };
2091
+ const reactiveGetter = (source2) => {
2092
+ if (deep) return source2;
2093
+ if (isShallow(source2) || deep === false || deep === 0)
2094
+ return traverse(source2, 1);
2095
+ return traverse(source2);
2096
+ };
2097
+ let effect;
2098
+ let getter;
2099
+ let cleanup;
2100
+ let boundCleanup;
2101
+ let forceTrigger = false;
2102
+ let isMultiSource = false;
2103
+ if (isRef(source)) {
2104
+ getter = () => source.value;
2105
+ forceTrigger = isShallow(source);
2106
+ } else if (isReactive(source)) {
2107
+ getter = () => reactiveGetter(source);
2108
+ forceTrigger = true;
2109
+ } else if (isArray(source)) {
2110
+ isMultiSource = true;
2111
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2112
+ getter = () => source.map((s) => {
2113
+ if (isRef(s)) {
2114
+ return s.value;
2115
+ } else if (isReactive(s)) {
2116
+ return reactiveGetter(s);
2117
+ } else if (isFunction(s)) {
2118
+ return call ? call(s, 2) : s();
2119
+ } else {
2120
+ warnInvalidSource(s);
2121
+ }
2122
+ });
2123
+ } else if (isFunction(source)) {
2124
+ if (cb) {
2125
+ getter = call ? () => call(source, 2) : source;
2126
+ } else {
2127
+ getter = () => {
2128
+ if (cleanup) {
2129
+ pauseTracking();
2130
+ try {
2131
+ cleanup();
2132
+ } finally {
2133
+ resetTracking();
2134
+ }
2135
+ }
2136
+ const currentEffect = activeWatcher;
2137
+ activeWatcher = effect;
2138
+ try {
2139
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2140
+ } finally {
2141
+ activeWatcher = currentEffect;
2142
+ }
2143
+ };
2144
+ }
2145
+ } else {
2146
+ getter = NOOP;
2147
+ warnInvalidSource(source);
2148
+ }
2149
+ if (cb && deep) {
2150
+ const baseGetter = getter;
2151
+ const depth = deep === true ? Infinity : deep;
2152
+ getter = () => traverse(baseGetter(), depth);
2153
+ }
2154
+ const scope = getCurrentScope();
2155
+ const watchHandle = () => {
2156
+ effect.stop();
2157
+ if (scope) {
2158
+ remove(scope.effects, effect);
2159
+ }
2160
+ };
2161
+ if (once) {
2162
+ if (cb) {
2163
+ const _cb = cb;
2164
+ cb = (...args) => {
2165
+ _cb(...args);
2166
+ watchHandle();
2167
+ };
2168
+ } else {
2169
+ const _getter = getter;
2170
+ getter = () => {
2171
+ _getter();
2172
+ watchHandle();
2173
+ };
2174
+ }
2175
+ }
2176
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2177
+ const job = (immediateFirstRun) => {
2178
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2179
+ return;
2180
+ }
2181
+ if (cb) {
2182
+ const newValue = effect.run();
2183
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2184
+ if (cleanup) {
2185
+ cleanup();
2186
+ }
2187
+ const currentWatcher = activeWatcher;
2188
+ activeWatcher = effect;
2189
+ try {
2190
+ const args = [
2191
+ newValue,
2192
+ // pass undefined as the old value when it's changed for the first time
2193
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2194
+ boundCleanup
2195
+ ];
2196
+ call ? call(cb, 3, args) : (
2197
+ // @ts-expect-error
2198
+ cb(...args)
2199
+ );
2200
+ oldValue = newValue;
2201
+ } finally {
2202
+ activeWatcher = currentWatcher;
2203
+ }
2204
+ }
2205
+ } else {
2206
+ effect.run();
2207
+ }
2208
+ };
2209
+ if (augmentJob) {
2210
+ augmentJob(job);
2211
+ }
2212
+ effect = new ReactiveEffect(getter);
2213
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2214
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2215
+ cleanup = effect.onStop = () => {
2216
+ const cleanups = cleanupMap.get(effect);
2217
+ if (cleanups) {
2218
+ if (call) {
2219
+ call(cleanups, 4);
2220
+ } else {
2221
+ for (const cleanup2 of cleanups) cleanup2();
2222
+ }
2223
+ cleanupMap.delete(effect);
2224
+ }
2225
+ };
2226
+ {
2227
+ effect.onTrack = options.onTrack;
2228
+ effect.onTrigger = options.onTrigger;
2229
+ }
2230
+ if (cb) {
2231
+ if (immediate) {
2232
+ job(true);
2233
+ } else {
2234
+ oldValue = effect.run();
2235
+ }
2236
+ } else if (scheduler) {
2237
+ scheduler(job.bind(null, true), true);
2238
+ } else {
2239
+ effect.run();
2240
+ }
2241
+ watchHandle.pause = effect.pause.bind(effect);
2242
+ watchHandle.resume = effect.resume.bind(effect);
2243
+ watchHandle.stop = watchHandle;
2244
+ return watchHandle;
2245
+ }
2246
+ function traverse(value, depth = Infinity, seen) {
2247
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2248
+ return value;
2249
+ }
2250
+ seen = seen || /* @__PURE__ */ new Set();
2251
+ if (seen.has(value)) {
2252
+ return value;
2253
+ }
2254
+ seen.add(value);
2255
+ depth--;
2256
+ if (isRef(value)) {
2257
+ traverse(value.value, depth, seen);
2258
+ } else if (isArray(value)) {
2259
+ for (let i = 0; i < value.length; i++) {
2260
+ traverse(value[i], depth, seen);
2261
+ }
2262
+ } else if (isSet(value) || isMap(value)) {
2263
+ value.forEach((v) => {
2264
+ traverse(v, depth, seen);
2265
+ });
2266
+ } else if (isPlainObject(value)) {
2267
+ for (const key in value) {
2268
+ traverse(value[key], depth, seen);
2269
+ }
2270
+ for (const key of Object.getOwnPropertySymbols(value)) {
2271
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2272
+ traverse(value[key], depth, seen);
2273
+ }
2274
+ }
2275
+ }
2276
+ return value;
2277
+ }
2278
+
2060
2279
  const stack$1 = [];
2061
2280
  function pushWarningContext(vnode) {
2062
2281
  stack$1.push(vnode);
@@ -2184,12 +2403,6 @@ const ErrorCodes = {
2184
2403
  "0": "SETUP_FUNCTION",
2185
2404
  "RENDER_FUNCTION": 1,
2186
2405
  "1": "RENDER_FUNCTION",
2187
- "WATCH_GETTER": 2,
2188
- "2": "WATCH_GETTER",
2189
- "WATCH_CALLBACK": 3,
2190
- "3": "WATCH_CALLBACK",
2191
- "WATCH_CLEANUP": 4,
2192
- "4": "WATCH_CLEANUP",
2193
2406
  "NATIVE_EVENT_HANDLER": 5,
2194
2407
  "5": "NATIVE_EVENT_HANDLER",
2195
2408
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2341,7 +2554,7 @@ function nextTick(fn) {
2341
2554
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2342
2555
  }
2343
2556
  function findInsertionIndex(id) {
2344
- let start = flushIndex + 1;
2557
+ let start = isFlushing ? flushIndex + 1 : 0;
2345
2558
  let end = queue.length;
2346
2559
  while (start < end) {
2347
2560
  const middle = start + end >>> 1;
@@ -2357,15 +2570,13 @@ function findInsertionIndex(id) {
2357
2570
  }
2358
2571
  function queueJob(job) {
2359
2572
  if (!(job.flags & 1)) {
2360
- if (job.id == null) {
2361
- queue.push(job);
2362
- } else if (
2363
- // fast path when the job id is larger than the tail
2364
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2365
- ) {
2573
+ const jobId = getId(job);
2574
+ const lastJob = queue[queue.length - 1];
2575
+ if (!lastJob || // fast path when the job id is larger than the tail
2576
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2366
2577
  queue.push(job);
2367
2578
  } else {
2368
- queue.splice(findInsertionIndex(job.id), 0, job);
2579
+ queue.splice(findInsertionIndex(jobId), 0, job);
2369
2580
  }
2370
2581
  if (!(job.flags & 4)) {
2371
2582
  job.flags |= 1;
@@ -2379,12 +2590,6 @@ function queueFlush() {
2379
2590
  currentFlushPromise = resolvedPromise.then(flushJobs);
2380
2591
  }
2381
2592
  }
2382
- function invalidateJob(job) {
2383
- const i = queue.indexOf(job);
2384
- if (i > flushIndex) {
2385
- queue.splice(i, 1);
2386
- }
2387
- }
2388
2593
  function queuePostFlushCb(cb) {
2389
2594
  if (!isArray(cb)) {
2390
2595
  if (activePostFlushCbs && cb.id === -1) {
@@ -2446,24 +2651,13 @@ function flushPostFlushCbs(seen) {
2446
2651
  postFlushIndex = 0;
2447
2652
  }
2448
2653
  }
2449
- const getId = (job) => job.id == null ? Infinity : job.id;
2450
- const comparator = (a, b) => {
2451
- const diff = getId(a) - getId(b);
2452
- if (diff === 0) {
2453
- const isAPre = a.flags & 2;
2454
- const isBPre = b.flags & 2;
2455
- if (isAPre && !isBPre) return -1;
2456
- if (isBPre && !isAPre) return 1;
2457
- }
2458
- return diff;
2459
- };
2654
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2460
2655
  function flushJobs(seen) {
2461
2656
  isFlushPending = false;
2462
2657
  isFlushing = true;
2463
2658
  {
2464
2659
  seen = seen || /* @__PURE__ */ new Map();
2465
2660
  }
2466
- queue.sort(comparator);
2467
2661
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2468
2662
  try {
2469
2663
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3104,7 +3298,7 @@ function on(instance, event, fn) {
3104
3298
  function once(instance, event, fn) {
3105
3299
  const wrapped = (...args) => {
3106
3300
  off(instance, event, wrapped);
3107
- fn.call(instance.proxy, ...args);
3301
+ fn.apply(instance.proxy, args);
3108
3302
  };
3109
3303
  wrapped.fn = fn;
3110
3304
  on(instance, event, wrapped);
@@ -4023,7 +4217,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
4023
4217
  // @__NO_SIDE_EFFECTS__
4024
4218
  function defineComponent(options, extraOptions) {
4025
4219
  return isFunction(options) ? (
4026
- // #8326: extend call and options.name access are considered side-effects
4220
+ // #8236: extend call and options.name access are considered side-effects
4027
4221
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
4028
4222
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
4029
4223
  ) : options;
@@ -5150,6 +5344,7 @@ const KeepAliveImpl = {
5150
5344
  );
5151
5345
  const { include, exclude, max } = props;
5152
5346
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
5347
+ vnode.shapeFlag &= ~256;
5153
5348
  current = vnode;
5154
5349
  return rawVNode;
5155
5350
  }
@@ -6638,23 +6833,43 @@ function callHook$1(hook, instance, type) {
6638
6833
  );
6639
6834
  }
6640
6835
  function createWatcher(raw, ctx, publicThis, key) {
6641
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6836
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6837
+ const options = {};
6838
+ {
6839
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6840
+ const newValue = getter();
6841
+ if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
6842
+ options.deep = true;
6843
+ }
6844
+ const baseGetter = getter;
6845
+ getter = () => {
6846
+ const val = baseGetter();
6847
+ if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
6848
+ traverse(val);
6849
+ }
6850
+ return val;
6851
+ };
6852
+ }
6642
6853
  if (isString(raw)) {
6643
6854
  const handler = ctx[raw];
6644
6855
  if (isFunction(handler)) {
6645
- watch(getter, handler);
6856
+ {
6857
+ watch(getter, handler, options);
6858
+ }
6646
6859
  } else {
6647
6860
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6648
6861
  }
6649
6862
  } else if (isFunction(raw)) {
6650
- watch(getter, raw.bind(publicThis));
6863
+ {
6864
+ watch(getter, raw.bind(publicThis), options);
6865
+ }
6651
6866
  } else if (isObject(raw)) {
6652
6867
  if (isArray(raw)) {
6653
6868
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6654
6869
  } else {
6655
6870
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6656
6871
  if (isFunction(handler)) {
6657
- watch(getter, handler, raw);
6872
+ watch(getter, handler, extend(raw, options) );
6658
6873
  } else {
6659
6874
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6660
6875
  }
@@ -6878,7 +7093,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6878
7093
  return vm;
6879
7094
  }
6880
7095
  }
6881
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7096
+ Vue.version = `2.6.14-compat:${"3.5.0-rc.1"}`;
6882
7097
  Vue.config = singletonApp.config;
6883
7098
  Vue.use = (plugin, ...options) => {
6884
7099
  if (plugin && isFunction(plugin.install)) {
@@ -7210,7 +7425,7 @@ function defineReactive(obj, key, val) {
7210
7425
  if (isArray(val)) {
7211
7426
  methodsToPatch.forEach((m) => {
7212
7427
  val[m] = (...args) => {
7213
- Array.prototype[m].call(reactiveVal, ...args);
7428
+ Array.prototype[m].apply(reactiveVal, args);
7214
7429
  };
7215
7430
  });
7216
7431
  } else {
@@ -8405,7 +8620,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8405
8620
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8406
8621
  subTree = filterSingleRoot(subTree.children) || subTree;
8407
8622
  }
8408
- if (vnode === subTree) {
8623
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8409
8624
  const parentVNode = parentComponent.vnode;
8410
8625
  setScopeId(
8411
8626
  el,
@@ -8735,7 +8950,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8735
8950
  return;
8736
8951
  } else {
8737
8952
  instance.next = n2;
8738
- invalidateJob(instance.update);
8739
8953
  instance.update();
8740
8954
  }
8741
8955
  } else {
@@ -9659,7 +9873,6 @@ function watchSyncEffect(effect, options) {
9659
9873
  extend({}, options, { flush: "sync" })
9660
9874
  );
9661
9875
  }
9662
- const INITIAL_WATCHER_VALUE = {};
9663
9876
  function watch(source, cb, options) {
9664
9877
  if (!isFunction(cb)) {
9665
9878
  warn$1(
@@ -9668,21 +9881,8 @@ function watch(source, cb, options) {
9668
9881
  }
9669
9882
  return doWatch(source, cb, options);
9670
9883
  }
9671
- function doWatch(source, cb, {
9672
- immediate,
9673
- deep,
9674
- flush,
9675
- once,
9676
- onTrack,
9677
- onTrigger
9678
- } = EMPTY_OBJ) {
9679
- if (cb && once) {
9680
- const _cb = cb;
9681
- cb = (...args) => {
9682
- _cb(...args);
9683
- watchHandle();
9684
- };
9685
- }
9884
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9885
+ const { immediate, deep, flush, once } = options;
9686
9886
  if (!cb) {
9687
9887
  if (immediate !== void 0) {
9688
9888
  warn$1(
@@ -9700,173 +9900,53 @@ function doWatch(source, cb, {
9700
9900
  );
9701
9901
  }
9702
9902
  }
9703
- const warnInvalidSource = (s) => {
9704
- warn$1(
9705
- `Invalid watch source: `,
9706
- s,
9707
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9708
- );
9709
- };
9710
- const instance = currentInstance;
9711
- const reactiveGetter = (source2) => {
9712
- if (deep) return source2;
9713
- if (isShallow(source2) || deep === false || deep === 0)
9714
- return traverse(source2, 1);
9715
- return traverse(source2);
9716
- };
9717
- let getter;
9718
- let forceTrigger = false;
9719
- let isMultiSource = false;
9720
- if (isRef(source)) {
9721
- getter = () => source.value;
9722
- forceTrigger = isShallow(source);
9723
- } else if (isReactive(source)) {
9724
- getter = () => reactiveGetter(source);
9725
- forceTrigger = true;
9726
- } else if (isArray(source)) {
9727
- isMultiSource = true;
9728
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9729
- getter = () => source.map((s) => {
9730
- if (isRef(s)) {
9731
- return s.value;
9732
- } else if (isReactive(s)) {
9733
- return reactiveGetter(s);
9734
- } else if (isFunction(s)) {
9735
- return callWithErrorHandling(s, instance, 2);
9736
- } else {
9737
- warnInvalidSource(s);
9738
- }
9739
- });
9740
- } else if (isFunction(source)) {
9741
- if (cb) {
9742
- getter = () => callWithErrorHandling(source, instance, 2);
9743
- } else {
9744
- getter = () => {
9745
- if (cleanup) {
9746
- cleanup();
9747
- }
9748
- return callWithAsyncErrorHandling(
9749
- source,
9750
- instance,
9751
- 3,
9752
- [onCleanup]
9753
- );
9754
- };
9755
- }
9756
- } else {
9757
- getter = NOOP;
9758
- warnInvalidSource(source);
9759
- }
9760
- if (cb && !deep) {
9761
- const baseGetter = getter;
9762
- getter = () => {
9763
- const val = baseGetter();
9764
- if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
9765
- traverse(val);
9766
- }
9767
- return val;
9768
- };
9769
- }
9770
- if (cb && deep) {
9771
- const baseGetter = getter;
9772
- const depth = deep === true ? Infinity : deep;
9773
- getter = () => traverse(baseGetter(), depth);
9774
- }
9775
- let cleanup;
9776
- let onCleanup = (fn) => {
9777
- cleanup = effect.onStop = () => {
9778
- callWithErrorHandling(fn, instance, 4);
9779
- cleanup = effect.onStop = void 0;
9780
- };
9781
- };
9903
+ const baseWatchOptions = extend({}, options);
9904
+ baseWatchOptions.onWarn = warn$1;
9782
9905
  let ssrCleanup;
9783
9906
  if (isInSSRComponentSetup) {
9784
- onCleanup = NOOP;
9785
- if (!cb) {
9786
- getter();
9787
- } else if (immediate) {
9788
- callWithAsyncErrorHandling(cb, instance, 3, [
9789
- getter(),
9790
- isMultiSource ? [] : void 0,
9791
- onCleanup
9792
- ]);
9793
- }
9794
9907
  if (flush === "sync") {
9795
9908
  const ctx = useSSRContext();
9796
9909
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9910
+ } else if (!cb || immediate) {
9911
+ baseWatchOptions.once = true;
9797
9912
  } else {
9798
- const watchHandle2 = () => {
9913
+ return {
9914
+ stop: NOOP,
9915
+ resume: NOOP,
9916
+ pause: NOOP
9799
9917
  };
9800
- watchHandle2.stop = NOOP;
9801
- watchHandle2.resume = NOOP;
9802
- watchHandle2.pause = NOOP;
9803
- return watchHandle2;
9804
9918
  }
9805
9919
  }
9806
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9807
- const job = (immediateFirstRun) => {
9808
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9809
- return;
9810
- }
9811
- if (cb) {
9812
- const newValue = effect.run();
9813
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
9814
- if (cleanup) {
9815
- cleanup();
9816
- }
9817
- callWithAsyncErrorHandling(cb, instance, 3, [
9818
- newValue,
9819
- // pass undefined as the old value when it's changed for the first time
9820
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9821
- onCleanup
9822
- ]);
9823
- oldValue = newValue;
9920
+ const instance = currentInstance;
9921
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9922
+ let isPre = false;
9923
+ if (flush === "post") {
9924
+ baseWatchOptions.scheduler = (job) => {
9925
+ queuePostRenderEffect(job, instance && instance.suspense);
9926
+ };
9927
+ } else if (flush !== "sync") {
9928
+ isPre = true;
9929
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9930
+ if (isFirstRun) {
9931
+ job();
9932
+ } else {
9933
+ queueJob(job);
9824
9934
  }
9825
- } else {
9826
- effect.run();
9827
- }
9828
- };
9829
- if (cb) job.flags |= 4;
9830
- const effect = new ReactiveEffect(getter);
9831
- let scheduler;
9832
- if (flush === "sync") {
9833
- scheduler = job;
9834
- } else if (flush === "post") {
9835
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9836
- } else {
9837
- job.flags |= 2;
9838
- if (instance) job.id = instance.uid;
9839
- scheduler = () => queueJob(job);
9935
+ };
9840
9936
  }
9841
- effect.scheduler = scheduler;
9842
- const scope = getCurrentScope();
9843
- const watchHandle = () => {
9844
- effect.stop();
9845
- if (scope) {
9846
- remove(scope.effects, effect);
9937
+ baseWatchOptions.augmentJob = (job) => {
9938
+ if (cb) {
9939
+ job.flags |= 4;
9847
9940
  }
9848
- };
9849
- watchHandle.pause = effect.pause.bind(effect);
9850
- watchHandle.resume = effect.resume.bind(effect);
9851
- watchHandle.stop = watchHandle;
9852
- {
9853
- effect.onTrack = onTrack;
9854
- effect.onTrigger = onTrigger;
9855
- }
9856
- if (cb) {
9857
- if (immediate) {
9858
- job(true);
9859
- } else {
9860
- oldValue = effect.run();
9941
+ if (isPre) {
9942
+ job.flags |= 2;
9943
+ if (instance) {
9944
+ job.id = instance.uid;
9945
+ job.i = instance;
9946
+ }
9861
9947
  }
9862
- } else if (flush === "post") {
9863
- queuePostRenderEffect(
9864
- effect.run.bind(effect),
9865
- instance && instance.suspense
9866
- );
9867
- } else {
9868
- effect.run();
9869
- }
9948
+ };
9949
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9870
9950
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9871
9951
  return watchHandle;
9872
9952
  }
@@ -9895,38 +9975,6 @@ function createPathGetter(ctx, path) {
9895
9975
  return cur;
9896
9976
  };
9897
9977
  }
9898
- function traverse(value, depth = Infinity, seen) {
9899
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9900
- return value;
9901
- }
9902
- seen = seen || /* @__PURE__ */ new Set();
9903
- if (seen.has(value)) {
9904
- return value;
9905
- }
9906
- seen.add(value);
9907
- depth--;
9908
- if (isRef(value)) {
9909
- traverse(value.value, depth, seen);
9910
- } else if (isArray(value)) {
9911
- for (let i = 0; i < value.length; i++) {
9912
- traverse(value[i], depth, seen);
9913
- }
9914
- } else if (isSet(value) || isMap(value)) {
9915
- value.forEach((v) => {
9916
- traverse(v, depth, seen);
9917
- });
9918
- } else if (isPlainObject(value)) {
9919
- for (const key in value) {
9920
- traverse(value[key], depth, seen);
9921
- }
9922
- for (const key of Object.getOwnPropertySymbols(value)) {
9923
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9924
- traverse(value[key], depth, seen);
9925
- }
9926
- }
9927
- }
9928
- return value;
9929
- }
9930
9978
 
9931
9979
  function useModel(props, name, options = EMPTY_OBJ) {
9932
9980
  const i = getCurrentInstance();
@@ -12181,7 +12229,7 @@ function isMemoSame(cached, memo) {
12181
12229
  return true;
12182
12230
  }
12183
12231
 
12184
- const version = "3.5.0-beta.2";
12232
+ const version = "3.5.0-rc.1";
12185
12233
  const warn = warn$1 ;
12186
12234
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12187
12235
  const devtools = devtools$1 ;
@@ -12814,8 +12862,9 @@ function compatCoerceAttr(el, key, value, instance = null) {
12814
12862
 
12815
12863
  function patchDOMProp(el, key, value, parentComponent) {
12816
12864
  if (key === "innerHTML" || key === "textContent") {
12817
- if (value == null) return;
12818
- el[key] = value;
12865
+ if (value != null) {
12866
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
12867
+ }
12819
12868
  return;
12820
12869
  }
12821
12870
  const tag = el.tagName;
@@ -13258,6 +13307,9 @@ class VueElement extends BaseClass {
13258
13307
  delete this._props[key];
13259
13308
  } else {
13260
13309
  this._props[key] = val;
13310
+ if (key === "key" && this._app) {
13311
+ this._app._ceVNode.key = val;
13312
+ }
13261
13313
  }
13262
13314
  if (shouldUpdate && this._instance) {
13263
13315
  this._update();
@@ -14157,6 +14209,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14157
14209
  effectScope: effectScope,
14158
14210
  getCurrentInstance: getCurrentInstance,
14159
14211
  getCurrentScope: getCurrentScope,
14212
+ getCurrentWatcher: getCurrentWatcher,
14160
14213
  getTransitionRawChildren: getTransitionRawChildren,
14161
14214
  guardReactiveProps: guardReactiveProps,
14162
14215
  h: h,
@@ -14199,6 +14252,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14199
14252
  onServerPrefetch: onServerPrefetch,
14200
14253
  onUnmounted: onUnmounted,
14201
14254
  onUpdated: onUpdated,
14255
+ onWatcherCleanup: onWatcherCleanup,
14202
14256
  openBlock: openBlock,
14203
14257
  popScopeId: popScopeId,
14204
14258
  provide: provide,
@@ -15762,6 +15816,9 @@ const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || no
15762
15816
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
15763
15817
  function isReferenced(node, parent, grandparent) {
15764
15818
  switch (parent.type) {
15819
+ // yes: PARENT[NODE]
15820
+ // yes: NODE.child
15821
+ // no: parent.NODE
15765
15822
  case "MemberExpression":
15766
15823
  case "OptionalMemberExpression":
15767
15824
  if (parent.property === node) {
@@ -15770,12 +15827,23 @@ function isReferenced(node, parent, grandparent) {
15770
15827
  return parent.object === node;
15771
15828
  case "JSXMemberExpression":
15772
15829
  return parent.object === node;
15830
+ // no: let NODE = init;
15831
+ // yes: let id = NODE;
15773
15832
  case "VariableDeclarator":
15774
15833
  return parent.init === node;
15834
+ // yes: () => NODE
15835
+ // no: (NODE) => {}
15775
15836
  case "ArrowFunctionExpression":
15776
15837
  return parent.body === node;
15838
+ // no: class { #NODE; }
15839
+ // no: class { get #NODE() {} }
15840
+ // no: class { #NODE() {} }
15841
+ // no: class { fn() { return this.#NODE; } }
15777
15842
  case "PrivateName":
15778
15843
  return false;
15844
+ // no: class { NODE() {} }
15845
+ // yes: class { [NODE]() {} }
15846
+ // no: class { foo(NODE) {} }
15779
15847
  case "ClassMethod":
15780
15848
  case "ClassPrivateMethod":
15781
15849
  case "ObjectMethod":
@@ -15783,11 +15851,18 @@ function isReferenced(node, parent, grandparent) {
15783
15851
  return !!parent.computed;
15784
15852
  }
15785
15853
  return false;
15854
+ // yes: { [NODE]: "" }
15855
+ // no: { NODE: "" }
15856
+ // depends: { NODE }
15857
+ // depends: { key: NODE }
15786
15858
  case "ObjectProperty":
15787
15859
  if (parent.key === node) {
15788
15860
  return !!parent.computed;
15789
15861
  }
15790
15862
  return !grandparent;
15863
+ // no: class { NODE = value; }
15864
+ // yes: class { [NODE] = value; }
15865
+ // yes: class { key = NODE; }
15791
15866
  case "ClassProperty":
15792
15867
  if (parent.key === node) {
15793
15868
  return !!parent.computed;
@@ -15795,47 +15870,80 @@ function isReferenced(node, parent, grandparent) {
15795
15870
  return true;
15796
15871
  case "ClassPrivateProperty":
15797
15872
  return parent.key !== node;
15873
+ // no: class NODE {}
15874
+ // yes: class Foo extends NODE {}
15798
15875
  case "ClassDeclaration":
15799
15876
  case "ClassExpression":
15800
15877
  return parent.superClass === node;
15878
+ // yes: left = NODE;
15879
+ // no: NODE = right;
15801
15880
  case "AssignmentExpression":
15802
15881
  return parent.right === node;
15882
+ // no: [NODE = foo] = [];
15883
+ // yes: [foo = NODE] = [];
15803
15884
  case "AssignmentPattern":
15804
15885
  return parent.right === node;
15886
+ // no: NODE: for (;;) {}
15805
15887
  case "LabeledStatement":
15806
15888
  return false;
15889
+ // no: try {} catch (NODE) {}
15807
15890
  case "CatchClause":
15808
15891
  return false;
15892
+ // no: function foo(...NODE) {}
15809
15893
  case "RestElement":
15810
15894
  return false;
15811
15895
  case "BreakStatement":
15812
15896
  case "ContinueStatement":
15813
15897
  return false;
15898
+ // no: function NODE() {}
15899
+ // no: function foo(NODE) {}
15814
15900
  case "FunctionDeclaration":
15815
15901
  case "FunctionExpression":
15816
15902
  return false;
15903
+ // no: export NODE from "foo";
15904
+ // no: export * as NODE from "foo";
15817
15905
  case "ExportNamespaceSpecifier":
15818
15906
  case "ExportDefaultSpecifier":
15819
15907
  return false;
15908
+ // no: export { foo as NODE };
15909
+ // yes: export { NODE as foo };
15910
+ // no: export { NODE as foo } from "foo";
15820
15911
  case "ExportSpecifier":
15821
15912
  return parent.local === node;
15913
+ // no: import NODE from "foo";
15914
+ // no: import * as NODE from "foo";
15915
+ // no: import { NODE as foo } from "foo";
15916
+ // no: import { foo as NODE } from "foo";
15917
+ // no: import NODE from "bar";
15822
15918
  case "ImportDefaultSpecifier":
15823
15919
  case "ImportNamespaceSpecifier":
15824
15920
  case "ImportSpecifier":
15825
15921
  return false;
15922
+ // no: import "foo" assert { NODE: "json" }
15826
15923
  case "ImportAttribute":
15827
15924
  return false;
15925
+ // no: <div NODE="foo" />
15828
15926
  case "JSXAttribute":
15829
15927
  return false;
15928
+ // no: [NODE] = [];
15929
+ // no: ({ NODE }) = [];
15830
15930
  case "ObjectPattern":
15831
15931
  case "ArrayPattern":
15832
15932
  return false;
15933
+ // no: new.NODE
15934
+ // no: NODE.target
15833
15935
  case "MetaProperty":
15834
15936
  return false;
15937
+ // yes: type X = { someProperty: NODE }
15938
+ // no: type X = { NODE: OtherType }
15835
15939
  case "ObjectTypeProperty":
15836
15940
  return parent.key !== node;
15941
+ // yes: enum X { Foo = NODE }
15942
+ // no: enum X { NODE }
15837
15943
  case "TSEnumMember":
15838
15944
  return parent.id !== node;
15945
+ // yes: { [NODE]: value }
15946
+ // no: { NODE: value }
15839
15947
  case "TSPropertySignature":
15840
15948
  if (parent.key === node) {
15841
15949
  return !!parent.computed;
@@ -16428,7 +16536,9 @@ const tokenizer = new Tokenizer(stack, {
16428
16536
  case 17:
16429
16537
  case 18:
16430
16538
  case 19:
16539
+ // "
16431
16540
  case 20:
16541
+ // '
16432
16542
  case 21:
16433
16543
  emitError(9, end);
16434
16544
  break;
@@ -17454,6 +17564,7 @@ function traverseNode(node, context) {
17454
17564
  context.helper(TO_DISPLAY_STRING);
17455
17565
  }
17456
17566
  break;
17567
+ // for container types, further traverse downwards
17457
17568
  case 9:
17458
17569
  for (let i2 = 0; i2 < node.branches.length; i2++) {
17459
17570
  traverseNode(node.branches[i2], context);
@@ -17934,6 +18045,7 @@ function genNode(node, context) {
17934
18045
  case 21:
17935
18046
  genNodeList(node.body, context, true, false);
17936
18047
  break;
18048
+ // SSR only types
17937
18049
  case 22:
17938
18050
  genTemplateLiteral(node, context);
17939
18051
  break;
@@ -17949,6 +18061,7 @@ function genNode(node, context) {
17949
18061
  case 26:
17950
18062
  genReturnStatement(node, context);
17951
18063
  break;
18064
+ /* v8 ignore start */
17952
18065
  case 10:
17953
18066
  break;
17954
18067
  default:
@@ -20364,27 +20477,35 @@ function parseFilter(node, context) {
20364
20477
  case 34:
20365
20478
  inDouble = true;
20366
20479
  break;
20480
+ // "
20367
20481
  case 39:
20368
20482
  inSingle = true;
20369
20483
  break;
20484
+ // '
20370
20485
  case 96:
20371
20486
  inTemplateString = true;
20372
20487
  break;
20488
+ // `
20373
20489
  case 40:
20374
20490
  paren++;
20375
20491
  break;
20492
+ // (
20376
20493
  case 41:
20377
20494
  paren--;
20378
20495
  break;
20496
+ // )
20379
20497
  case 91:
20380
20498
  square++;
20381
20499
  break;
20500
+ // [
20382
20501
  case 93:
20383
20502
  square--;
20384
20503
  break;
20504
+ // ]
20385
20505
  case 123:
20386
20506
  curly++;
20387
20507
  break;
20508
+ // {
20388
20509
  case 125:
20389
20510
  curly--;
20390
20511
  break;