@vue/runtime-core 3.4.0 → 3.4.2

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.
@@ -1747,6 +1747,19 @@ function isVNodeSuspensible(vnode) {
1747
1747
  return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
1748
1748
  }
1749
1749
 
1750
+ const ssrContextKey = Symbol.for("v-scx");
1751
+ const useSSRContext = () => {
1752
+ {
1753
+ const ctx = inject(ssrContextKey);
1754
+ if (!ctx) {
1755
+ warn$1(
1756
+ `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
1757
+ );
1758
+ }
1759
+ return ctx;
1760
+ }
1761
+ };
1762
+
1750
1763
  function watchEffect(effect, options) {
1751
1764
  return doWatch(effect, null, options);
1752
1765
  }
@@ -1821,8 +1834,8 @@ function doWatch(source, cb, {
1821
1834
  getter = () => source.value;
1822
1835
  forceTrigger = reactivity.isShallow(source);
1823
1836
  } else if (reactivity.isReactive(source)) {
1824
- getter = () => source;
1825
- deep = true;
1837
+ getter = reactivity.isShallow(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
1838
+ forceTrigger = true;
1826
1839
  } else if (shared.isArray(source)) {
1827
1840
  isMultiSource = true;
1828
1841
  forceTrigger = source.some((s) => reactivity.isReactive(s) || reactivity.isShallow(s));
@@ -1830,7 +1843,7 @@ function doWatch(source, cb, {
1830
1843
  if (reactivity.isRef(s)) {
1831
1844
  return s.value;
1832
1845
  } else if (reactivity.isReactive(s)) {
1833
- return traverse(s);
1846
+ return traverse(s, reactivity.isShallow(s) || deep === false ? 1 : void 0);
1834
1847
  } else if (shared.isFunction(s)) {
1835
1848
  return callWithErrorHandling(s, instance, 2);
1836
1849
  } else {
@@ -1984,28 +1997,34 @@ function createPathGetter(ctx, path) {
1984
1997
  return cur;
1985
1998
  };
1986
1999
  }
1987
- function traverse(value, seen) {
2000
+ function traverse(value, depth, currentDepth = 0, seen) {
1988
2001
  if (!shared.isObject(value) || value["__v_skip"]) {
1989
2002
  return value;
1990
2003
  }
2004
+ if (depth && depth > 0) {
2005
+ if (currentDepth >= depth) {
2006
+ return value;
2007
+ }
2008
+ currentDepth++;
2009
+ }
1991
2010
  seen = seen || /* @__PURE__ */ new Set();
1992
2011
  if (seen.has(value)) {
1993
2012
  return value;
1994
2013
  }
1995
2014
  seen.add(value);
1996
2015
  if (reactivity.isRef(value)) {
1997
- traverse(value.value, seen);
2016
+ traverse(value.value, depth, currentDepth, seen);
1998
2017
  } else if (shared.isArray(value)) {
1999
2018
  for (let i = 0; i < value.length; i++) {
2000
- traverse(value[i], seen);
2019
+ traverse(value[i], depth, currentDepth, seen);
2001
2020
  }
2002
2021
  } else if (shared.isSet(value) || shared.isMap(value)) {
2003
2022
  value.forEach((v) => {
2004
- traverse(v, seen);
2023
+ traverse(v, depth, currentDepth, seen);
2005
2024
  });
2006
2025
  } else if (shared.isPlainObject(value)) {
2007
2026
  for (const key in value) {
2008
- traverse(value[key], seen);
2027
+ traverse(value[key], depth, currentDepth, seen);
2009
2028
  }
2010
2029
  }
2011
2030
  return value;
@@ -3273,6 +3292,7 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
3273
3292
  warn$1(`useModel() called with prop "${name}" which is not declared.`);
3274
3293
  return reactivity.ref();
3275
3294
  }
3295
+ const camelizedName = shared.camelize(name);
3276
3296
  const res = reactivity.customRef((track, trigger) => {
3277
3297
  let localValue;
3278
3298
  watchSyncEffect(() => {
@@ -3289,7 +3309,8 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
3289
3309
  },
3290
3310
  set(value) {
3291
3311
  const rawProps = i.vnode.props;
3292
- if (!(rawProps && name in rawProps) && shared.hasChanged(value, localValue)) {
3312
+ if (!(rawProps && // check if parent has passed v-model
3313
+ (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && shared.hasChanged(value, localValue)) {
3293
3314
  localValue = value;
3294
3315
  trigger();
3295
3316
  }
@@ -3303,7 +3324,7 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
3303
3324
  return {
3304
3325
  next() {
3305
3326
  if (i2 < 2) {
3306
- return { value: i2++ ? props[modifierKey] : res, done: false };
3327
+ return { value: i2++ ? props[modifierKey] || {} : res, done: false };
3307
3328
  } else {
3308
3329
  return { done: true };
3309
3330
  }
@@ -7759,19 +7780,6 @@ function h(type, propsOrChildren, children) {
7759
7780
  }
7760
7781
  }
7761
7782
 
7762
- const ssrContextKey = Symbol.for("v-scx");
7763
- const useSSRContext = () => {
7764
- {
7765
- const ctx = inject(ssrContextKey);
7766
- if (!ctx) {
7767
- warn$1(
7768
- `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
7769
- );
7770
- }
7771
- return ctx;
7772
- }
7773
- };
7774
-
7775
7783
  function isShallow(value) {
7776
7784
  return !!(value && value["__v_isShallow"]);
7777
7785
  }
