vue 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.
@@ -3293,6 +3293,19 @@ function isVNodeSuspensible(vnode) {
3293
3293
  return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
3294
3294
  }
3295
3295
 
3296
+ const ssrContextKey = Symbol.for("v-scx");
3297
+ const useSSRContext = () => {
3298
+ {
3299
+ const ctx = inject(ssrContextKey);
3300
+ if (!ctx) {
3301
+ warn$1(
3302
+ `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
3303
+ );
3304
+ }
3305
+ return ctx;
3306
+ }
3307
+ };
3308
+
3296
3309
  function watchEffect(effect, options) {
3297
3310
  return doWatch(effect, null, options);
3298
3311
  }
@@ -3367,8 +3380,8 @@ function doWatch(source, cb, {
3367
3380
  getter = () => source.value;
3368
3381
  forceTrigger = isShallow(source);
3369
3382
  } else if (isReactive(source)) {
3370
- getter = () => source;
3371
- deep = true;
3383
+ getter = isShallow(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
3384
+ forceTrigger = true;
3372
3385
  } else if (isArray(source)) {
3373
3386
  isMultiSource = true;
3374
3387
  forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
@@ -3376,7 +3389,7 @@ function doWatch(source, cb, {
3376
3389
  if (isRef(s)) {
3377
3390
  return s.value;
3378
3391
  } else if (isReactive(s)) {
3379
- return traverse(s);
3392
+ return traverse(s, isShallow(s) || deep === false ? 1 : void 0);
3380
3393
  } else if (isFunction(s)) {
3381
3394
  return callWithErrorHandling(s, instance, 2);
3382
3395
  } else {
@@ -3509,28 +3522,34 @@ function createPathGetter(ctx, path) {
3509
3522
  return cur;
3510
3523
  };
3511
3524
  }
3512
- function traverse(value, seen) {
3525
+ function traverse(value, depth, currentDepth = 0, seen) {
3513
3526
  if (!isObject(value) || value["__v_skip"]) {
3514
3527
  return value;
3515
3528
  }
3529
+ if (depth && depth > 0) {
3530
+ if (currentDepth >= depth) {
3531
+ return value;
3532
+ }
3533
+ currentDepth++;
3534
+ }
3516
3535
  seen = seen || /* @__PURE__ */ new Set();
3517
3536
  if (seen.has(value)) {
3518
3537
  return value;
3519
3538
  }
3520
3539
  seen.add(value);
3521
3540
  if (isRef(value)) {
3522
- traverse(value.value, seen);
3541
+ traverse(value.value, depth, currentDepth, seen);
3523
3542
  } else if (isArray(value)) {
3524
3543
  for (let i = 0; i < value.length; i++) {
3525
- traverse(value[i], seen);
3544
+ traverse(value[i], depth, currentDepth, seen);
3526
3545
  }
3527
3546
  } else if (isSet(value) || isMap(value)) {
3528
3547
  value.forEach((v) => {
3529
- traverse(v, seen);
3548
+ traverse(v, depth, currentDepth, seen);
3530
3549
  });
3531
3550
  } else if (isPlainObject(value)) {
3532
3551
  for (const key in value) {
3533
- traverse(value[key], seen);
3552
+ traverse(value[key], depth, currentDepth, seen);
3534
3553
  }
3535
3554
  }
3536
3555
  return value;
@@ -4792,6 +4811,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
4792
4811
  warn$1(`useModel() called with prop "${name}" which is not declared.`);
4793
4812
  return ref();
4794
4813
  }
4814
+ const camelizedName = camelize(name);
4795
4815
  const res = customRef((track, trigger) => {
4796
4816
  let localValue;
4797
4817
  watchSyncEffect(() => {
@@ -4808,7 +4828,8 @@ function useModel(props, name, options = EMPTY_OBJ) {
4808
4828
  },
4809
4829
  set(value) {
4810
4830
  const rawProps = i.vnode.props;
4811
- if (!(rawProps && name in rawProps) && hasChanged(value, localValue)) {
4831
+ if (!(rawProps && // check if parent has passed v-model
4832
+ (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && hasChanged(value, localValue)) {
4812
4833
  localValue = value;
4813
4834
  trigger();
4814
4835
  }
@@ -4822,7 +4843,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
4822
4843
  return {
4823
4844
  next() {
4824
4845
  if (i2 < 2) {
4825
- return { value: i2++ ? props[modifierKey] : res, done: false };
4846
+ return { value: i2++ ? props[modifierKey] || {} : res, done: false };
4826
4847
  } else {
4827
4848
  return { done: true };
4828
4849
  }
@@ -9261,19 +9282,6 @@ function h(type, propsOrChildren, children) {
9261
9282
  }
9262
9283
  }
9263
9284
 
9264
- const ssrContextKey = Symbol.for("v-scx");
9265
- const useSSRContext = () => {
9266
- {
9267
- const ctx = inject(ssrContextKey);
9268
- if (!ctx) {
9269
- warn$1(
9270
- `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
9271
- );
9272
- }
9273
- return ctx;
9274
- }
9275
- };
9276
-
9277
9285
  function initCustomFormatter() {
9278
9286
  if (typeof window === "undefined") {
9279
9287
  return;
@@ -9475,7 +9483,7 @@ function isMemoSame(cached, memo) {
9475
9483
  return true;
9476
9484
  }
9477
9485
 
9478
- const version = "3.4.0";
9486
+ const version = "3.4.2";
9479
9487
  const warn = warn$1 ;
9480
9488
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9481
9489
  const devtools = devtools$1 ;