@vue/compat 3.4.3 → 3.4.5

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
@@ -3573,7 +3573,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3573
3573
  hiddenContainer,
3574
3574
  anchor,
3575
3575
  deps: 0,
3576
- pendingId: 0,
3576
+ pendingId: suspenseId++,
3577
3577
  timeout: typeof timeout === "number" ? timeout : -1,
3578
3578
  activeBranch: null,
3579
3579
  pendingBranch: null,
@@ -3950,7 +3950,6 @@ function doWatch(source, cb, {
3950
3950
  onTrack,
3951
3951
  onTrigger
3952
3952
  } = EMPTY_OBJ) {
3953
- var _a;
3954
3953
  if (cb && once) {
3955
3954
  const _cb = cb;
3956
3955
  cb = (...args) => {
@@ -3958,6 +3957,11 @@ function doWatch(source, cb, {
3958
3957
  unwatch();
3959
3958
  };
3960
3959
  }
3960
+ if (deep !== void 0 && typeof deep === "number") {
3961
+ warn$1(
3962
+ `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
3963
+ );
3964
+ }
3961
3965
  if (!cb) {
3962
3966
  if (immediate !== void 0) {
3963
3967
  warn$1(
@@ -3982,7 +3986,11 @@ function doWatch(source, cb, {
3982
3986
  `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
3983
3987
  );
3984
3988
  };
3985
- const instance = getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
3989
+ const instance = currentInstance;
3990
+ const reactiveGetter = (source2) => deep === true ? source2 : (
3991
+ // for deep: false, only traverse root-level properties
3992
+ traverse(source2, deep === false ? 1 : void 0)
3993
+ );
3986
3994
  let getter;
3987
3995
  let forceTrigger = false;
3988
3996
  let isMultiSource = false;
@@ -3990,7 +3998,7 @@ function doWatch(source, cb, {
3990
3998
  getter = () => source.value;
3991
3999
  forceTrigger = isShallow(source);
3992
4000
  } else if (isReactive(source)) {
3993
- getter = isShallow(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
4001
+ getter = () => reactiveGetter(source);
3994
4002
  forceTrigger = true;
3995
4003
  } else if (isArray(source)) {
3996
4004
  isMultiSource = true;
@@ -3999,7 +4007,7 @@ function doWatch(source, cb, {
3999
4007
  if (isRef(s)) {
4000
4008
  return s.value;
4001
4009
  } else if (isReactive(s)) {
4002
- return traverse(s, isShallow(s) || deep === false ? 1 : void 0);
4010
+ return reactiveGetter(s);
4003
4011
  } else if (isFunction(s)) {
4004
4012
  return callWithErrorHandling(s, instance, 2);
4005
4013
  } else {
@@ -4011,9 +4019,6 @@ function doWatch(source, cb, {
4011
4019
  getter = () => callWithErrorHandling(source, instance, 2);
4012
4020
  } else {
4013
4021
  getter = () => {
4014
- if (instance && instance.isUnmounted) {
4015
- return;
4016
- }
4017
4022
  if (cleanup) {
4018
4023
  cleanup();
4019
4024
  }
@@ -4105,10 +4110,11 @@ function doWatch(source, cb, {
4105
4110
  scheduler = () => queueJob(job);
4106
4111
  }
4107
4112
  const effect = new ReactiveEffect(getter, NOOP, scheduler);
4113
+ const scope = getCurrentScope();
4108
4114
  const unwatch = () => {
4109
4115
  effect.stop();
4110
- if (instance && instance.scope) {
4111
- remove(instance.scope.effects, effect);
4116
+ if (scope) {
4117
+ remove(scope.effects, effect);
4112
4118
  }
4113
4119
  };
4114
4120
  {
@@ -5984,6 +5990,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
5984
5990
  return ref();
5985
5991
  }
5986
5992
  const camelizedName = camelize(name);
5993
+ const hyphenatedName = hyphenate(name);
5987
5994
  const res = customRef((track, trigger) => {
5988
5995
  let localValue;
5989
5996
  watchSyncEffect(() => {
@@ -6001,7 +6008,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
6001
6008
  set(value) {
6002
6009
  const rawProps = i.vnode.props;
6003
6010
  if (!(rawProps && // check if parent has passed v-model
6004
- (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && hasChanged(value, localValue)) {
6011
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
6005
6012
  localValue = value;
6006
6013
  trigger();
6007
6014
  }
@@ -6595,7 +6602,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6595
6602
  return vm;
6596
6603
  }
6597
6604
  }
6598
- Vue.version = `2.6.14-compat:${"3.4.3"}`;
6605
+ Vue.version = `2.6.14-compat:${"3.4.5"}`;
6599
6606
  Vue.config = singletonApp.config;
6600
6607
  Vue.use = (p, ...options) => {
6601
6608
  if (p && isFunction(p.install)) {
@@ -11315,7 +11322,7 @@ function isMemoSame(cached, memo) {
11315
11322
  return true;
11316
11323
  }
11317
11324
 
11318
- const version = "3.4.3";
11325
+ const version = "3.4.5";
11319
11326
  const warn = warn$1 ;
11320
11327
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11321
11328
  const devtools = devtools$1 ;
@@ -14482,6 +14489,18 @@ function isInDestructureAssignment(parent, parentStack) {
14482
14489
  }
14483
14490
  return false;
14484
14491
  }
14492
+ function isInNewExpression(parentStack) {
14493
+ let i = parentStack.length;
14494
+ while (i--) {
14495
+ const p = parentStack[i];
14496
+ if (p.type === "NewExpression") {
14497
+ return true;
14498
+ } else if (p.type !== "MemberExpression") {
14499
+ break;
14500
+ }
14501
+ }
14502
+ return false;
14503
+ }
14485
14504
  function walkFunctionParams(node, onIdent) {
14486
14505
  for (const p of node.params) {
14487
14506
  for (const id of extractIdentifiers(p)) {
@@ -17067,12 +17086,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17067
17086
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
17068
17087
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
17069
17088
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
17089
+ const isNewExpression = parent && isInNewExpression(parentStack);
17090
+ const wrapWithUnref = (raw2) => {
17091
+ const wrapped = `${context.helperString(UNREF)}(${raw2})`;
17092
+ return isNewExpression ? `(${wrapped})` : wrapped;
17093
+ };
17070
17094
  if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
17071
17095
  return raw;
17072
17096
  } else if (type === "setup-ref") {
17073
17097
  return `${raw}.value`;
17074
17098
  } else if (type === "setup-maybe-ref") {
17075
- return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : `${context.helperString(UNREF)}(${raw})`;
17099
+ return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
17076
17100
  } else if (type === "setup-let") {
17077
17101
  if (isAssignmentLVal) {
17078
17102
  const { right: rVal, operator } = parent;
@@ -17099,7 +17123,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17099
17123
  } else if (isDestructureAssignment) {
17100
17124
  return raw;
17101
17125
  } else {
17102
- return `${context.helperString(UNREF)}(${raw})`;
17126
+ return wrapWithUnref(raw);
17103
17127
  }
17104
17128
  } else if (type === "props") {
17105
17129
  return genPropsAccessExp(raw);
@@ -2626,7 +2626,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2626
2626
  hiddenContainer,
2627
2627
  anchor,
2628
2628
  deps: 0,
2629
- pendingId: 0,
2629
+ pendingId: suspenseId++,
2630
2630
  timeout: typeof timeout === "number" ? timeout : -1,
2631
2631
  activeBranch: null,
2632
2632
  pendingBranch: null,
@@ -2972,7 +2972,6 @@ function doWatch(source, cb, {
2972
2972
  onTrack,
2973
2973
  onTrigger
2974
2974
  } = EMPTY_OBJ) {
2975
- var _a;
2976
2975
  if (cb && once) {
2977
2976
  const _cb = cb;
2978
2977
  cb = (...args) => {
@@ -2980,7 +2979,11 @@ function doWatch(source, cb, {
2980
2979
  unwatch();
2981
2980
  };
2982
2981
  }
2983
- const instance = getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
2982
+ const instance = currentInstance;
2983
+ const reactiveGetter = (source2) => deep === true ? source2 : (
2984
+ // for deep: false, only traverse root-level properties
2985
+ traverse(source2, deep === false ? 1 : void 0)
2986
+ );
2984
2987
  let getter;
2985
2988
  let forceTrigger = false;
2986
2989
  let isMultiSource = false;
@@ -2988,7 +2991,7 @@ function doWatch(source, cb, {
2988
2991
  getter = () => source.value;
2989
2992
  forceTrigger = isShallow(source);
2990
2993
  } else if (isReactive(source)) {
2991
- getter = isShallow(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
2994
+ getter = () => reactiveGetter(source);
2992
2995
  forceTrigger = true;
2993
2996
  } else if (isArray(source)) {
2994
2997
  isMultiSource = true;
@@ -2997,7 +3000,7 @@ function doWatch(source, cb, {
2997
3000
  if (isRef(s)) {
2998
3001
  return s.value;
2999
3002
  } else if (isReactive(s)) {
3000
- return traverse(s, isShallow(s) || deep === false ? 1 : void 0);
3003
+ return reactiveGetter(s);
3001
3004
  } else if (isFunction(s)) {
3002
3005
  return callWithErrorHandling(s, instance, 2);
3003
3006
  } else ;
@@ -3007,9 +3010,6 @@ function doWatch(source, cb, {
3007
3010
  getter = () => callWithErrorHandling(source, instance, 2);
3008
3011
  } else {
3009
3012
  getter = () => {
3010
- if (instance && instance.isUnmounted) {
3011
- return;
3012
- }
3013
3013
  if (cleanup) {
3014
3014
  cleanup();
3015
3015
  }
@@ -3100,10 +3100,11 @@ function doWatch(source, cb, {
3100
3100
  scheduler = () => queueJob(job);
3101
3101
  }
3102
3102
  const effect = new ReactiveEffect(getter, NOOP, scheduler);
3103
+ const scope = getCurrentScope();
3103
3104
  const unwatch = () => {
3104
3105
  effect.stop();
3105
- if (instance && instance.scope) {
3106
- remove(instance.scope.effects, effect);
3106
+ if (scope) {
3107
+ remove(scope.effects, effect);
3107
3108
  }
3108
3109
  };
3109
3110
  if (cb) {
@@ -4783,6 +4784,7 @@ function useAttrs() {
4783
4784
  function useModel(props, name, options = EMPTY_OBJ) {
4784
4785
  const i = getCurrentInstance();
4785
4786
  const camelizedName = camelize(name);
4787
+ const hyphenatedName = hyphenate(name);
4786
4788
  const res = customRef((track, trigger) => {
4787
4789
  let localValue;
4788
4790
  watchSyncEffect(() => {
@@ -4800,7 +4802,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
4800
4802
  set(value) {
4801
4803
  const rawProps = i.vnode.props;
4802
4804
  if (!(rawProps && // check if parent has passed v-model
4803
- (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && hasChanged(value, localValue)) {
4805
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
4804
4806
  localValue = value;
4805
4807
  trigger();
4806
4808
  }
@@ -5281,7 +5283,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5281
5283
  return vm;
5282
5284
  }
5283
5285
  }
5284
- Vue.version = `2.6.14-compat:${"3.4.3"}`;
5286
+ Vue.version = `2.6.14-compat:${"3.4.5"}`;
5285
5287
  Vue.config = singletonApp.config;
5286
5288
  Vue.use = (p, ...options) => {
5287
5289
  if (p && isFunction(p.install)) {
@@ -9081,7 +9083,7 @@ function isMemoSame(cached, memo) {
9081
9083
  return true;
9082
9084
  }
9083
9085
 
9084
- const version = "3.4.3";
9086
+ const version = "3.4.5";
9085
9087
  const warn$1 = NOOP;
9086
9088
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9087
9089
  const devtools = void 0;
@@ -12077,6 +12079,18 @@ function isInDestructureAssignment(parent, parentStack) {
12077
12079
  }
12078
12080
  return false;
12079
12081
  }
12082
+ function isInNewExpression(parentStack) {
12083
+ let i = parentStack.length;
12084
+ while (i--) {
12085
+ const p = parentStack[i];
12086
+ if (p.type === "NewExpression") {
12087
+ return true;
12088
+ } else if (p.type !== "MemberExpression") {
12089
+ break;
12090
+ }
12091
+ }
12092
+ return false;
12093
+ }
12080
12094
  function walkFunctionParams(node, onIdent) {
12081
12095
  for (const p of node.params) {
12082
12096
  for (const id of extractIdentifiers(p)) {
@@ -14589,12 +14603,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
14589
14603
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
14590
14604
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
14591
14605
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
14606
+ const isNewExpression = parent && isInNewExpression(parentStack);
14607
+ const wrapWithUnref = (raw2) => {
14608
+ const wrapped = `${context.helperString(UNREF)}(${raw2})`;
14609
+ return isNewExpression ? `(${wrapped})` : wrapped;
14610
+ };
14592
14611
  if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
14593
14612
  return raw;
14594
14613
  } else if (type === "setup-ref") {
14595
14614
  return `${raw}.value`;
14596
14615
  } else if (type === "setup-maybe-ref") {
14597
- return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : `${context.helperString(UNREF)}(${raw})`;
14616
+ return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
14598
14617
  } else if (type === "setup-let") {
14599
14618
  if (isAssignmentLVal) {
14600
14619
  const { right: rVal, operator } = parent;
@@ -14621,7 +14640,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
14621
14640
  } else if (isDestructureAssignment) {
14622
14641
  return raw;
14623
14642
  } else {
14624
- return `${context.helperString(UNREF)}(${raw})`;
14643
+ return wrapWithUnref(raw);
14625
14644
  }
14626
14645
  } else if (type === "props") {
14627
14646
  return genPropsAccessExp(raw);
@@ -3522,7 +3522,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3522
3522
  hiddenContainer,
3523
3523
  anchor,
3524
3524
  deps: 0,
3525
- pendingId: 0,
3525
+ pendingId: suspenseId++,
3526
3526
  timeout: typeof timeout === "number" ? timeout : -1,
3527
3527
  activeBranch: null,
3528
3528
  pendingBranch: null,
@@ -3899,7 +3899,6 @@ function doWatch(source, cb, {
3899
3899
  onTrack,
3900
3900
  onTrigger
3901
3901
  } = EMPTY_OBJ) {
3902
- var _a;
3903
3902
  if (cb && once) {
3904
3903
  const _cb = cb;
3905
3904
  cb = (...args) => {
@@ -3907,6 +3906,11 @@ function doWatch(source, cb, {
3907
3906
  unwatch();
3908
3907
  };
3909
3908
  }
3909
+ if (deep !== void 0 && typeof deep === "number") {
3910
+ warn$1(
3911
+ `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
3912
+ );
3913
+ }
3910
3914
  if (!cb) {
3911
3915
  if (immediate !== void 0) {
3912
3916
  warn$1(
@@ -3931,7 +3935,11 @@ function doWatch(source, cb, {
3931
3935
  `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
3932
3936
  );
3933
3937
  };
3934
- const instance = getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
3938
+ const instance = currentInstance;
3939
+ const reactiveGetter = (source2) => deep === true ? source2 : (
3940
+ // for deep: false, only traverse root-level properties
3941
+ traverse(source2, deep === false ? 1 : void 0)
3942
+ );
3935
3943
  let getter;
3936
3944
  let forceTrigger = false;
3937
3945
  let isMultiSource = false;
@@ -3939,7 +3947,7 @@ function doWatch(source, cb, {
3939
3947
  getter = () => source.value;
3940
3948
  forceTrigger = isShallow(source);
3941
3949
  } else if (isReactive(source)) {
3942
- getter = isShallow(source) || deep === false ? () => traverse(source, 1) : () => traverse(source);
3950
+ getter = () => reactiveGetter(source);
3943
3951
  forceTrigger = true;
3944
3952
  } else if (isArray(source)) {
3945
3953
  isMultiSource = true;
@@ -3948,7 +3956,7 @@ function doWatch(source, cb, {
3948
3956
  if (isRef(s)) {
3949
3957
  return s.value;
3950
3958
  } else if (isReactive(s)) {
3951
- return traverse(s, isShallow(s) || deep === false ? 1 : void 0);
3959
+ return reactiveGetter(s);
3952
3960
  } else if (isFunction(s)) {
3953
3961
  return callWithErrorHandling(s, instance, 2);
3954
3962
  } else {
@@ -3960,9 +3968,6 @@ function doWatch(source, cb, {
3960
3968
  getter = () => callWithErrorHandling(source, instance, 2);
3961
3969
  } else {
3962
3970
  getter = () => {
3963
- if (instance && instance.isUnmounted) {
3964
- return;
3965
- }
3966
3971
  if (cleanup) {
3967
3972
  cleanup();
3968
3973
  }
@@ -4035,10 +4040,11 @@ function doWatch(source, cb, {
4035
4040
  scheduler = () => queueJob(job);
4036
4041
  }
4037
4042
  const effect = new ReactiveEffect(getter, NOOP, scheduler);
4043
+ const scope = getCurrentScope();
4038
4044
  const unwatch = () => {
4039
4045
  effect.stop();
4040
- if (instance && instance.scope) {
4041
- remove(instance.scope.effects, effect);
4046
+ if (scope) {
4047
+ remove(scope.effects, effect);
4042
4048
  }
4043
4049
  };
4044
4050
  {
@@ -5906,6 +5912,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
5906
5912
  return ref();
5907
5913
  }
5908
5914
  const camelizedName = camelize(name);
5915
+ const hyphenatedName = hyphenate(name);
5909
5916
  const res = customRef((track, trigger) => {
5910
5917
  let localValue;
5911
5918
  watchSyncEffect(() => {
@@ -5923,7 +5930,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
5923
5930
  set(value) {
5924
5931
  const rawProps = i.vnode.props;
5925
5932
  if (!(rawProps && // check if parent has passed v-model
5926
- (name in rawProps || camelizedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps)) && hasChanged(value, localValue)) {
5933
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
5927
5934
  localValue = value;
5928
5935
  trigger();
5929
5936
  }
@@ -6517,7 +6524,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6517
6524
  return vm;
6518
6525
  }
6519
6526
  }
6520
- Vue.version = `2.6.14-compat:${"3.4.3"}`;
6527
+ Vue.version = `2.6.14-compat:${"3.4.5"}`;
6521
6528
  Vue.config = singletonApp.config;
6522
6529
  Vue.use = (p, ...options) => {
6523
6530
  if (p && isFunction(p.install)) {
@@ -11220,7 +11227,7 @@ function isMemoSame(cached, memo) {
11220
11227
  return true;
11221
11228
  }
11222
11229
 
11223
- const version = "3.4.3";
11230
+ const version = "3.4.5";
11224
11231
  const warn = warn$1 ;
11225
11232
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11226
11233
  const devtools = devtools$1 ;