@vueuse/integrations 6.3.2 → 6.5.3

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,337 +1,402 @@
1
- import { shallowRef, ref, unref, watch, computed, isRef, watchEffect } from 'vue-demi';
1
+ import { shallowRef, ref, watch, computed, isRef, watchEffect } from 'vue-demi';
2
2
  import axios from 'axios';
3
3
  import { tryOnScopeDispose, isNumber, isClient } from '@vueuse/shared';
4
4
  import Cookie from 'universal-cookie';
5
+ import { createDrauu } from 'drauu';
6
+ import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1 } from '@vueuse/core';
5
7
  import { createFocusTrap } from 'focus-trap';
6
8
  import jwt_decode from 'jwt-decode';
7
9
  import nprogress from 'nprogress';
8
10
  import QRCode from 'qrcode';
9
11
 
10
- /**
11
- * Wrapper for axios.
12
- *
13
- * @see https://vueuse.org/useAxios
14
- * @param url
15
- * @param config
16
- */
17
- function useAxios(url, ...args) {
18
- let config = {};
19
- let instance = axios;
20
- if (args.length > 0) {
21
- /**
22
- * Unable to use `instanceof` here becuase of (https://github.com/axios/axios/issues/737)
23
- * so instead we are checking if there is a `requset` on the object to see if it is an
24
- * axios instance
25
- */
26
- if ('request' in args[0])
27
- instance = args[0];
28
- else
29
- config = args[0];
30
- }
31
- if (args.length > 1) {
32
- if ('request' in args[1])
33
- instance = args[1];
34
- }
35
- const response = shallowRef();
36
- const data = shallowRef();
37
- const isFinished = ref(false);
38
- const isLoading = ref(true);
39
- const aborted = ref(false);
40
- const error = shallowRef();
41
- const cancelToken = axios.CancelToken.source();
42
- const abort = (message) => {
43
- if (isFinished.value || !isLoading.value)
44
- return;
45
- cancelToken.cancel(message);
46
- aborted.value = true;
47
- isLoading.value = false;
48
- isFinished.value = false;
49
- };
50
- instance(url, Object.assign(Object.assign({}, config), { cancelToken: cancelToken.token }))
51
- .then((r) => {
52
- response.value = r;
53
- data.value = r.data;
54
- })
55
- .catch((e) => {
56
- error.value = e;
57
- })
58
- .finally(() => {
59
- isLoading.value = false;
60
- isFinished.value = true;
61
- });
62
- return {
63
- response,
64
- data,
65
- error,
66
- finished: isFinished,
67
- loading: isLoading,
68
- isFinished,
69
- isLoading,
70
- cancel: abort,
71
- canceled: aborted,
72
- aborted,
73
- abort,
74
- };
12
+ var __defProp$3 = Object.defineProperty;
13
+ var __defProps$1 = Object.defineProperties;
14
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
15
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
16
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
17
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
18
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19
+ var __spreadValues$3 = (a, b) => {
20
+ for (var prop in b || (b = {}))
21
+ if (__hasOwnProp$3.call(b, prop))
22
+ __defNormalProp$3(a, prop, b[prop]);
23
+ if (__getOwnPropSymbols$3)
24
+ for (var prop of __getOwnPropSymbols$3(b)) {
25
+ if (__propIsEnum$3.call(b, prop))
26
+ __defNormalProp$3(a, prop, b[prop]);
27
+ }
28
+ return a;
29
+ };
30
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
31
+ function useAxios(url, ...args) {
32
+ let config = {};
33
+ let instance = axios;
34
+ if (args.length > 0) {
35
+ if ("request" in args[0])
36
+ instance = args[0];
37
+ else
38
+ config = args[0];
39
+ }
40
+ if (args.length > 1) {
41
+ if ("request" in args[1])
42
+ instance = args[1];
43
+ }
44
+ const response = shallowRef();
45
+ const data = shallowRef();
46
+ const isFinished = ref(false);
47
+ const isLoading = ref(true);
48
+ const aborted = ref(false);
49
+ const error = shallowRef();
50
+ const cancelToken = axios.CancelToken.source();
51
+ const abort = (message) => {
52
+ if (isFinished.value || !isLoading.value)
53
+ return;
54
+ cancelToken.cancel(message);
55
+ aborted.value = true;
56
+ isLoading.value = false;
57
+ isFinished.value = false;
58
+ };
59
+ instance(url, __spreadProps$1(__spreadValues$3({}, config), { cancelToken: cancelToken.token })).then((r) => {
60
+ response.value = r;
61
+ data.value = r.data;
62
+ }).catch((e) => {
63
+ error.value = e;
64
+ }).finally(() => {
65
+ isLoading.value = false;
66
+ isFinished.value = true;
67
+ });
68
+ return {
69
+ response,
70
+ data,
71
+ error,
72
+ finished: isFinished,
73
+ loading: isLoading,
74
+ isFinished,
75
+ isLoading,
76
+ cancel: abort,
77
+ canceled: aborted,
78
+ aborted,
79
+ abort
80
+ };
75
81
  }
76
82
 
77
- /**
78
- * Creates a new {@link useCookies} function
79
- * @param {Object} req - incoming http request (for SSR)
80
- * @see https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie universal-cookie
81
- * @description Creates universal-cookie instance using request (default is window.document.cookie) and returns {@link useCookies} function with provided universal-cookie instance
82
- */
83
- function createCookies(req) {
84
- const universalCookie = new Cookie(req ? req.headers.cookie : null);
85
- return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
86
- }
87
- /**
88
- * Reactive methods to work with cookies (use {@link createCookies} method instead if you are using SSR)
89
- * @param {string[]|null|undefined} dependencies - array of watching cookie's names. Pass empty array if don't want to watch cookies changes.
90
- * @param {Object} options
91
- * @param {boolean} options.doNotParse - don't try parse value as JSON
92
- * @param {boolean} options.autoUpdateDependencies - automatically update watching dependencies
93
- * @param {Object} cookies - universal-cookie instance
94
- */
95
- function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
96
- const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
97
- let previousCookies = cookies.getAll({ doNotParse: true });
98
- /**
99
- * Adds reactivity to get/getAll methods
100
- */
101
- const touches = ref(0);
102
- const onChange = () => {
103
- const newCookies = cookies.getAll({ doNotParse: true });
104
- if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
105
- touches.value++;
106
- previousCookies = newCookies;
107
- };
108
- cookies.addChangeListener(onChange);
109
- tryOnScopeDispose(() => {
110
- cookies.removeChangeListener(onChange);
111
- });
112
- return {
113
- /**
114
- * Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
115
- */
116
- get: (...args) => {
117
- /**
118
- * Auto update watching dependencies if needed
119
- */
120
- if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
121
- watchingDependencies.push(args[0]);
122
- // eslint-disable-next-line no-unused-expressions
123
- touches.value; // adds reactivity to method
124
- return cookies.get(args[0], Object.assign({ doNotParse }, args[1]));
125
- },
126
- /**
127
- * Reactive get all cookies
128
- */
129
- getAll: (...args) => {
130
- // eslint-disable-next-line no-unused-expressions
131
- touches.value; // adds reactivity to method
132
- return cookies.getAll(Object.assign({ doNotParse }, args[0]));
133
- },
134
- set: (...args) => cookies.set(...args),
135
- remove: (...args) => cookies.remove(...args),
136
- addChangeListener: (...args) => cookies.addChangeListener(...args),
137
- removeChangeListener: (...args) => cookies.removeChangeListener(...args),
138
- };
139
- }
140
- function shouldUpdate(dependencies, newCookies, oldCookies) {
141
- if (!dependencies)
142
- return true;
143
- for (const dependency of dependencies) {
144
- if (newCookies[dependency] !== oldCookies[dependency])
145
- return true;
146
- }
147
- return false;
83
+ var __defProp$2 = Object.defineProperty;
84
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
85
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
86
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
87
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
88
+ var __spreadValues$2 = (a, b) => {
89
+ for (var prop in b || (b = {}))
90
+ if (__hasOwnProp$2.call(b, prop))
91
+ __defNormalProp$2(a, prop, b[prop]);
92
+ if (__getOwnPropSymbols$2)
93
+ for (var prop of __getOwnPropSymbols$2(b)) {
94
+ if (__propIsEnum$2.call(b, prop))
95
+ __defNormalProp$2(a, prop, b[prop]);
96
+ }
97
+ return a;
98
+ };
99
+ function createCookies(req) {
100
+ const universalCookie = new Cookie(req ? req.headers.cookie : null);
101
+ return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
148
102
  }
149
-
150
- /*! *****************************************************************************
151
- Copyright (c) Microsoft Corporation.
152
-
153
- Permission to use, copy, modify, and/or distribute this software for any
154
- purpose with or without fee is hereby granted.
155
-
156
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
157
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
158
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
159
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
160
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
161
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
162
- PERFORMANCE OF THIS SOFTWARE.
163
- ***************************************************************************** */
164
-
165
- function __rest(s, e) {
166
- var t = {};
167
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
168
- t[p] = s[p];
169
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
170
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
171
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
172
- t[p[i]] = s[p[i]];
173
- }
174
- return t;
103
+ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
104
+ const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
105
+ let previousCookies = cookies.getAll({ doNotParse: true });
106
+ const touches = ref(0);
107
+ const onChange = () => {
108
+ const newCookies = cookies.getAll({ doNotParse: true });
109
+ if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
110
+ touches.value++;
111
+ previousCookies = newCookies;
112
+ };
113
+ cookies.addChangeListener(onChange);
114
+ tryOnScopeDispose(() => {
115
+ cookies.removeChangeListener(onChange);
116
+ });
117
+ return {
118
+ get: (...args) => {
119
+ if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
120
+ watchingDependencies.push(args[0]);
121
+ touches.value;
122
+ return cookies.get(args[0], __spreadValues$2({ doNotParse }, args[1]));
123
+ },
124
+ getAll: (...args) => {
125
+ touches.value;
126
+ return cookies.getAll(__spreadValues$2({ doNotParse }, args[0]));
127
+ },
128
+ set: (...args) => cookies.set(...args),
129
+ remove: (...args) => cookies.remove(...args),
130
+ addChangeListener: (...args) => cookies.addChangeListener(...args),
131
+ removeChangeListener: (...args) => cookies.removeChangeListener(...args)
132
+ };
175
133
  }
