@vueuse/integrations 8.7.3 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +15 -23
- package/index.d.ts +12 -5
- package/index.iife.js +15 -23
- package/index.iife.min.js +1 -1
- package/index.mjs +15 -23
- package/package.json +4 -4
- package/useAsyncValidator.cjs +3 -2
- package/useAsyncValidator.d.ts +10 -3
- package/useAsyncValidator.iife.js +3 -2
- package/useAsyncValidator.iife.min.js +1 -1
- package/useAsyncValidator.mjs +3 -2
- package/useAxios.cjs +9 -20
- package/useAxios.d.ts +2 -2
- package/useAxios.iife.js +9 -20
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +9 -20
- package/useDrauu.cjs +3 -1
- package/useDrauu.iife.js +3 -1
- package/useDrauu.iife.min.js +1 -1
- package/useDrauu.mjs +3 -1
package/index.cjs
CHANGED
|
@@ -45,7 +45,7 @@ var __spreadValues$4 = (a, b) => {
|
|
|
45
45
|
return a;
|
|
46
46
|
};
|
|
47
47
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
48
|
-
function useAsyncValidator(value, rules) {
|
|
48
|
+
function useAsyncValidator(value, rules, options = {}) {
|
|
49
49
|
const errorInfo = vueDemi.ref();
|
|
50
50
|
const isFinished = vueDemi.ref(false);
|
|
51
51
|
const pass = vueDemi.ref(false);
|
|
@@ -57,12 +57,13 @@ function useAsyncValidator(value, rules) {
|
|
|
57
57
|
var _a;
|
|
58
58
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
59
59
|
});
|
|
60
|
+
const { validateOption = {} } = options;
|
|
60
61
|
vueDemi.watchEffect(async () => {
|
|
61
62
|
isFinished.value = false;
|
|
62
63
|
pass.value = false;
|
|
63
64
|
const validator = new Schema__default["default"](vueDemi.unref(rules));
|
|
64
65
|
try {
|
|
65
|
-
await validator.validate(vueDemi.unref(value));
|
|
66
|
+
await validator.validate(vueDemi.unref(value), validateOption);
|
|
66
67
|
pass.value = true;
|
|
67
68
|
errorInfo.value = null;
|
|
68
69
|
} catch (err) {
|
|
@@ -147,24 +148,20 @@ function useAxios(...args) {
|
|
|
147
148
|
isLoading.value = loading2;
|
|
148
149
|
isFinished.value = !loading2;
|
|
149
150
|
};
|
|
151
|
+
const waitUntilFinished = () => new Promise((resolve, reject) => {
|
|
152
|
+
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch(reject);
|
|
153
|
+
});
|
|
154
|
+
const then = (onFulfilled, onRejected) => waitUntilFinished().then(onFulfilled, onRejected);
|
|
150
155
|
const execute = (executeUrl = url, config = {}) => {
|
|
151
|
-
|
|
152
|
-
let _config;
|
|
153
|
-
if (typeof executeUrl === "string") {
|
|
154
|
-
_url = executeUrl;
|
|
155
|
-
_config = config;
|
|
156
|
-
} else {
|
|
157
|
-
_config = config;
|
|
158
|
-
}
|
|
156
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : "";
|
|
159
157
|
loading(true);
|
|
160
|
-
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig),
|
|
158
|
+
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
161
159
|
response.value = r;
|
|
162
160
|
data.value = r.data;
|
|
163
161
|
}).catch((e) => {
|
|
164
162
|
error.value = e;
|
|
165
|
-
}).finally(() =>
|
|
166
|
-
|
|
167
|
-
});
|
|
163
|
+
}).finally(() => loading(false));
|
|
164
|
+
return { then };
|
|
168
165
|
};
|
|
169
166
|
if (options.immediate && url)
|
|
170
167
|
execute();
|
|
@@ -184,15 +181,8 @@ function useAxios(...args) {
|
|
|
184
181
|
abort,
|
|
185
182
|
execute
|
|
186
183
|
};
|
|
187
|
-
function waitUntilFinished() {
|
|
188
|
-
return new Promise((resolve, reject) => {
|
|
189
|
-
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch((error2) => reject(error2));
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
184
|
return __spreadProps$1(__spreadValues$3({}, result), {
|
|
193
|
-
then
|
|
194
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
195
|
-
}
|
|
185
|
+
then
|
|
196
186
|
});
|
|
197
187
|
}
|
|
198
188
|
|
|
@@ -323,8 +313,10 @@ function useDrauu(target, options) {
|
|
|
323
313
|
});
|
|
324
314
|
vueDemi.watch(brush, () => {
|
|
325
315
|
const instance = drauuInstance.value;
|
|
326
|
-
if (instance)
|
|
316
|
+
if (instance) {
|
|
327
317
|
instance.brush = brush.value;
|
|
318
|
+
instance.mode = brush.value.mode;
|
|
319
|
+
}
|
|
328
320
|
}, { deep: true });
|
|
329
321
|
const undo = () => {
|
|
330
322
|
var _a;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaybeRef } from '@vueuse/shared';
|
|
2
|
-
import {
|
|
2
|
+
import { ValidateError, ValidateOption, Rules } from 'async-validator';
|
|
3
3
|
import * as vue_demi from 'vue-demi';
|
|
4
4
|
import { Ref, ShallowRef, WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
5
5
|
import { AxiosResponse, AxiosError, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
@@ -26,12 +26,19 @@ interface UseAsyncValidatorReturn {
|
|
|
26
26
|
errors: Ref<AsyncValidatorError['errors'] | undefined>;
|
|
27
27
|
errorFields: Ref<AsyncValidatorError['fields'] | undefined>;
|
|
28
28
|
}
|
|
29
|
+
interface UseAsyncValidatorOptions {
|
|
30
|
+
/**
|
|
31
|
+
* @see https://github.com/yiminghe/async-validator#options
|
|
32
|
+
*/
|
|
33
|
+
validateOption?: ValidateOption;
|
|
34
|
+
}
|
|
29
35
|
/**
|
|
30
36
|
* Wrapper for async-validator.
|
|
31
37
|
*
|
|
32
38
|
* @see https://vueuse.org/useAsyncValidator
|
|
39
|
+
* @see https://github.com/yiminghe/async-validator
|
|
33
40
|
*/
|
|
34
|
-
declare function useAsyncValidator(value: MaybeRef<Record<string, any>>, rules: MaybeRef<Rules
|
|
41
|
+
declare function useAsyncValidator(value: MaybeRef<Record<string, any>>, rules: MaybeRef<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
|
|
35
42
|
|
|
36
43
|
interface UseAxiosReturn<T> {
|
|
37
44
|
/**
|
|
@@ -95,13 +102,13 @@ interface StrictUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
|
95
102
|
/**
|
|
96
103
|
* Manually call the axios request
|
|
97
104
|
*/
|
|
98
|
-
execute: (url?: string, config?: AxiosRequestConfig) =>
|
|
105
|
+
execute: (url?: string, config?: AxiosRequestConfig) => PromiseLike<StrictUseAxiosReturn<T>>;
|
|
99
106
|
}
|
|
100
107
|
interface EasyUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
101
108
|
/**
|
|
102
109
|
* Manually call the axios request
|
|
103
110
|
*/
|
|
104
|
-
execute: (url: string, config?: AxiosRequestConfig) =>
|
|
111
|
+
execute: (url: string, config?: AxiosRequestConfig) => PromiseLike<EasyUseAxiosReturn<T>>;
|
|
105
112
|
}
|
|
106
113
|
interface UseAxiosOptions {
|
|
107
114
|
/**
|
|
@@ -334,4 +341,4 @@ declare function useNProgress(currentProgress?: MaybeRef<number | null | undefin
|
|
|
334
341
|
*/
|
|
335
342
|
declare function useQRCode(text: MaybeRef<string>, options?: QRCode.QRCodeToDataURLOptions): vue_demi.Ref<string>;
|
|
336
343
|
|
|
337
|
-
export { ChangeCaseType, EasyUseAxiosReturn, FuseOptions, JwtOptions, JwtResult, StrictUseAxiosReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, createCookies, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
|
344
|
+
export { AsyncValidatorError, ChangeCaseType, EasyUseAxiosReturn, FuseOptions, JwtOptions, JwtResult, StrictUseAxiosReturn, UseAsyncValidatorOptions, UseAsyncValidatorReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, createCookies, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
package/index.iife.js
CHANGED
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
return a;
|
|
120
120
|
};
|
|
121
121
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
122
|
-
function useAsyncValidator(value, rules) {
|
|
122
|
+
function useAsyncValidator(value, rules, options = {}) {
|
|
123
123
|
const errorInfo = vueDemi.ref();
|
|
124
124
|
const isFinished = vueDemi.ref(false);
|
|
125
125
|
const pass = vueDemi.ref(false);
|
|
@@ -131,12 +131,13 @@
|
|
|
131
131
|
var _a;
|
|
132
132
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
133
133
|
});
|
|
134
|
+
const { validateOption = {} } = options;
|
|
134
135
|
vueDemi.watchEffect(async () => {
|
|
135
136
|
isFinished.value = false;
|
|
136
137
|
pass.value = false;
|
|
137
138
|
const validator = new Schema__default["default"](vueDemi.unref(rules));
|
|
138
139
|
try {
|
|
139
|
-
await validator.validate(vueDemi.unref(value));
|
|
140
|
+
await validator.validate(vueDemi.unref(value), validateOption);
|
|
140
141
|
pass.value = true;
|
|
141
142
|
errorInfo.value = null;
|
|
142
143
|
} catch (err) {
|
|
@@ -221,24 +222,20 @@
|
|
|
221
222
|
isLoading.value = loading2;
|
|
222
223
|
isFinished.value = !loading2;
|
|
223
224
|
};
|
|
225
|
+
const waitUntilFinished = () => new Promise((resolve, reject) => {
|
|
226
|
+
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch(reject);
|
|
227
|
+
});
|
|
228
|
+
const then = (onFulfilled, onRejected) => waitUntilFinished().then(onFulfilled, onRejected);
|
|
224
229
|
const execute = (executeUrl = url, config = {}) => {
|
|
225
|
-
|
|
226
|
-
let _config;
|
|
227
|
-
if (typeof executeUrl === "string") {
|
|
228
|
-
_url = executeUrl;
|
|
229
|
-
_config = config;
|
|
230
|
-
} else {
|
|
231
|
-
_config = config;
|
|
232
|
-
}
|
|
230
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : "";
|
|
233
231
|
loading(true);
|
|
234
|
-
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig),
|
|
232
|
+
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
235
233
|
response.value = r;
|
|
236
234
|
data.value = r.data;
|
|
237
235
|
}).catch((e) => {
|
|
238
236
|
error.value = e;
|
|
239
|
-
}).finally(() =>
|
|
240
|
-
|
|
241
|
-
});
|
|
237
|
+
}).finally(() => loading(false));
|
|
238
|
+
return { then };
|
|
242
239
|
};
|
|
243
240
|
if (options.immediate && url)
|
|
244
241
|
execute();
|
|
@@ -258,15 +255,8 @@
|
|
|
258
255
|
abort,
|
|
259
256
|
execute
|
|
260
257
|
};
|
|
261
|
-
function waitUntilFinished() {
|
|
262
|
-
return new Promise((resolve, reject) => {
|
|
263
|
-
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch((error2) => reject(error2));
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
258
|
return __spreadProps$1(__spreadValues$3({}, result), {
|
|
267
|
-
then
|
|
268
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
269
|
-
}
|
|
259
|
+
then
|
|
270
260
|
});
|
|
271
261
|
}
|
|
272
262
|
|
|
@@ -397,8 +387,10 @@
|
|
|
397
387
|
});
|
|
398
388
|
vueDemi.watch(brush, () => {
|
|
399
389
|
const instance = drauuInstance.value;
|
|
400
|
-
if (instance)
|
|
390
|
+
if (instance) {
|
|
401
391
|
instance.brush = brush.value;
|
|
392
|
+
instance.mode = brush.value.mode;
|
|
393
|
+
}
|
|
402
394
|
}, { deep: true });
|
|
403
395
|
const undo = () => {
|
|
404
396
|
var _a;
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(o,c,m){if(o.install)return o;if(c)if(c.version.slice(0,4)==="2.7."){for(var n in c)o[n]=c[n];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=c,o.Vue2=c,o.version=c.version,o.set=function(_,d,y){return Array.isArray(_)?(_.length=Math.max(_.length,d),_.splice(d,1,y),y):(c.set(_,d,y),y)},o.del=function(_,d){if(Array.isArray(_)){_.splice(d,1);return}c.delete(_,d)}}else if(c.version.slice(0,2)==="2.")if(m){for(var n in m)o[n]=m[n];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=c,o.Vue2=c,o.version=c.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(c.version.slice(0,2)==="3."){for(var n in c)o[n]=c[n];o.isVue2=!1,o.isVue3=!0,o.install=function(){},o.Vue=c,o.Vue2=void 0,o.version=c.version,o.set=function(_,d,y){return Array.isArray(_)?(_.length=Math.max(_.length,d),_.splice(d,1,y),y):(_[d]=y,y)},o.del=function(_,d){if(Array.isArray(_)){_.splice(d,1);return}delete _[d]}}else console.error("[vue-demi] Vue version "+c.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return o}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(o,c,m,n,_,d,y,V,E,D,ee,re,te,ne){"use strict";function S(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var ae=S(m),U=S(_),T=S(y),oe=S(ee),se=S(re),w=S(te),le=S(ne),ue=Object.defineProperty,fe=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,G=(t,r,e)=>r in t?ue(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,pe=(t,r)=>{for(var e in r||(r={}))ie.call(r,e)&&G(t,e,r[e]);if(k)for(var e of k(r))de.call(r,e)&&G(t,e,r[e]);return t},ve=(t,r)=>fe(t,ce(r));function _e(t,r){const e=n.ref(),a=n.ref(!1),u=n.ref(!1),p=n.computed(()=>{var l;return((l=e.value)==null?void 0:l.errors)||[]}),h=n.computed(()=>{var l;return((l=e.value)==null?void 0:l.fields)||{}});n.watchEffect(async()=>{a.value=!1,u.value=!1;const l=new ae.default(n.unref(r));try{await l.validate(n.unref(t)),u.value=!0,e.value=null}catch(v){e.value=v}finally{a.value=!0}});const i={pass:u,isFinished:a,errorInfo:e,errors:p,errorFields:h};function s(){return new Promise((l,v)=>{c.until(a).toBe(!0).then(()=>l(i)).catch(P=>v(P))})}return ve(pe({},i),{then(l,v){return s().then(l,v)}})}var he=Object.defineProperty,Oe=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable,J=(t,r,e)=>r in t?he(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,H=(t,r)=>{for(var e in r||(r={}))ye.call(r,e)&&J(t,e,r[e]);if(Q)for(var e of Q(r))we.call(r,e)&&J(t,e,r[e]);return t},M=(t,r)=>Oe(t,Pe(r));function Ce(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=c.isString(r)?1:0;let a={},u=U.default,p={immediate:!!e};const h=O=>!!(O==null?void 0:O.request);t.length>0+e&&(h(t[0+e])?u=t[0+e]:a=t[0+e]),t.length>1+e&&h(t[1+e])&&(u=t[1+e]),(t.length===2+e&&!h(t[1+e])||t.length===3+e)&&(p=t[t.length-1]);const i=n.shallowRef(),s=n.shallowRef(),l=n.ref(!1),v=n.ref(!1),P=n.ref(!1),C=n.shallowRef(),j=U.default.CancelToken.source(),I=O=>{l.value||!v.value||(j.cancel(O),P.value=!0,v.value=!1,l.value=!1)},F=O=>{v.value=O,l.value=!O},R=(O=r,g={})=>{let A=r??"",f;typeof O=="string"&&(A=O),f=g,F(!0),u(A,M(H(H({},a),f),{cancelToken:j.token})).then(b=>{i.value=b,s.value=b.data}).catch(b=>{C.value=b}).finally(()=>{F(!1)})};p.immediate&&r&&R();const L={response:i,data:s,error:C,finished:l,loading:v,isFinished:l,isLoading:v,cancel:I,isAborted:P,canceled:P,aborted:P,isCanceled:P,abort:I,execute:R};function N(){return new Promise((O,g)=>{c.until(l).toBe(!0).then(()=>O(L)).catch(A=>g(A))})}return M(H({},L),{then(O,g){return N().then(O,g)}})}var ge=Object.freeze({__proto__:null,camelCase:d.camelCase,capitalCase:d.capitalCase,constantCase:d.constantCase,dotCase:d.dotCase,headerCase:d.headerCase,noCase:d.noCase,paramCase:d.paramCase,pascalCase:d.pascalCase,pathCase:d.pathCase,sentenceCase:d.sentenceCase,snakeCase:d.snakeCase});function be(t,r,e){const a=n.ref(t);return n.computed({get(){return ge[r](a.value,e)},set(u){a.value=u}})}var Ee=Object.defineProperty,z=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,B=(t,r,e)=>r in t?Ee(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,W=(t,r)=>{for(var e in r||(r={}))Se.call(r,e)&&B(t,e,r[e]);if(z)for(var e of z(r))Ae.call(r,e)&&B(t,e,r[e]);return t};function je(t){const r=new T.default(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:u=!1}={})=>q(e,{doNotParse:a,autoUpdateDependencies:u},r)}function q(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},a=new T.default){const u=e?[...t||[]]:t;let p=a.getAll({doNotParse:!0});const h=n.ref(0),i=()=>{const s=a.getAll({doNotParse:!0});me(u||null,s,p)&&h.value++,p=s};return a.addChangeListener(i),c.tryOnScopeDispose(()=>{a.removeChangeListener(i)}),{get:(...s)=>(e&&u&&!u.includes(s[0])&&u.push(s[0]),h.value,a.get(s[0],W({doNotParse:r},s[1]))),getAll:(...s)=>(h.value,a.getAll(W({doNotParse:r},s[0]))),set:(...s)=>a.set(...s),remove:(...s)=>a.remove(...s),addChangeListener:(...s)=>a.addChangeListener(...s),removeChangeListener:(...s)=>a.removeChangeListener(...s)}}function me(t,r,e){if(!t)return!0;for(const a of t)if(r[a]!==e[a])return!0;return!1}var $e=Object.defineProperty,K=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable,X=(t,r,e)=>r in t?$e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Re=(t,r)=>{for(var e in r||(r={}))Ie.call(r,e)&&X(t,e,r[e]);if(K)for(var e of K(r))Fe.call(r,e)&&X(t,e,r[e]);return t};function Le(t,r){const e=n.ref();let a=[];const u=E.createEventHook(),p=E.createEventHook(),h=E.createEventHook(),i=E.createEventHook(),s=E.createEventHook(),l=n.ref(!1),v=n.ref(!1),P=n.ref(!1),C=n.ref(!1),j=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});n.watch(j,()=>{const f=e.value;f&&(f.brush=j.value)},{deep:!0});const I=()=>{var f;return(f=e.value)==null?void 0:f.undo()},F=()=>{var f;return(f=e.value)==null?void 0:f.redo()},R=()=>{var f;return(f=e.value)==null?void 0:f.clear()},L=()=>{var f;return(f=e.value)==null?void 0:f.cancel()},N=f=>{var b;return(b=e.value)==null?void 0:b.load(f)},O=()=>{var f;return(f=e.value)==null?void 0:f.dump()},g=()=>{var f;a.forEach(b=>b()),(f=e.value)==null||f.unmount()},A=()=>{e.value&&(l.value=e.value.canUndo(),v.value=e.value.canRedo(),P.value=e.value.altPressed,C.value=e.value.shiftPressed)};return n.watch(()=>E.unrefElement(t),f=>{!f||typeof SVGSVGElement=="undefined"||!(f instanceof SVGSVGElement)||(e.value&&g(),e.value=V.createDrauu(Re({el:f},r)),A(),a=[e.value.on("canceled",()=>p.trigger()),e.value.on("committed",()=>h.trigger()),e.value.on("start",()=>i.trigger()),e.value.on("end",()=>s.trigger()),e.value.on("changed",()=>{A(),u.trigger()})])},{flush:"post"}),c.tryOnScopeDispose(()=>g()),{drauuInstance:e,load:N,dump:O,clear:R,cancel:L,undo:I,redo:F,canUndo:l,canRedo:v,brush:j,onChanged:u.on,onCommitted:h.on,onStart:i.on,onEnd:s.on,onCanceled:p.on}}var He=Object.defineProperty,Ne=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,x=(t,r,e)=>r in t?He(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Te=(t,r)=>{for(var e in r||(r={}))Y.call(r,e)&&x(t,e,r[e]);if($)for(var e of $(r))Z.call(r,e)&&x(t,e,r[e]);return t},ke=(t,r)=>Ne(t,Ue(r)),Ge=(t,r)=>{var e={};for(var a in t)Y.call(t,a)&&r.indexOf(a)<0&&(e[a]=t[a]);if(t!=null&&$)for(var a of $(t))r.indexOf(a)<0&&Z.call(t,a)&&(e[a]=t[a]);return e};function Qe(t,r={}){let e;const a=r,{immediate:u}=a,p=Ge(a,["immediate"]),h=n.ref(!1),i=n.ref(!1),s=C=>e&&e.activate(C),l=C=>e&&e.deactivate(C),v=()=>{e&&(e.pause(),i.value=!0)},P=()=>{e&&(e.unpause(),i.value=!1)};return n.watch(()=>E.unrefElement(t),C=>{!C||(e=D.createFocusTrap(C,ke(Te({},p),{onActivate(){h.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){h.value=!1,r.onDeactivate&&r.onDeactivate()}})),u&&s())},{flush:"post"}),E.tryOnScopeDispose(()=>l()),{hasFocus:h,isPaused:i,activate:s,deactivate:l,pause:v,unpause:P}}function Je(t,r,e){var a;const u=(i,s)=>{var l;const v=s;return new oe.default((l=n.unref(i))!=null?l:[],v)},p=n.ref(u(r,(a=n.unref(e))==null?void 0:a.fuseOptions));return n.watch(()=>{var i;return(i=n.unref(e))==null?void 0:i.fuseOptions},i=>{p.value=u(r,i)},{deep:!0}),n.watch(()=>n.unref(r),i=>{p.value.setCollection(i)},{deep:!0}),{results:n.computed(()=>{var i,s;if(((i=n.unref(e))==null?void 0:i.matchAllWhenSearchEmpty)&&!n.unref(t))return n.unref(r).map((v,P)=>({item:v,refIndex:P}));const l=(s=n.unref(e))==null?void 0:s.resultLimit;return p.value.search(n.unref(t),l?{limit:l}:void 0)})}}function Me(t,r={}){const e=n.ref(t),{onError:a,fallbackValue:u=null}=r,p=(s,l)=>{try{return se.default(s,l)}catch(v){return a==null||a(v),u}},h=n.computed(()=>p(e.value,{header:!0})),i=n.computed(()=>p(e.value));return{header:h,payload:i}}function ze(t=null,r){const e=n.isRef(t)?t:n.ref(t),a=n.computed({set:p=>p?w.default.start():w.default.done(),get:()=>c.isNumber(e.value)&&e.value<1});r&&w.default.configure(r);const u=w.default.set;return w.default.set=p=>(e.value=p,u.call(w.default,p)),n.watchEffect(()=>{c.isNumber(e.value)&&u.call(w.default,e.value)}),c.tryOnScopeDispose(w.default.remove),{isLoading:a,progress:e,start:w.default.start,done:w.default.done,remove:()=>{e.value=null,w.default.remove()}}}function Be(t,r){const e=n.ref(t),a=n.ref("");return n.watch(e,async u=>{e.value&&c.isClient&&(a.value=await le.default.toDataURL(u,r))},{immediate:!0}),a}o.createCookies=je,o.useAsyncValidator=_e,o.useAxios=Ce,o.useChangeCase=be,o.useCookies=q,o.useDrauu=Le,o.useFocusTrap=Qe,o.useFuse=Je,o.useJwt=Me,o.useNProgress=ze,o.useQRCode=Be,Object.defineProperty(o,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueUse,Schema,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,jwt_decode,nprogress,QRCode);
|
|
1
|
+
var VueDemi=function(o,u,A){if(o.install)return o;if(u)if(u.version.slice(0,4)==="2.7."){for(var n in u)o[n]=u[n];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=u,o.Vue2=u,o.version=u.version,o.set=function(_,d,w){return Array.isArray(_)?(_.length=Math.max(_.length,d),_.splice(d,1,w),w):(u.set(_,d,w),w)},o.del=function(_,d){if(Array.isArray(_)){_.splice(d,1);return}u.delete(_,d)}}else if(u.version.slice(0,2)==="2.")if(A){for(var n in A)o[n]=A[n];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=u,o.Vue2=u,o.version=u.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(u.version.slice(0,2)==="3."){for(var n in u)o[n]=u[n];o.isVue2=!1,o.isVue3=!0,o.install=function(){},o.Vue=u,o.Vue2=void 0,o.version=u.version,o.set=function(_,d,w){return Array.isArray(_)?(_.length=Math.max(_.length,d),_.splice(d,1,w),w):(_[d]=w,w)},o.del=function(_,d){if(Array.isArray(_)){_.splice(d,1);return}delete _[d]}}else console.error("[vue-demi] Vue version "+u.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return o}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(o,u,A,n,_,d,w,V,E,D,ee,te,re,ne){"use strict";function m(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var ae=m(A),U=m(_),T=m(w),oe=m(ee),se=m(te),C=m(re),le=m(ne),ue=Object.defineProperty,fe=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,G=(r,t,e)=>t in r?ue(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pe=(r,t)=>{for(var e in t||(t={}))ie.call(t,e)&&G(r,e,t[e]);if(k)for(var e of k(t))de.call(t,e)&&G(r,e,t[e]);return r},ve=(r,t)=>fe(r,ce(t));function _e(r,t,e={}){const a=n.ref(),l=n.ref(!1),i=n.ref(!1),h=n.computed(()=>{var v;return((v=a.value)==null?void 0:v.errors)||[]}),c=n.computed(()=>{var v;return((v=a.value)==null?void 0:v.fields)||{}}),{validateOption:s={}}=e;n.watchEffect(async()=>{l.value=!1,i.value=!1;const v=new ae.default(n.unref(t));try{await v.validate(n.unref(r),s),i.value=!0,a.value=null}catch(P){a.value=P}finally{l.value=!0}});const p={pass:i,isFinished:l,errorInfo:a,errors:h,errorFields:c};function O(){return new Promise((v,P)=>{u.until(l).toBe(!0).then(()=>v(p)).catch(g=>P(g))})}return ve(pe({},p),{then(v,P){return O().then(v,P)}})}var he=Object.defineProperty,Oe=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable,J=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H=(r,t)=>{for(var e in t||(t={}))ye.call(t,e)&&J(r,e,t[e]);if(Q)for(var e of Q(t))we.call(t,e)&&J(r,e,t[e]);return r},M=(r,t)=>Oe(r,Pe(t));function Ce(...r){const t=typeof r[0]=="string"?r[0]:void 0,e=u.isString(t)?1:0;let a={},l=U.default,i={immediate:!!e};const h=y=>!!(y==null?void 0:y.request);r.length>0+e&&(h(r[0+e])?l=r[0+e]:a=r[0+e]),r.length>1+e&&h(r[1+e])&&(l=r[1+e]),(r.length===2+e&&!h(r[1+e])||r.length===3+e)&&(i=r[r.length-1]);const c=n.shallowRef(),s=n.shallowRef(),p=n.ref(!1),O=n.ref(!1),v=n.ref(!1),P=n.shallowRef(),g=U.default.CancelToken.source(),$=y=>{p.value||!O.value||(g.cancel(y),v.value=!0,O.value=!1,p.value=!1)},I=y=>{O.value=y,p.value=!y},N=()=>new Promise((y,S)=>{u.until(p).toBe(!0).then(()=>y(L)).catch(S)}),F=(y,S)=>N().then(y,S),R=(y=t,S={})=>{const f=typeof y=="string"?y:t??"";return I(!0),l(f,M(H(H({},a),S),{cancelToken:g.token})).then(b=>{c.value=b,s.value=b.data}).catch(b=>{P.value=b}).finally(()=>I(!1)),{then:F}};i.immediate&&t&&R();const L={response:c,data:s,error:P,finished:p,loading:O,isFinished:p,isLoading:O,cancel:$,isAborted:v,canceled:v,aborted:v,isCanceled:v,abort:$,execute:R};return M(H({},L),{then:F})}var ge=Object.freeze({__proto__:null,camelCase:d.camelCase,capitalCase:d.capitalCase,constantCase:d.constantCase,dotCase:d.dotCase,headerCase:d.headerCase,noCase:d.noCase,paramCase:d.paramCase,pascalCase:d.pascalCase,pathCase:d.pathCase,sentenceCase:d.sentenceCase,snakeCase:d.snakeCase});function be(r,t,e){const a=n.ref(r);return n.computed({get(){return ge[t](a.value,e)},set(l){a.value=l}})}var Ee=Object.defineProperty,z=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,B=(r,t,e)=>t in r?Ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W=(r,t)=>{for(var e in t||(t={}))Se.call(t,e)&&B(r,e,t[e]);if(z)for(var e of z(t))me.call(t,e)&&B(r,e,t[e]);return r};function Ae(r){const t=new T.default(r?r.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:l=!1}={})=>q(e,{doNotParse:a,autoUpdateDependencies:l},t)}function q(r,{doNotParse:t=!1,autoUpdateDependencies:e=!1}={},a=new T.default){const l=e?[...r||[]]:r;let i=a.getAll({doNotParse:!0});const h=n.ref(0),c=()=>{const s=a.getAll({doNotParse:!0});je(l||null,s,i)&&h.value++,i=s};return a.addChangeListener(c),u.tryOnScopeDispose(()=>{a.removeChangeListener(c)}),{get:(...s)=>(e&&l&&!l.includes(s[0])&&l.push(s[0]),h.value,a.get(s[0],W({doNotParse:t},s[1]))),getAll:(...s)=>(h.value,a.getAll(W({doNotParse:t},s[0]))),set:(...s)=>a.set(...s),remove:(...s)=>a.remove(...s),addChangeListener:(...s)=>a.addChangeListener(...s),removeChangeListener:(...s)=>a.removeChangeListener(...s)}}function je(r,t,e){if(!r)return!0;for(const a of r)if(t[a]!==e[a])return!0;return!1}var $e=Object.defineProperty,K=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable,X=(r,t,e)=>t in r?$e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Re=(r,t)=>{for(var e in t||(t={}))Ie.call(t,e)&&X(r,e,t[e]);if(K)for(var e of K(t))Fe.call(t,e)&&X(r,e,t[e]);return r};function Le(r,t){const e=n.ref();let a=[];const l=E.createEventHook(),i=E.createEventHook(),h=E.createEventHook(),c=E.createEventHook(),s=E.createEventHook(),p=n.ref(!1),O=n.ref(!1),v=n.ref(!1),P=n.ref(!1),g=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});n.watch(g,()=>{const f=e.value;f&&(f.brush=g.value,f.mode=g.value.mode)},{deep:!0});const $=()=>{var f;return(f=e.value)==null?void 0:f.undo()},I=()=>{var f;return(f=e.value)==null?void 0:f.redo()},N=()=>{var f;return(f=e.value)==null?void 0:f.clear()},F=()=>{var f;return(f=e.value)==null?void 0:f.cancel()},R=f=>{var b;return(b=e.value)==null?void 0:b.load(f)},L=()=>{var f;return(f=e.value)==null?void 0:f.dump()},y=()=>{var f;a.forEach(b=>b()),(f=e.value)==null||f.unmount()},S=()=>{e.value&&(p.value=e.value.canUndo(),O.value=e.value.canRedo(),v.value=e.value.altPressed,P.value=e.value.shiftPressed)};return n.watch(()=>E.unrefElement(r),f=>{!f||typeof SVGSVGElement=="undefined"||!(f instanceof SVGSVGElement)||(e.value&&y(),e.value=V.createDrauu(Re({el:f},t)),S(),a=[e.value.on("canceled",()=>i.trigger()),e.value.on("committed",()=>h.trigger()),e.value.on("start",()=>c.trigger()),e.value.on("end",()=>s.trigger()),e.value.on("changed",()=>{S(),l.trigger()})])},{flush:"post"}),u.tryOnScopeDispose(()=>y()),{drauuInstance:e,load:R,dump:L,clear:N,cancel:F,undo:$,redo:I,canUndo:p,canRedo:O,brush:g,onChanged:l.on,onCommitted:h.on,onStart:c.on,onEnd:s.on,onCanceled:i.on}}var He=Object.defineProperty,Ne=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,x=(r,t,e)=>t in r?He(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Te=(r,t)=>{for(var e in t||(t={}))Y.call(t,e)&&x(r,e,t[e]);if(j)for(var e of j(t))Z.call(t,e)&&x(r,e,t[e]);return r},ke=(r,t)=>Ne(r,Ue(t)),Ge=(r,t)=>{var e={};for(var a in r)Y.call(r,a)&&t.indexOf(a)<0&&(e[a]=r[a]);if(r!=null&&j)for(var a of j(r))t.indexOf(a)<0&&Z.call(r,a)&&(e[a]=r[a]);return e};function Qe(r,t={}){let e;const a=t,{immediate:l}=a,i=Ge(a,["immediate"]),h=n.ref(!1),c=n.ref(!1),s=P=>e&&e.activate(P),p=P=>e&&e.deactivate(P),O=()=>{e&&(e.pause(),c.value=!0)},v=()=>{e&&(e.unpause(),c.value=!1)};return n.watch(()=>E.unrefElement(r),P=>{!P||(e=D.createFocusTrap(P,ke(Te({},i),{onActivate(){h.value=!0,t.onActivate&&t.onActivate()},onDeactivate(){h.value=!1,t.onDeactivate&&t.onDeactivate()}})),l&&s())},{flush:"post"}),E.tryOnScopeDispose(()=>p()),{hasFocus:h,isPaused:c,activate:s,deactivate:p,pause:O,unpause:v}}function Je(r,t,e){var a;const l=(c,s)=>{var p;const O=s;return new oe.default((p=n.unref(c))!=null?p:[],O)},i=n.ref(l(t,(a=n.unref(e))==null?void 0:a.fuseOptions));return n.watch(()=>{var c;return(c=n.unref(e))==null?void 0:c.fuseOptions},c=>{i.value=l(t,c)},{deep:!0}),n.watch(()=>n.unref(t),c=>{i.value.setCollection(c)},{deep:!0}),{results:n.computed(()=>{var c,s;if(((c=n.unref(e))==null?void 0:c.matchAllWhenSearchEmpty)&&!n.unref(r))return n.unref(t).map((O,v)=>({item:O,refIndex:v}));const p=(s=n.unref(e))==null?void 0:s.resultLimit;return i.value.search(n.unref(r),p?{limit:p}:void 0)})}}function Me(r,t={}){const e=n.ref(r),{onError:a,fallbackValue:l=null}=t,i=(s,p)=>{try{return se.default(s,p)}catch(O){return a==null||a(O),l}},h=n.computed(()=>i(e.value,{header:!0})),c=n.computed(()=>i(e.value));return{header:h,payload:c}}function ze(r=null,t){const e=n.isRef(r)?r:n.ref(r),a=n.computed({set:i=>i?C.default.start():C.default.done(),get:()=>u.isNumber(e.value)&&e.value<1});t&&C.default.configure(t);const l=C.default.set;return C.default.set=i=>(e.value=i,l.call(C.default,i)),n.watchEffect(()=>{u.isNumber(e.value)&&l.call(C.default,e.value)}),u.tryOnScopeDispose(C.default.remove),{isLoading:a,progress:e,start:C.default.start,done:C.default.done,remove:()=>{e.value=null,C.default.remove()}}}function Be(r,t){const e=n.ref(r),a=n.ref("");return n.watch(e,async l=>{e.value&&u.isClient&&(a.value=await le.default.toDataURL(l,t))},{immediate:!0}),a}o.createCookies=Ae,o.useAsyncValidator=_e,o.useAxios=Ce,o.useChangeCase=be,o.useCookies=q,o.useDrauu=Le,o.useFocusTrap=Qe,o.useFuse=Je,o.useJwt=Me,o.useNProgress=ze,o.useQRCode=Be,Object.defineProperty(o,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueUse,Schema,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,jwt_decode,nprogress,QRCode);
|
package/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ var __spreadValues$4 = (a, b) => {
|
|
|
31
31
|
return a;
|
|
32
32
|
};
|
|
33
33
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
34
|
-
function useAsyncValidator(value, rules) {
|
|
34
|
+
function useAsyncValidator(value, rules, options = {}) {
|
|
35
35
|
const errorInfo = ref();
|
|
36
36
|
const isFinished = ref(false);
|
|
37
37
|
const pass = ref(false);
|
|
@@ -43,12 +43,13 @@ function useAsyncValidator(value, rules) {
|
|
|
43
43
|
var _a;
|
|
44
44
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
45
45
|
});
|
|
46
|
+
const { validateOption = {} } = options;
|
|
46
47
|
watchEffect(async () => {
|
|
47
48
|
isFinished.value = false;
|
|
48
49
|
pass.value = false;
|
|
49
50
|
const validator = new Schema(unref(rules));
|
|
50
51
|
try {
|
|
51
|
-
await validator.validate(unref(value));
|
|
52
|
+
await validator.validate(unref(value), validateOption);
|
|
52
53
|
pass.value = true;
|
|
53
54
|
errorInfo.value = null;
|
|
54
55
|
} catch (err) {
|
|
@@ -133,24 +134,20 @@ function useAxios(...args) {
|
|
|
133
134
|
isLoading.value = loading2;
|
|
134
135
|
isFinished.value = !loading2;
|
|
135
136
|
};
|
|
137
|
+
const waitUntilFinished = () => new Promise((resolve, reject) => {
|
|
138
|
+
until(isFinished).toBe(true).then(() => resolve(result)).catch(reject);
|
|
139
|
+
});
|
|
140
|
+
const then = (onFulfilled, onRejected) => waitUntilFinished().then(onFulfilled, onRejected);
|
|
136
141
|
const execute = (executeUrl = url, config = {}) => {
|
|
137
|
-
|
|
138
|
-
let _config;
|
|
139
|
-
if (typeof executeUrl === "string") {
|
|
140
|
-
_url = executeUrl;
|
|
141
|
-
_config = config;
|
|
142
|
-
} else {
|
|
143
|
-
_config = config;
|
|
144
|
-
}
|
|
142
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : "";
|
|
145
143
|
loading(true);
|
|
146
|
-
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig),
|
|
144
|
+
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
147
145
|
response.value = r;
|
|
148
146
|
data.value = r.data;
|
|
149
147
|
}).catch((e) => {
|
|
150
148
|
error.value = e;
|
|
151
|
-
}).finally(() =>
|
|
152
|
-
|
|
153
|
-
});
|
|
149
|
+
}).finally(() => loading(false));
|
|
150
|
+
return { then };
|
|
154
151
|
};
|
|
155
152
|
if (options.immediate && url)
|
|
156
153
|
execute();
|
|
@@ -170,15 +167,8 @@ function useAxios(...args) {
|
|
|
170
167
|
abort,
|
|
171
168
|
execute
|
|
172
169
|
};
|
|
173
|
-
function waitUntilFinished() {
|
|
174
|
-
return new Promise((resolve, reject) => {
|
|
175
|
-
until(isFinished).toBe(true).then(() => resolve(result)).catch((error2) => reject(error2));
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
170
|
return __spreadProps$1(__spreadValues$3({}, result), {
|
|
179
|
-
then
|
|
180
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
181
|
-
}
|
|
171
|
+
then
|
|
182
172
|
});
|
|
183
173
|
}
|
|
184
174
|
|
|
@@ -309,8 +299,10 @@ function useDrauu(target, options) {
|
|
|
309
299
|
});
|
|
310
300
|
watch(brush, () => {
|
|
311
301
|
const instance = drauuInstance.value;
|
|
312
|
-
if (instance)
|
|
302
|
+
if (instance) {
|
|
313
303
|
instance.brush = brush.value;
|
|
304
|
+
instance.mode = brush.value.mode;
|
|
305
|
+
}
|
|
314
306
|
}, { deep: true });
|
|
315
307
|
const undo = () => {
|
|
316
308
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.0",
|
|
4
4
|
"description": "Integration wrappers for utility libraries",
|
|
5
5
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -138,14 +138,14 @@
|
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
"dependencies": {
|
|
141
|
-
"@vueuse/core": "8.
|
|
142
|
-
"@vueuse/shared": "8.
|
|
141
|
+
"@vueuse/core": "8.8.0",
|
|
142
|
+
"@vueuse/shared": "8.8.0",
|
|
143
143
|
"vue-demi": "*"
|
|
144
144
|
},
|
|
145
145
|
"devDependencies": {
|
|
146
146
|
"@types/nprogress": "^0.2.0",
|
|
147
147
|
"@types/qrcode": "^1.4.2",
|
|
148
|
-
"async-validator": "^4.
|
|
148
|
+
"async-validator": "^4.2.5",
|
|
149
149
|
"axios": "^0.27.2",
|
|
150
150
|
"change-case": "^4.1.2",
|
|
151
151
|
"drauu": "^0.3.0",
|
package/useAsyncValidator.cjs
CHANGED
|
@@ -29,7 +29,7 @@ var __spreadValues = (a, b) => {
|
|
|
29
29
|
return a;
|
|
30
30
|
};
|
|
31
31
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
32
|
-
function useAsyncValidator(value, rules) {
|
|
32
|
+
function useAsyncValidator(value, rules, options = {}) {
|
|
33
33
|
const errorInfo = vueDemi.ref();
|
|
34
34
|
const isFinished = vueDemi.ref(false);
|
|
35
35
|
const pass = vueDemi.ref(false);
|
|
@@ -41,12 +41,13 @@ function useAsyncValidator(value, rules) {
|
|
|
41
41
|
var _a;
|
|
42
42
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
43
43
|
});
|
|
44
|
+
const { validateOption = {} } = options;
|
|
44
45
|
vueDemi.watchEffect(async () => {
|
|
45
46
|
isFinished.value = false;
|
|
46
47
|
pass.value = false;
|
|
47
48
|
const validator = new Schema__default["default"](vueDemi.unref(rules));
|
|
48
49
|
try {
|
|
49
|
-
await validator.validate(vueDemi.unref(value));
|
|
50
|
+
await validator.validate(vueDemi.unref(value), validateOption);
|
|
50
51
|
pass.value = true;
|
|
51
52
|
errorInfo.value = null;
|
|
52
53
|
} catch (err) {
|
package/useAsyncValidator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaybeRef } from '@vueuse/shared';
|
|
2
|
-
import {
|
|
2
|
+
import { ValidateError, ValidateOption, Rules } from 'async-validator';
|
|
3
3
|
import { Ref } from 'vue-demi';
|
|
4
4
|
|
|
5
5
|
declare type AsyncValidatorError = Error & {
|
|
@@ -13,11 +13,18 @@ interface UseAsyncValidatorReturn {
|
|
|
13
13
|
errors: Ref<AsyncValidatorError['errors'] | undefined>;
|
|
14
14
|
errorFields: Ref<AsyncValidatorError['fields'] | undefined>;
|
|
15
15
|
}
|
|
16
|
+
interface UseAsyncValidatorOptions {
|
|
17
|
+
/**
|
|
18
|
+
* @see https://github.com/yiminghe/async-validator#options
|
|
19
|
+
*/
|
|
20
|
+
validateOption?: ValidateOption;
|
|
21
|
+
}
|
|
16
22
|
/**
|
|
17
23
|
* Wrapper for async-validator.
|
|
18
24
|
*
|
|
19
25
|
* @see https://vueuse.org/useAsyncValidator
|
|
26
|
+
* @see https://github.com/yiminghe/async-validator
|
|
20
27
|
*/
|
|
21
|
-
declare function useAsyncValidator(value: MaybeRef<Record<string, any>>, rules: MaybeRef<Rules
|
|
28
|
+
declare function useAsyncValidator(value: MaybeRef<Record<string, any>>, rules: MaybeRef<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
|
|
22
29
|
|
|
23
|
-
export { useAsyncValidator };
|
|
30
|
+
export { AsyncValidatorError, UseAsyncValidatorOptions, UseAsyncValidatorReturn, useAsyncValidator };
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
return a;
|
|
114
114
|
};
|
|
115
115
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
116
|
-
function useAsyncValidator(value, rules) {
|
|
116
|
+
function useAsyncValidator(value, rules, options = {}) {
|
|
117
117
|
const errorInfo = vueDemi.ref();
|
|
118
118
|
const isFinished = vueDemi.ref(false);
|
|
119
119
|
const pass = vueDemi.ref(false);
|
|
@@ -125,12 +125,13 @@
|
|
|
125
125
|
var _a;
|
|
126
126
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
127
127
|
});
|
|
128
|
+
const { validateOption = {} } = options;
|
|
128
129
|
vueDemi.watchEffect(async () => {
|
|
129
130
|
isFinished.value = false;
|
|
130
131
|
pass.value = false;
|
|
131
132
|
const validator = new Schema__default["default"](vueDemi.unref(rules));
|
|
132
133
|
try {
|
|
133
|
-
await validator.validate(vueDemi.unref(value));
|
|
134
|
+
await validator.validate(vueDemi.unref(value), validateOption);
|
|
134
135
|
pass.value = true;
|
|
135
136
|
errorInfo.value = null;
|
|
136
137
|
} catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(r,e,c){if(r.install)return r;if(e)if(e.version.slice(0,4)==="2.7."){for(var s in e)r[s]=e[s];r.isVue2=!0,r.isVue3=!1,r.install=function(){},r.Vue=e,r.Vue2=e,r.version=e.version,r.set=function(n,
|
|
1
|
+
var VueDemi=function(r,e,c){if(r.install)return r;if(e)if(e.version.slice(0,4)==="2.7."){for(var s in e)r[s]=e[s];r.isVue2=!0,r.isVue3=!1,r.install=function(){},r.Vue=e,r.Vue2=e,r.version=e.version,r.set=function(n,o,a){return Array.isArray(n)?(n.length=Math.max(n.length,o),n.splice(o,1,a),a):(e.set(n,o,a),a)},r.del=function(n,o){if(Array.isArray(n)){n.splice(o,1);return}e.delete(n,o)}}else if(e.version.slice(0,2)==="2.")if(c){for(var s in c)r[s]=c[s];r.isVue2=!0,r.isVue3=!1,r.install=function(){},r.Vue=e,r.Vue2=e,r.version=e.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(e.version.slice(0,2)==="3."){for(var s in e)r[s]=e[s];r.isVue2=!1,r.isVue3=!0,r.install=function(){},r.Vue=e,r.Vue2=void 0,r.version=e.version,r.set=function(n,o,a){return Array.isArray(n)?(n.length=Math.max(n.length,o),n.splice(o,1,a),a):(n[o]=a,a)},r.del=function(n,o){if(Array.isArray(n)){n.splice(o,1);return}delete n[o]}}else console.error("[vue-demi] Vue version "+e.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return r}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(r,e,c,s){"use strict";function n(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var o=n(c),a=Object.defineProperty,P=Object.defineProperties,O=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,_=(t,i,l)=>i in t?a(t,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[i]=l,b=(t,i)=>{for(var l in i||(i={}))w.call(i,l)&&_(t,l,i[l]);if(h)for(var l of h(i))A.call(i,l)&&_(t,l,i[l]);return t},j=(t,i)=>P(t,O(i));function I(t,i,l={}){const u=s.ref(),p=s.ref(!1),v=s.ref(!1),S=s.computed(()=>{var f;return((f=u.value)==null?void 0:f.errors)||[]}),U=s.computed(()=>{var f;return((f=u.value)==null?void 0:f.fields)||{}}),{validateOption:E={}}=l;s.watchEffect(async()=>{p.value=!1,v.value=!1;const f=new o.default(s.unref(i));try{await f.validate(s.unref(t),E),v.value=!0,u.value=null}catch(d){u.value=d}finally{p.value=!0}});const y={pass:v,isFinished:p,errorInfo:u,errors:S,errorFields:U};function F(){return new Promise((f,d)=>{e.until(p).toBe(!0).then(()=>f(y)).catch(M=>d(M))})}return j(b({},y),{then(f,d){return F().then(f,d)}})}r.useAsyncValidator=I,Object.defineProperty(r,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueUse,Schema,VueDemi);
|
package/useAsyncValidator.mjs
CHANGED
|
@@ -21,7 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
function useAsyncValidator(value, rules) {
|
|
24
|
+
function useAsyncValidator(value, rules, options = {}) {
|
|
25
25
|
const errorInfo = ref();
|
|
26
26
|
const isFinished = ref(false);
|
|
27
27
|
const pass = ref(false);
|
|
@@ -33,12 +33,13 @@ function useAsyncValidator(value, rules) {
|
|
|
33
33
|
var _a;
|
|
34
34
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
35
35
|
});
|
|
36
|
+
const { validateOption = {} } = options;
|
|
36
37
|
watchEffect(async () => {
|
|
37
38
|
isFinished.value = false;
|
|
38
39
|
pass.value = false;
|
|
39
40
|
const validator = new Schema(unref(rules));
|
|
40
41
|
try {
|
|
41
|
-
await validator.validate(unref(value));
|
|
42
|
+
await validator.validate(unref(value), validateOption);
|
|
42
43
|
pass.value = true;
|
|
43
44
|
errorInfo.value = null;
|
|
44
45
|
} catch (err) {
|
package/useAxios.cjs
CHANGED
|
@@ -67,24 +67,20 @@ function useAxios(...args) {
|
|
|
67
67
|
isLoading.value = loading2;
|
|
68
68
|
isFinished.value = !loading2;
|
|
69
69
|
};
|
|
70
|
+
const waitUntilFinished = () => new Promise((resolve, reject) => {
|
|
71
|
+
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch(reject);
|
|
72
|
+
});
|
|
73
|
+
const then = (onFulfilled, onRejected) => waitUntilFinished().then(onFulfilled, onRejected);
|
|
70
74
|
const execute = (executeUrl = url, config = {}) => {
|
|
71
|
-
|
|
72
|
-
let _config;
|
|
73
|
-
if (typeof executeUrl === "string") {
|
|
74
|
-
_url = executeUrl;
|
|
75
|
-
_config = config;
|
|
76
|
-
} else {
|
|
77
|
-
_config = config;
|
|
78
|
-
}
|
|
75
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : "";
|
|
79
76
|
loading(true);
|
|
80
|
-
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig),
|
|
77
|
+
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
81
78
|
response.value = r;
|
|
82
79
|
data.value = r.data;
|
|
83
80
|
}).catch((e) => {
|
|
84
81
|
error.value = e;
|
|
85
|
-
}).finally(() =>
|
|
86
|
-
|
|
87
|
-
});
|
|
82
|
+
}).finally(() => loading(false));
|
|
83
|
+
return { then };
|
|
88
84
|
};
|
|
89
85
|
if (options.immediate && url)
|
|
90
86
|
execute();
|
|
@@ -104,15 +100,8 @@ function useAxios(...args) {
|
|
|
104
100
|
abort,
|
|
105
101
|
execute
|
|
106
102
|
};
|
|
107
|
-
function waitUntilFinished() {
|
|
108
|
-
return new Promise((resolve, reject) => {
|
|
109
|
-
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch((error2) => reject(error2));
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
103
|
return __spreadProps(__spreadValues({}, result), {
|
|
113
|
-
then
|
|
114
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
115
|
-
}
|
|
104
|
+
then
|
|
116
105
|
});
|
|
117
106
|
}
|
|
118
107
|
|
package/useAxios.d.ts
CHANGED
|
@@ -63,13 +63,13 @@ interface StrictUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
|
63
63
|
/**
|
|
64
64
|
* Manually call the axios request
|
|
65
65
|
*/
|
|
66
|
-
execute: (url?: string, config?: AxiosRequestConfig) =>
|
|
66
|
+
execute: (url?: string, config?: AxiosRequestConfig) => PromiseLike<StrictUseAxiosReturn<T>>;
|
|
67
67
|
}
|
|
68
68
|
interface EasyUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
69
69
|
/**
|
|
70
70
|
* Manually call the axios request
|
|
71
71
|
*/
|
|
72
|
-
execute: (url: string, config?: AxiosRequestConfig) =>
|
|
72
|
+
execute: (url: string, config?: AxiosRequestConfig) => PromiseLike<EasyUseAxiosReturn<T>>;
|
|
73
73
|
}
|
|
74
74
|
interface UseAxiosOptions {
|
|
75
75
|
/**
|
package/useAxios.iife.js
CHANGED
|
@@ -151,24 +151,20 @@
|
|
|
151
151
|
isLoading.value = loading2;
|
|
152
152
|
isFinished.value = !loading2;
|
|
153
153
|
};
|
|
154
|
+
const waitUntilFinished = () => new Promise((resolve, reject) => {
|
|
155
|
+
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch(reject);
|
|
156
|
+
});
|
|
157
|
+
const then = (onFulfilled, onRejected) => waitUntilFinished().then(onFulfilled, onRejected);
|
|
154
158
|
const execute = (executeUrl = url, config = {}) => {
|
|
155
|
-
|
|
156
|
-
let _config;
|
|
157
|
-
if (typeof executeUrl === "string") {
|
|
158
|
-
_url = executeUrl;
|
|
159
|
-
_config = config;
|
|
160
|
-
} else {
|
|
161
|
-
_config = config;
|
|
162
|
-
}
|
|
159
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : "";
|
|
163
160
|
loading(true);
|
|
164
|
-
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig),
|
|
161
|
+
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
165
162
|
response.value = r;
|
|
166
163
|
data.value = r.data;
|
|
167
164
|
}).catch((e) => {
|
|
168
165
|
error.value = e;
|
|
169
|
-
}).finally(() =>
|
|
170
|
-
|
|
171
|
-
});
|
|
166
|
+
}).finally(() => loading(false));
|
|
167
|
+
return { then };
|
|
172
168
|
};
|
|
173
169
|
if (options.immediate && url)
|
|
174
170
|
execute();
|
|
@@ -188,15 +184,8 @@
|
|
|
188
184
|
abort,
|
|
189
185
|
execute
|
|
190
186
|
};
|
|
191
|
-
function waitUntilFinished() {
|
|
192
|
-
return new Promise((resolve, reject) => {
|
|
193
|
-
shared.until(isFinished).toBe(true).then(() => resolve(result)).catch((error2) => reject(error2));
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
187
|
return __spreadProps(__spreadValues({}, result), {
|
|
197
|
-
then
|
|
198
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
199
|
-
}
|
|
188
|
+
then
|
|
200
189
|
});
|
|
201
190
|
}
|
|
202
191
|
|
package/useAxios.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(e,t,a){if(e.install)return e;if(t)if(t.version.slice(0,4)==="2.7."){for(var c in t)e[c]=t[c];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.set=function(r,i,f){return Array.isArray(r)?(r.length=Math.max(r.length,i),r.splice(i,1,f),f):(t.set(r,i,f),f)},e.del=function(r,i){if(Array.isArray(r)){r.splice(i,1);return}t.delete(r,i)}}else if(t.version.slice(0,2)==="2.")if(a){for(var c in a)e[c]=a[c];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(t.version.slice(0,2)==="3."){for(var c in t)e[c]=t[c];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=t,e.Vue2=void 0,e.version=t.version,e.set=function(r,i,f){return Array.isArray(r)?(r.length=Math.max(r.length,i),r.splice(i,1,f),f):(r[i]=f,f)},e.del=function(r,i){if(Array.isArray(r)){r.splice(i,1);return}delete r[i]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(e,t,a,c){"use strict";function r(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var i=r(c),f=Object.defineProperty,
|
|
1
|
+
var VueDemi=function(e,t,a){if(e.install)return e;if(t)if(t.version.slice(0,4)==="2.7."){for(var c in t)e[c]=t[c];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.set=function(r,i,f){return Array.isArray(r)?(r.length=Math.max(r.length,i),r.splice(i,1,f),f):(t.set(r,i,f),f)},e.del=function(r,i){if(Array.isArray(r)){r.splice(i,1);return}t.delete(r,i)}}else if(t.version.slice(0,2)==="2.")if(a){for(var c in a)e[c]=a[c];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(t.version.slice(0,2)==="3."){for(var c in t)e[c]=t[c];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=t,e.Vue2=void 0,e.version=t.version,e.set=function(r,i,f){return Array.isArray(r)?(r.length=Math.max(r.length,i),r.splice(i,1,f),f):(r[i]=f,f)},e.del=function(r,i){if(Array.isArray(r)){r.splice(i,1);return}delete r[i]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(e,t,a,c){"use strict";function r(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var i=r(c),f=Object.defineProperty,F=Object.defineProperties,L=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,b=(n,s,o)=>s in n?f(n,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[s]=o,_=(n,s)=>{for(var o in s||(s={}))q.call(s,o)&&b(n,o,s[o]);if(A)for(var o of A(s))B.call(s,o)&&b(n,o,s[o]);return n},O=(n,s)=>F(n,L(s));function N(...n){const s=typeof n[0]=="string"?n[0]:void 0,o=a.isString(s)?1:0;let w={},y=i.default,j={immediate:!!o};const P=l=>!!(l==null?void 0:l.request);n.length>0+o&&(P(n[0+o])?y=n[0+o]:w=n[0+o]),n.length>1+o&&P(n[1+o])&&(y=n[1+o]),(n.length===2+o&&!P(n[1+o])||n.length===3+o)&&(j=n[n.length-1]);const x=t.shallowRef(),C=t.shallowRef(),u=t.ref(!1),d=t.ref(!1),p=t.ref(!1),I=t.shallowRef(),M=i.default.CancelToken.source(),R=l=>{u.value||!d.value||(M.cancel(l),p.value=!0,d.value=!1,u.value=!1)},S=l=>{d.value=l,u.value=!l},z=()=>new Promise((l,v)=>{a.until(u).toBe(!0).then(()=>l(E)).catch(v)}),T=(l,v)=>z().then(l,v),U=(l=s,v={})=>{const G=typeof l=="string"?l:s??"";return S(!0),y(G,O(_(_({},w),v),{cancelToken:M.token})).then(h=>{x.value=h,C.value=h.data}).catch(h=>{I.value=h}).finally(()=>S(!1)),{then:T}};j.immediate&&s&&U();const E={response:x,data:C,error:I,finished:u,loading:d,isFinished:u,isLoading:d,cancel:R,isAborted:p,canceled:p,aborted:p,isCanceled:p,abort:R,execute:U};return O(_({},E),{then:T})}e.useAxios=N,Object.defineProperty(e,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios);
|
package/useAxios.mjs
CHANGED
|
@@ -59,24 +59,20 @@ function useAxios(...args) {
|
|
|
59
59
|
isLoading.value = loading2;
|
|
60
60
|
isFinished.value = !loading2;
|
|
61
61
|
};
|
|
62
|
+
const waitUntilFinished = () => new Promise((resolve, reject) => {
|
|
63
|
+
until(isFinished).toBe(true).then(() => resolve(result)).catch(reject);
|
|
64
|
+
});
|
|
65
|
+
const then = (onFulfilled, onRejected) => waitUntilFinished().then(onFulfilled, onRejected);
|
|
62
66
|
const execute = (executeUrl = url, config = {}) => {
|
|
63
|
-
|
|
64
|
-
let _config;
|
|
65
|
-
if (typeof executeUrl === "string") {
|
|
66
|
-
_url = executeUrl;
|
|
67
|
-
_config = config;
|
|
68
|
-
} else {
|
|
69
|
-
_config = config;
|
|
70
|
-
}
|
|
67
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : "";
|
|
71
68
|
loading(true);
|
|
72
|
-
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig),
|
|
69
|
+
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), config), { cancelToken: cancelToken.token })).then((r) => {
|
|
73
70
|
response.value = r;
|
|
74
71
|
data.value = r.data;
|
|
75
72
|
}).catch((e) => {
|
|
76
73
|
error.value = e;
|
|
77
|
-
}).finally(() =>
|
|
78
|
-
|
|
79
|
-
});
|
|
74
|
+
}).finally(() => loading(false));
|
|
75
|
+
return { then };
|
|
80
76
|
};
|
|
81
77
|
if (options.immediate && url)
|
|
82
78
|
execute();
|
|
@@ -96,15 +92,8 @@ function useAxios(...args) {
|
|
|
96
92
|
abort,
|
|
97
93
|
execute
|
|
98
94
|
};
|
|
99
|
-
function waitUntilFinished() {
|
|
100
|
-
return new Promise((resolve, reject) => {
|
|
101
|
-
until(isFinished).toBe(true).then(() => resolve(result)).catch((error2) => reject(error2));
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
95
|
return __spreadProps(__spreadValues({}, result), {
|
|
105
|
-
then
|
|
106
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
107
|
-
}
|
|
96
|
+
then
|
|
108
97
|
});
|
|
109
98
|
}
|
|
110
99
|
|
package/useDrauu.cjs
CHANGED
|
@@ -46,8 +46,10 @@ function useDrauu(target, options) {
|
|
|
46
46
|
});
|
|
47
47
|
vueDemi.watch(brush, () => {
|
|
48
48
|
const instance = drauuInstance.value;
|
|
49
|
-
if (instance)
|
|
49
|
+
if (instance) {
|
|
50
50
|
instance.brush = brush.value;
|
|
51
|
+
instance.mode = brush.value.mode;
|
|
52
|
+
}
|
|
51
53
|
}, { deep: true });
|
|
52
54
|
const undo = () => {
|
|
53
55
|
var _a;
|
package/useDrauu.iife.js
CHANGED
|
@@ -129,8 +129,10 @@
|
|
|
129
129
|
});
|
|
130
130
|
vueDemi.watch(brush, () => {
|
|
131
131
|
const instance = drauuInstance.value;
|
|
132
|
-
if (instance)
|
|
132
|
+
if (instance) {
|
|
133
133
|
instance.brush = brush.value;
|
|
134
|
+
instance.mode = brush.value.mode;
|
|
135
|
+
}
|
|
134
136
|
}, { deep: true });
|
|
135
137
|
const undo = () => {
|
|
136
138
|
var _a;
|
package/useDrauu.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(e,r,c){if(e.install)return e;if(r)if(r.version.slice(0,4)==="2.7."){for(var t in r)e[t]=r[t];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=r,e.Vue2=r,e.version=r.version,e.set=function(s,a,
|
|
1
|
+
var VueDemi=function(e,r,c){if(e.install)return e;if(r)if(r.version.slice(0,4)==="2.7."){for(var t in r)e[t]=r[t];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=r,e.Vue2=r,e.version=r.version,e.set=function(s,a,u){return Array.isArray(s)?(s.length=Math.max(s.length,a),s.splice(a,1,u),u):(r.set(s,a,u),u)},e.del=function(s,a){if(Array.isArray(s)){s.splice(a,1);return}r.delete(s,a)}}else if(r.version.slice(0,2)==="2.")if(c){for(var t in c)e[t]=c[t];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=r,e.Vue2=r,e.version=r.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var t in r)e[t]=r[t];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=r,e.Vue2=void 0,e.version=r.version,e.set=function(s,a,u){return Array.isArray(s)?(s.length=Math.max(s.length,a),s.splice(a,1,u),u):(s[a]=u,u)},e.del=function(s,a){if(Array.isArray(s)){s.splice(a,1);return}delete s[a]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(e,r,c,t,s){"use strict";var a=Object.defineProperty,u=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,v=(i,l,n)=>l in i?a(i,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[l]=n,g=(i,l)=>{for(var n in l||(l={}))S.call(l,n)&&v(i,n,l[n]);if(u)for(var n of u(l))w.call(l,n)&&v(i,n,l[n]);return i};function C(i,l){const n=r.ref();let p=[];const h=t.createEventHook(),_=t.createEventHook(),y=t.createEventHook(),E=t.createEventHook(),P=t.createEventHook(),b=r.ref(!1),A=r.ref(!1),U=r.ref(!1),I=r.ref(!1),d=r.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});r.watch(d,()=>{const o=n.value;o&&(o.brush=d.value,o.mode=d.value.mode)},{deep:!0});const k=()=>{var o;return(o=n.value)==null?void 0:o.undo()},G=()=>{var o;return(o=n.value)==null?void 0:o.redo()},j=()=>{var o;return(o=n.value)==null?void 0:o.clear()},M=()=>{var o;return(o=n.value)==null?void 0:o.cancel()},R=o=>{var f;return(f=n.value)==null?void 0:f.load(o)},m=()=>{var o;return(o=n.value)==null?void 0:o.dump()},H=()=>{var o;p.forEach(f=>f()),(o=n.value)==null||o.unmount()},O=()=>{n.value&&(b.value=n.value.canUndo(),A.value=n.value.canRedo(),U.value=n.value.altPressed,I.value=n.value.shiftPressed)};return r.watch(()=>t.unrefElement(i),o=>{!o||typeof SVGSVGElement=="undefined"||!(o instanceof SVGSVGElement)||(n.value&&H(),n.value=c.createDrauu(g({el:o},l)),O(),p=[n.value.on("canceled",()=>_.trigger()),n.value.on("committed",()=>y.trigger()),n.value.on("start",()=>E.trigger()),n.value.on("end",()=>P.trigger()),n.value.on("changed",()=>{O(),h.trigger()})])},{flush:"post"}),s.tryOnScopeDispose(()=>H()),{drauuInstance:n,load:R,dump:m,clear:j,cancel:M,undo:k,redo:G,canUndo:b,canRedo:A,brush:d,onChanged:h.on,onCommitted:y.on,onStart:E.on,onEnd:P.on,onCanceled:_.on}}e.useDrauu=C,Object.defineProperty(e,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi,Drauu,VueUse,VueUse);
|
package/useDrauu.mjs
CHANGED
|
@@ -42,8 +42,10 @@ function useDrauu(target, options) {
|
|
|
42
42
|
});
|
|
43
43
|
watch(brush, () => {
|
|
44
44
|
const instance = drauuInstance.value;
|
|
45
|
-
if (instance)
|
|
45
|
+
if (instance) {
|
|
46
46
|
instance.brush = brush.value;
|
|
47
|
+
instance.mode = brush.value.mode;
|
|
48
|
+
}
|
|
47
49
|
}, { deep: true });
|
|
48
50
|
const undo = () => {
|
|
49
51
|
var _a;
|