@vueuse/shared 8.7.3 → 8.8.0

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/index.mjs CHANGED
@@ -1,30 +1,30 @@
1
- import { shallowRef, watchEffect, readonly, ref, watch, customRef, effectScope, provide, inject, getCurrentScope, onScopeDispose, isVue3, isRef, unref, computed, reactive, toRefs as toRefs$1, toRef, isVue2, set as set$1, getCurrentInstance, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted } from 'vue-demi';
1
+ import { shallowRef, watchEffect, readonly, ref, watch, customRef, effectScope, provide, inject, getCurrentScope, onScopeDispose, isVue3, isRef, unref, computed, reactive, toRefs as toRefs$1, toRef, isVue2, set as set$1, getCurrentInstance, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted, isReactive } from 'vue-demi';
2
2
 
3
- var __defProp$8 = Object.defineProperty;
4
- var __defProps$5 = Object.defineProperties;
5
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
7
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
8
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues$8 = (a, b) => {
3
+ var __defProp$9 = Object.defineProperty;
4
+ var __defProps$6 = Object.defineProperties;
5
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues$9 = (a, b) => {
11
11
  for (var prop in b || (b = {}))
12
- if (__hasOwnProp$a.call(b, prop))
13
- __defNormalProp$8(a, prop, b[prop]);
14
- if (__getOwnPropSymbols$a)
15
- for (var prop of __getOwnPropSymbols$a(b)) {
16
- if (__propIsEnum$a.call(b, prop))
17
- __defNormalProp$8(a, prop, b[prop]);
12
+ if (__hasOwnProp$b.call(b, prop))
13
+ __defNormalProp$9(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols$b)
15
+ for (var prop of __getOwnPropSymbols$b(b)) {
16
+ if (__propIsEnum$b.call(b, prop))
17
+ __defNormalProp$9(a, prop, b[prop]);
18
18
  }
19
19
  return a;
20
20
  };
21
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
21
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
22
22
  function computedEager(fn, options) {
23
23
  var _a;
24
24
  const result = shallowRef();
25
25
  watchEffect(() => {
26
26
  result.value = fn();
27
- }, __spreadProps$5(__spreadValues$8({}, options), {
27
+ }, __spreadProps$6(__spreadValues$9({}, options), {
28
28
  flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
29
29
  }));
30
30
  return readonly(result);
@@ -188,25 +188,25 @@ function logicOr(...args) {
188
188
  return computed(() => args.some((i) => unref(i)));
189
189
  }
190
190
 
191
- var __defProp$7 = Object.defineProperty;
192
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
193
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
194
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
195
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
196
- var __spreadValues$7 = (a, b) => {
191
+ var __defProp$8 = Object.defineProperty;
192
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
193
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
194
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
195
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
196
+ var __spreadValues$8 = (a, b) => {
197
197
  for (var prop in b || (b = {}))
198
- if (__hasOwnProp$9.call(b, prop))
199
- __defNormalProp$7(a, prop, b[prop]);
200
- if (__getOwnPropSymbols$9)
201
- for (var prop of __getOwnPropSymbols$9(b)) {
202
- if (__propIsEnum$9.call(b, prop))
203
- __defNormalProp$7(a, prop, b[prop]);
198
+ if (__hasOwnProp$a.call(b, prop))
199
+ __defNormalProp$8(a, prop, b[prop]);
200
+ if (__getOwnPropSymbols$a)
201
+ for (var prop of __getOwnPropSymbols$a(b)) {
202
+ if (__propIsEnum$a.call(b, prop))
203
+ __defNormalProp$8(a, prop, b[prop]);
204
204
  }
205
205
  return a;
206
206
  };
207
207
  function makeDestructurable(obj, arr) {
208
208
  if (typeof Symbol !== "undefined") {
209
- const clone = __spreadValues$7({}, obj);
209
+ const clone = __spreadValues$8({}, obj);
210
210
  Object.defineProperty(clone, Symbol.iterator, {
211
211
  enumerable: false,
212
212
  value() {
@@ -288,11 +288,13 @@ function reactiveComputed(fn) {
288
288
  }
289
289
 
290
290
  function reactiveOmit(obj, ...keys) {
291
- return reactiveComputed(() => Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !keys.includes(e[0]))));
291
+ const flatKeys = keys.flat();
292
+ return reactiveComputed(() => Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0]))));
292
293
  }
293
294
 
294
295
  function reactivePick(obj, ...keys) {
295
- return reactive(Object.fromEntries(keys.map((k) => [k, toRef(obj, k)])));
296
+ const flatKeys = keys.flat();
297
+ return reactive(Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
296
298
  }
297
299
 
298
300
  function refAutoReset(defaultValue, afterMs = 1e4) {
@@ -581,6 +583,14 @@ function refWithControl(initial, options = {}) {
581
583
  }
582
584
  const controlledRef = refWithControl;
583
585
 
586
+ function resolveRef(r) {
587
+ return typeof r === "function" ? computed(r) : ref(r);
588
+ }
589
+
590
+ function resolveUnref(r) {
591
+ return typeof r === "function" ? r() : unref(r);
592
+ }
593
+
584
594
  function set(...args) {
585
595
  if (args.length === 2) {
586
596
  const [ref, value] = args;
@@ -627,25 +637,25 @@ function syncRefs(source, targets, options = {}) {
627
637
  return watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
628
638
  }
629
639
 
630
- var __defProp$6 = Object.defineProperty;
631
- var __defProps$4 = Object.defineProperties;
632
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
633
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
634
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
635
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
636
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
637
- var __spreadValues$6 = (a, b) => {
640
+ var __defProp$7 = Object.defineProperty;
641
+ var __defProps$5 = Object.defineProperties;
642
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
643
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
644
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
645
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
646
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
647
+ var __spreadValues$7 = (a, b) => {
638
648
  for (var prop in b || (b = {}))
639
- if (__hasOwnProp$8.call(b, prop))
640
- __defNormalProp$6(a, prop, b[prop]);
641
- if (__getOwnPropSymbols$8)
642
- for (var prop of __getOwnPropSymbols$8(b)) {
643
- if (__propIsEnum$8.call(b, prop))
644
- __defNormalProp$6(a, prop, b[prop]);
649
+ if (__hasOwnProp$9.call(b, prop))
650
+ __defNormalProp$7(a, prop, b[prop]);
651
+ if (__getOwnPropSymbols$9)
652
+ for (var prop of __getOwnPropSymbols$9(b)) {
653
+ if (__propIsEnum$9.call(b, prop))
654
+ __defNormalProp$7(a, prop, b[prop]);
645
655
  }
646
656
  return a;
647
657
  };
648
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
658
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
649
659
  function toRefs(objectRef) {
650
660
  if (!isRef(objectRef))
651
661
  return toRefs$1(objectRef);
@@ -661,7 +671,7 @@ function toRefs(objectRef) {
661
671
  copy[key] = v;
662
672
  objectRef.value = copy;
663
673
  } else {
664
- const newObject = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
674
+ const newObject = __spreadProps$5(__spreadValues$7({}, objectRef.value), { [key]: v });
665
675
  Object.setPrototypeOf(newObject, objectRef.value);
666
676
  objectRef.value = newObject;
667
677
  }
@@ -918,19 +928,19 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
918
928
  };
919
929
  }
920
930
 
921
- var __defProp$5 = Object.defineProperty;
922
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
923
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
924
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
925
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
926
- var __spreadValues$5 = (a, b) => {
931
+ var __defProp$6 = Object.defineProperty;
932
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
933
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
934
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
935
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
936
+ var __spreadValues$6 = (a, b) => {
927
937
  for (var prop in b || (b = {}))
928
- if (__hasOwnProp$7.call(b, prop))
929
- __defNormalProp$5(a, prop, b[prop]);
930
- if (__getOwnPropSymbols$7)
931
- for (var prop of __getOwnPropSymbols$7(b)) {
932
- if (__propIsEnum$7.call(b, prop))
933
- __defNormalProp$5(a, prop, b[prop]);
938
+ if (__hasOwnProp$8.call(b, prop))
939
+ __defNormalProp$6(a, prop, b[prop]);
940
+ if (__getOwnPropSymbols$8)
941
+ for (var prop of __getOwnPropSymbols$8(b)) {
942
+ if (__propIsEnum$8.call(b, prop))
943
+ __defNormalProp$6(a, prop, b[prop]);
934
944
  }
935
945
  return a;
936
946
  };
@@ -942,7 +952,7 @@ function useInterval(interval = 1e3, options = {}) {
942
952
  const counter = ref(0);
943
953
  const controls = useIntervalFn(() => counter.value += 1, interval, { immediate });
944
954
  if (exposeControls) {
945
- return __spreadValues$5({
955
+ return __spreadValues$6({
946
956
  counter
947
957
  }, controls);
948
958
  } else {
@@ -995,19 +1005,19 @@ function useTimeoutFn(cb, interval, options = {}) {
995
1005
  };
996
1006
  }
997
1007
 
998
- var __defProp$4 = Object.defineProperty;
999
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1000
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1001
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1002
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1003
- var __spreadValues$4 = (a, b) => {
1008
+ var __defProp$5 = Object.defineProperty;
1009
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1010
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1011
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1012
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1013
+ var __spreadValues$5 = (a, b) => {
1004
1014
  for (var prop in b || (b = {}))
1005
- if (__hasOwnProp$6.call(b, prop))
1006
- __defNormalProp$4(a, prop, b[prop]);
1007
- if (__getOwnPropSymbols$6)
1008
- for (var prop of __getOwnPropSymbols$6(b)) {
1009
- if (__propIsEnum$6.call(b, prop))
1010
- __defNormalProp$4(a, prop, b[prop]);
1015
+ if (__hasOwnProp$7.call(b, prop))
1016
+ __defNormalProp$5(a, prop, b[prop]);
1017
+ if (__getOwnPropSymbols$7)
1018
+ for (var prop of __getOwnPropSymbols$7(b)) {
1019
+ if (__propIsEnum$7.call(b, prop))
1020
+ __defNormalProp$5(a, prop, b[prop]);
1011
1021
  }
1012
1022
  return a;
1013
1023
  };
@@ -1018,7 +1028,7 @@ function useTimeout(interval = 1e3, options = {}) {
1018
1028
  const controls = useTimeoutFn(noop, interval, options);
1019
1029
  const ready = computed(() => !controls.isPending.value);
1020
1030
  if (exposeControls) {
1021
- return __spreadValues$4({
1031
+ return __spreadValues$5({
1022
1032
  ready
1023
1033
  }, controls);
1024
1034
  } else {
@@ -1048,17 +1058,17 @@ function useToggle(initialValue = false, options = {}) {
1048
1058
  return [innerValue, toggle];
1049
1059
  }
1050
1060
 
1051
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1052
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1053
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1061
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1062
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1063
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1054
1064
  var __objRest$5 = (source, exclude) => {
1055
1065
  var target = {};
1056
1066
  for (var prop in source)
1057
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1067
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1058
1068
  target[prop] = source[prop];
1059
- if (source != null && __getOwnPropSymbols$5)
1060
- for (var prop of __getOwnPropSymbols$5(source)) {
1061
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1069
+ if (source != null && __getOwnPropSymbols$6)
1070
+ for (var prop of __getOwnPropSymbols$6(source)) {
1071
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1062
1072
  target[prop] = source[prop];
1063
1073
  }
1064
1074
  return target;
@@ -1072,17 +1082,17 @@ function watchWithFilter(source, cb, options = {}) {
1072
1082
  return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
1073
1083
  }
1074
1084
 
1075
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1076
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1077
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1085
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1086
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1087
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1078
1088
  var __objRest$4 = (source, exclude) => {
1079
1089
  var target = {};
1080
1090
  for (var prop in source)
1081
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1091
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1082
1092
  target[prop] = source[prop];
1083
- if (source != null && __getOwnPropSymbols$4)
1084
- for (var prop of __getOwnPropSymbols$4(source)) {
1085
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1093
+ if (source != null && __getOwnPropSymbols$5)
1094
+ for (var prop of __getOwnPropSymbols$5(source)) {
1095
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1086
1096
  target[prop] = source[prop];
1087
1097
  }
1088
1098
  return target;
@@ -1103,33 +1113,33 @@ function watchAtMost(source, cb, options) {
1103
1113
  return { count: current, stop };
1104
1114
  }
1105
1115
 
1106
- var __defProp$3 = Object.defineProperty;
1107
- var __defProps$3 = Object.defineProperties;
1108
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1109
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1110
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1111
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1112
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1113
- var __spreadValues$3 = (a, b) => {
1116
+ var __defProp$4 = Object.defineProperty;
1117
+ var __defProps$4 = Object.defineProperties;
1118
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1119
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1120
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1121
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1122
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1123
+ var __spreadValues$4 = (a, b) => {
1114
1124
  for (var prop in b || (b = {}))
1115
- if (__hasOwnProp$3.call(b, prop))
1116
- __defNormalProp$3(a, prop, b[prop]);
1117
- if (__getOwnPropSymbols$3)
1118
- for (var prop of __getOwnPropSymbols$3(b)) {
1119
- if (__propIsEnum$3.call(b, prop))
1120
- __defNormalProp$3(a, prop, b[prop]);
1125
+ if (__hasOwnProp$4.call(b, prop))
1126
+ __defNormalProp$4(a, prop, b[prop]);
1127
+ if (__getOwnPropSymbols$4)
1128
+ for (var prop of __getOwnPropSymbols$4(b)) {
1129
+ if (__propIsEnum$4.call(b, prop))
1130
+ __defNormalProp$4(a, prop, b[prop]);
1121
1131
  }
1122
1132
  return a;
1123
1133
  };
1124
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1134
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1125
1135
  var __objRest$3 = (source, exclude) => {
1126
1136
  var target = {};
1127
1137
  for (var prop in source)
1128
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
1138
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1129
1139
  target[prop] = source[prop];
1130
- if (source != null && __getOwnPropSymbols$3)
1131
- for (var prop of __getOwnPropSymbols$3(source)) {
1132
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
1140
+ if (source != null && __getOwnPropSymbols$4)
1141
+ for (var prop of __getOwnPropSymbols$4(source)) {
1142
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1133
1143
  target[prop] = source[prop];
1134
1144
  }
1135
1145
  return target;
@@ -1142,38 +1152,38 @@ function watchDebounced(source, cb, options = {}) {
1142
1152
  "debounce",
1143
1153
  "maxWait"
1144
1154
  ]);
1145
- return watchWithFilter(source, cb, __spreadProps$3(__spreadValues$3({}, watchOptions), {
1155
+ return watchWithFilter(source, cb, __spreadProps$4(__spreadValues$4({}, watchOptions), {
1146
1156
  eventFilter: debounceFilter(debounce, { maxWait })
1147
1157
  }));
1148
1158
  }
1149
1159
 
1150
- var __defProp$2 = Object.defineProperty;
1151
- var __defProps$2 = Object.defineProperties;
1152
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1153
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1154
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1155
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1156
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1157
- var __spreadValues$2 = (a, b) => {
1160
+ var __defProp$3 = Object.defineProperty;
1161
+ var __defProps$3 = Object.defineProperties;
1162
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1163
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1164
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1165
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1166
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1167
+ var __spreadValues$3 = (a, b) => {
1158
1168
  for (var prop in b || (b = {}))
1159
- if (__hasOwnProp$2.call(b, prop))
1160
- __defNormalProp$2(a, prop, b[prop]);
1161
- if (__getOwnPropSymbols$2)
1162
- for (var prop of __getOwnPropSymbols$2(b)) {
1163
- if (__propIsEnum$2.call(b, prop))
1164
- __defNormalProp$2(a, prop, b[prop]);
1169
+ if (__hasOwnProp$3.call(b, prop))
1170
+ __defNormalProp$3(a, prop, b[prop]);
1171
+ if (__getOwnPropSymbols$3)
1172
+ for (var prop of __getOwnPropSymbols$3(b)) {
1173
+ if (__propIsEnum$3.call(b, prop))
1174
+ __defNormalProp$3(a, prop, b[prop]);
1165
1175
  }
1166
1176
  return a;
1167
1177
  };
1168
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1178
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1169
1179
  var __objRest$2 = (source, exclude) => {
1170
1180
  var target = {};
1171
1181
  for (var prop in source)
1172
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1182
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
1173
1183
  target[prop] = source[prop];
1174
- if (source != null && __getOwnPropSymbols$2)
1175
- for (var prop of __getOwnPropSymbols$2(source)) {
1176
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1184
+ if (source != null && __getOwnPropSymbols$3)
1185
+ for (var prop of __getOwnPropSymbols$3(source)) {
1186
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
1177
1187
  target[prop] = source[prop];
1178
1188
  }
1179
1189
  return target;
@@ -1210,7 +1220,7 @@ function watchIgnorable(source, cb, options = {}) {
1210
1220
  };
1211
1221
  disposables.push(watch(source, () => {
1212
1222
  syncCounter.value++;
1213
- }, __spreadProps$2(__spreadValues$2({}, watchOptions), { flush: "sync" })));
1223
+ }, __spreadProps$3(__spreadValues$3({}, watchOptions), { flush: "sync" })));
1214
1224
  ignoreUpdates = (updater) => {
1215
1225
  const syncCounterPrev = syncCounter.value;
1216
1226
  updater();
@@ -1238,6 +1248,50 @@ function watchOnce(source, cb, options) {
1238
1248
  }, options);
1239
1249
  }
1240
1250
 
1251
+ var __defProp$2 = Object.defineProperty;
1252
+ var __defProps$2 = Object.defineProperties;
1253
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1254
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1255
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1256
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1257
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1258
+ var __spreadValues$2 = (a, b) => {
1259
+ for (var prop in b || (b = {}))
1260
+ if (__hasOwnProp$2.call(b, prop))
1261
+ __defNormalProp$2(a, prop, b[prop]);
1262
+ if (__getOwnPropSymbols$2)
1263
+ for (var prop of __getOwnPropSymbols$2(b)) {
1264
+ if (__propIsEnum$2.call(b, prop))
1265
+ __defNormalProp$2(a, prop, b[prop]);
1266
+ }
1267
+ return a;
1268
+ };
1269
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1270
+ var __objRest$1 = (source, exclude) => {
1271
+ var target = {};
1272
+ for (var prop in source)
1273
+ if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1274
+ target[prop] = source[prop];
1275
+ if (source != null && __getOwnPropSymbols$2)
1276
+ for (var prop of __getOwnPropSymbols$2(source)) {
1277
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1278
+ target[prop] = source[prop];
1279
+ }
1280
+ return target;
1281
+ };
1282
+ function watchPausable(source, cb, options = {}) {
1283
+ const _a = options, {
1284
+ eventFilter: filter
1285
+ } = _a, watchOptions = __objRest$1(_a, [
1286
+ "eventFilter"
1287
+ ]);
1288
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1289
+ const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$2({}, watchOptions), {
1290
+ eventFilter
1291
+ }));
1292
+ return { stop, pause, resume, isActive };
1293
+ }
1294
+
1241
1295
  var __defProp$1 = Object.defineProperty;
1242
1296
  var __defProps$1 = Object.defineProperties;
1243
1297
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
@@ -1257,7 +1311,7 @@ var __spreadValues$1 = (a, b) => {
1257
1311
  return a;
1258
1312
  };
1259
1313
  var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1260
- var __objRest$1 = (source, exclude) => {
1314
+ var __objRest = (source, exclude) => {
1261
1315
  var target = {};
1262
1316
  for (var prop in source)
1263
1317
  if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -1269,17 +1323,19 @@ var __objRest$1 = (source, exclude) => {
1269
1323
  }
1270
1324
  return target;
1271
1325
  };
1272
- function watchPausable(source, cb, options = {}) {
1326
+ function watchThrottled(source, cb, options = {}) {
1273
1327
  const _a = options, {
1274
- eventFilter: filter
1275
- } = _a, watchOptions = __objRest$1(_a, [
1276
- "eventFilter"
1328
+ throttle = 0,
1329
+ trailing = true,
1330
+ leading = true
1331
+ } = _a, watchOptions = __objRest(_a, [
1332
+ "throttle",
1333
+ "trailing",
1334
+ "leading"
1277
1335
  ]);
1278
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1279
- const stop = watchWithFilter(source, cb, __spreadProps$1(__spreadValues$1({}, watchOptions), {
1280
- eventFilter
1336
+ return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$1({}, watchOptions), {
1337
+ eventFilter: throttleFilter(throttle, trailing, leading)
1281
1338
  }));
1282
- return { stop, pause, resume, isActive };
1283
1339
  }
1284
1340
 
1285
1341
  var __defProp = Object.defineProperty;
@@ -1301,31 +1357,47 @@ var __spreadValues = (a, b) => {
1301
1357
  return a;
1302
1358
  };
1303
1359
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1304
- var __objRest = (source, exclude) => {
1305
- var target = {};
1306
- for (var prop in source)
1307
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
1308
- target[prop] = source[prop];
1309
- if (source != null && __getOwnPropSymbols)
1310
- for (var prop of __getOwnPropSymbols(source)) {
1311
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
1312
- target[prop] = source[prop];
1313
- }
1314
- return target;
1315
- };
1316
- function watchThrottled(source, cb, options = {}) {
1317
- const _a = options, {
1318
- throttle = 0,
1319
- trailing = true,
1320
- leading = true
1321
- } = _a, watchOptions = __objRest(_a, [
1322
- "throttle",
1323
- "trailing",
1324
- "leading"
1325
- ]);
1326
- return watchWithFilter(source, cb, __spreadProps(__spreadValues({}, watchOptions), {
1327
- eventFilter: throttleFilter(throttle, trailing, leading)
1328
- }));
1360
+ function watchTriggerable(source, cb, options = {}) {
1361
+ let cleanupFn;
1362
+ function onEffect() {
1363
+ if (!cleanupFn)
1364
+ return;
1365
+ const fn = cleanupFn;
1366
+ cleanupFn = void 0;
1367
+ fn();
1368
+ }
1369
+ function onCleanup(callback) {
1370
+ cleanupFn = callback;
1371
+ }
1372
+ const _cb = (value, oldValue) => {
1373
+ onEffect();
1374
+ return cb(value, oldValue, onCleanup);
1375
+ };
1376
+ const res = watchIgnorable(source, _cb, options);
1377
+ const { ignoreUpdates } = res;
1378
+ const trigger = () => {
1379
+ let res2;
1380
+ ignoreUpdates(() => {
1381
+ res2 = _cb(getWatchSources(source), getOldValue(source));
1382
+ });
1383
+ return res2;
1384
+ };
1385
+ return __spreadProps(__spreadValues({}, res), {
1386
+ trigger
1387
+ });
1388
+ }
1389
+ function getWatchSources(sources) {
1390
+ if (isReactive(sources))
1391
+ return sources;
1392
+ if (Array.isArray(sources))
1393
+ return sources.map((item) => getOneWatchSource(item));
1394
+ return getOneWatchSource(sources);
1395
+ }
1396
+ function getOneWatchSource(source) {
1397
+ return typeof source === "function" ? source() : unref(source);
1398
+ }
1399
+ function getOldValue(source) {
1400
+ return Array.isArray(source) ? source.map(() => void 0) : void 0;
1329
1401
  }
1330
1402
 
1331
1403
  function whenever(source, cb, options) {
@@ -1335,4 +1407,4 @@ function whenever(source, cb, options) {
1335
1407
  }, options);
1336
1408
  }
1337
1409
 
1338
- export { __onlyVue3, logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchWithFilter, whenever };
1410
+ export { __onlyVue3, logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/shared",
3
- "version": "8.7.3",
3
+ "version": "8.8.0",
4
4
  "author": "Anthony Fu <https://github.com/antfu>",
5
5
  "license": "MIT",
6
6
  "funding": "https://github.com/sponsors/antfu",