176
-
177
- /**
178
- * Get the dom element of a ref of element or Vue component instance
179
- *
180
- * @param elRef
181
- */
182
- function unrefElement(elRef) {
183
- var _a, _b;
184
- const plain = unref(elRef);
185
- return (_b = (_a = plain) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : plain;
134
+ function shouldUpdate(dependencies, newCookies, oldCookies) {
135
+ if (!dependencies)
136
+ return true;
137
+ for (const dependency of dependencies) {
138
+ if (newCookies[dependency] !== oldCookies[dependency])
139
+ return true;
140
+ }
141
+ return false;
186
142
  }
187
143
 
188
- var SwipeDirection;
189
- (function (SwipeDirection) {
190
- SwipeDirection["UP"] = "UP";
191
- SwipeDirection["RIGHT"] = "RIGHT";
192
- SwipeDirection["DOWN"] = "DOWN";
193
- SwipeDirection["LEFT"] = "LEFT";
194
- SwipeDirection["NONE"] = "NONE";
195
- })(SwipeDirection || (SwipeDirection = {}));
144
+ var __defProp$1 = Object.defineProperty;
145
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
146
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
147
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
148
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
149
+ var __spreadValues$1 = (a, b) => {
150
+ for (var prop in b || (b = {}))
151
+ if (__hasOwnProp$1.call(b, prop))
152
+ __defNormalProp$1(a, prop, b[prop]);
153
+ if (__getOwnPropSymbols$1)
154
+ for (var prop of __getOwnPropSymbols$1(b)) {
155
+ if (__propIsEnum$1.call(b, prop))
156
+ __defNormalProp$1(a, prop, b[prop]);
157
+ }
158
+ return a;
159
+ };
160
+ function useDrauu(target, options) {
161
+ const drauuInstance = ref();
162
+ let disposables = [];
163
+ const onChangedHook = createEventHook();
164
+ const onCanceledHook = createEventHook();
165
+ const onCommittedHook = createEventHook();
166
+ const onStartHook = createEventHook();
167
+ const onEndHook = createEventHook();
168
+ const canUndo = ref(false);
169
+ const canRedo = ref(false);
170
+ const altPressed = ref(false);
171
+ const shiftPressed = ref(false);
172
+ const brush = ref({
173
+ color: "black",
174
+ size: 3,
175
+ arrowEnd: false,
176
+ cornerRadius: 0,
177
+ dasharray: void 0,
178
+ fill: "transparent",
179
+ mode: "draw"
180
+ });
181
+ watch(brush, () => {
182
+ const instance = drauuInstance.value;
183
+ if (instance)
184
+ instance.brush = brush.value;
185
+ }, { deep: true });
186
+ const undo = () => {
187
+ var _a;
188
+ return (_a = drauuInstance.value) == null ? void 0 : _a.undo();
189
+ };
190
+ const redo = () => {
191
+ var _a;
192
+ return (_a = drauuInstance.value) == null ? void 0 : _a.redo();
193
+ };
194
+ const clear = () => {
195
+ var _a;
196
+ return (_a = drauuInstance.value) == null ? void 0 : _a.clear();
197
+ };
198
+ const cancel = () => {
199
+ var _a;
200
+ return (_a = drauuInstance.value) == null ? void 0 : _a.cancel();
201
+ };
202
+ const load = (svg) => {
203
+ var _a;
204
+ return (_a = drauuInstance.value) == null ? void 0 : _a.load(svg);
205
+ };
206
+ const dump = () => {
207
+ var _a;
208
+ return (_a = drauuInstance.value) == null ? void 0 : _a.dump();
209
+ };
210
+ const cleanup = () => {
211
+ var _a;
212
+ disposables.forEach((dispose) => dispose());
213
+ (_a = drauuInstance.value) == null ? void 0 : _a.unmount();
214
+ };
215
+ const syncStatus = () => {
216
+ if (drauuInstance.value) {
217
+ canUndo.value = drauuInstance.value.canUndo();
218
+ canRedo.value = drauuInstance.value.canRedo();
219
+ altPressed.value = drauuInstance.value.altPressed;
220
+ shiftPressed.value = drauuInstance.value.shiftPressed;
221
+ }
222
+ };
223
+ watch(() => unrefElement(target), (el) => {
224
+ if (!el || !(el instanceof SVGSVGElement))
225
+ return;
226
+ if (drauuInstance.value)
227
+ cleanup();
228
+ drauuInstance.value = createDrauu(__spreadValues$1({ el }, options));
229
+ syncStatus();
230
+ disposables = [
231
+ drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
232
+ drauuInstance.value.on("committed", () => onCommittedHook.trigger()),
233
+ drauuInstance.value.on("start", () => onStartHook.trigger()),
234
+ drauuInstance.value.on("end", () => onEndHook.trigger()),
235
+ drauuInstance.value.on("changed", () => {
236
+ syncStatus();
237
+ onChangedHook.trigger();
238
+ })
239
+ ];
240
+ }, { flush: "post" });
241
+ tryOnScopeDispose(() => cleanup());
242
+ return {
243
+ drauuInstance,
244
+ load,
245
+ dump,
246
+ clear,
247
+ cancel,
248
+ undo,
249
+ redo,
250
+ canUndo,
251
+ canRedo,
252
+ brush,
253
+ onChanged: onChangedHook.on,
254
+ onCommitted: onCommittedHook.on,
255
+ onStart: onStartHook.on,
256
+ onEnd: onEndHook.on,
257
+ onCanceled: onCanceledHook.on
258
+ };
259
+ }
196
260
 
197
- /**
198
- * Reactive focus-trap
199
- *
200
- * @see https://vueuse.org/useFocusTrap
201
- * @param target The target element to trap focus within
202
- * @param options Focus trap options
203
- * @param autoFocus Focus trap automatically when mounted
204
- */
205
- function useFocusTrap(target, options = {}) {
206
- let trap;
207
- const { immediate } = options, focusTrapOptions = __rest(options, ["immediate"]);
208
- const hasFocus = ref(false);
209
- const isPaused = ref(false);
210
- const activate = (opts) => trap && trap.activate(opts);
211
- const deactivate = (opts) => trap && trap.deactivate(opts);
212
- const pause = () => {
213
- if (trap) {
214
- trap.pause();
215
- isPaused.value = true;
216
- }
217
- };
218
- const unpause = () => {
219
- if (trap) {
220
- trap.unpause();
221
- isPaused.value = false;
222
- }
223
- };
224
- watch(() => unrefElement(target), (el) => {
225
- if (!el)
226
- return;
227
- trap = createFocusTrap(el, Object.assign(Object.assign({}, focusTrapOptions), { onActivate() {
228
- hasFocus.value = true;
229
- // Apply if user provided onActivate option
230
- if (options.onActivate)
231
- options.onActivate();
232
- },
233
- onDeactivate() {
234
- hasFocus.value = false;
235
- // Apply if user provided onDeactivate option
236
- if (options.onDeactivate)
237
- options.onDeactivate();
238
- } }));
239
- // Focus if immediate is set to true
240
- if (immediate)
241
- activate();
242
- }, { flush: 'post' });
243
- // Cleanup on unmount
244
- tryOnScopeDispose(() => deactivate());
245
- return {
246
- hasFocus,
247
- isPaused,
248
- activate,
249
- deactivate,
250
- pause,
251
- unpause,
252
- };
261
+ var __defProp = Object.defineProperty;
262
+ var __defProps = Object.defineProperties;
263
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
264
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
265
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
266
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
267
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
268
+ var __spreadValues = (a, b) => {
269
+ for (var prop in b || (b = {}))
270
+ if (__hasOwnProp.call(b, prop))
271
+ __defNormalProp(a, prop, b[prop]);
272
+ if (__getOwnPropSymbols)
273
+ for (var prop of __getOwnPropSymbols(b)) {
274
+ if (__propIsEnum.call(b, prop))
275
+ __defNormalProp(a, prop, b[prop]);
276
+ }
277
+ return a;
278
+ };
279
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
280
+ var __objRest = (source, exclude) => {
281
+ var target = {};
282
+ for (var prop in source)
283
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
284
+ target[prop] = source[prop];
285
+ if (source != null && __getOwnPropSymbols)
286
+ for (var prop of __getOwnPropSymbols(source)) {
287
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
288
+ target[prop] = source[prop];
289
+ }
290
+ return target;
291
+ };
292
+ function useFocusTrap(target, options = {}) {
293
+ let trap;
294
+ const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
295
+ const hasFocus = ref(false);
296
+ const isPaused = ref(false);
297
+ const activate = (opts) => trap && trap.activate(opts);
298
+ const deactivate = (opts) => trap && trap.deactivate(opts);
299
+ const pause = () => {
300
+ if (trap) {
301
+ trap.pause();
302
+ isPaused.value = true;
303
+ }
304
+ };
305
+ const unpause = () => {
306
+ if (trap) {
307
+ trap.unpause();
308
+ isPaused.value = false;
309
+ }
310
+ };
311
+ watch(() => unrefElement(target), (el) => {
312
+ if (!el)
313
+ return;
314
+ trap = createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
315
+ onActivate() {
316
+ hasFocus.value = true;
317
+ if (options.onActivate)
318
+ options.onActivate();
319
+ },
320
+ onDeactivate() {
321
+ hasFocus.value = false;
322
+ if (options.onDeactivate)
323
+ options.onDeactivate();
324
+ }
325
+ }));
326
+ if (immediate)
327
+ activate();
328
+ }, { flush: "post" });
329
+ tryOnScopeDispose$1(() => deactivate());
330
+ return {
331
+ hasFocus,
332
+ isPaused,
333
+ activate,
334
+ deactivate,
335
+ pause,
336
+ unpause
337
+ };
253
338
  }
