@vueuse/shared 11.3.0 → 12.0.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.iife.js CHANGED
@@ -1,158 +1,31 @@
1
- var _VueDemiGlobal = typeof globalThis !== 'undefined'
2
- ? globalThis
3
- : typeof global !== 'undefined'
4
- ? global
5
- : typeof self !== 'undefined'
6
- ? self
7
- : this
8
- var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
9
- if (VueDemi.install) {
10
- return VueDemi
11
- }
12
- if (!Vue) {
13
- console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.')
14
- return VueDemi
15
- }
16
-
17
- // Vue 2.7
18
- if (Vue.version.slice(0, 4) === '2.7.') {
19
- for (var key in Vue) {
20
- VueDemi[key] = Vue[key]
21
- }
22
- VueDemi.isVue2 = true
23
- VueDemi.isVue3 = false
24
- VueDemi.install = function () {}
25
- VueDemi.Vue = Vue
26
- VueDemi.Vue2 = Vue
27
- VueDemi.version = Vue.version
28
- VueDemi.warn = Vue.util.warn
29
- VueDemi.hasInjectionContext = function() {
30
- return !!VueDemi.getCurrentInstance()
31
- }
32
- function createApp(rootComponent, rootProps) {
33
- var vm
34
- var provide = {}
35
- var app = {
36
- config: Vue.config,
37
- use: Vue.use.bind(Vue),
38
- mixin: Vue.mixin.bind(Vue),
39
- component: Vue.component.bind(Vue),
40
- provide: function (key, value) {
41
- provide[key] = value
42
- return this
43
- },
44
- directive: function (name, dir) {
45
- if (dir) {
46
- Vue.directive(name, dir)
47
- return app
48
- } else {
49
- return Vue.directive(name)
50
- }
51
- },
52
- mount: function (el, hydrating) {
53
- if (!vm) {
54
- vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
55
- vm.$mount(el, hydrating)
56
- return vm
57
- } else {
58
- return vm
59
- }
60
- },
61
- unmount: function () {
62
- if (vm) {
63
- vm.$destroy()
64
- vm = undefined
65
- }
66
- },
67
- }
68
- return app
69
- }
70
- VueDemi.createApp = createApp
71
- }
72
- // Vue 2.6.x
73
- else if (Vue.version.slice(0, 2) === '2.') {
74
- if (VueCompositionAPI) {
75
- for (var key in VueCompositionAPI) {
76
- VueDemi[key] = VueCompositionAPI[key]
77
- }
78
- VueDemi.isVue2 = true
79
- VueDemi.isVue3 = false
80
- VueDemi.install = function () {}
81
- VueDemi.Vue = Vue
82
- VueDemi.Vue2 = Vue
83
- VueDemi.version = Vue.version
84
- VueDemi.hasInjectionContext = function() {
85
- return !!VueDemi.getCurrentInstance()
86
- }
87
- } else {
88
- console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
89
- }
90
- }
91
- // Vue 3
92
- else if (Vue.version.slice(0, 2) === '3.') {
93
- for (var key in Vue) {
94
- VueDemi[key] = Vue[key]
95
- }
96
- VueDemi.isVue2 = false
97
- VueDemi.isVue3 = true
98
- VueDemi.install = function () {}
99
- VueDemi.Vue = Vue
100
- VueDemi.Vue2 = undefined
101
- VueDemi.version = Vue.version
102
- VueDemi.set = function (target, key, val) {
103
- if (Array.isArray(target)) {
104
- target.length = Math.max(target.length, key)
105
- target.splice(key, 1, val)
106
- return val
107
- }
108
- target[key] = val
109
- return val
110
- }
111
- VueDemi.del = function (target, key) {
112
- if (Array.isArray(target)) {
113
- target.splice(key, 1)
114
- return
115
- }
116
- delete target[key]
117
- }
118
- } else {
119
- console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
120
- }
121
- return VueDemi
122
- })(
123
- (_VueDemiGlobal.VueDemi = _VueDemiGlobal.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})),
124
- _VueDemiGlobal.Vue || (typeof Vue !== 'undefined' ? Vue : undefined),
125
- _VueDemiGlobal.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
126
- );
127
- ;
128
- ;(function (exports, vueDemi) {
1
+ (function (exports, vue) {
129
2
  'use strict';
130
3
 
131
4
  function computedEager(fn, options) {
132
5
  var _a;
133
- const result = vueDemi.shallowRef();
134
- vueDemi.watchEffect(() => {
6
+ const result = vue.shallowRef();
7
+ vue.watchEffect(() => {
135
8
  result.value = fn();
136
9
  }, {
137
10
  ...options,
138
11
  flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
139
12
  });
140
- return vueDemi.readonly(result);
13
+ return vue.readonly(result);
141
14
  }
142
15
 
143
16
  function computedWithControl(source, fn) {
144
17
  let v = void 0;
145
18
  let track;
146
19
  let trigger;
147
- const dirty = vueDemi.ref(true);
20
+ const dirty = vue.ref(true);
148
21
  const update = () => {
149
22
  dirty.value = true;
150
23
  trigger();
151
24
  };
152
- vueDemi.watch(source, update, { flush: "sync" });
25
+ vue.watch(source, update, { flush: "sync" });
153
26
  const get = typeof fn === "function" ? fn : fn.get;
154
27
  const set = typeof fn === "function" ? void 0 : fn.set;
155
- const result = vueDemi.customRef((_track, _trigger) => {
28
+ const result = vue.customRef((_track, _trigger) => {
156
29
  track = _track;
157
30
  trigger = _trigger;
158
31
  return {
@@ -175,8 +48,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
175
48
  }
176
49
 
177
50
  function tryOnScopeDispose(fn) {
178
- if (vueDemi.getCurrentScope()) {
179
- vueDemi.onScopeDispose(fn);
51
+ if (vue.getCurrentScope()) {
52
+ vue.onScopeDispose(fn);
180
53
  return true;
181
54
  }
182
55
  return false;
@@ -208,7 +81,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
208
81
  function createGlobalState(stateFactory) {
209
82
  let initialized = false;
210
83
  let state;
211
- const scope = vueDemi.effectScope(true);
84
+ const scope = vue.effectScope(true);
212
85
  return (...args) => {
213
86
  if (!initialized) {
214
87
  state = scope.run(() => stateFactory(...args));
@@ -223,24 +96,24 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
223
96
  const injectLocal = (...args) => {
224
97
  var _a;
225
98
  const key = args[0];
226
- const instance = (_a = vueDemi.getCurrentInstance()) == null ? void 0 : _a.proxy;
99
+ const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
227
100
  if (instance == null)
228
101
  throw new Error("injectLocal must be called in setup");
229
102
  if (localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
230
103
  return localProvidedStateMap.get(instance)[key];
231
- return vueDemi.inject(...args);
104
+ return vue.inject(...args);
232
105
  };
233
106
 
234
107
  const provideLocal = (key, value) => {
235
108
  var _a;
236
- const instance = (_a = vueDemi.getCurrentInstance()) == null ? void 0 : _a.proxy;
109
+ const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
237
110
  if (instance == null)
238
111
  throw new Error("provideLocal must be called in setup");
239
112
  if (!localProvidedStateMap.has(instance))
240
113
  localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null));
241
114
  const localProvidedState = localProvidedStateMap.get(instance);
242
115
  localProvidedState[key] = value;
243
- vueDemi.provide(key, value);
116
+ vue.provide(key, value);
244
117
  };
245
118
 
246
119
  function createInjectionState(composable, options) {
@@ -270,7 +143,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
270
143
  return (...args) => {
271
144
  subscribers += 1;
272
145
  if (!scope) {
273
- scope = vueDemi.effectScope(true);
146
+ scope = vue.effectScope(true);
274
147
  state = scope.run(() => composable(...args));
275
148
  }
276
149
  tryOnScopeDispose(dispose);
@@ -279,15 +152,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
279
152
  }
280
153
 
281
154
  function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
282
- if (!vueDemi.isVue3 && !vueDemi.version.startsWith("2.7.")) {
283
- if (process.env.NODE_ENV !== "production")
284
- throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");
285
- return;
286
- }
287
155
  for (const [key, value] of Object.entries(extend)) {
288
156
  if (key === "value")
289
157
  continue;
290
- if (vueDemi.isRef(value) && unwrap) {
158
+ if (vue.isRef(value) && unwrap) {
291
159
  Object.defineProperty(ref, key, {
292
160
  get() {
293
161
  return value.value;
@@ -306,12 +174,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
306
174
 
307
175
  function get(obj, key) {
308
176
  if (key == null)
309
- return vueDemi.unref(obj);
310
- return vueDemi.unref(obj)[key];
177
+ return vue.unref(obj);
178
+ return vue.unref(obj)[key];
311
179
  }
312
180
 
313
181
  function isDefined(v) {
314
- return vueDemi.unref(v) != null;
182
+ return vue.unref(v) != null;
315
183
  }
316
184
 
317
185
  function makeDestructurable(obj, arr) {
@@ -336,14 +204,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
336
204
  }
337
205
 
338
206
  function toValue(r) {
339
- return typeof r === "function" ? r() : vueDemi.unref(r);
207
+ return typeof r === "function" ? r() : vue.unref(r);
340
208
  }
341
209
  const resolveUnref = toValue;
342
210
 
343
211
  function reactify(fn, options) {
344
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
212
+ const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vue.unref : toValue;
345
213
  return function(...args) {
346
- return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
214
+ return vue.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
347
215
  };
348
216
  }
349
217
 
@@ -371,14 +239,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
371
239
  }
372
240
 
373
241
  function toReactive(objectRef) {
374
- if (!vueDemi.isRef(objectRef))
375
- return vueDemi.reactive(objectRef);
242
+ if (!vue.isRef(objectRef))
243
+ return vue.reactive(objectRef);
376
244
  const proxy = new Proxy({}, {
377
245
  get(_, p, receiver) {
378
- return vueDemi.unref(Reflect.get(objectRef.value, p, receiver));
246
+ return vue.unref(Reflect.get(objectRef.value, p, receiver));
379
247
  },
380
248
  set(_, p, value) {
381
- if (vueDemi.isRef(objectRef.value[p]) && !vueDemi.isRef(value))
249
+ if (vue.isRef(objectRef.value[p]) && !vue.isRef(value))
382
250
  objectRef.value[p].value = value;
383
251
  else
384
252
  objectRef.value[p] = value;
@@ -400,25 +268,19 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
400
268
  };
401
269
  }
402
270
  });
403
- return vueDemi.reactive(proxy);
271
+ return vue.reactive(proxy);
404
272
  }
405
273
 
406
274
  function reactiveComputed(fn) {
407
- return toReactive(vueDemi.computed(fn));
275
+ return toReactive(vue.computed(fn));
408
276
  }
409
277
 
410
278
  function reactiveOmit(obj, ...keys) {
411
279
  const flatKeys = keys.flat();
412
280
  const predicate = flatKeys[0];
413
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
281
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
414
282
  }
415
283
 
416
- const directiveHooks = {
417
- mounted: vueDemi.isVue3 ? "mounted" : "inserted",
418
- updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
419
- unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
420
- };
421
-
422
284
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
423
285
  const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
424
286
  const isDef = (val) => typeof val !== "undefined";
@@ -508,7 +370,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
508
370
  let trailing;
509
371
  let leading;
510
372
  let rejectOnCancel;
511
- if (!vueDemi.isRef(args[0]) && typeof args[0] === "object")
373
+ if (!vue.isRef(args[0]) && typeof args[0] === "object")
512
374
  ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
513
375
  else
514
376
  [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
@@ -553,7 +415,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
553
415
  return filter;
554
416
  }
555
417
  function pausableFilter(extendFilter = bypassFilter) {
556
- const isActive = vueDemi.ref(true);
418
+ const isActive = vue.ref(true);
557
419
  function pause() {
558
420
  isActive.value = false;
559
421
  }
@@ -564,7 +426,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
564
426
  if (isActive.value)
565
427
  extendFilter(...args);
566
428
  };
567
- return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
429
+ return { isActive: vue.readonly(isActive), pause, resume, eventFilter };
568
430
  }
569
431
 
570
432
  function cacheStringFunction(fn) {
@@ -642,25 +504,25 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
642
504
  return Object.entries(obj);
643
505
  }
644
506
  function getLifeCycleTarget(target) {
645
- return target || vueDemi.getCurrentInstance();
507
+ return target || vue.getCurrentInstance();
646
508
  }
647
509
 
648
510
  function toRef(...args) {
649
511
  if (args.length !== 1)
650
- return vueDemi.toRef(...args);
512
+ return vue.toRef(...args);
651
513
  const r = args[0];
652
- return typeof r === "function" ? vueDemi.readonly(vueDemi.customRef(() => ({ get: r, set: noop }))) : vueDemi.ref(r);
514
+ return typeof r === "function" ? vue.readonly(vue.customRef(() => ({ get: r, set: noop }))) : vue.ref(r);
653
515
  }
654
516
  const resolveRef = toRef;
655
517
 
656
518
  function reactivePick(obj, ...keys) {
657
519
  const flatKeys = keys.flat();
658
520
  const predicate = flatKeys[0];
659
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
521
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
660
522
  }
661
523
 
662
524
  function refAutoReset(defaultValue, afterMs = 1e4) {
663
- return vueDemi.customRef((track, trigger) => {
525
+ return vue.customRef((track, trigger) => {
664
526
  let value = toValue(defaultValue);
665
527
  let timer;
666
528
  const resetAfter = () => setTimeout(() => {
@@ -693,16 +555,16 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
693
555
  }
694
556
 
695
557
  function refDebounced(value, ms = 200, options = {}) {
696
- const debounced = vueDemi.ref(value.value);
558
+ const debounced = vue.ref(value.value);
697
559
  const updater = useDebounceFn(() => {
698
560
  debounced.value = value.value;
699
561
  }, ms, options);
700
- vueDemi.watch(value, () => updater());
562
+ vue.watch(value, () => updater());
701
563
  return debounced;
702
564
  }
703
565
 
704
566
  function refDefault(source, defaultValue) {
705
- return vueDemi.computed({
567
+ return vue.computed({
706
568
  get() {
707
569
  var _a;
708
570
  return (_a = source.value) != null ? _a : defaultValue;
@@ -723,11 +585,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
723
585
  function refThrottled(value, delay = 200, trailing = true, leading = true) {
724
586
  if (delay <= 0)
725
587
  return value;
726
- const throttled = vueDemi.ref(value.value);
588
+ const throttled = vue.ref(value.value);
727
589
  const updater = useThrottleFn(() => {
728
590
  throttled.value = value.value;
729
591
  }, delay, trailing, leading);
730
- vueDemi.watch(value, () => updater());
592
+ vue.watch(value, () => updater());
731
593
  return throttled;
732
594
  }
733
595
 
@@ -735,7 +597,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
735
597
  let source = initial;
736
598
  let track;
737
599
  let trigger;
738
- const ref = vueDemi.customRef((_track, _trigger) => {
600
+ const ref = vue.customRef((_track, _trigger) => {
739
601
  track = _track;
740
602
  trigger = _trigger;
741
603
  return {
@@ -789,12 +651,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
789
651
  ref.value = value;
790
652
  }
791
653
  if (args.length === 3) {
792
- if (vueDemi.isVue2) {
793
- vueDemi.set(...args);
794
- } else {
795
- const [target, key, value] = args;
796
- target[key] = value;
797
- }
654
+ const [target, key, value] = args;
655
+ target[key] = value;
798
656
  }
799
657
  }
800
658
 
@@ -803,7 +661,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
803
661
  eventFilter = bypassFilter,
804
662
  ...watchOptions
805
663
  } = options;
806
- return vueDemi.watch(
664
+ return vue.watch(
807
665
  source,
808
666
  createFilterWrapper(
809
667
  eventFilter,
@@ -877,7 +735,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
877
735
  } = options;
878
736
  if (!Array.isArray(targets))
879
737
  targets = [targets];
880
- return vueDemi.watch(
738
+ return vue.watch(
881
739
  source,
882
740
  (newValue) => targets.forEach((target) => target.value = newValue),
883
741
  { flush, deep, immediate }
@@ -885,11 +743,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
885
743
  }
886
744
 
887
745
  function toRefs(objectRef, options = {}) {
888
- if (!vueDemi.isRef(objectRef))
889
- return vueDemi.toRefs(objectRef);
746
+ if (!vue.isRef(objectRef))
747
+ return vue.toRefs(objectRef);
890
748
  const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
891
749
  for (const key in objectRef.value) {
892
- result[key] = vueDemi.customRef(() => ({
750
+ result[key] = vue.customRef(() => ({
893
751
  get() {
894
752
  return objectRef.value[key];
895
753
  },
@@ -918,47 +776,47 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
918
776
  function tryOnBeforeMount(fn, sync = true, target) {
919
777
  const instance = getLifeCycleTarget(target);
920
778
  if (instance)
921
- vueDemi.onBeforeMount(fn, target);
779
+ vue.onBeforeMount(fn, target);
922
780
  else if (sync)
923
781
  fn();
924
782
  else
925
- vueDemi.nextTick(fn);
783
+ vue.nextTick(fn);
926
784
  }
927
785
 
928
786
  function tryOnBeforeUnmount(fn, target) {
929
787
  const instance = getLifeCycleTarget(target);
930
788
  if (instance)
931
- vueDemi.onBeforeUnmount(fn, target);
789
+ vue.onBeforeUnmount(fn, target);
932
790
  }
933
791
 
934
792
  function tryOnMounted(fn, sync = true, target) {
935
793
  const instance = getLifeCycleTarget();
936
794
  if (instance)
937
- vueDemi.onMounted(fn, target);
795
+ vue.onMounted(fn, target);
938
796
  else if (sync)
939
797
  fn();
940
798
  else
941
- vueDemi.nextTick(fn);
799
+ vue.nextTick(fn);
942
800
  }
943
801
 
944
802
  function tryOnUnmounted(fn, target) {
945
803
  const instance = getLifeCycleTarget(target);
946
804
  if (instance)
947
- vueDemi.onUnmounted(fn, target);
805
+ vue.onUnmounted(fn, target);
948
806
  }
949
807
 
950
808
  function createUntil(r, isNot = false) {
951
809
  function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
952
810
  let stop = null;
953
811
  const watcher = new Promise((resolve) => {
954
- stop = vueDemi.watch(
812
+ stop = vue.watch(
955
813
  r,
956
814
  (v) => {
957
815
  if (condition(v) !== isNot) {
958
816
  if (stop)
959
817
  stop();
960
818
  else
961
- vueDemi.nextTick(() => stop == null ? void 0 : stop());
819
+ vue.nextTick(() => stop == null ? void 0 : stop());
962
820
  resolve(v);
963
821
  }
964
822
  },
@@ -978,19 +836,19 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
978
836
  return Promise.race(promises);
979
837
  }
980
838
  function toBe(value, options) {
981
- if (!vueDemi.isRef(value))
839
+ if (!vue.isRef(value))
982
840
  return toMatch((v) => v === value, options);
983
841
  const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
984
842
  let stop = null;
985
843
  const watcher = new Promise((resolve) => {
986
- stop = vueDemi.watch(
844
+ stop = vue.watch(
987
845
  [r, value],
988
846
  ([v1, v2]) => {
989
847
  if (isNot !== (v1 === v2)) {
990
848
  if (stop)
991
849
  stop();
992
850
  else
993
- vueDemi.nextTick(() => stop == null ? void 0 : stop());
851
+ vue.nextTick(() => stop == null ? void 0 : stop());
994
852
  resolve(v1);
995
853
  }
996
854
  },
@@ -1084,25 +942,25 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1084
942
  const key = compareFn;
1085
943
  compareFn = (value, othVal) => value[key] === othVal[key];
1086
944
  }
1087
- return vueDemi.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
945
+ return vue.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
1088
946
  }
1089
947
 
1090
948
  function useArrayEvery(list, fn) {
1091
- return vueDemi.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
949
+ return vue.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
1092
950
  }
1093
951
 
1094
952
  function useArrayFilter(list, fn) {
1095
- return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
953
+ return vue.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
1096
954
  }
1097
955
 
1098
956
  function useArrayFind(list, fn) {
1099
- return vueDemi.computed(() => toValue(
957
+ return vue.computed(() => toValue(
1100
958
  toValue(list).find((element, index, array) => fn(toValue(element), index, array))
1101
959
  ));
1102
960
  }
1103
961
 
1104
962
  function useArrayFindIndex(list, fn) {
1105
- return vueDemi.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
963
+ return vue.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
1106
964
  }
1107
965
 
1108
966
  function findLast(arr, cb) {
@@ -1114,7 +972,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1114
972
  return void 0;
1115
973
  }
1116
974
  function useArrayFindLast(list, fn) {
1117
- return vueDemi.computed(() => toValue(
975
+ return vue.computed(() => toValue(
1118
976
  !Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
1119
977
  ));
1120
978
  }
@@ -1137,7 +995,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1137
995
  comparator = (element, value2) => element[key] === toValue(value2);
1138
996
  }
1139
997
  comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
1140
- return vueDemi.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
998
+ return vue.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
1141
999
  toValue(element),
1142
1000
  toValue(value),
1143
1001
  index,
@@ -1146,23 +1004,23 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1146
1004
  }
1147
1005
 
1148
1006
  function useArrayJoin(list, separator) {
1149
- return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
1007
+ return vue.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
1150
1008
  }
1151
1009
 
1152
1010
  function useArrayMap(list, fn) {
1153
- return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
1011
+ return vue.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
1154
1012
  }
1155
1013
 
1156
1014
  function useArrayReduce(list, reducer, ...args) {
1157
1015
  const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
1158
- return vueDemi.computed(() => {
1016
+ return vue.computed(() => {
1159
1017
  const resolved = toValue(list);
1160
1018
  return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
1161
1019
  });
1162
1020
  }
1163
1021
 
1164
1022
  function useArraySome(list, fn) {
1165
- return vueDemi.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
1023
+ return vue.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
1166
1024
  }
1167
1025
 
1168
1026
  function uniq(array) {
@@ -1176,15 +1034,15 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1176
1034
  }, []);
1177
1035
  }
1178
1036
  function useArrayUnique(list, compareFn) {
1179
- return vueDemi.computed(() => {
1037
+ return vue.computed(() => {
1180
1038
  const resolvedList = toValue(list).map((element) => toValue(element));
1181
1039
  return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1182
1040
  });
1183
1041
  }
1184
1042
 
1185
1043
  function useCounter(initialValue = 0, options = {}) {
1186
- let _initialValue = vueDemi.unref(initialValue);
1187
- const count = vueDemi.ref(initialValue);
1044
+ let _initialValue = vue.unref(initialValue);
1045
+ const count = vue.ref(initialValue);
1188
1046
  const {
1189
1047
  max = Number.POSITIVE_INFINITY,
1190
1048
  min = Number.NEGATIVE_INFINITY
@@ -1281,7 +1139,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1281
1139
  return new Date(date);
1282
1140
  }
1283
1141
  function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1284
- return vueDemi.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1142
+ return vue.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1285
1143
  }
1286
1144
 
1287
1145
  function useIntervalFn(cb, interval = 1e3, options = {}) {
@@ -1290,7 +1148,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1290
1148
  immediateCallback = false
1291
1149
  } = options;
1292
1150
  let timer = null;
1293
- const isActive = vueDemi.ref(false);
1151
+ const isActive = vue.ref(false);
1294
1152
  function clean() {
1295
1153
  if (timer) {
1296
1154
  clearInterval(timer);
@@ -1314,8 +1172,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1314
1172
  }
1315
1173
  if (immediate && isClient)
1316
1174
  resume();
1317
- if (vueDemi.isRef(interval) || typeof interval === "function") {
1318
- const stopWatch = vueDemi.watch(interval, () => {
1175
+ if (vue.isRef(interval) || typeof interval === "function") {
1176
+ const stopWatch = vue.watch(interval, () => {
1319
1177
  if (isActive.value && isClient)
1320
1178
  resume();
1321
1179
  });
@@ -1335,7 +1193,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1335
1193
  immediate = true,
1336
1194
  callback
1337
1195
  } = options;
1338
- const counter = vueDemi.ref(0);
1196
+ const counter = vue.ref(0);
1339
1197
  const update = () => counter.value += 1;
1340
1198
  const reset = () => {
1341
1199
  counter.value = 0;
@@ -1361,8 +1219,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1361
1219
 
1362
1220
  function useLastChanged(source, options = {}) {
1363
1221
  var _a;
1364
- const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
1365
- vueDemi.watch(
1222
+ const ms = vue.ref((_a = options.initialValue) != null ? _a : null);
1223
+ vue.watch(
1366
1224
  source,
1367
1225
  () => ms.value = timestamp(),
1368
1226
  options
@@ -1374,7 +1232,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1374
1232
  const {
1375
1233
  immediate = true
1376
1234
  } = options;
1377
- const isPending = vueDemi.ref(false);
1235
+ const isPending = vue.ref(false);
1378
1236
  let timer = null;
1379
1237
  function clear() {
1380
1238
  if (timer) {
@@ -1402,7 +1260,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1402
1260
  }
1403
1261
  tryOnScopeDispose(stop);
1404
1262
  return {
1405
- isPending: vueDemi.readonly(isPending),
1263
+ isPending: vue.readonly(isPending),
1406
1264
  start,
1407
1265
  stop
1408
1266
  };
@@ -1418,7 +1276,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1418
1276
  interval,
1419
1277
  options
1420
1278
  );
1421
- const ready = vueDemi.computed(() => !controls.isPending.value);
1279
+ const ready = vue.computed(() => !controls.isPending.value);
1422
1280
  if (exposeControls) {
1423
1281
  return {
1424
1282
  ready,
@@ -1435,7 +1293,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1435
1293
  radix,
1436
1294
  nanToZero
1437
1295
  } = options;
1438
- return vueDemi.computed(() => {
1296
+ return vue.computed(() => {
1439
1297
  let resolved = toValue(value);
1440
1298
  if (typeof resolved === "string")
1441
1299
  resolved = Number[method](resolved, radix);
@@ -1446,7 +1304,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1446
1304
  }
1447
1305
 
1448
1306
  function useToString(value) {
1449
- return vueDemi.computed(() => `${toValue(value)}`);
1307
+ return vue.computed(() => `${toValue(value)}`);
1450
1308
  }
1451
1309
 
1452
1310
  function useToggle(initialValue = false, options = {}) {
@@ -1454,8 +1312,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1454
1312
  truthyValue = true,
1455
1313
  falsyValue = false
1456
1314
  } = options;
1457
- const valueIsRef = vueDemi.isRef(initialValue);
1458
- const _value = vueDemi.ref(initialValue);
1315
+ const valueIsRef = vue.isRef(initialValue);
1316
+ const _value = vue.ref(initialValue);
1459
1317
  function toggle(value) {
1460
1318
  if (arguments.length) {
1461
1319
  _value.value = value;
@@ -1474,7 +1332,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1474
1332
 
1475
1333
  function watchArray(source, cb, options) {
1476
1334
  let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)];
1477
- return vueDemi.watch(source, (newList, _, onCleanup) => {
1335
+ return vue.watch(source, (newList, _, onCleanup) => {
1478
1336
  const oldListRemains = Array.from({ length: oldList.length });
1479
1337
  const added = [];
1480
1338
  for (const obj of newList) {
@@ -1500,13 +1358,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1500
1358
  count,
1501
1359
  ...watchOptions
1502
1360
  } = options;
1503
- const current = vueDemi.ref(0);
1361
+ const current = vue.ref(0);
1504
1362
  const stop = watchWithFilter(
1505
1363
  source,
1506
1364
  (...args) => {
1507
1365
  current.value += 1;
1508
1366
  if (current.value >= toValue(count))
1509
- vueDemi.nextTick(() => stop());
1367
+ vue.nextTick(() => stop());
1510
1368
  cb(...args);
1511
1369
  },
1512
1370
  watchOptions
@@ -1531,7 +1389,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1531
1389
  }
1532
1390
 
1533
1391
  function watchDeep(source, cb, options) {
1534
- return vueDemi.watch(
1392
+ return vue.watch(
1535
1393
  source,
1536
1394
  cb,
1537
1395
  {
@@ -1554,7 +1412,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1554
1412
  let ignorePrevAsyncUpdates;
1555
1413
  let stop;
1556
1414
  if (watchOptions.flush === "sync") {
1557
- const ignore = vueDemi.ref(false);
1415
+ const ignore = vue.ref(false);
1558
1416
  ignorePrevAsyncUpdates = () => {
1559
1417
  };
1560
1418
  ignoreUpdates = (updater) => {
@@ -1562,7 +1420,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1562
1420
  updater();
1563
1421
  ignore.value = false;
1564
1422
  };
1565
- stop = vueDemi.watch(
1423
+ stop = vue.watch(
1566
1424
  source,
1567
1425
  (...args) => {
1568
1426
  if (!ignore.value)
@@ -1572,13 +1430,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1572
1430
  );
1573
1431
  } else {
1574
1432
  const disposables = [];
1575
- const ignoreCounter = vueDemi.ref(0);
1576
- const syncCounter = vueDemi.ref(0);
1433
+ const ignoreCounter = vue.ref(0);
1434
+ const syncCounter = vue.ref(0);
1577
1435
  ignorePrevAsyncUpdates = () => {
1578
1436
  ignoreCounter.value = syncCounter.value;
1579
1437
  };
1580
1438
  disposables.push(
1581
- vueDemi.watch(
1439
+ vue.watch(
1582
1440
  source,
1583
1441
  () => {
1584
1442
  syncCounter.value++;
@@ -1592,7 +1450,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1592
1450
  ignoreCounter.value += syncCounter.value - syncCounterPrev;
1593
1451
  };
1594
1452
  disposables.push(
1595
- vueDemi.watch(
1453
+ vue.watch(
1596
1454
  source,
1597
1455
  (...args) => {
1598
1456
  const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
@@ -1613,7 +1471,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1613
1471
  }
1614
1472
 
1615
1473
  function watchImmediate(source, cb, options) {
1616
- return vueDemi.watch(
1474
+ return vue.watch(
1617
1475
  source,
1618
1476
  cb,
1619
1477
  {
@@ -1624,8 +1482,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1624
1482
  }
1625
1483
 
1626
1484
  function watchOnce(source, cb, options) {
1627
- const stop = vueDemi.watch(source, (...args) => {
1628
- vueDemi.nextTick(() => stop());
1485
+ const stop = vue.watch(source, (...args) => {
1486
+ vue.nextTick(() => stop());
1629
1487
  return cb(...args);
1630
1488
  }, options);
1631
1489
  return stop;
@@ -1679,7 +1537,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1679
1537
  };
1680
1538
  }
1681
1539
  function getWatchSources(sources) {
1682
- if (vueDemi.isReactive(sources))
1540
+ if (vue.isReactive(sources))
1683
1541
  return sources;
1684
1542
  if (Array.isArray(sources))
1685
1543
  return sources.map((item) => toValue(item));
@@ -1690,12 +1548,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1690
1548
  }
1691
1549
 
1692
1550
  function whenever(source, cb, options) {
1693
- const stop = vueDemi.watch(
1551
+ const stop = vue.watch(
1694
1552
  source,
1695
1553
  (v, ov, onInvalidate) => {
1696
1554
  if (v) {
1697
1555
  if (options == null ? void 0 : options.once)
1698
- vueDemi.nextTick(() => stop());
1556
+ vue.nextTick(() => stop());
1699
1557
  cb(v, ov, onInvalidate);
1700
1558
  }
1701
1559
  },
@@ -1727,7 +1585,6 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1727
1585
  exports.debounceFilter = debounceFilter;
1728
1586
  exports.debouncedRef = refDebounced;
1729
1587
  exports.debouncedWatch = watchDebounced;
1730
- exports.directiveHooks = directiveHooks;
1731
1588
  exports.eagerComputed = computedEager;
1732
1589
  exports.extendRef = extendRef;
1733
1590
  exports.formatDate = formatDate;
@@ -1827,4 +1684,4 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1827
1684
  exports.watchWithFilter = watchWithFilter;
1828
1685
  exports.whenever = whenever;
1829
1686
 
1830
- })(this.VueUse = this.VueUse || {}, VueDemi);
1687
+ })(this.VueUse = this.VueUse || {}, Vue);