@@ -7977,7 +7985,7 @@ function isMemoSame(cached, memo) {
7977
7985
  return true;
7978
7986
  }
7979
7987
 
7980
- const version = "3.4.0";
7988
+ const version = "3.4.2";
7981
7989
  const warn = warn$1 ;
7982
7990
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
7983
7991
  const devtools = devtools$1 ;
@@ -1215,6 +1215,14 @@ function isVNodeSuspensible(vnode) {
1215
1215
  return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
1216
1216
  }
1217
1217
 
1218
+ const ssrContextKey = Symbol.for("v-scx");
1219
+ const useSSRContext = () => {
1220
+ {
1221
+ const ctx = inject(ssrContextKey);
1222
+ return ctx;
1223
+ }
1224
+ };
1225
+
1218
1226
  function watchEffect(effect, options) {
1219
1227
  return doWatch(effect, null, options);
1220
1228
  }
@@ -1260,8 +1268,8 @@ function doWatch(source, cb, {
1260
1268
  getter = () => source.value;
1261
1269
  forceTrigger = reactivity.isShallow(source);
1262
1270
  } else if (reactivity.isReactive(source)) {
1263
- getter = () => source;
1264
- deep = true;
1271
+ getter = reactivity.isShallow(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
1272
+ forceTrigger = true;
1265
1273
  } else if (shared.isArray(source)) {
1266
1274
  isMultiSource = true;
1267
1275
  forceTrigger = source.some((s) => reactivity.isReactive(s) || reactivity.isShallow(s));
@@ -1269,7 +1277,7 @@ function doWatch(source, cb, {
1269
1277
  if (reactivity.isRef(s)) {
1270
1278
  return s.value;
1271
1279
  } else if (reactivity.isReactive(s)) {
1272
- return traverse(s);
1280
+ return traverse(s, reactivity.isShallow(s) || deep === false ? 1 : void 0);
1273
1281
  } else if (shared.isFunction(s)) {
1274
1282
  return callWithErrorHandling(s, instance, 2);
1275
1283
  } else ;
@@ -1416,28 +1424,34 @@ function createPathGetter(ctx, path) {
1416
1424
  return cur;
1417
1425
  };
1418
1426
  }
1419
- function traverse(value, seen) {
1427
+ function traverse(value, depth, currentDepth = 0, seen) {
1420
1428
  if (!shared.isObject(value) || value["__v_skip"]) {
1421
1429
  return value;
1422
1430
  }
1431
+ if (depth && depth > 0) {
1432
+ if (currentDepth >= depth) {
1433
+ return value;
1434
+ }
1435
+ currentDepth++;
1436
+ }
1423
1437
  seen = seen || /* @__PURE__ */ new Set();
1424
1438
  if (seen.has(value)) {
1425
1439
  return value;
1426
1440
  }
1427
1441
  seen.add(value);
1428
1442
  if (reactivity.isRef(value)) {
1429
- traverse(value.value, seen);
1443
+ traverse(value.value, depth, currentDepth, seen);
1430
1444
  } else if (shared.isArray(value)) {
1431
1445
  for (let i = 0; i < value.length; i++) {
1432
- traverse(value[i], seen);
1446
+ traverse(value[i], depth, currentDepth, seen);
1433
1447
  }
1434
1448
  } else if (shared.isSet(value) || shared.isMap(value)) {
1435
1449
  value.forEach((v) => {
1436
- traverse(v, seen);
1450
+ traverse(v, depth, currentDepth, seen);
1437
1451
  });
1438
1452
  } else if (shared.isPlainObject(value)) {
1439
1453
  for (const key in value) {
1440
- traverse(value[key], seen);
1454
+ traverse(value[key], depth, currentDepth, seen);
1441
1455
  }
1442
1456
  }
1443
1457
  return value;
@@ -2514,6 +2528,7 @@ function useAttrs() {
2514
2528
  }
2515
2529
  function useModel(props, name, options = shared.EMPTY_OBJ) {
2516
2530
  const i = getCurrentInstance();
2531
+ const camelizedName = shared.camelize(name);
2517
2532
  const res = reactivity.customRef((track, trigger) => {
2518
2533
  let localValue;
2519
2534
  watchSyncEffect(() => {
@@ -2530,7 +2545,8 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
2530
2545
  },
2531
2546
  set(value) {
2532
2547
  const rawProps = i.vnode.props;
2533
- if (!(rawProps && name in rawProps) && shared.hasChanged(value, localValue)) {
2548
+ if (!(rawProps && // check if parent has passed v-model
2549
+ (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && shared.hasChanged(value, localValue)) {
2534
2550
  localValue = value;
2535
2551
  trigger();
2536
2552
  }
@@ -2544,7 +2560,7 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
2544
2560
  return {
2545
2561
  next() {
2546
2562
  if (i2 < 2) {
2547
- return { value: i2++ ? props[modifierKey] : res, done: false };
2563
+ return { value: i2++ ? props[modifierKey] || {} : res, done: false };
2548
2564
  } else {
2549
2565
  return { done: true };
2550
2566
  }
@@ -6206,14 +6222,6 @@ function h(type, propsOrChildren, children) {
6206
6222
  }
6207
6223
  }
6208
6224
 
6209
- const ssrContextKey = Symbol.for("v-scx");
6210
- const useSSRContext = () => {
6211
- {
6212
- const ctx = inject(ssrContextKey);
6213
- return ctx;
6214
- }
6215
- };
6216
-
6217
6225
  function initCustomFormatter() {
6218
6226
  {
6219
6227
  return;
@@ -6245,7 +6253,7 @@ function isMemoSame(cached, memo) {
6245
6253
  return true;
6246
6254
  }
6247
6255
 
6248
- const version = "3.4.0";
6256
+ const version = "3.4.2";
6249
6257
  const warn$1 = shared.NOOP;
6250
6258
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
6251
6259
  const devtools = void 0;
@@ -1153,9 +1153,9 @@ export declare function watchEffect(effect: WatchEffect, options?: WatchOptionsB
1153
1153
  export declare function watchPostEffect(effect: WatchEffect, options?: DebuggerOptions): WatchStopHandle;
1154
1154
  export declare function watchSyncEffect(effect: WatchEffect, options?: DebuggerOptions): WatchStopHandle;
1155
1155
  type MultiWatchSources = (WatchSource<unknown> | object)[];
1156
+ export declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle;
1156
1157
  export declare function watch<T extends MultiWatchSources, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle;
1157
1158
  export declare function watch<T extends Readonly<MultiWatchSources>, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle;
1158
- export declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle;
1159
1159
  export declare function watch<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle;
1160
1160
 
1161
1161
  type AsyncComponentResolveResult<T = Component> = T | {
@@ -1,6 +1,6 @@
1
1
  import { pauseTracking, resetTracking, isRef, toRaw, getCurrentScope, isShallow as isShallow$1, isReactive, ReactiveEffect, ref, shallowReadonly, track, customRef, reactive, shallowReactive, trigger, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, isReadonly } from '@vue/reactivity';
2
2
  export { EffectScope, ReactiveEffect, TrackOpTypes, TriggerOpTypes, customRef, effect, effectScope, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
3
- import { isString, isFunction, isPromise, isArray, NOOP, getGlobalThis, extend, EMPTY_OBJ, toHandlerKey, looseToNumber, hyphenate, camelize, isObject, isOn, hasOwn, isModelListener, capitalize, toNumber, hasChanged, remove, isSet, isMap, isPlainObject, isBuiltInDirective, invokeArrayFns, isRegExp, isGloballyAllowed, NO, def, isReservedProp, EMPTY_ARR, toRawType, makeMap, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr } from '@vue/shared';
3
+ import { isString, isFunction, isPromise, isArray, NOOP, getGlobalThis, extend, EMPTY_OBJ, toHandlerKey, looseToNumber, hyphenate, camelize, isObject, isOn, hasOwn, isModelListener, capitalize, toNumber, isSet, isMap, isPlainObject, hasChanged, remove, isBuiltInDirective, invokeArrayFns, isRegExp, isGloballyAllowed, NO, def, isReservedProp, EMPTY_ARR, toRawType, makeMap, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr } from '@vue/shared';
4
4
  export { camelize, capitalize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
5
5
 
6
6
  const stack = [];
@@ -1749,6 +1749,19 @@ function isVNodeSuspensible(vnode) {
1749
1749
  return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
1750
1750
  }
1751
1751
 
1752
+ const ssrContextKey = Symbol.for("v-scx");
1753
+ const useSSRContext = () => {
1754
+ {
1755
+ const ctx = inject(ssrContextKey);
1756
+ if (!ctx) {
1757
+ !!(process.env.NODE_ENV !== "production") && warn$1(
1758
+ `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
1759
+ );
1760
+ }
1761
+ return ctx;
1762
+ }
1763
+ };
1764
+
1752
1765
  function watchEffect(effect, options) {
1753
1766
  return doWatch(effect, null, options);
1754
1767
  }
@@ -1823,8 +1836,8 @@ function doWatch(source, cb, {
1823
1836
  getter = () => source.value;
1824
1837
  forceTrigger = isShallow$1(source);
1825
1838
  } else if (isReactive(source)) {
1826
- getter = () => source;
1827
- deep = true;
1839
+ getter = isShallow$1(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
1840
+ forceTrigger = true;
1828
1841
  } else if (isArray(source)) {
1829
1842
  isMultiSource = true;
1830
1843
  forceTrigger = source.some((s) => isReactive(s) || isShallow$1(s));
@@ -1832,7 +1845,7 @@ function doWatch(source, cb, {
1832
1845
  if (isRef(s)) {
1833
1846
  return s.value;
1834
1847
  } else if (isReactive(s)) {
1835
- return traverse(s);
1848
+ return traverse(s, isShallow$1(s) || deep === false ? 1 : void 0);
1836
1849
  } else if (isFunction(s)) {
1837
1850
  return callWithErrorHandling(s, instance, 2);
1838
1851
  } else {
@@ -1986,28 +1999,34 @@ function createPathGetter(ctx, path) {
1986
1999
  return cur;
1987
2000
  };
1988
2001
  }
1989
- function traverse(value, seen) {
2002
+ function traverse(value, depth, currentDepth = 0, seen) {
1990
2003
  if (!isObject(value) || value["__v_skip"]) {
1991
2004
  return value;
1992
2005
  }
2006
+ if (depth && depth > 0) {
2007
+ if (currentDepth >= depth) {
2008
+ return value;
2009
+ }
2010
+ currentDepth++;
2011
+ }
1993
2012
  seen = seen || /* @__PURE__ */ new Set();
1994
2013
  if (seen.has(value)) {
1995
2014
  return value;
1996
2015
  }
1997
2016
  seen.add(value);
1998
2017
  if (isRef(value)) {
1999
- traverse(value.value, seen);
2018
+ traverse(value.value, depth, currentDepth, seen);
2000
2019
  } else if (isArray(value)) {
2001
2020
  for (let i = 0; i < value.length; i++) {
2002
- traverse(value[i], seen);
2021
+ traverse(value[i], depth, currentDepth, seen);
2003
2022
  }
2004
2023
  } else if (isSet(value) || isMap(value)) {
2005
2024
  value.forEach((v) => {
2006
- traverse(v, seen);
2025
+ traverse(v, depth, currentDepth, seen);
2007
2026
  });
2008
2027
  } else if (isPlainObject(value)) {
2009
2028
  for (const key in value) {
2010
- traverse(value[key], seen);
2029
+ traverse(value[key], depth, currentDepth, seen);
2011
2030
  }
2012
2031
  }
2013
2032
  return value;
@@ -3277,6 +3296,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
3277
3296
  warn$1(`useModel() called with prop "${name}" which is not declared.`);
3278
3297
  return ref();
3279
3298
  }
3299
+ const camelizedName = camelize(name);
3280
3300
  const res = customRef((track, trigger) => {
3281
3301
  let localValue;
3282
3302
  watchSyncEffect(() => {
@@ -3293,7 +3313,8 @@ function useModel(props, name, options = EMPTY_OBJ) {
3293
3313
  },
3294
3314
  set(value) {
3295
3315
  const rawProps = i.vnode.props;
3296
- if (!(rawProps && name in rawProps) && hasChanged(value, localValue)) {
3316
+ if (!(rawProps && // check if parent has passed v-model
3317
+ (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && hasChanged(value, localValue)) {
3297
3318
  localValue = value;
3298
3319
  trigger();
3299
3320
  }
@@ -3307,7 +3328,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
3307
3328
  return {
3308
3329
  next() {
3309
3330
  if (i2 < 2) {
3310
- return { value: i2++ ? props[modifierKey] : res, done: false };
3331
+ return { value: i2++ ? props[modifierKey] || {} : res, done: false };
3311
3332
  } else {
3312
3333
  return { done: true };
3313
3334
  }
@@ -7831,19 +7852,6 @@ function h(type, propsOrChildren, children) {
7831
7852
  }
7832
7853
  }
7833
7854
 
7834
- const ssrContextKey = Symbol.for("v-scx");
7835
- const useSSRContext = () => {
7836
- {
7837
- const ctx = inject(ssrContextKey);
7838
- if (!ctx) {
7839
- !!(process.env.NODE_ENV !== "production") && warn$1(
7840
- `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
7841
- );
7842
- }
7843
- return ctx;
7844
- }
7845
- };
7846
-
7847
7855
  function isShallow(value) {
7848
7856
  return !!(value && value["__v_isShallow"]);
7849
7857
  }
@@ -8049,7 +8057,7 @@ function isMemoSame(cached, memo) {
8049
8057
  return true;
8050
8058
  }
8051
8059
 
8052
- const version = "3.4.0";
8060
+ const version = "3.4.2";
8053
8061
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
8054
8062
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8055
8063
  const devtools = !!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__ ? devtools$1 : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "@vue/runtime-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.4.0",
36
- "@vue/reactivity": "3.4.0"
35
+ "@vue/shared": "3.4.2",
36
+ "@vue/reactivity": "3.4.2"
37
37
  }
38
38
  }