254
339
 
255
- /**
256
- * Reactive decoded jwt token.
257
- *
258
- * @see https://vueuse.org/useJwt
259
- * @param jwt
260
- */
261
- function useJwt(encodedJwt, options = {}) {
262
- const encodedJwtRef = ref(encodedJwt);
263
- const { onError, fallbackValue = null, } = options;
264
- const decodeWithFallback = (encodedJwt, options) => {
265
- try {
266
- return jwt_decode(encodedJwt, options);
267
- }
268
- catch (err) {
269
- onError === null || onError === void 0 ? void 0 : onError(err);
270
- return fallbackValue;
271
- }
272
- };
273
- const header = computed(() => decodeWithFallback(encodedJwtRef.value, { header: true }));
274
- const payload = computed(() => decodeWithFallback(encodedJwtRef.value));
275
- return {
276
- header,
277
- payload,
278
- };
340
+ function useJwt(encodedJwt, options = {}) {
341
+ const encodedJwtRef = ref(encodedJwt);
342
+ const {
343
+ onError,
344
+ fallbackValue = null
345
+ } = options;
346
+ const decodeWithFallback = (encodedJwt2, options2) => {
347
+ try {
348
+ return jwt_decode(encodedJwt2, options2);
349
+ } catch (err) {
350
+ onError == null ? void 0 : onError(err);
351
+ return fallbackValue;
352
+ }
353
+ };
354
+ const header = computed(() => decodeWithFallback(encodedJwtRef.value, { header: true }));
355
+ const payload = computed(() => decodeWithFallback(encodedJwtRef.value));
356
+ return {
357
+ header,
358
+ payload
359
+ };
279
360
  }
280
361
 
281
- /**
282
- * Reactive progress bar.
283
- *
284
- * @see https://vueuse.org/useNProgress
285
- * @param currentProgress
286
- * @param options
287
- */
288
- function useNProgress(currentProgress = null, options) {
289
- const progress = isRef(currentProgress)
290
- ? currentProgress
291
- : ref(currentProgress);
292
- const isLoading = computed({
293
- set: load => load ? nprogress.start() : nprogress.done(),
294
- get: () => isNumber(progress.value) && progress.value < 1,
295
- });
296
- if (options)
297
- nprogress.configure(options);
298
- const setProgress = nprogress.set;
299
- nprogress.set = (n) => {
300
- progress.value = n;
301
- return setProgress.call(nprogress, n);
302
- };
303
- watchEffect(() => {
304
- if (isNumber(progress.value))
305
- setProgress.call(nprogress, progress.value);
306
- });
307
- tryOnScopeDispose(nprogress.remove);
308
- return {
309
- isLoading,
310
- progress,
311
- start: nprogress.start,
312
- done: nprogress.done,
313
- remove: () => {
314
- progress.value = null;
315
- nprogress.remove();
316
- },
317
- };
362
+ function useNProgress(currentProgress = null, options) {
363
+ const progress = isRef(currentProgress) ? currentProgress : ref(currentProgress);
364
+ const isLoading = computed({
365
+ set: (load) => load ? nprogress.start() : nprogress.done(),
366
+ get: () => isNumber(progress.value) && progress.value < 1
367
+ });
368
+ if (options)
369
+ nprogress.configure(options);
370
+ const setProgress = nprogress.set;
371
+ nprogress.set = (n) => {
372
+ progress.value = n;
373
+ return setProgress.call(nprogress, n);
374
+ };
375
+ watchEffect(() => {
376
+ if (isNumber(progress.value))
377
+ setProgress.call(nprogress, progress.value);
378
+ });
379
+ tryOnScopeDispose(nprogress.remove);
380
+ return {
381
+ isLoading,
382
+ progress,
383
+ start: nprogress.start,
384
+ done: nprogress.done,
385
+ remove: () => {
386
+ progress.value = null;
387
+ nprogress.remove();
388
+ }
389
+ };
318
390
  }
319
391
 
320
- /**
321
- * Wrapper for qrcode.
322
- *
323
- * @see https://vueuse.org/useQRCode
324
- * @param text
325
- * @param options
326
- */
327
- function useQRCode(text, options) {
328
- const src = ref(text);
329
- const result = ref('');
330
- watch(src, async (value) => {
331
- if (src.value && isClient)
332
- result.value = await QRCode.toDataURL(value, options);
333
- }, { immediate: true });
334
- return result;
392
+ function useQRCode(text, options) {
393
+ const src = ref(text);
394
+ const result = ref("");
395
+ watch(src, async (value) => {
396
+ if (src.value && isClient)
397
+ result.value = await QRCode.toDataURL(value, options);
398
+ }, { immediate: true });
399
+ return result;
335
400
  }
336
401
 
337
- export { createCookies, useAxios, useCookies, useFocusTrap, useJwt, useNProgress, useQRCode };
402
+ export { createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useJwt, useNProgress, useQRCode };