Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-request

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-request - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

271

dist/index.cjs.js

@@ -18,27 +18,2 @@ 'use strict';

const RequestConfig = vueDemi.defineComponent({
name: 'RequestConfig',
props: {
config: {
type: Object,
required: true
}
},
setup(props, {
slots
}) {
const {
config
} = props;
vueDemi.provide(GLOBAL_OPTIONS_PROVIDE_KEY, config);
return () => {
var _slots$default;
return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
};
}
});
const objectToString = Object.prototype.toString;

@@ -53,10 +28,10 @@ const toTypeString = val => objectToString.call(val);

const isDocumentVisibility = () => {
var _window, _window$document;
var _window$document;
return !isServer && ((_window = window) === null || _window === void 0 ? void 0 : (_window$document = _window.document) === null || _window$document === void 0 ? void 0 : _window$document.visibilityState) === 'visible';
return !isServer && ((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.visibilityState) === 'visible';
};
const isOnline = () => {
var _ref, _window2, _window2$navigator;
var _ref, _window$navigator;
return (_ref = !isServer && ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$navigator = _window2.navigator) === null || _window2$navigator === void 0 ? void 0 : _window2$navigator.onLine)) !== null && _ref !== void 0 ? _ref : true;
return (_ref = !isServer && ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.onLine)) !== null && _ref !== void 0 ? _ref : true;
};

@@ -88,2 +63,5 @@ const resolvedPromise = Promise.resolve(null);

}
const refToRaw = value => {
return vueDemi.isRef(value) ? value.value : value;
};

@@ -190,3 +168,3 @@ const definePlugin = options => {

queryInstance.data.value = cache.data;
queryInstance.params.value = cache.params || [];
queryInstance.params.value = cache.params;
}

@@ -196,5 +174,3 @@

vueDemi.onUnmounted(() => {
var _unSubscribe$value;
(_unSubscribe$value = unSubscribe.value) === null || _unSubscribe$value === void 0 ? void 0 : _unSubscribe$value.call(unSubscribe);
unSubscribe.value();
});

