@vueuse/integrations 13.9.0 → 14.0.0-alpha.1

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.
Files changed (114) hide show
  1. package/dist/index.d.ts +473 -0
  2. package/dist/index.iife.js +772 -0
  3. package/dist/index.iife.min.js +1 -0
  4. package/dist/index.js +731 -0
  5. package/dist/useAsyncValidator/component.d.ts +19 -0
  6. package/dist/useAsyncValidator/component.js +20 -0
  7. package/dist/useAsyncValidator.d.ts +48 -0
  8. package/dist/useAsyncValidator.iife.js +99 -0
  9. package/dist/useAsyncValidator.iife.min.js +1 -0
  10. package/dist/useAsyncValidator.js +73 -0
  11. package/{useAxios.d.mts → dist/useAxios.d.ts} +86 -86
  12. package/dist/useAxios.iife.js +150 -0
  13. package/dist/useAxios.iife.min.js +1 -0
  14. package/dist/useAxios.js +124 -0
  15. package/{useChangeCase.d.mts → dist/useChangeCase.d.ts} +7 -9
  16. package/dist/useChangeCase.iife.js +61 -0
  17. package/dist/useChangeCase.iife.min.js +1 -0
  18. package/dist/useChangeCase.js +35 -0
  19. package/dist/useCookies.d.ts +64 -0
  20. package/dist/useCookies.iife.js +104 -0
  21. package/dist/useCookies.iife.min.js +1 -0
  22. package/dist/useCookies.js +77 -0
  23. package/dist/useDrauu.d.ts +33 -0
  24. package/dist/useDrauu.iife.js +146 -0
  25. package/dist/useDrauu.iife.min.js +1 -0
  26. package/dist/useDrauu.js +120 -0
  27. package/dist/useFocusTrap/component.d.ts +21 -0
  28. package/dist/useFocusTrap/component.js +17 -0
  29. package/dist/useFocusTrap.d.ts +55 -0
  30. package/dist/useFocusTrap.iife.js +97 -0
  31. package/dist/useFocusTrap.iife.min.js +1 -0
  32. package/dist/useFocusTrap.js +71 -0
  33. package/dist/useFuse.d.ts +33 -0
  34. package/dist/useFuse.iife.js +62 -0
  35. package/dist/useFuse.iife.min.js +1 -0
  36. package/dist/useFuse.js +36 -0
  37. package/dist/useIDBKeyval.d.ts +52 -0
  38. package/dist/useIDBKeyval.iife.js +93 -0
  39. package/dist/useIDBKeyval.iife.min.js +1 -0
  40. package/dist/useIDBKeyval.js +67 -0
  41. package/dist/useJwt.d.ts +28 -0
  42. package/dist/useJwt.iife.js +55 -0
  43. package/dist/useJwt.iife.min.js +1 -0
  44. package/dist/useJwt.js +29 -0
  45. package/dist/useNProgress.d.ts +21 -0
  46. package/dist/useNProgress.iife.js +66 -0
  47. package/dist/useNProgress.iife.min.js +1 -0
  48. package/dist/useNProgress.js +40 -0
  49. package/dist/useQRCode.d.ts +16 -0
  50. package/dist/useQRCode.iife.js +49 -0
  51. package/dist/useQRCode.iife.min.js +1 -0
  52. package/dist/useQRCode.js +23 -0
  53. package/dist/useSortable/component.d.ts +18 -0
  54. package/dist/useSortable/component.js +23 -0
  55. package/{useSortable.d.mts → dist/useSortable.d.ts} +20 -20
  56. package/dist/useSortable.iife.js +107 -0
  57. package/dist/useSortable.iife.min.js +1 -0
  58. package/dist/useSortable.js +78 -0
  59. package/package.json +27 -29
  60. package/index.d.mts +0 -458
  61. package/index.iife.js +0 -708
  62. package/index.iife.min.js +0 -1
  63. package/index.mjs +0 -685
  64. package/useAsyncValidator/component.d.mts +0 -27
  65. package/useAsyncValidator/component.mjs +0 -87
  66. package/useAsyncValidator.d.mts +0 -48
  67. package/useAsyncValidator.iife.js +0 -73
  68. package/useAsyncValidator.iife.min.js +0 -1
  69. package/useAsyncValidator.mjs +0 -72
  70. package/useAxios.iife.js +0 -124
  71. package/useAxios.iife.min.js +0 -1
  72. package/useAxios.mjs +0 -123
  73. package/useChangeCase.iife.js +0 -50
  74. package/useChangeCase.iife.min.js +0 -1
  75. package/useChangeCase.mjs +0 -29
  76. package/useCookies.d.mts +0 -56
  77. package/useCookies.iife.js +0 -64
  78. package/useCookies.iife.min.js +0 -1
  79. package/useCookies.mjs +0 -62
  80. package/useDrauu.d.mts +0 -33
  81. package/useDrauu.iife.js +0 -114
  82. package/useDrauu.iife.min.js +0 -1
  83. package/useDrauu.mjs +0 -114
  84. package/useFocusTrap/component.d.mts +0 -18
  85. package/useFocusTrap/component.mjs +0 -31
  86. package/useFocusTrap.d.mts +0 -55
  87. package/useFocusTrap.iife.js +0 -74
  88. package/useFocusTrap.iife.min.js +0 -1
  89. package/useFocusTrap.mjs +0 -74
  90. package/useFuse.d.mts +0 -33
  91. package/useFuse.iife.js +0 -45
  92. package/useFuse.iife.min.js +0 -1
  93. package/useFuse.mjs +0 -43
  94. package/useIDBKeyval.d.mts +0 -52
  95. package/useIDBKeyval.iife.js +0 -70
  96. package/useIDBKeyval.iife.min.js +0 -1
  97. package/useIDBKeyval.mjs +0 -69
  98. package/useJwt.d.mts +0 -28
  99. package/useJwt.iife.js +0 -27
  100. package/useJwt.iife.min.js +0 -1
  101. package/useJwt.mjs +0 -25
  102. package/useNProgress.d.mts +0 -21
  103. package/useNProgress.iife.js +0 -36
  104. package/useNProgress.iife.min.js +0 -1
  105. package/useNProgress.mjs +0 -35
  106. package/useQRCode.d.mts +0 -14
  107. package/useQRCode.iife.js +0 -20
  108. package/useQRCode.iife.min.js +0 -1
  109. package/useQRCode.mjs +0 -19
  110. package/useSortable/component.d.mts +0 -40
  111. package/useSortable/component.mjs +0 -89
  112. package/useSortable.iife.js +0 -66
  113. package/useSortable.iife.min.js +0 -1
  114. package/useSortable.mjs +0 -62
@@ -0,0 +1,124 @@
1
+ import { noop, until } from "@vueuse/shared";
2
+ import axios, { AxiosError } from "axios";
3
+ import { ref, shallowRef } from "vue";
4
+
5
+ //#region useAxios/index.ts
6
+ /**
7
+ * Wrapper for axios.
8
+ *
9
+ * @see https://vueuse.org/useAxios
10
+ */
11
+ function useAxios(...args) {
12
+ const url = typeof args[0] === "string" ? args[0] : void 0;
13
+ const argsPlaceholder = typeof url === "string" ? 1 : 0;
14
+ const defaultOptions = {
15
+ immediate: !!argsPlaceholder,
16
+ shallow: true,
17
+ abortPrevious: true
18
+ };
19
+ let defaultConfig = {};
20
+ let instance = axios;
21
+ let options = defaultOptions;
22
+ const isAxiosInstance = (val) => !!(val === null || val === void 0 ? void 0 : val.request);
23
+ if (args.length > 0 + argsPlaceholder)
24
+ /**
25
+ * Unable to use `instanceof` here because of (https://github.com/axios/axios/issues/737)
26
+ * so instead we are checking if there is a `request` on the object to see if it is an
27
+ * axios instance
28
+ */
29
+ if (isAxiosInstance(args[0 + argsPlaceholder])) instance = args[0 + argsPlaceholder];
30
+ else defaultConfig = args[0 + argsPlaceholder];
31
+ if (args.length > 1 + argsPlaceholder) {
32
+ if (isAxiosInstance(args[1 + argsPlaceholder])) instance = args[1 + argsPlaceholder];
33
+ }
34
+ if (args.length === 2 + argsPlaceholder && !isAxiosInstance(args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder) options = args[args.length - 1] || defaultOptions;
35
+ const { shallow, onSuccess = noop, onError = noop, immediate, resetOnExecute = false } = options;
36
+ const initialData = options.initialData;
37
+ const response = shallowRef();
38
+ const data = (shallow ? shallowRef : ref)(initialData);
39
+ const isFinished = shallowRef(false);
40
+ const isLoading = shallowRef(false);
41
+ const isAborted = shallowRef(false);
42
+ const error = shallowRef();
43
+ let abortController = new AbortController();
44
+ const abort = (message) => {
45
+ if (isFinished.value || !isLoading.value) return;
46
+ abortController.abort(message);
47
+ abortController = new AbortController();
48
+ isAborted.value = true;
49
+ isLoading.value = false;
50
+ isFinished.value = false;
51
+ };
52
+ const loading = (loading$1) => {
53
+ isLoading.value = loading$1;
54
+ isFinished.value = !loading$1;
55
+ };
56
+ /**
57
+ * Reset data to initialData
58
+ */
59
+ const resetData = () => {
60
+ if (resetOnExecute) data.value = initialData;
61
+ };
62
+ const waitUntilFinished = () => new Promise((resolve, reject) => {
63
+ until(isFinished).toBe(true).then(() => error.value ? reject(error.value) : resolve(result));
64
+ });
65
+ const promise = {
66
+ then: (...args$1) => waitUntilFinished().then(...args$1),
67
+ catch: (...args$1) => waitUntilFinished().catch(...args$1)
68
+ };
69
+ let executeCounter = 0;
70
+ const execute = (executeUrl = url, config = {}) => {
71
+ error.value = void 0;
72
+ const _url = typeof executeUrl === "string" ? executeUrl : url !== null && url !== void 0 ? url : config.url;
73
+ if (_url === void 0) {
74
+ error.value = new AxiosError(AxiosError.ERR_INVALID_URL);
75
+ isFinished.value = true;
76
+ return promise;
77
+ }
78
+ resetData();
79
+ if (options.abortPrevious !== false) abort();
80
+ loading(true);
81
+ executeCounter += 1;
82
+ const currentExecuteCounter = executeCounter;
83
+ isAborted.value = false;
84
+ instance(_url, {
85
+ ...defaultConfig,
86
+ ...typeof executeUrl === "object" ? executeUrl : config,
87
+ signal: abortController.signal
88
+ }).then((r) => {
89
+ if (isAborted.value) return;
90
+ response.value = r;
91
+ const result$1 = r.data;
92
+ data.value = result$1;
93
+ onSuccess(result$1);
94
+ }).catch((e) => {
95
+ error.value = e;
96
+ onError(e);
97
+ }).finally(() => {
98
+ var _options$onFinish;
99
+ (_options$onFinish = options.onFinish) === null || _options$onFinish === void 0 || _options$onFinish.call(options);
100
+ if (currentExecuteCounter === executeCounter) loading(false);
101
+ });
102
+ return promise;
103
+ };
104
+ if (immediate && url) execute();
105
+ const result = {
106
+ response,
107
+ data,
108
+ error,
109
+ isFinished,
110
+ isLoading,
111
+ cancel: abort,
112
+ isAborted,
113
+ isCanceled: isAborted,
114
+ abort,
115
+ execute
116
+ };
117
+ return {
118
+ ...result,
119
+ ...promise
120
+ };
121
+ }
122
+
123
+ //#endregion
124
+ export { useAxios };
@@ -1,15 +1,13 @@
1
- import * as changeCase from 'change-case';
2
- import { Options } from 'change-case';
3
- import { MaybeRef, MaybeRefOrGetter, WritableComputedRef, ComputedRef } from 'vue';
1
+ import * as changeCase from "change-case";
2
+ import { Options } from "change-case";
3
+ import { ComputedRef, MaybeRef, MaybeRefOrGetter, WritableComputedRef } from "vue";
4
4
 
5
+ //#region useChangeCase/index.d.ts
5
6
  type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
6
- type FilterKeys<T> = {
7
- [K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
8
- };
7
+ type FilterKeys<T> = { [K in keyof T as K extends string ? K : never]: EndsWithCase<K> };
9
8
  type ChangeCaseKeys = FilterKeys<typeof changeCase>;
10
9
  type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
11
10
  declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
12
11
  declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
13
-
14
- export { useChangeCase };
15
- export type { ChangeCaseType };
12
+ //#endregion
13
+ export { ChangeCaseType, useChangeCase };
@@ -0,0 +1,61 @@
1
+ (function(exports, change_case, vue) {
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+
25
+ //#endregion
26
+ change_case = __toESM(change_case);
27
+ vue = __toESM(vue);
28
+
29
+ //#region useChangeCase/index.ts
30
+ const changeCaseTransforms = /* @__PURE__ */ Object.entries(change_case).filter(([name, fn]) => typeof fn === "function" && name.endsWith("Case")).reduce((acc, [name, fn]) => {
31
+ acc[name] = fn;
32
+ return acc;
33
+ }, {});
34
+ /**
35
+ * Reactive wrapper for `change-case`
36
+ *
37
+ * @see https://vueuse.org/useChangeCase
38
+ *
39
+ * @__NO_SIDE_EFFECTS__
40
+ */
41
+ function useChangeCase(input, type, options) {
42
+ const typeRef = (0, vue.computed)(() => {
43
+ const t = (0, vue.toValue)(type);
44
+ if (!changeCaseTransforms[t]) throw new Error(`Invalid change case type "${t}"`);
45
+ return t;
46
+ });
47
+ if (typeof input === "function") return (0, vue.computed)(() => changeCaseTransforms[typeRef.value]((0, vue.toValue)(input), (0, vue.toValue)(options)));
48
+ const text = (0, vue.ref)(input);
49
+ return (0, vue.computed)({
50
+ get() {
51
+ return changeCaseTransforms[typeRef.value](text.value, (0, vue.toValue)(options));
52
+ },
53
+ set(value) {
54
+ text.value = value;
55
+ }
56
+ });
57
+ }
58
+
59
+ //#endregion
60
+ exports.useChangeCase = useChangeCase;
61
+ })(this.VueUse = this.VueUse || {}, changeCase, Vue);
@@ -0,0 +1 @@
1
+ (function(exports,t,n){var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e));t=u(t),n=u(n);let d=Object.entries(t).filter(([e,t])=>typeof t==`function`&&e.endsWith(`Case`)).reduce((e,[t,n])=>(e[t]=n,e),{});function f(e,t,r){let i=(0,n.computed)(()=>{let e=(0,n.toValue)(t);if(!d[e])throw Error(`Invalid change case type "${e}"`);return e});if(typeof e==`function`)return(0,n.computed)(()=>d[i.value]((0,n.toValue)(e),(0,n.toValue)(r)));let a=(0,n.ref)(e);return(0,n.computed)({get(){return d[i.value](a.value,(0,n.toValue)(r))},set(e){a.value=e}})}exports.useChangeCase=f})(this.VueUse=this.VueUse||{},changeCase,Vue);
@@ -0,0 +1,35 @@
1
+ import * as changeCase from "change-case";
2
+ import { computed, ref, toValue } from "vue";
3
+
4
+ //#region useChangeCase/index.ts
5
+ const changeCaseTransforms = /* @__PURE__ */ Object.entries(changeCase).filter(([name, fn]) => typeof fn === "function" && name.endsWith("Case")).reduce((acc, [name, fn]) => {
6
+ acc[name] = fn;
7
+ return acc;
8
+ }, {});
9
+ /**
10
+ * Reactive wrapper for `change-case`
11
+ *
12
+ * @see https://vueuse.org/useChangeCase
13
+ *
14
+ * @__NO_SIDE_EFFECTS__
15
+ */
16
+ function useChangeCase(input, type, options) {
17
+ const typeRef = computed(() => {
18
+ const t = toValue(type);
19
+ if (!changeCaseTransforms[t]) throw new Error(`Invalid change case type "${t}"`);
20
+ return t;
21
+ });
22
+ if (typeof input === "function") return computed(() => changeCaseTransforms[typeRef.value](toValue(input), toValue(options)));
23
+ const text = ref(input);
24
+ return computed({
25
+ get() {
26
+ return changeCaseTransforms[typeRef.value](text.value, toValue(options));
27
+ },
28
+ set(value) {
29
+ text.value = value;
30
+ }
31
+ });
32
+ }
33
+
34
+ //#endregion
35
+ export { useChangeCase };
@@ -0,0 +1,64 @@
1
+ import * as universal_cookie0 from "universal-cookie";
2
+ import Cookie from "universal-cookie";
3
+ import { IncomingMessage } from "node:http";
4
+
5
+ //#region useCookies/index.d.ts
6
+
7
+ /**
8
+ * Creates a new {@link useCookies} function
9
+ * @param req - incoming http request (for SSR)
10
+ * @see https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie universal-cookie
11
+ * @description Creates universal-cookie instance using request (default is window.document.cookie) and returns {@link useCookies} function with provided universal-cookie instance
12
+ */
13
+ declare function createCookies(req?: IncomingMessage): (dependencies?: string[] | null, {
14
+ doNotParse,
15
+ autoUpdateDependencies
16
+ }?: {
17
+ doNotParse?: boolean | undefined;
18
+ autoUpdateDependencies?: boolean | undefined;
19
+ }) => {
20
+ /**
21
+ * Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
22
+ */
23
+ get: <T = any>(name: string, options?: universal_cookie0.CookieGetOptions | undefined) => T;
24
+ /**
25
+ * Reactive get all cookies
26
+ */
27
+ getAll: <T = any>(options?: universal_cookie0.CookieGetOptions | undefined) => T;
28
+ set: (name: string, value: any, options?: universal_cookie0.CookieSetOptions | undefined) => void;
29
+ remove: (name: string, options?: universal_cookie0.CookieSetOptions | undefined) => void;
30
+ addChangeListener: (callback: universal_cookie0.CookieChangeListener) => void;
31
+ removeChangeListener: (callback: universal_cookie0.CookieChangeListener) => void;
32
+ };
33
+ /**
34
+ * Reactive methods to work with cookies (use {@link createCookies} method instead if you are using SSR)
35
+ * @param dependencies - array of watching cookie's names. Pass empty array if don't want to watch cookies changes.
36
+ * @param options
37
+ * @param options.doNotParse - don't try parse value as JSON
38
+ * @param options.autoUpdateDependencies - automatically update watching dependencies
39
+ * @param cookies - universal-cookie instance
40
+ *
41
+ * @__NO_SIDE_EFFECTS__
42
+ */
43
+ declare function useCookies(dependencies?: string[] | null, {
44
+ doNotParse,
45
+ autoUpdateDependencies
46
+ }?: {
47
+ doNotParse?: boolean | undefined;
48
+ autoUpdateDependencies?: boolean | undefined;
49
+ }, cookies?: Cookie): {
50
+ /**
51
+ * Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
52
+ */
53
+ get: <T = any>(name: string, options?: universal_cookie0.CookieGetOptions | undefined) => T;
54
+ /**
55
+ * Reactive get all cookies
56
+ */
57
+ getAll: <T = any>(options?: universal_cookie0.CookieGetOptions | undefined) => T;
58
+ set: (name: string, value: any, options?: universal_cookie0.CookieSetOptions | undefined) => void;
59
+ remove: (name: string, options?: universal_cookie0.CookieSetOptions | undefined) => void;
60
+ addChangeListener: (callback: universal_cookie0.CookieChangeListener) => void;
61
+ removeChangeListener: (callback: universal_cookie0.CookieChangeListener) => void;
62
+ };
63
+ //#endregion
64
+ export { createCookies, useCookies };
@@ -0,0 +1,104 @@
1
+ (function(exports, __vueuse_shared, universal_cookie, vue) {
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+
25
+ //#endregion
26
+ __vueuse_shared = __toESM(__vueuse_shared);
27
+ universal_cookie = __toESM(universal_cookie);
28
+ vue = __toESM(vue);
29
+
30
+ //#region useCookies/index.ts
31
+ /**
32
+ * Creates a new {@link useCookies} function
33
+ * @param req - incoming http request (for SSR)
34
+ * @see https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie universal-cookie
35
+ * @description Creates universal-cookie instance using request (default is window.document.cookie) and returns {@link useCookies} function with provided universal-cookie instance
36
+ */
37
+ function createCookies(req) {
38
+ const universalCookie = new universal_cookie.default(req ? req.headers.cookie : null);
39
+ return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, {
40
+ doNotParse,
41
+ autoUpdateDependencies
42
+ }, universalCookie);
43
+ }
44
+ /**
45
+ * Reactive methods to work with cookies (use {@link createCookies} method instead if you are using SSR)
46
+ * @param dependencies - array of watching cookie's names. Pass empty array if don't want to watch cookies changes.
47
+ * @param options
48
+ * @param options.doNotParse - don't try parse value as JSON
49
+ * @param options.autoUpdateDependencies - automatically update watching dependencies
50
+ * @param cookies - universal-cookie instance
51
+ *
52
+ * @__NO_SIDE_EFFECTS__
53
+ */
54
+ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new universal_cookie.default()) {
55
+ const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
56
+ let previousCookies = cookies.getAll({ doNotParse: true });
57
+ /**
58
+ * Adds reactivity to get/getAll methods
59
+ */
60
+ const touches = (0, vue.shallowRef)(0);
61
+ const onChange = () => {
62
+ const newCookies = cookies.getAll({ doNotParse: true });
63
+ if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies)) touches.value++;
64
+ previousCookies = newCookies;
65
+ };
66
+ cookies.addChangeListener(onChange);
67
+ (0, __vueuse_shared.tryOnScopeDispose)(() => {
68
+ cookies.removeChangeListener(onChange);
69
+ });
70
+ return {
71
+ get: (...args) => {
72
+ /**
73
+ * Auto update watching dependencies if needed
74
+ */
75
+ if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0])) watchingDependencies.push(args[0]);
76
+ touches.value;
77
+ return cookies.get(args[0], {
78
+ doNotParse,
79
+ ...args[1]
80
+ });
81
+ },
82
+ getAll: (...args) => {
83
+ touches.value;
84
+ return cookies.getAll({
85
+ doNotParse,
86
+ ...args[0]
87
+ });
88
+ },
89
+ set: (...args) => cookies.set(...args),
90
+ remove: (...args) => cookies.remove(...args),
91
+ addChangeListener: (...args) => cookies.addChangeListener(...args),
92
+ removeChangeListener: (...args) => cookies.removeChangeListener(...args)
93
+ };
94
+ }
95
+ function shouldUpdate(dependencies, newCookies, oldCookies) {
96
+ if (!dependencies) return true;
97
+ for (const dependency of dependencies) if (newCookies[dependency] !== oldCookies[dependency]) return true;
98
+ return false;
99
+ }
100
+
101
+ //#endregion
102
+ exports.createCookies = createCookies;
103
+ exports.useCookies = useCookies;
104
+ })(this.VueUse = this.VueUse || {}, VueUse, UniversalCookie, Vue);
@@ -0,0 +1 @@
1
+ (function(exports,t,n,r){var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:i(c(e)),u(t||!e||!e.__esModule?a(n,`default`,{value:e,enumerable:!0}):n,e));t=d(t),n=d(n),r=d(r);function f(e){let t=new n.default(e?e.headers.cookie:null);return(e,{doNotParse:n=!1,autoUpdateDependencies:r=!1}={})=>p(e,{doNotParse:n,autoUpdateDependencies:r},t)}function p(e,{doNotParse:i=!1,autoUpdateDependencies:a=!1}={},o=new n.default){let s=a?[...e||[]]:e,c=o.getAll({doNotParse:!0}),l=(0,r.shallowRef)(0),u=()=>{let e=o.getAll({doNotParse:!0});m(s||null,e,c)&&l.value++,c=e};return o.addChangeListener(u),(0,t.tryOnScopeDispose)(()=>{o.removeChangeListener(u)}),{get:(...e)=>(a&&s&&!s.includes(e[0])&&s.push(e[0]),l.value,o.get(e[0],{doNotParse:i,...e[1]})),getAll:(...e)=>(l.value,o.getAll({doNotParse:i,...e[0]})),set:(...e)=>o.set(...e),remove:(...e)=>o.remove(...e),addChangeListener:(...e)=>o.addChangeListener(...e),removeChangeListener:(...e)=>o.removeChangeListener(...e)}}function m(e,t,n){if(!e)return!0;for(let r of e)if(t[r]!==n[r])return!0;return!1}exports.createCookies=f,exports.useCookies=p})(this.VueUse=this.VueUse||{},VueUse,UniversalCookie,Vue);
@@ -0,0 +1,77 @@
1
+ import { tryOnScopeDispose } from "@vueuse/shared";
2
+ import Cookie from "universal-cookie";
3
+ import { shallowRef } from "vue";
4
+
5
+ //#region useCookies/index.ts
6
+ /**
7
+ * Creates a new {@link useCookies} function
8
+ * @param req - incoming http request (for SSR)
9
+ * @see https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie universal-cookie
10
+ * @description Creates universal-cookie instance using request (default is window.document.cookie) and returns {@link useCookies} function with provided universal-cookie instance
11
+ */
12
+ function createCookies(req) {
13
+ const universalCookie = new Cookie(req ? req.headers.cookie : null);
14
+ return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, {
15
+ doNotParse,
16
+ autoUpdateDependencies
17
+ }, universalCookie);
18
+ }
19
+ /**
20
+ * Reactive methods to work with cookies (use {@link createCookies} method instead if you are using SSR)
21
+ * @param dependencies - array of watching cookie's names. Pass empty array if don't want to watch cookies changes.
22
+ * @param options
23
+ * @param options.doNotParse - don't try parse value as JSON
24
+ * @param options.autoUpdateDependencies - automatically update watching dependencies
25
+ * @param cookies - universal-cookie instance
26
+ *
27
+ * @__NO_SIDE_EFFECTS__
28
+ */
29
+ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
30
+ const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
31
+ let previousCookies = cookies.getAll({ doNotParse: true });
32
+ /**
33
+ * Adds reactivity to get/getAll methods
34
+ */
35
+ const touches = shallowRef(0);
36
+ const onChange = () => {
37
+ const newCookies = cookies.getAll({ doNotParse: true });
38
+ if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies)) touches.value++;
39
+ previousCookies = newCookies;
40
+ };
41
+ cookies.addChangeListener(onChange);
42
+ tryOnScopeDispose(() => {
43
+ cookies.removeChangeListener(onChange);
44
+ });
45
+ return {
46
+ get: (...args) => {
47
+ /**
48
+ * Auto update watching dependencies if needed
49
+ */
50
+ if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0])) watchingDependencies.push(args[0]);
51
+ touches.value;
52
+ return cookies.get(args[0], {
53
+ doNotParse,
54
+ ...args[1]
55
+ });
56
+ },
57
+ getAll: (...args) => {
58
+ touches.value;
59
+ return cookies.getAll({
60
+ doNotParse,
61
+ ...args[0]
62
+ });
63
+ },
64
+ set: (...args) => cookies.set(...args),
65
+ remove: (...args) => cookies.remove(...args),
66
+ addChangeListener: (...args) => cookies.addChangeListener(...args),
67
+ removeChangeListener: (...args) => cookies.removeChangeListener(...args)
68
+ };
69
+ }
70
+ function shouldUpdate(dependencies, newCookies, oldCookies) {
71
+ if (!dependencies) return true;
72
+ for (const dependency of dependencies) if (newCookies[dependency] !== oldCookies[dependency]) return true;
73
+ return false;
74
+ }
75
+
76
+ //#endregion
77
+ export { createCookies, useCookies };
@@ -0,0 +1,33 @@
1
+ import { EventHookOn, MaybeComputedElementRef } from "@vueuse/core";
2
+ import { Brush, Drauu, Options } from "drauu";
3
+ import { Ref, ShallowRef } from "vue";
4
+
5
+ //#region useDrauu/index.d.ts
6
+ type UseDrauuOptions = Omit<Options, 'el'>;
7
+ interface UseDrauuReturn {
8
+ drauuInstance: Ref<Drauu | undefined>;
9
+ load: (svg: string) => void;
10
+ dump: () => string | undefined;
11
+ clear: () => void;
12
+ cancel: () => void;
13
+ undo: () => boolean | undefined;
14
+ redo: () => boolean | undefined;
15
+ canUndo: ShallowRef<boolean>;
16
+ canRedo: ShallowRef<boolean>;
17
+ brush: Ref<Brush>;
18
+ onChanged: EventHookOn;
19
+ onCommitted: EventHookOn;
20
+ onStart: EventHookOn;
21
+ onEnd: EventHookOn;
22
+ onCanceled: EventHookOn;
23
+ }
24
+ /**
25
+ * Reactive drauu
26
+ *
27
+ * @see https://vueuse.org/useDrauu
28
+ * @param target The target svg element
29
+ * @param options Drauu Options
30
+ */
31
+ declare function useDrauu(target: MaybeComputedElementRef, options?: UseDrauuOptions): UseDrauuReturn;
32
+ //#endregion
33
+ export { UseDrauuOptions, UseDrauuReturn, useDrauu };
@@ -0,0 +1,146 @@
1
+ (function(exports, __vueuse_core, __vueuse_shared, drauu, vue) {
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+
25
+ //#endregion
26
+ __vueuse_core = __toESM(__vueuse_core);
27
+ __vueuse_shared = __toESM(__vueuse_shared);
28
+ drauu = __toESM(drauu);
29
+ vue = __toESM(vue);
30
+
31
+ //#region useDrauu/index.ts
32
+ /**
33
+ * Reactive drauu
34
+ *
35
+ * @see https://vueuse.org/useDrauu
36
+ * @param target The target svg element
37
+ * @param options Drauu Options
38
+ */
39
+ function useDrauu(target, options) {
40
+ const drauuInstance = (0, vue.ref)();
41
+ let disposables = [];
42
+ const onChangedHook = (0, __vueuse_core.createEventHook)();
43
+ const onCanceledHook = (0, __vueuse_core.createEventHook)();
44
+ const onCommittedHook = (0, __vueuse_core.createEventHook)();
45
+ const onStartHook = (0, __vueuse_core.createEventHook)();
46
+ const onEndHook = (0, __vueuse_core.createEventHook)();
47
+ const canUndo = (0, vue.shallowRef)(false);
48
+ const canRedo = (0, vue.shallowRef)(false);
49
+ const altPressed = (0, vue.shallowRef)(false);
50
+ const shiftPressed = (0, vue.shallowRef)(false);
51
+ const brush = (0, vue.ref)({
52
+ color: "black",
53
+ size: 3,
54
+ arrowEnd: false,
55
+ cornerRadius: 0,
56
+ dasharray: void 0,
57
+ fill: "transparent",
58
+ mode: "draw",
59
+ ...options === null || options === void 0 ? void 0 : options.brush
60
+ });
61
+ (0, vue.watch)(brush, () => {
62
+ const instance = drauuInstance.value;
63
+ if (instance) {
64
+ instance.brush = brush.value;
65
+ instance.mode = brush.value.mode;
66
+ }
67
+ }, { deep: true });
68
+ const undo = () => {
69
+ var _drauuInstance$value;
70
+ return (_drauuInstance$value = drauuInstance.value) === null || _drauuInstance$value === void 0 ? void 0 : _drauuInstance$value.undo();
71
+ };
72
+ const redo = () => {
73
+ var _drauuInstance$value2;
74
+ return (_drauuInstance$value2 = drauuInstance.value) === null || _drauuInstance$value2 === void 0 ? void 0 : _drauuInstance$value2.redo();
75
+ };
76
+ const clear = () => {
77
+ var _drauuInstance$value3;
78
+ return (_drauuInstance$value3 = drauuInstance.value) === null || _drauuInstance$value3 === void 0 ? void 0 : _drauuInstance$value3.clear();
79
+ };
80
+ const cancel = () => {
81
+ var _drauuInstance$value4;
82
+ return (_drauuInstance$value4 = drauuInstance.value) === null || _drauuInstance$value4 === void 0 ? void 0 : _drauuInstance$value4.cancel();
83
+ };
84
+ const load = (svg) => {
85
+ var _drauuInstance$value5;
86
+ return (_drauuInstance$value5 = drauuInstance.value) === null || _drauuInstance$value5 === void 0 ? void 0 : _drauuInstance$value5.load(svg);
87
+ };
88
+ const dump = () => {
89
+ var _drauuInstance$value6;
90
+ return (_drauuInstance$value6 = drauuInstance.value) === null || _drauuInstance$value6 === void 0 ? void 0 : _drauuInstance$value6.dump();
91
+ };
92
+ const cleanup = () => {
93
+ var _drauuInstance$value7;
94
+ disposables.forEach((dispose) => dispose());
95
+ (_drauuInstance$value7 = drauuInstance.value) === null || _drauuInstance$value7 === void 0 || _drauuInstance$value7.unmount();
96
+ };
97
+ const syncStatus = () => {
98
+ if (drauuInstance.value) {
99
+ canUndo.value = drauuInstance.value.canUndo();
100
+ canRedo.value = drauuInstance.value.canRedo();
101
+ altPressed.value = drauuInstance.value.altPressed;
102
+ shiftPressed.value = drauuInstance.value.shiftPressed;
103
+ }
104
+ };
105
+ (0, vue.watch)(() => (0, __vueuse_core.unrefElement)(target), (el) => {
106
+ if (!el || typeof SVGSVGElement === "undefined" || !(el instanceof SVGSVGElement)) return;
107
+ if (drauuInstance.value) cleanup();
108
+ drauuInstance.value = (0, drauu.createDrauu)({
109
+ el,
110
+ ...options
111
+ });
112
+ syncStatus();
113
+ disposables = [
114
+ drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
115
+ drauuInstance.value.on("committed", (node) => onCommittedHook.trigger(node)),
116
+ drauuInstance.value.on("start", () => onStartHook.trigger()),
117
+ drauuInstance.value.on("end", () => onEndHook.trigger()),
118
+ drauuInstance.value.on("changed", () => {
119
+ syncStatus();
120
+ onChangedHook.trigger();
121
+ })
122
+ ];
123
+ }, { flush: "post" });
124
+ (0, __vueuse_shared.tryOnScopeDispose)(() => cleanup());
125
+ return {
126
+ drauuInstance,
127
+ load,
128
+ dump,
129
+ clear,
130
+ cancel,
131
+ undo,
132
+ redo,
133
+ canUndo,
134
+ canRedo,
135
+ brush,
136
+ onChanged: onChangedHook.on,
137
+ onCommitted: onCommittedHook.on,
138
+ onStart: onStartHook.on,
139
+ onEnd: onEndHook.on,
140
+ onCanceled: onCanceledHook.on
141
+ };
142
+ }
143
+
144
+ //#endregion
145
+ exports.useDrauu = useDrauu;
146
+ })(this.VueUse = this.VueUse || {}, VueUse, VueUse, Drauu, Vue);