@@ -241,6 +217,4 @@ return {

onSuccess(data, params) {
var _unSubscribe$value2;
unSubscribe.value();
(_unSubscribe$value2 = unSubscribe.value) === null || _unSubscribe$value2 === void 0 ? void 0 : _unSubscribe$value2.call(unSubscribe);
_setCache(cacheKey, cacheTime, {

@@ -256,6 +230,4 @@ data,

onMutate(data) {
var _unSubscribe$value3;
unSubscribe.value();
(_unSubscribe$value3 = unSubscribe.value) === null || _unSubscribe$value3 === void 0 ? void 0 : _unSubscribe$value3.call(unSubscribe);
_setCache(cacheKey, cacheTime, {

@@ -486,3 +458,5 @@ data,

const debouncedRun = vueDemi.ref();
if (isNil(debounceInterval)) return {};
const debounceOptionsRef = vueDemi.computed(() => debounceOptions);
const debounceIntervalRef = vueDemi.computed(() => refToRaw(debounceInterval));
const originRunRef = vueDemi.ref(queryInstance.context.runAsync);

@@ -493,18 +467,24 @@ if (!manual) {

const originRun = queryInstance.context.runAsync;
debouncedRun.value = debounce(callback => callback(), debounceInterval, debounceOptions);
vueDemi.watchEffect(onInvalidate => {
if (isNil(debounceIntervalRef.value)) return;
debouncedRun.value = debounce(callback => callback(), debounceIntervalRef.value, debounceOptionsRef.value);
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
if (initialAutoRunFlag.value) {
initialAutoRunFlag.value = false;
originRun(...args).then(resolve).catch(reject);
} else {
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
if (initialAutoRunFlag.value) {
initialAutoRunFlag.value = false;
originRunRef.value(...args).then(resolve).catch(reject);
} else {
debouncedRun.value(() => {
originRunRef.value(...args).then(resolve).catch(reject);
});
}
});
onInvalidate(() => {
var _debouncedRun$value;
(_debouncedRun$value = debouncedRun.value) === null || _debouncedRun$value === void 0 ? void 0 : _debouncedRun$value.call(debouncedRun, () => {
originRun(...args).then(resolve).catch(reject);
});
}
(_debouncedRun$value = debouncedRun.value) === null || _debouncedRun$value === void 0 ? void 0 : _debouncedRun$value.cancel();
queryInstance.context.runAsync = originRunRef.value;
});
});
return {

@@ -526,2 +506,4 @@ onCancel() {

const retriedCount = vueDemi.ref(0);
const errorRetryCountRef = vueDemi.computed(() => refToRaw(errorRetryCount));
const errorRetryIntervalRef = vueDemi.computed(() => refToRaw(errorRetryInterval));
let isRetrying = false; // reset retried count

@@ -534,3 +516,3 @@

const actualErrorRetryInterval = vueDemi.computed(() => {
if (errorRetryInterval) return errorRetryInterval;
if (errorRetryIntervalRef.value) return errorRetryIntervalRef.value;
const baseTime = 1000;

@@ -547,4 +529,4 @@ const minCoefficient = 1;

let timerId;
const isInfiniteRetry = errorRetryCount === -1;
const hasRetryCount = retriedCount.value < errorRetryCount; // if errorRetryCount is -1, it will retry the request until it success
const isInfiniteRetry = errorRetryCountRef.value === -1;
const hasRetryCount = retriedCount.value < errorRetryCountRef.value; // if errorRetryCount is -1, it will retry the request until it success

@@ -599,3 +581,4 @@ if (isInfiniteRetry || hasRetryCount) {

}) => {
const delayLoadingTimer = vueDemi.ref();
const delayLoadingTimer = vueDemi.ref(() => {});
const loadingDelayRef = vueDemi.computed(() => refToRaw(loadingDelay));

@@ -605,6 +588,6 @@ const delayLoading = () => {

if (loadingDelay) {
if (loadingDelayRef.value) {
timerId = setTimeout(() => {
queryInstance.loading.value = true;
}, loadingDelay);
}, loadingDelayRef.value);
}

@@ -617,6 +600,4 @@

onBefore() {
var _delayLoadingTimer$va;
queryInstance.loading.value = !loadingDelay;
(_delayLoadingTimer$va = delayLoadingTimer.value) === null || _delayLoadingTimer$va === void 0 ? void 0 : _delayLoadingTimer$va.call(delayLoadingTimer);
queryInstance.loading.value = !loadingDelayRef.value;
delayLoadingTimer.value();
delayLoadingTimer.value = delayLoading();

@@ -626,11 +607,7 @@ },

onCancel() {
var _delayLoadingTimer$va2;
(_delayLoadingTimer$va2 = delayLoadingTimer.value) === null || _delayLoadingTimer$va2 === void 0 ? void 0 : _delayLoadingTimer$va2.call(delayLoadingTimer);
delayLoadingTimer.value();
},
onAfter() {
var _delayLoadingTimer$va3;
(_delayLoadingTimer$va3 = delayLoadingTimer.value) === null || _delayLoadingTimer$va3 === void 0 ? void 0 : _delayLoadingTimer$va3.call(delayLoadingTimer);
delayLoadingTimer.value();
}

@@ -697,2 +674,4 @@

const stopPollingWhenHiddenOrOffline = vueDemi.ref(false);
const pollingIntervalRef = vueDemi.computed(() => refToRaw(pollingInterval));
const errorRetryCountRef = vueDemi.computed(() => refToRaw(errorRetryCount));
const unsubscribeList = [];

@@ -704,10 +683,17 @@

const isKeepPolling = () => {
return (// pollingWhenHidden = true or pollingWhenHidden = false and document is visibility
(pollingWhenHidden || isDocumentVisibility()) && ( // pollingWhenOffline = true or pollingWhenOffline = false and is online
pollingWhenOffline || isOnline())
);
};
const polling = pollingFunc => {
// if errorRetry is enabled, then skip this method
if (queryInstance.error.value && errorRetryCount !== 0) return;
if (queryInstance.error.value && errorRetryCountRef.value !== 0) return;
let timerId;
if (!isNil(pollingInterval) && pollingInterval >= 0) {
if ((pollingWhenHidden || isDocumentVisibility()) && (pollingWhenOffline || isOnline())) {
timerId = setTimeout(pollingFunc, pollingInterval);
if (!isNil(pollingIntervalRef.value) && pollingIntervalRef.value >= 0) {
if (isKeepPolling()) {
timerId = setTimeout(pollingFunc, pollingIntervalRef.value);
} else {

@@ -724,8 +710,14 @@ // stop polling

const rePolling = () => {
if (stopPollingWhenHiddenOrOffline.value && (pollingWhenHidden || isDocumentVisibility()) && (pollingWhenOffline || isOnline())) {
if (stopPollingWhenHiddenOrOffline.value && isKeepPolling()) {
queryInstance.context.refresh();
stopPollingWhenHiddenOrOffline.value = false;
}
}; // subscribe polling
};
vueDemi.watch(pollingIntervalRef, () => {
if (pollingTimer.value) {
pollingTimer.value();
pollingTimer.value = polling(() => queryInstance.context.refresh());
}
}); // subscribe polling

@@ -792,2 +784,3 @@ if (!pollingWhenHidden) {

refreshDeps = [],
refreshDepsAction,
manual

@@ -798,3 +791,9 @@ }) => {

vueDemi.watch(refreshDeps, () => {
!manual && queryInstance.context.refresh();
if (manual) return;
if (refreshDepsAction) {
refreshDepsAction();
} else {
queryInstance.context.refresh();
}
});

@@ -822,3 +821,4 @@ }

}) => {
const limitRefresh = limitTrigger(queryInstance.context.refresh, refocusTimespan);
const refreshOnWindowFocusRef = vueDemi.computed(() => refToRaw(refreshOnWindowFocus));
const refocusTimespanRef = vueDemi.computed(() => refToRaw(refocusTimespan));
const unsubscribeList = [];

@@ -830,9 +830,17 @@

if (refreshOnWindowFocus) {
addUnsubscribeList(subscriber('VISIBLE_LISTENER', limitRefresh));
addUnsubscribeList(subscriber('FOCUS_LISTENER', limitRefresh));
}
const unsubscribe = () => {
unsubscribeList.forEach(fn => fn());
};
vueDemi.watchEffect(() => {
unsubscribe();
if (refreshOnWindowFocusRef.value) {
const limitRefresh = limitTrigger(queryInstance.context.refresh, refocusTimespanRef.value);
addUnsubscribeList(subscriber('VISIBLE_LISTENER', limitRefresh));
addUnsubscribeList(subscriber('FOCUS_LISTENER', limitRefresh));
}
});
vueDemi.onUnmounted(() => {
unsubscribeList.forEach(unsubscribe => unsubscribe());
unsubscribe();
});

@@ -847,14 +855,22 @@ return {};

const throttledRun = vueDemi.ref();
if (isNil(throttleInterval)) return {};
const originRun = queryInstance.context.runAsync;
throttledRun.value = throttle(callback => callback(), throttleInterval, throttleOptions);
const throttleIntervalRef = vueDemi.computed(() => refToRaw(throttleInterval));
const throttleOptionsRef = vueDemi.computed(() => throttleOptions);
const originRunRef = vueDemi.ref(queryInstance.context.runAsync);
vueDemi.watchEffect(onInvalidate => {
if (isNil(throttleInterval)) return {};
throttledRun.value = throttle(callback => callback(), throttleIntervalRef.value, throttleOptionsRef.value);
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
var _throttledRun$value;
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
throttledRun.value(() => {
originRunRef.value(...args).then(resolve).catch(reject);
});
});
(_throttledRun$value = throttledRun.value) === null || _throttledRun$value === void 0 ? void 0 : _throttledRun$value.call(throttledRun, () => {
originRun(...args).then(resolve).catch(reject);
onInvalidate(() => {
var _throttledRun$value;
(_throttledRun$value = throttledRun.value) === null || _throttledRun$value === void 0 ? void 0 : _throttledRun$value.cancel();
queryInstance.context.runAsync = originRunRef.value;
});
});
return {

@@ -1005,3 +1021,3 @@ onCancel() {

function useQuery(service, options = {}, plugins = []) {
function useQuery(service, options = {}, plugins) {
const injectedGlobalOptions = vueDemi.inject(GLOBAL_OPTIONS_PROVIDE_KEY, {});

@@ -1171,27 +1187,20 @@ const config = { ...getGlobalOptions(),

function usePagination(service, options) {
var _getGlobalOptions$pag, _injectedGlobalOption;
const defaultOptions = {
pagination: {
currentKey: 'current',
pageSizeKey: 'pageSize',
totalKey: 'total',
totalPageKey: 'totalPage'
}
function usePagination(service, options = {}) {
const defaultPaginationOptions = {
currentKey: 'current',
pageSizeKey: 'pageSize',
totalKey: 'total',
totalPageKey: 'totalPage'
};
const injectedGlobalOptions = vueDemi.inject(GLOBAL_OPTIONS_PROVIDE_KEY, {});
const {
pagination: {
currentKey,
pageSizeKey,
totalKey,
totalPageKey
},
pagination,
...restOptions
} = merge(defaultOptions, {
pagination: (_getGlobalOptions$pag = getGlobalOptions().pagination) !== null && _getGlobalOptions$pag !== void 0 ? _getGlobalOptions$pag : {}
}, {
pagination: (_injectedGlobalOption = injectedGlobalOptions.pagination) !== null && _injectedGlobalOption !== void 0 ? _injectedGlobalOption : {}
}, options !== null && options !== void 0 ? options : {});
} = options;
const {
currentKey,
pageSizeKey,
totalKey,
totalPageKey
} = merge(defaultPaginationOptions, getGlobalOptions().pagination || {}, injectedGlobalOptions.pagination || {}, pagination || {});
const finallyOptions = merge({

@@ -1207,4 +1216,2 @@ defaultParams: [{

run,
runAsync,
cancel,
...rest

@@ -1244,24 +1251,10 @@ } = useRequest(service, finallyOptions);

const reloading = vueDemi.ref(false);
const reload = async () => {
const {
defaultParams,
manual
} = finallyOptions;
cancel();
if (!manual) {
reloading.value = true;
await runAsync(...defaultParams);
reloading.value = false;
}
};
const total = vueDemi.computed(() => get(data.value, totalKey, 0));
const current = vueDemi.computed({
get: () => {
var _params$value$0$curre, _params$value, _params$value$;
var _params$value$0$curre, _params$value;
return (_params$value$0$curre = (_params$value = params.value) === null || _params$value === void 0 ? void 0 : (_params$value$ = _params$value[0]) === null || _params$value$ === void 0 ? void 0 : _params$value$[currentKey]) !== null && _params$value$0$curre !== void 0 ? _params$value$0$curre : finallyOptions.defaultParams[0][currentKey];
return (// @ts-ignore
(_params$value$0$curre = (_params$value = params.value) === null || _params$value === void 0 ? void 0 : _params$value[0][currentKey]) !== null && _params$value$0$curre !== void 0 ? _params$value$0$curre : finallyOptions.defaultParams[0][currentKey]
);
},

@@ -1274,5 +1267,7 @@ set: val => {

get: () => {
var _params$value$0$pageS, _params$value2, _params$value2$;
var _params$value$0$pageS, _params$value2;
return (_params$value$0$pageS = (_params$value2 = params.value) === null || _params$value2 === void 0 ? void 0 : (_params$value2$ = _params$value2[0]) === null || _params$value2$ === void 0 ? void 0 : _params$value2$[pageSizeKey]) !== null && _params$value$0$pageS !== void 0 ? _params$value$0$pageS : finallyOptions.defaultParams[0][pageSizeKey];
return (// @ts-ignore
(_params$value$0$pageS = (_params$value2 = params.value) === null || _params$value2 === void 0 ? void 0 : _params$value2[0][pageSizeKey]) !== null && _params$value$0$pageS !== void 0 ? _params$value$0$pageS : finallyOptions.defaultParams[0][pageSizeKey]
);
},

@@ -1291,10 +1286,6 @@ set: val => {

totalPage,
reloading,
run,
runAsync,
changeCurrent,
changePageSize,
changePagination,
reload,
cancel,
...rest

@@ -1304,3 +1295,6 @@ };

exports.RequestConfig = RequestConfig;
var useRequestProvider = (config => {
vueDemi.provide(GLOBAL_OPTIONS_PROVIDE_KEY, config);
});
exports.setGlobalOptions = setGlobalOptions;

@@ -1310,1 +1304,2 @@ exports.useLoadMore = useLoadMore;

exports.useRequest = useRequest;
exports.useRequestProvider = useRequestProvider;

@@ -1,2 +0,2 @@

import { defineComponent, provide, ref, onUnmounted, computed, watch, shallowRef, inject } from 'vue-demi';
import { isRef, ref, onUnmounted, computed, watchEffect, watch, shallowRef, inject, provide } from 'vue-demi';

@@ -14,27 +14,2 @@ const GLOBAL_OPTIONS = {};

const RequestConfig = defineComponent({
name: 'RequestConfig',
props: {
config: {
type: Object,
required: true
}
},
setup(props, {
slots
}) {
const {
config
} = props;
provide(GLOBAL_OPTIONS_PROVIDE_KEY, config);
return () => {
var _slots$default;
return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
};
}
});
const objectToString = Object.prototype.toString;

@@ -49,10 +24,10 @@ const toTypeString = val => objectToString.call(val);

const isDocumentVisibility = () => {
var _window, _window$document;
var _window$document;
return !isServer && ((_window = window) === null || _window === void 0 ? void 0 : (_window$document = _window.document) === null || _window$document === void 0 ? void 0 : _window$document.visibilityState) === 'visible';
return !isServer && ((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.visibilityState) === 'visible';
};
const isOnline = () => {
var _ref, _window2, _window2$navigator;
var _ref, _window$navigator;
return (_ref = !isServer && ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$navigator = _window2.navigator) === null || _window2$navigator === void 0 ? void 0 : _window2$navigator.onLine)) !== null && _ref !== void 0 ? _ref : true;
return (_ref = !isServer && ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.onLine)) !== null && _ref !== void 0 ? _ref : true;
};

@@ -84,2 +59,5 @@ const resolvedPromise = Promise.resolve(null);

}
const refToRaw = value => {
return isRef(value) ? value.value : value;
};

@@ -186,3 +164,3 @@ const definePlugin = options => {

queryInstance.data.value = cache.data;
queryInstance.params.value = cache.params || [];
queryInstance.params.value = cache.params;
}

@@ -192,5 +170,3 @@

onUnmounted(() => {
var _unSubscribe$value;
(_unSubscribe$value = unSubscribe.value) === null || _unSubscribe$value === void 0 ? void 0 : _unSubscribe$value.call(unSubscribe);
unSubscribe.value();
});

@@ -237,6 +213,4 @@ return {

onSuccess(data, params) {
var _unSubscribe$value2;
unSubscribe.value();
(_unSubscribe$value2 = unSubscribe.value) === null || _unSubscribe$value2 === void 0 ? void 0 : _unSubscribe$value2.call(unSubscribe);
_setCache(cacheKey, cacheTime, {

@@ -252,6 +226,4 @@ data,

onMutate(data) {
var _unSubscribe$value3;
unSubscribe.value();
(_unSubscribe$value3 = unSubscribe.value) === null || _unSubscribe$value3 === void 0 ? void 0 : _unSubscribe$value3.call(unSubscribe);
_setCache(cacheKey, cacheTime, {

@@ -482,3 +454,5 @@ data,

const debouncedRun = ref();
if (isNil(debounceInterval)) return {};
const debounceOptionsRef = computed(() => debounceOptions);
const debounceIntervalRef = computed(() => refToRaw(debounceInterval));
const originRunRef = ref(queryInstance.context.runAsync);

@@ -489,18 +463,24 @@ if (!manual) {

const originRun = queryInstance.context.runAsync;
debouncedRun.value = debounce(callback => callback(), debounceInterval, debounceOptions);
watchEffect(onInvalidate => {
if (isNil(debounceIntervalRef.value)) return;
debouncedRun.value = debounce(callback => callback(), debounceIntervalRef.value, debounceOptionsRef.value);
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
if (initialAutoRunFlag.value) {
initialAutoRunFlag.value = false;
originRun(...args).then(resolve).catch(reject);
} else {
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
if (initialAutoRunFlag.value) {
initialAutoRunFlag.value = false;
originRunRef.value(...args).then(resolve).catch(reject);
} else {
debouncedRun.value(() => {
originRunRef.value(...args).then(resolve).catch(reject);
});
}
});
onInvalidate(() => {
var _debouncedRun$value;
(_debouncedRun$value = debouncedRun.value) === null || _debouncedRun$value === void 0 ? void 0 : _debouncedRun$value.call(debouncedRun, () => {
originRun(...args).then(resolve).catch(reject);
});
}
(_debouncedRun$value = debouncedRun.value) === null || _debouncedRun$value === void 0 ? void 0 : _debouncedRun$value.cancel();
queryInstance.context.runAsync = originRunRef.value;
});
});
return {

@@ -522,2 +502,4 @@ onCancel() {

const retriedCount = ref(0);
const errorRetryCountRef = computed(() => refToRaw(errorRetryCount));
const errorRetryIntervalRef = computed(() => refToRaw(errorRetryInterval));
let isRetrying = false; // reset retried count

@@ -530,3 +512,3 @@

const actualErrorRetryInterval = computed(() => {
if (errorRetryInterval) return errorRetryInterval;
if (errorRetryIntervalRef.value) return errorRetryIntervalRef.value;
const baseTime = 1000;

@@ -543,4 +525,4 @@ const minCoefficient = 1;

let timerId;
const isInfiniteRetry = errorRetryCount === -1;
const hasRetryCount = retriedCount.value < errorRetryCount; // if errorRetryCount is -1, it will retry the request until it success
const isInfiniteRetry = errorRetryCountRef.value === -1;
const hasRetryCount = retriedCount.value < errorRetryCountRef.value; // if errorRetryCount is -1, it will retry the request until it success

@@ -595,3 +577,4 @@ if (isInfiniteRetry || hasRetryCount) {

}) => {
const delayLoadingTimer = ref();
const delayLoadingTimer = ref(() => {});
const loadingDelayRef = computed(() => refToRaw(loadingDelay));

@@ -601,6 +584,6 @@ const delayLoading = () => {

if (loadingDelay) {
if (loadingDelayRef.value) {
timerId = setTimeout(() => {
queryInstance.loading.value = true;
}, loadingDelay);
}, loadingDelayRef.value);
}

@@ -613,6 +596,4 @@

onBefore() {
var _delayLoadingTimer$va;
queryInstance.loading.value = !loadingDelay;
(_delayLoadingTimer$va = delayLoadingTimer.value) === null || _delayLoadingTimer$va === void 0 ? void 0 : _delayLoadingTimer$va.call(delayLoadingTimer);
queryInstance.loading.value = !loadingDelayRef.value;
delayLoadingTimer.value();
delayLoadingTimer.value = delayLoading();

@@ -622,11 +603,7 @@ },

onCancel() {
var _delayLoadingTimer$va2;
(_delayLoadingTimer$va2 = delayLoadingTimer.value) === null || _delayLoadingTimer$va2 === void 0 ? void 0 : _delayLoadingTimer$va2.call(delayLoadingTimer);
delayLoadingTimer.value();
},
onAfter() {
var _delayLoadingTimer$va3;
(_delayLoadingTimer$va3 = delayLoadingTimer.value) === null || _delayLoadingTimer$va3 === void 0 ? void 0 : _delayLoadingTimer$va3.call(delayLoadingTimer);
delayLoadingTimer.value();
}

@@ -693,2 +670,4 @@

const stopPollingWhenHiddenOrOffline = ref(false);
const pollingIntervalRef = computed(() => refToRaw(pollingInterval));
const errorRetryCountRef = computed(() => refToRaw(errorRetryCount));
const unsubscribeList = [];

@@ -700,10 +679,17 @@

const isKeepPolling = () => {
return (// pollingWhenHidden = true or pollingWhenHidden = false and document is visibility
(pollingWhenHidden || isDocumentVisibility()) && ( // pollingWhenOffline = true or pollingWhenOffline = false and is online
pollingWhenOffline || isOnline())
);
};
const polling = pollingFunc => {
// if errorRetry is enabled, then skip this method
if (queryInstance.error.value && errorRetryCount !== 0) return;
if (queryInstance.error.value && errorRetryCountRef.value !== 0) return;
let timerId;
if (!isNil(pollingInterval) && pollingInterval >= 0) {
if ((pollingWhenHidden || isDocumentVisibility()) && (pollingWhenOffline || isOnline())) {
timerId = setTimeout(pollingFunc, pollingInterval);
if (!isNil(pollingIntervalRef.value) && pollingIntervalRef.value >= 0) {
if (isKeepPolling()) {
timerId = setTimeout(pollingFunc, pollingIntervalRef.value);
} else {

@@ -720,8 +706,14 @@ // stop polling

const rePolling = () => {
if (stopPollingWhenHiddenOrOffline.value && (pollingWhenHidden || isDocumentVisibility()) && (pollingWhenOffline || isOnline())) {
if (stopPollingWhenHiddenOrOffline.value && isKeepPolling()) {
queryInstance.context.refresh();
stopPollingWhenHiddenOrOffline.value = false;
}
}; // subscribe polling
};
watch(pollingIntervalRef, () => {
if (pollingTimer.value) {
pollingTimer.value();
pollingTimer.value = polling(() => queryInstance.context.refresh());
}
}); // subscribe polling

@@ -788,2 +780,3 @@ if (!pollingWhenHidden) {

refreshDeps = [],
refreshDepsAction,
manual

@@ -794,3 +787,9 @@ }) => {

watch(refreshDeps, () => {
!manual && queryInstance.context.refresh();
if (manual) return;
if (refreshDepsAction) {
refreshDepsAction();
} else {
queryInstance.context.refresh();
}
});

@@ -818,3 +817,4 @@ }

}) => {
const limitRefresh = limitTrigger(queryInstance.context.refresh, refocusTimespan);
const refreshOnWindowFocusRef = computed(() => refToRaw(refreshOnWindowFocus));
const refocusTimespanRef = computed(() => refToRaw(refocusTimespan));
const unsubscribeList = [];

@@ -826,9 +826,17 @@

if (refreshOnWindowFocus) {
addUnsubscribeList(subscriber('VISIBLE_LISTENER', limitRefresh));
addUnsubscribeList(subscriber('FOCUS_LISTENER', limitRefresh));
}
const unsubscribe = () => {
unsubscribeList.forEach(fn => fn());
};
watchEffect(() => {
unsubscribe();
if (refreshOnWindowFocusRef.value) {
const limitRefresh = limitTrigger(queryInstance.context.refresh, refocusTimespanRef.value);
addUnsubscribeList(subscriber('VISIBLE_LISTENER', limitRefresh));
addUnsubscribeList(subscriber('FOCUS_LISTENER', limitRefresh));
}
});
onUnmounted(() => {
unsubscribeList.forEach(unsubscribe => unsubscribe());
unsubscribe();
});

@@ -843,14 +851,22 @@ return {};

const throttledRun = ref();
if (isNil(throttleInterval)) return {};
const originRun = queryInstance.context.runAsync;
throttledRun.value = throttle(callback => callback(), throttleInterval, throttleOptions);
const throttleIntervalRef = computed(() => refToRaw(throttleInterval));
const throttleOptionsRef = computed(() => throttleOptions);
const originRunRef = ref(queryInstance.context.runAsync);
watchEffect(onInvalidate => {
if (isNil(throttleInterval)) return {};
throttledRun.value = throttle(callback => callback(), throttleIntervalRef.value, throttleOptionsRef.value);
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
var _throttledRun$value;
queryInstance.context.runAsync = (...args) => new Promise((resolve, reject) => {
throttledRun.value(() => {
originRunRef.value(...args).then(resolve).catch(reject);
});
});
(_throttledRun$value = throttledRun.value) === null || _throttledRun$value === void 0 ? void 0 : _throttledRun$value.call(throttledRun, () => {
originRun(...args).then(resolve).catch(reject);
onInvalidate(() => {
var _throttledRun$value;
(_throttledRun$value = throttledRun.value) === null || _throttledRun$value === void 0 ? void 0 : _throttledRun$value.cancel();
queryInstance.context.runAsync = originRunRef.value;
});
});
return {

@@ -1001,3 +1017,3 @@ onCancel() {

function useQuery(service, options = {}, plugins = []) {
function useQuery(service, options = {}, plugins) {
const injectedGlobalOptions = inject(GLOBAL_OPTIONS_PROVIDE_KEY, {});

@@ -1167,27 +1183,20 @@ const config = { ...getGlobalOptions(),

function usePagination(service, options) {
var _getGlobalOptions$pag, _injectedGlobalOption;
const defaultOptions = {
pagination: {
currentKey: 'current',
pageSizeKey: 'pageSize',
totalKey: 'total',
totalPageKey: 'totalPage'
}
function usePagination(service, options = {}) {
const defaultPaginationOptions = {
currentKey: 'current',
pageSizeKey: 'pageSize',
totalKey: 'total',
totalPageKey: 'totalPage'
};
const injectedGlobalOptions = inject(GLOBAL_OPTIONS_PROVIDE_KEY, {});
const {
pagination: {
currentKey,
pageSizeKey,
totalKey,
totalPageKey
},
pagination,
...restOptions
} = merge(defaultOptions, {
pagination: (_getGlobalOptions$pag = getGlobalOptions().pagination) !== null && _getGlobalOptions$pag !== void 0 ? _getGlobalOptions$pag : {}
}, {
pagination: (_injectedGlobalOption = injectedGlobalOptions.pagination) !== null && _injectedGlobalOption !== void 0 ? _injectedGlobalOption : {}
}, options !== null && options !== void 0 ? options : {});
} = options;
const {
currentKey,
pageSizeKey,
totalKey,
totalPageKey
} = merge(defaultPaginationOptions, getGlobalOptions().pagination || {}, injectedGlobalOptions.pagination || {}, pagination || {});
const finallyOptions = merge({

@@ -1203,4 +1212,2 @@ defaultParams: [{

run,
runAsync,
cancel,
...rest

@@ -1240,24 +1247,10 @@ } = useRequest(service, finallyOptions);

const reloading = ref(false);
const reload = async () => {
const {
defaultParams,
manual
} = finallyOptions;
cancel();
if (!manual) {
reloading.value = true;
await runAsync(...defaultParams);
reloading.value = false;
}
};
const total = computed(() => get(data.value, totalKey, 0));
const current = computed({
get: () => {
var _params$value$0$curre, _params$value, _params$value$;
var _params$value$0$curre, _params$value;
return (_params$value$0$curre = (_params$value = params.value) === null || _params$value === void 0 ? void 0 : (_params$value$ = _params$value[0]) === null || _params$value$ === void 0 ? void 0 : _params$value$[currentKey]) !== null && _params$value$0$curre !== void 0 ? _params$value$0$curre : finallyOptions.defaultParams[0][currentKey];
return (// @ts-ignore
(_params$value$0$curre = (_params$value = params.value) === null || _params$value === void 0 ? void 0 : _params$value[0][currentKey]) !== null && _params$value$0$curre !== void 0 ? _params$value$0$curre : finallyOptions.defaultParams[0][currentKey]
);
},

@@ -1270,5 +1263,7 @@ set: val => {

get: () => {
var _params$value$0$pageS, _params$value2, _params$value2$;
var _params$value$0$pageS, _params$value2;
return (_params$value$0$pageS = (_params$value2 = params.value) === null || _params$value2 === void 0 ? void 0 : (_params$value2$ = _params$value2[0]) === null || _params$value2$ === void 0 ? void 0 : _params$value2$[pageSizeKey]) !== null && _params$value$0$pageS !== void 0 ? _params$value$0$pageS : finallyOptions.defaultParams[0][pageSizeKey];
return (// @ts-ignore
(_params$value$0$pageS = (_params$value2 = params.value) === null || _params$value2 === void 0 ? void 0 : _params$value2[0][pageSizeKey]) !== null && _params$value$0$pageS !== void 0 ? _params$value$0$pageS : finallyOptions.defaultParams[0][pageSizeKey]
);
},

@@ -1287,10 +1282,6 @@ set: val => {

totalPage,
reloading,
run,
runAsync,
changeCurrent,
changePageSize,
changePagination,
reload,
cancel,
...rest

@@ -1300,2 +1291,6 @@ };

export { RequestConfig, setGlobalOptions, useLoadMore, usePagination, useRequest };
var useRequestProvider = (config => {
provide(GLOBAL_OPTIONS_PROVIDE_KEY, config);
});
export { setGlobalOptions, useLoadMore, usePagination, useRequest, useRequestProvider };

@@ -1,3 +0,2 @@

import * as vue_demi from 'vue-demi';
import { Ref, ComputedRef, WritableComputedRef, WatchSource, PropType } from 'vue-demi';
import { Ref, ComputedRef, WritableComputedRef, WatchSource } from 'vue-demi';

@@ -26,9 +25,10 @@ declare type LoadMoreExtendsOption = {

interface PaginationType {
currentKey: string;
pageSizeKey: string;
totalKey: string;
totalPageKey: string;
}
interface PaginationExtendsOption {
pagination?: {
currentKey?: string;
pageSizeKey?: string;
totalKey?: string;
totalPageKey?: string;
};
pagination?: Partial<PaginationType>;
}

@@ -42,4 +42,2 @@ interface PaginationOptions<R, P extends unknown[]> extends Options<R, P>, PaginationExtendsOption {

totalPage: ComputedRef<number>;
reloading: Ref<boolean>;
reload: () => void;
changeCurrent: (current: number) => void;

@@ -86,17 +84,17 @@ changePageSize: (pageSize: number) => void;

declare type BaseOptions = {
loadingDelay?: number;
pollingInterval?: number;
loadingDelay?: number | Ref<number>;
pollingInterval?: number | Ref<number>;
pollingWhenHidden?: boolean;
pollingWhenOffline?: boolean;
debounceInterval?: number;
debounceInterval?: number | Ref<number>;
debounceOptions?: DebounceOptions;
throttleOptions?: ThrottleOptions;
throttleInterval?: number;
refreshOnWindowFocus?: boolean;
refocusTimespan?: number;
throttleInterval?: number | Ref<number>;
refreshOnWindowFocus?: boolean | Ref<boolean>;
refocusTimespan?: number | Ref<number>;
cacheTime?: number;
staleTime?: number;
manual?: boolean;
errorRetryCount?: number;
errorRetryInterval?: number;
errorRetryCount?: number | Ref<number>;
errorRetryInterval?: number | Ref<number>;
getCache?: (cacheKey: string) => CacheData;

@@ -111,2 +109,3 @@ setCache?: (cacheKey: string, cacheData: CacheData) => void;

cacheKey?: string;
refreshDepsAction?: () => void;
onSuccess?: (data: R, params: P) => void;

@@ -120,18 +119,6 @@ onError?: (error: Error, params: P) => void;

declare const RequestConfig: vue_demi.DefineComponent<{
config: {
type: PropType<GlobalOptions>;
required: true;
};
}, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
[key: string]: any;
}>[] | undefined, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, Record<string, any>, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
config: {
type: PropType<GlobalOptions>;
required: true;
};
}>>, {}>;
declare function useRequest<R, P extends unknown[] = any>(service: Service<R, P>, options?: Options<R, P>): QueryResult<R, P>;
export { RequestConfig, setGlobalOptions, useLoadMore, usePagination, useRequest };
declare const _default: (config: GlobalOptions) => void;
export { setGlobalOptions, useLoadMore, usePagination, useRequest, _default as useRequestProvider };

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).VueRequest=e.VueRequest||{},e.vueDemi)}(this,(function(e,n){"use strict";const t={},a=Symbol("GLOBAL_OPTIONS_PROVIDE_KEY"),r=()=>t,o=n.defineComponent({name:"RequestConfig",props:{config:{type:Object,required:!0}},setup(e,{slots:t}){const{config:r}=e;return n.provide(a,r),()=>{var e;return null===(e=t.default)||void 0===e?void 0:e.call(t)}}}),l=Object.prototype.toString,u=e=>"[object Object]"===(e=>l.call(e))(e),i=e=>null!==e&&"object"==typeof e,c=e=>e instanceof Function,s=e=>null==e,v="undefined"==typeof window,d=()=>{var e,n;return!v&&"visible"===(null===(e=window)||void 0===e||null===(n=e.document)||void 0===n?void 0:n.visibilityState)},f=()=>{var e,n,t;return null===(e=!v&&(null===(n=window)||void 0===n||null===(t=n.navigator)||void 0===t?void 0:t.onLine))||void 0===e||e},m=Promise.resolve(null),p=(e,n,t)=>{const a=n.replace(/\[(\d+)\]/g,".$1").split(".");let r=e;for(const e of a)if(r=Object(r)[e],void 0===r)return t;return r};function g(e,n){const t=Object.assign({},e);for(const e of n)delete t[e];return t}const h=new Map,y=new Map,w=new Map;var E=(e,{cacheKey:t,cacheTime:a=6e5,staleTime:r=0,getCache:o,setCache:l})=>{if(!t)return{};const u=n.ref();let i;const c=e=>o?o(e):(e=>{if(s(e))return;return h.get(e)})(e),v=(e,n,t)=>{l?l(e,t):((e,n,t)=>{const a=h.get(e);null!=a&&a.timer&&clearTimeout(a.timer);const r=setTimeout((()=>h.delete(e)),n);h.set(e,{...t,timer:r})})(e,n,t),((e,n)=>{w.has(e)&&w.get(e).forEach((e=>e(n)))})(e,t.data)},d=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),f=()=>{return n=t,a=n=>{e.data.value=n},w.has(n)?w.get(n).push(a):w.set(n,[a]),()=>{const e=w.get(n).indexOf(a);w.get(n).splice(e,1)};var n,a},m=c(t);return m&&d(m,"data")&&(e.data.value=m.data,e.params.value=m.params||[]),u.value=f(),n.onUnmounted((()=>{var e;null===(e=u.value)||void 0===e||e.call(u)})),{onBefore(){const n=c(t);return n&&d(n,"data")?(a=n.time,-1===r||a+r>(new Date).getTime()?(e.data.value=n.data,e.loading.value=!1,{isBreak:!0,breakResult:n.data}):void(e.data.value=n.data)):{};var a},onQuery(e,n){let a=(e=>y.get(e))(t);return a&&a!==i||(a=e(...n),i=a,((e,n)=>{y.set(e,n),n.then((n=>(y.delete(e),n))).catch((()=>{y.delete(e)}))})(t,a)),{servicePromise:a}},onSuccess(e,n){var r;null===(r=u.value)||void 0===r||r.call(u),v(t,a,{data:e,params:n,time:(new Date).getTime()}),u.value=f()},onMutate(n){var r;null===(r=u.value)||void 0===r||r.call(u),v(t,a,{data:n,params:e.params.value,time:(new Date).getTime()}),u.value=f()}}};function A(e,n,t){let a,r,o,l,u,c,s=0,v=!1,d=!1,f=!0;const m=!n&&0!==n&&"function"==typeof window.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function p(n){const t=a,o=r;return a=r=void 0,s=n,l=e.apply(o,t),l}function g(e,n){return m?(window.cancelAnimationFrame(u),window.requestAnimationFrame(e)):setTimeout(e,n)}function h(e){const t=e-c;return void 0===c||t>=n||t<0||d&&e-s>=o}function y(){const e=Date.now();if(h(e))return w(e);u=g(y,function(e){const t=e-s,a=n-(e-c);return d?Math.min(a,o-t):a}(e))}function w(e){return u=void 0,f&&a?p(e):(a=r=void 0,l)}function E(...e){const t=Date.now(),o=h(t);if(a=e,r=this,c=t,o){if(void 0===u)return function(e){return s=e,u=g(y,n),v?p(e):l}(c);if(d)return u=g(y,n),p(c)}return void 0===u&&(u=g(y,n)),l}return n=+n||0,i(t)&&(v=!!t.leading,d="maxWait"in t,o=d?Math.max(+t.maxWait||0,n):o,f="trailing"in t?!!t.trailing:f),E.cancel=function(){void 0!==u&&function(e){if(m)return window.cancelAnimationFrame(e);clearTimeout(e)}(u),s=0,a=c=r=u=void 0},E.flush=function(){return void 0===u?l:w(Date.now())},E.pending=function(){return void 0!==u},E}function T(e,n){for(const a in n)void 0!==n[a]&&(i(n[a])&&i(e[a])&&a in e?(u(n[a])||(t=n[a],Array.isArray(t)))&&T(e[a],n[a]):e[a]=n[a]);var t}function S(e,...n){const t=Object.assign({},e);if(!n.length)return t;for(const e of n)T(t,e);return t}var x,b=(e,{debounceInterval:t,debounceOptions:a,manual:r})=>{const o=n.ref(!1),l=n.ref();if(s(t))return{};r||(o.value=!0);const u=e.context.runAsync;return l.value=A((e=>e()),t,a),e.context.runAsync=(...e)=>new Promise(((n,t)=>{var a;o.value?(o.value=!1,u(...e).then(n).catch(t)):null===(a=l.value)||void 0===a||a.call(l,(()=>{u(...e).then(n).catch(t)}))})),{onCancel(){var e;null===(e=l.value)||void 0===e||e.cancel()}}},O=(e,{errorRetryCount:t=0,errorRetryInterval:a=0})=>{const r=n.ref(),o=n.ref(0);let l=!1;const u=()=>{o.value=0},i=n.computed((()=>{if(a)return a;return 1e3*Math.floor(Math.random()*2**Math.min(o.value,9)+1)})),c=()=>{r.value&&r.value()};return{onBefore(){l||u(),l=!1,c()},onSuccess(){u()},onError(){r.value=(()=>{let n;const a=-1===t,r=o.value<t;return(a||r)&&(a||(o.value+=1),n=setTimeout((()=>{l=!0,e.context.refresh()}),i.value)),()=>n&&clearTimeout(n)})()},onCancel(){u(),c()}}},P=(e,{loadingDelay:t=0})=>{const a=n.ref();return{onBefore(){var n;e.loading.value=!t,null===(n=a.value)||void 0===n||n.call(a),a.value=(()=>{let n;return t&&(n=setTimeout((()=>{e.loading.value=!0}),t)),()=>n&&clearTimeout(n)})()},onCancel(){var e;null===(e=a.value)||void 0===e||e.call(a)},onAfter(){var e;null===(e=a.value)||void 0===e||e.call(a)}}};const R=new Set,C=new Set,L=new Set,I=(e,n)=>{let t;switch(e){case"FOCUS_LISTENER":t=R;break;case"RECONNECT_LISTENER":t=L;break;case"VISIBLE_LISTENER":t=C}if(!t.has(n))return t.add(n),()=>{t.delete(n)}},j=e=>{e.forEach((e=>{e()}))};!v&&null!==(x=window)&&void 0!==x&&x.addEventListener&&(window.addEventListener("visibilitychange",(()=>{d()&&j(C)}),!1),window.addEventListener("focus",(()=>j(R)),!1),window.addEventListener("online",(()=>j(L)),!1));var M=(e,{pollingInterval:t,pollingWhenHidden:a=!1,pollingWhenOffline:r=!1,errorRetryCount:o=0})=>{const l=n.ref(),u=n.ref(!1),i=[],c=e=>{e&&i.push(e)},v=()=>{u.value&&(a||d())&&(r||f())&&(e.context.refresh(),u.value=!1)};return a||c(I("VISIBLE_LISTENER",v)),r||c(I("RECONNECT_LISTENER",v)),n.onUnmounted((()=>{i.forEach((e=>e()))})),{onBefore(){var e;null===(e=l.value)||void 0===e||e.call(l)},onCancel(){var e;null===(e=l.value)||void 0===e||e.call(l)},onAfter(){l.value=(n=>{if(e.error.value&&0!==o)return;let l;if(!s(t)&&t>=0){if(!a&&!d()||!r&&!f())return void(u.value=!0);l=setTimeout(n,t)}return()=>l&&clearTimeout(l)})((()=>e.context.refresh()))}}},B=(e,{ready:t=n.ref(!0),manual:a,defaultParams:r=[]})=>(n.watch(t,(n=>{!a&&n&&e.context.run(...r)}),{flush:"sync"}),{onBefore(){if(!t.value)return e.loading.value=!1,{isBreak:!0}}}),K=(e,{refreshDeps:t=[],manual:a})=>(null!=t&&t.length&&n.watch(t,(()=>{!a&&e.context.refresh()})),{});var N=(e,{refreshOnWindowFocus:t=!1,refocusTimespan:a=5e3})=>{const r=((e,n)=>{let t=!1;return(...a)=>{t||(t=!0,e(...a),setTimeout((()=>{t=!1}),n))}})(e.context.refresh,a),o=[],l=e=>{e&&o.push(e)};return t&&(l(I("VISIBLE_LISTENER",r)),l(I("FOCUS_LISTENER",r))),n.onUnmounted((()=>{o.forEach((e=>e()))})),{}},_=(e,{throttleInterval:t,throttleOptions:a})=>{const r=n.ref();if(s(t))return{};const o=e.context.runAsync;return r.value=function(e,n,t){let a=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return i(t)&&(a="leading"in t?!!t.leading:a,r="trailing"in t?!!t.trailing:r),A(e,n,{leading:a,trailing:r,maxWait:n})}((e=>e()),t,a),e.context.runAsync=(...e)=>new Promise(((n,t)=>{var a;null===(a=r.value)||void 0===a||a.call(r,(()=>{o(...e).then(n).catch(t)}))})),{onCancel(){var e;null===(e=r.value)||void 0===e||e.cancel()}}};const D=(e,t,a)=>{var r,o;const{initialData:l,onSuccess:u,onError:i,onBefore:s,onAfter:v}=t,d=n.ref(null!==(r=null==a?void 0:a.loading)&&void 0!==r&&r),f=n.shallowRef(null!==(o=null==a?void 0:a.data)&&void 0!==o?o:l),p=n.shallowRef(null==a?void 0:a.error),g=n.ref(null==a?void 0:a.params),h=n.ref([]),y={},w=(E={loading:d,data:f,error:p,params:g},A=[],e=>{Object.keys(e).forEach((n=>{E[n].value=e[n]})),A.forEach((e=>e(E)))});var E,A;const T=(e,...n)=>{const t=h.value.map((t=>{var a;return null===(a=t[e])||void 0===a?void 0:a.call(t,...n)}));return Object.assign({},...t)},S=n.ref(0);return y.runAsync=async(...n)=>{w({loading:!0,params:n}),S.value+=1;const t=S.value,{isBreak:a,breakResult:r=m}=T("onBefore",n);if(a)return r;null==s||s(n);try{let{servicePromise:a}=T("onQuery",e,g.value);a||(a=e(...g.value));const r=await a;return t!==S.value?m:(w({data:r,loading:!1,error:void 0}),T("onSuccess",r,n),null==u||u(r,n),T("onAfter",n,r,void 0),null==v||v(n),r)}catch(e){if(t!==S.value)return m;throw w({loading:!1,error:e}),T("onError",e,n),null==i||i(e,n),T("onAfter",n,void 0,e),null==v||v(n),e}},y.run=async(...e)=>{y.runAsync(...e).catch((e=>{i||console.error(e)}))},y.cancel=()=>{S.value+=1,w({loading:!1}),T("onCancel")},y.refresh=()=>{y.run(...g.value)},y.refreshAsync=()=>y.runAsync(...g.value),y.mutate=e=>{const n=c(e)?e(f.value):e;w({data:n}),T("onMutate",n)},{loading:d,data:f,error:p,params:g,plugins:h,context:y}};function k(e,t){return function(e,t={},o=[]){const l=n.inject(a,{}),u={...r(),...l,...t},{manual:i=!1,defaultParams:c=[]}=u,s=D(e,u);if(s.plugins.value=o.map((e=>e(s,u))),!i){const e=s.params.value||c;s.context.run(...e)}return n.onUnmounted((()=>{s.context.cancel()})),{loading:s.loading,data:s.data,error:s.error,params:s.params,cancel:s.context.cancel,refresh:s.context.refresh,refreshAsync:s.context.refreshAsync,mutate:s.context.mutate,run:s.context.run,runAsync:s.context.runAsync}}(e,t,[P,O,b,M,_,N,K,B,E])}e.RequestConfig=o,e.setGlobalOptions=e=>{Object.keys(e).forEach((n=>{t[n]=e[n]}))},e.useLoadMore=function(e,t){var o;const l=n.inject(a,{}),{isNoMore:u,listKey:i="list",...s}=Object.assign({listKey:null!==(o=l.listKey)&&void 0!==o?o:r().listKey},null!=t?t:{}),v=n.ref(!1),d=n.ref(!1),f=n.ref(!1),m=n.ref([]),{data:h,params:y,runAsync:w,run:E,cancel:A,...T}=k(e,{...s,onSuccess:(...e)=>{var n;v.value&&(m.value=[]),d.value=!1,v.value=!1,f.value=!1,null==s||null===(n=s.onSuccess)||void 0===n||n.call(s,...e)},onError:(...e)=>{var n;d.value=!1,v.value=!1,f.value=!1,null==s||null===(n=s.onError)||void 0===n||n.call(s,...e)},onAfter:(...e)=>{var n;null==s||null===(n=s.onAfter)||void 0===n||n.call(s,...e)}}),S=n.computed((()=>!(!u||!c(u))&&u(h.value)));n.watch(h,(e=>{if(e){const n=p(e,i);n&&Array.isArray(n)&&(m.value=[...m.value,...n])}}));const x=()=>{A(),d.value=!1,v.value=!1};return{data:h,dataList:m,params:y,noMore:S,loadingMore:d,refreshing:v,reloading:f,runAsync:w,reload:()=>{f.value=!0,x(),m.value=[];const[,...e]=y.value,n=[void 0,...e];E(...n)},loadMore:()=>{if(S.value)return;d.value=!0;const[,...e]=y.value,n=[{dataList:m.value,data:h.value},...e];E(...n)},refresh:()=>{v.value=!0;const[,...e]=y.value,n=[void 0,...e];w(...n)},cancel:x,run:E,refreshAsync:async()=>{v.value=!0;const[,...e]=y.value,n=[void 0,...e];await w(...n)},...g(T,["refresh","refreshAsync"])}},e.usePagination=function(e,t){var o,l;const u=n.inject(a,{}),{pagination:{currentKey:i,pageSizeKey:c,totalKey:s,totalPageKey:v},...d}=S({pagination:{currentKey:"current",pageSizeKey:"pageSize",totalKey:"total",totalPageKey:"totalPage"}},{pagination:null!==(o=r().pagination)&&void 0!==o?o:{}},{pagination:null!==(l=u.pagination)&&void 0!==l?l:{}},null!=t?t:{}),f=S({defaultParams:[{[i]:1,[c]:10}]},d),{data:m,params:g,run:h,runAsync:y,cancel:w,...E}=k(e,f),A=e=>{const[n,...t]=g.value||[],a=[{...n,...e},...t];h(...a)},T=e=>{A({[i]:e})},x=e=>{A({[c]:e})},b=n.ref(!1),O=n.computed((()=>p(m.value,s,0))),P=n.computed({get:()=>{var e,n,t;return null!==(e=null===(n=g.value)||void 0===n||null===(t=n[0])||void 0===t?void 0:t[i])&&void 0!==e?e:f.defaultParams[0][i]},set:e=>{T(e)}}),R=n.computed({get:()=>{var e,n,t;return null!==(e=null===(n=g.value)||void 0===n||null===(t=n[0])||void 0===t?void 0:t[c])&&void 0!==e?e:f.defaultParams[0][c]},set:e=>{x(e)}}),C=n.computed((()=>p(m.value,v,Math.ceil(O.value/R.value))));return{data:m,params:g,current:P,pageSize:R,total:O,totalPage:C,reloading:b,run:h,runAsync:y,changeCurrent:T,changePageSize:x,changePagination:(e,n)=>{A({[i]:e,[c]:n})},reload:async()=>{const{defaultParams:e,manual:n}=f;w(),n||(b.value=!0,await y(...e),b.value=!1)},cancel:w,...E}},e.useRequest=k,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).VueRequest=e.VueRequest||{},e.vueDemi)}(this,(function(e,n){"use strict";const t={},a=Symbol("GLOBAL_OPTIONS_PROVIDE_KEY"),r=()=>t,o=Object.prototype.toString,u=e=>"[object Object]"===(e=>o.call(e))(e),l=e=>null!==e&&"object"==typeof e,i=e=>e instanceof Function,c=e=>null==e,s="undefined"==typeof window,v=()=>{var e;return!s&&"visible"===(null===(e=window.document)||void 0===e?void 0:e.visibilityState)},d=Promise.resolve(null),f=(e,n,t)=>{const a=n.replace(/\[(\d+)\]/g,".$1").split(".");let r=e;for(const e of a)if(r=Object(r)[e],void 0===r)return t;return r};function m(e,n){const t=Object.assign({},e);for(const e of n)delete t[e];return t}const p=e=>n.isRef(e)?e.value:e,h=new Map,g=new Map,y=new Map;var w=(e,{cacheKey:t,cacheTime:a=6e5,staleTime:r=0,getCache:o,setCache:u})=>{if(!t)return{};const l=n.ref();let i;const s=e=>o?o(e):(e=>{if(c(e))return;return h.get(e)})(e),v=(e,n,t)=>{u?u(e,t):((e,n,t)=>{const a=h.get(e);null!=a&&a.timer&&clearTimeout(a.timer);const r=setTimeout((()=>h.delete(e)),n);h.set(e,{...t,timer:r})})(e,n,t),((e,n)=>{y.has(e)&&y.get(e).forEach((e=>e(n)))})(e,t.data)},d=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),f=()=>{return n=t,a=n=>{e.data.value=n},y.has(n)?y.get(n).push(a):y.set(n,[a]),()=>{const e=y.get(n).indexOf(a);y.get(n).splice(e,1)};var n,a},m=s(t);return m&&d(m,"data")&&(e.data.value=m.data,e.params.value=m.params),l.value=f(),n.onUnmounted((()=>{l.value()})),{onBefore(){const n=s(t);return n&&d(n,"data")?(a=n.time,-1===r||a+r>(new Date).getTime()?(e.data.value=n.data,e.loading.value=!1,{isBreak:!0,breakResult:n.data}):void(e.data.value=n.data)):{};var a},onQuery(e,n){let a=(e=>g.get(e))(t);return a&&a!==i||(a=e(...n),i=a,((e,n)=>{g.set(e,n),n.then((n=>(g.delete(e),n))).catch((()=>{g.delete(e)}))})(t,a)),{servicePromise:a}},onSuccess(e,n){l.value(),v(t,a,{data:e,params:n,time:(new Date).getTime()}),l.value=f()},onMutate(n){l.value(),v(t,a,{data:n,params:e.params.value,time:(new Date).getTime()}),l.value=f()}}};function E(e,n,t){let a,r,o,u,i,c,s=0,v=!1,d=!1,f=!0;const m=!n&&0!==n&&"function"==typeof window.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function p(n){const t=a,o=r;return a=r=void 0,s=n,u=e.apply(o,t),u}function h(e,n){return m?(window.cancelAnimationFrame(i),window.requestAnimationFrame(e)):setTimeout(e,n)}function g(e){const t=e-c;return void 0===c||t>=n||t<0||d&&e-s>=o}function y(){const e=Date.now();if(g(e))return w(e);i=h(y,function(e){const t=e-s,a=n-(e-c);return d?Math.min(a,o-t):a}(e))}function w(e){return i=void 0,f&&a?p(e):(a=r=void 0,u)}function E(...e){const t=Date.now(),o=g(t);if(a=e,r=this,c=t,o){if(void 0===i)return function(e){return s=e,i=h(y,n),v?p(e):u}(c);if(d)return i=h(y,n),p(c)}return void 0===i&&(i=h(y,n)),u}return n=+n||0,l(t)&&(v=!!t.leading,d="maxWait"in t,o=d?Math.max(+t.maxWait||0,n):o,f="trailing"in t?!!t.trailing:f),E.cancel=function(){void 0!==i&&function(e){if(m)return window.cancelAnimationFrame(e);clearTimeout(e)}(i),s=0,a=c=r=i=void 0},E.flush=function(){return void 0===i?u:w(Date.now())},E.pending=function(){return void 0!==i},E}function A(e,n){for(const a in n)void 0!==n[a]&&(l(n[a])&&l(e[a])&&a in e?(u(n[a])||(t=n[a],Array.isArray(t)))&&A(e[a],n[a]):e[a]=n[a]);var t}function x(e,...n){const t=Object.assign({},e);if(!n.length)return t;for(const e of n)A(t,e);return t}var T,S=(e,{debounceInterval:t,debounceOptions:a,manual:r})=>{const o=n.ref(!1),u=n.ref(),l=n.computed((()=>a)),i=n.computed((()=>p(t))),s=n.ref(e.context.runAsync);return r||(o.value=!0),n.watchEffect((n=>{c(i.value)||(u.value=E((e=>e()),i.value,l.value),e.context.runAsync=(...e)=>new Promise(((n,t)=>{o.value?(o.value=!1,s.value(...e).then(n).catch(t)):u.value((()=>{s.value(...e).then(n).catch(t)}))})),n((()=>{var n;null===(n=u.value)||void 0===n||n.cancel(),e.context.runAsync=s.value})))})),{onCancel(){var e;null===(e=u.value)||void 0===e||e.cancel()}}},b=(e,{errorRetryCount:t=0,errorRetryInterval:a=0})=>{const r=n.ref(),o=n.ref(0),u=n.computed((()=>p(t))),l=n.computed((()=>p(a)));let i=!1;const c=()=>{o.value=0},s=n.computed((()=>{if(l.value)return l.value;return 1e3*Math.floor(Math.random()*2**Math.min(o.value,9)+1)})),v=()=>{r.value&&r.value()};return{onBefore(){i||c(),i=!1,v()},onSuccess(){c()},onError(){r.value=(()=>{let n;const t=-1===u.value,a=o.value<u.value;return(t||a)&&(t||(o.value+=1),n=setTimeout((()=>{i=!0,e.context.refresh()}),s.value)),()=>n&&clearTimeout(n)})()},onCancel(){c(),v()}}},O=(e,{loadingDelay:t=0})=>{const a=n.ref((()=>{})),r=n.computed((()=>p(t)));return{onBefore(){e.loading.value=!r.value,a.value(),a.value=(()=>{let n;return r.value&&(n=setTimeout((()=>{e.loading.value=!0}),r.value)),()=>n&&clearTimeout(n)})()},onCancel(){a.value()},onAfter(){a.value()}}};const P=new Set,R=new Set,L=new Set,I=(e,n)=>{let t;switch(e){case"FOCUS_LISTENER":t=P;break;case"RECONNECT_LISTENER":t=L;break;case"VISIBLE_LISTENER":t=R}if(!t.has(n))return t.add(n),()=>{t.delete(n)}},j=e=>{e.forEach((e=>{e()}))};!s&&null!==(T=window)&&void 0!==T&&T.addEventListener&&(window.addEventListener("visibilitychange",(()=>{v()&&j(R)}),!1),window.addEventListener("focus",(()=>j(P)),!1),window.addEventListener("online",(()=>j(L)),!1));var C=(e,{pollingInterval:t,pollingWhenHidden:a=!1,pollingWhenOffline:r=!1,errorRetryCount:o=0})=>{const u=n.ref(),l=n.ref(!1),i=n.computed((()=>p(t))),d=n.computed((()=>p(o))),f=[],m=e=>{e&&f.push(e)},h=()=>{return(a||v())&&(r||null===(e=!s&&(null===(n=window.navigator)||void 0===n?void 0:n.onLine))||void 0===e||e);var e,n},g=n=>{if(e.error.value&&0!==d.value)return;let t;if(!c(i.value)&&i.value>=0){if(!h())return void(l.value=!0);t=setTimeout(n,i.value)}return()=>t&&clearTimeout(t)},y=()=>{l.value&&h()&&(e.context.refresh(),l.value=!1)};return n.watch(i,(()=>{u.value&&(u.value(),u.value=g((()=>e.context.refresh())))})),a||m(I("VISIBLE_LISTENER",y)),r||m(I("RECONNECT_LISTENER",y)),n.onUnmounted((()=>{f.forEach((e=>e()))})),{onBefore(){var e;null===(e=u.value)||void 0===e||e.call(u)},onCancel(){var e;null===(e=u.value)||void 0===e||e.call(u)},onAfter(){u.value=g((()=>e.context.refresh()))}}},M=(e,{ready:t=n.ref(!0),manual:a,defaultParams:r=[]})=>(n.watch(t,(n=>{!a&&n&&e.context.run(...r)}),{flush:"sync"}),{onBefore(){if(!t.value)return e.loading.value=!1,{isBreak:!0}}}),B=(e,{refreshDeps:t=[],refreshDepsAction:a,manual:r})=>(null!=t&&t.length&&n.watch(t,(()=>{r||(a?a():e.context.refresh())})),{});var K=(e,{refreshOnWindowFocus:t=!1,refocusTimespan:a=5e3})=>{const r=n.computed((()=>p(t))),o=n.computed((()=>p(a))),u=[],l=e=>{e&&u.push(e)},i=()=>{u.forEach((e=>e()))};return n.watchEffect((()=>{if(i(),r.value){const n=((e,n)=>{let t=!1;return(...a)=>{t||(t=!0,e(...a),setTimeout((()=>{t=!1}),n))}})(e.context.refresh,o.value);l(I("VISIBLE_LISTENER",n)),l(I("FOCUS_LISTENER",n))}})),n.onUnmounted((()=>{i()})),{}},N=(e,{throttleInterval:t,throttleOptions:a})=>{const r=n.ref(),o=n.computed((()=>p(t))),u=n.computed((()=>a)),i=n.ref(e.context.runAsync);return n.watchEffect((n=>{if(c(t))return{};r.value=function(e,n,t){let a=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return l(t)&&(a="leading"in t?!!t.leading:a,r="trailing"in t?!!t.trailing:r),E(e,n,{leading:a,trailing:r,maxWait:n})}((e=>e()),o.value,u.value),e.context.runAsync=(...e)=>new Promise(((n,t)=>{r.value((()=>{i.value(...e).then(n).catch(t)}))})),n((()=>{var n;null===(n=r.value)||void 0===n||n.cancel(),e.context.runAsync=i.value}))})),{onCancel(){var e;null===(e=r.value)||void 0===e||e.cancel()}}};const D=(e,t,a)=>{var r,o;const{initialData:u,onSuccess:l,onError:c,onBefore:s,onAfter:v}=t,f=n.ref(null!==(r=null==a?void 0:a.loading)&&void 0!==r&&r),m=n.shallowRef(null!==(o=null==a?void 0:a.data)&&void 0!==o?o:u),p=n.shallowRef(null==a?void 0:a.error),h=n.ref(null==a?void 0:a.params),g=n.ref([]),y={},w=(E={loading:f,data:m,error:p,params:h},A=[],e=>{Object.keys(e).forEach((n=>{E[n].value=e[n]})),A.forEach((e=>e(E)))});var E,A;const x=(e,...n)=>{const t=g.value.map((t=>{var a;return null===(a=t[e])||void 0===a?void 0:a.call(t,...n)}));return Object.assign({},...t)},T=n.ref(0);return y.runAsync=async(...n)=>{w({loading:!0,params:n}),T.value+=1;const t=T.value,{isBreak:a,breakResult:r=d}=x("onBefore",n);if(a)return r;null==s||s(n);try{let{servicePromise:a}=x("onQuery",e,h.value);a||(a=e(...h.value));const r=await a;return t!==T.value?d:(w({data:r,loading:!1,error:void 0}),x("onSuccess",r,n),null==l||l(r,n),x("onAfter",n,r,void 0),null==v||v(n),r)}catch(e){if(t!==T.value)return d;throw w({loading:!1,error:e}),x("onError",e,n),null==c||c(e,n),x("onAfter",n,void 0,e),null==v||v(n),e}},y.run=async(...e)=>{y.runAsync(...e).catch((e=>{c||console.error(e)}))},y.cancel=()=>{T.value+=1,w({loading:!1}),x("onCancel")},y.refresh=()=>{y.run(...h.value)},y.refreshAsync=()=>y.runAsync(...h.value),y.mutate=e=>{const n=i(e)?e(m.value):e;w({data:n}),x("onMutate",n)},{loading:f,data:m,error:p,params:h,plugins:g,context:y}};function _(e,t){return function(e,t={},o){const u=n.inject(a,{}),l={...r(),...u,...t},{manual:i=!1,defaultParams:c=[]}=l,s=D(e,l);if(s.plugins.value=o.map((e=>e(s,l))),!i){const e=s.params.value||c;s.context.run(...e)}return n.onUnmounted((()=>{s.context.cancel()})),{loading:s.loading,data:s.data,error:s.error,params:s.params,cancel:s.context.cancel,refresh:s.context.refresh,refreshAsync:s.context.refreshAsync,mutate:s.context.mutate,run:s.context.run,runAsync:s.context.runAsync}}(e,t,[O,b,S,C,N,K,B,M,w])}e.setGlobalOptions=e=>{Object.keys(e).forEach((n=>{t[n]=e[n]}))},e.useLoadMore=function(e,t){var o;const u=n.inject(a,{}),{isNoMore:l,listKey:c="list",...s}=Object.assign({listKey:null!==(o=u.listKey)&&void 0!==o?o:r().listKey},null!=t?t:{}),v=n.ref(!1),d=n.ref(!1),p=n.ref(!1),h=n.ref([]),{data:g,params:y,runAsync:w,run:E,cancel:A,...x}=_(e,{...s,onSuccess:(...e)=>{var n;v.value&&(h.value=[]),d.value=!1,v.value=!1,p.value=!1,null==s||null===(n=s.onSuccess)||void 0===n||n.call(s,...e)},onError:(...e)=>{var n;d.value=!1,v.value=!1,p.value=!1,null==s||null===(n=s.onError)||void 0===n||n.call(s,...e)},onAfter:(...e)=>{var n;null==s||null===(n=s.onAfter)||void 0===n||n.call(s,...e)}}),T=n.computed((()=>!(!l||!i(l))&&l(g.value)));n.watch(g,(e=>{if(e){const n=f(e,c);n&&Array.isArray(n)&&(h.value=[...h.value,...n])}}));const S=()=>{A(),d.value=!1,v.value=!1};return{data:g,dataList:h,params:y,noMore:T,loadingMore:d,refreshing:v,reloading:p,runAsync:w,reload:()=>{p.value=!0,S(),h.value=[];const[,...e]=y.value,n=[void 0,...e];E(...n)},loadMore:()=>{if(T.value)return;d.value=!0;const[,...e]=y.value,n=[{dataList:h.value,data:g.value},...e];E(...n)},refresh:()=>{v.value=!0;const[,...e]=y.value,n=[void 0,...e];w(...n)},cancel:S,run:E,refreshAsync:async()=>{v.value=!0;const[,...e]=y.value,n=[void 0,...e];await w(...n)},...m(x,["refresh","refreshAsync"])}},e.usePagination=function(e,t={}){const o=n.inject(a,{}),{pagination:u,...l}=t,{currentKey:i,pageSizeKey:c,totalKey:s,totalPageKey:v}=x({currentKey:"current",pageSizeKey:"pageSize",totalKey:"total",totalPageKey:"totalPage"},r().pagination||{},o.pagination||{},u||{}),d=x({defaultParams:[{[i]:1,[c]:10}]},l),{data:m,params:p,run:h,...g}=_(e,d),y=e=>{const[n,...t]=p.value||[],a=[{...n,...e},...t];h(...a)},w=e=>{y({[i]:e})},E=e=>{y({[c]:e})},A=n.computed((()=>f(m.value,s,0))),T=n.computed({get:()=>{var e,n;return null!==(e=null===(n=p.value)||void 0===n?void 0:n[0][i])&&void 0!==e?e:d.defaultParams[0][i]},set:e=>{w(e)}}),S=n.computed({get:()=>{var e,n;return null!==(e=null===(n=p.value)||void 0===n?void 0:n[0][c])&&void 0!==e?e:d.defaultParams[0][c]},set:e=>{E(e)}}),b=n.computed((()=>f(m.value,v,Math.ceil(A.value/S.value))));return{data:m,params:p,current:T,pageSize:S,total:A,totalPage:b,run:h,changeCurrent:w,changePageSize:E,changePagination:(e,n)=>{y({[i]:e,[c]:n})},...g}},e.useRequest=_,e.useRequestProvider=e=>{n.provide(a,e)},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "vue-request",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Vue composition API for data fetching, supports SWR, polling, error retry, cache request, pagination and other cool features.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -21,12 +21,12 @@ [English](./README.md) | 简体中文

</a>
<a href="https://www.npmjs.com/package/vue-request">
<img src="https://img.shields.io/bundlephobia/minzip/vue-request/latest" alt="Size" />
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/bundlephobia/minzip/vue-request/next" alt="Size" />
</a>
<a href="https://www.npmjs.com/package/vue-request">
<img src="https://img.shields.io/npm/v/vue-request" alt="Version" />
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/npm/v/vue-request/next" alt="Version" />
</a>
<a href="https://www.npmjs.com/package/vue-request">
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/github/languages/top/attojs/vue-request" alt="Languages" />
</a>
<a href="https://www.npmjs.com/package/vue-request">
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/npm/l/vue-request" alt="License" />

@@ -37,3 +37,3 @@ </a>

</a>
<a href="https://www.npmjs.com/package/vue-request">
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/npm/dm/vue-request" alt="Download" />

@@ -45,3 +45,3 @@ </a>

<span style="font-size: 40px">Alpha</span>
目前处于 Alpha 版本,详情请查看[更新日志](https://github.com/AttoJS/vue-request/issues/121)。

@@ -56,2 +56,3 @@ ## 为什么选择 VueRequest

- 🌈 &nbsp;兼容 Vue 2 & 3
- 🚀 &nbsp;所有数据都具有响应式

@@ -156,11 +157,2 @@ - 🔄 &nbsp;轮询请求

## TODO 列表
如果你有很酷的想法,欢迎提交 issue 以便我们讨论
- [x] 支持 Vue 2
- [x] 文档
- [x] 分页
- [x] 加载更多
## 致谢

@@ -167,0 +159,0 @@

@@ -15,3 +15,3 @@ English | [简体中文](README-zh_CN.md)

<p align="center">⚡️ Vue composition API for data fetching, supports SWR, polling, error retry, cache request, pagination, etc.</p>
<a href="https://codecov.io/github/attojs/vue-request?branch=master">
<a href="https://codecov.io/github/attojs/vue-request?branch=master">
<img

@@ -22,12 +22,12 @@ src="https://img.shields.io/codecov/c/github/attojs/vue-request?token=NW2XVQWGPP"

</a>
<a href="https://www.npmjs.com/package/vue-request">
<img src="https://img.shields.io/bundlephobia/minzip/vue-request/latest" alt="Size" />
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/bundlephobia/minzip/vue-request/next" alt="Size" />
</a>
<a href="https://www.npmjs.com/package/vue-request">
<img src="https://img.shields.io/npm/v/vue-request" alt="Version" />
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/npm/v/vue-request/next" alt="Version" />
</a>
<a href="https://www.npmjs.com/package/vue-request">
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/github/languages/top/attojs/vue-request" alt="Languages" />
</a>
<a href="https://www.npmjs.com/package/vue-request">
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/npm/l/vue-request" alt="License" />

@@ -38,3 +38,3 @@ </a>

</a>
<a href="https://www.npmjs.com/package/vue-request">
<a href="https://www.npmjs.com/package/vue-request/v/next">
<img src="https://img.shields.io/npm/dm/vue-request" alt="Download" />

@@ -46,3 +46,3 @@ </a>

<span style="font-size: 40px">Alpha</span>
Currently in Alpha version. For details, please see the [changelog](https://github.com/AttoJS/vue-request/issues/121).

@@ -57,2 +57,3 @@ ## Why VueRequest

- 🌈 &nbsp;Support Vue 2 & 3
- 🚀 &nbsp;All data is reactive

@@ -156,11 +157,2 @@ - 🔄 &nbsp;Interval polling

## TODO List
If you have any cool features, please submit an issue for discussion
- [x] Support Vue 2
- [x] Documentation
- [x] Pagination
- [x] Load More
## Thanks

@@ -167,0 +159,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc