@varlet/axle 0.2.7-alpha.1701535975035 → 0.2.7-alpha.1701536208987
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/es/chunk-KLNSLHAC.js +24 -0
- package/es/index.d.ts +29 -0
- package/es/index.js +214 -0
- package/es/instance-8e68a761.d.ts +64 -0
- package/es/use.d.ts +2 -56
- package/es/use.js +4 -19
- package/package.json +3 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
__spreadValues,
|
|
23
|
+
__spreadProps
|
|
24
|
+
};
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { R as RequestInterceptor, a as ResponseInterceptor } from './instance-8e68a761.js';
|
|
2
|
+
export { e as AxleInstance, A as AxleRequestConfig, b as FetchMethod, F as FetchRunner, I as Interceptor, c as ModifyMethod, M as ModifyRunner, d as RunnerMethod, i as createAxle, f as createFetchRunner, g as createModifyRunner, h as download } from './instance-8e68a761.js';
|
|
3
|
+
import { AxiosInterceptorOptions, AxiosResponse } from 'axios';
|
|
4
|
+
|
|
5
|
+
interface RequestHeadersInterceptorOptions {
|
|
6
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
7
|
+
axiosInterceptorOptions?: AxiosInterceptorOptions;
|
|
8
|
+
include?: string[];
|
|
9
|
+
exclude?: string[];
|
|
10
|
+
}
|
|
11
|
+
declare function requestHeadersInterceptor(options?: RequestHeadersInterceptorOptions): RequestInterceptor;
|
|
12
|
+
|
|
13
|
+
interface ResponseBlobInterceptorOptions {
|
|
14
|
+
onResponse?: (response: AxiosResponse<any, any>) => any;
|
|
15
|
+
axiosInterceptorOptions?: AxiosInterceptorOptions;
|
|
16
|
+
include?: string[];
|
|
17
|
+
exclude?: string[];
|
|
18
|
+
}
|
|
19
|
+
declare function responseBlobInterceptor(options?: ResponseBlobInterceptorOptions): ResponseInterceptor;
|
|
20
|
+
|
|
21
|
+
interface ResponseTimeoutInterceptorOptions {
|
|
22
|
+
normalizeErrorCode?: string;
|
|
23
|
+
axiosInterceptorOptions?: AxiosInterceptorOptions;
|
|
24
|
+
include?: string[];
|
|
25
|
+
exclude?: string[];
|
|
26
|
+
}
|
|
27
|
+
declare function responseTimeoutInterceptor(options?: ResponseTimeoutInterceptorOptions): ResponseInterceptor;
|
|
28
|
+
|
|
29
|
+
export { RequestHeadersInterceptorOptions, RequestInterceptor, ResponseBlobInterceptorOptions, ResponseInterceptor, ResponseTimeoutInterceptorOptions, requestHeadersInterceptor, responseBlobInterceptor, responseTimeoutInterceptor };
|
package/es/index.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues
|
|
3
|
+
} from "./chunk-KLNSLHAC.js";
|
|
4
|
+
|
|
5
|
+
// src/instance.ts
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
import qs from "qs";
|
|
8
|
+
import { inBrowser } from "@varlet/shared";
|
|
9
|
+
function createFetchRunner(service, method, responseType) {
|
|
10
|
+
return function(url, params, config) {
|
|
11
|
+
return service[method](url, __spreadValues({
|
|
12
|
+
params,
|
|
13
|
+
responseType
|
|
14
|
+
}, config));
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function createModifyRunner(service, method, contentType) {
|
|
18
|
+
return function(url, params, config) {
|
|
19
|
+
if (contentType === "application/x-www-form-urlencoded") {
|
|
20
|
+
params = qs.stringify(params);
|
|
21
|
+
}
|
|
22
|
+
if (contentType === "multipart/form-data") {
|
|
23
|
+
const formData = new FormData();
|
|
24
|
+
Object.keys(params).forEach((key) => formData.append(key, params[key]));
|
|
25
|
+
params = formData;
|
|
26
|
+
}
|
|
27
|
+
return service[method](url, params, __spreadValues({
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": contentType
|
|
30
|
+
}
|
|
31
|
+
}, config));
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function download(url, filename) {
|
|
35
|
+
if (!inBrowser()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const a = document.createElement("a");
|
|
39
|
+
a.download = filename;
|
|
40
|
+
a.style.display = "none";
|
|
41
|
+
a.href = typeof url === "string" ? url : URL.createObjectURL(url);
|
|
42
|
+
document.body.appendChild(a);
|
|
43
|
+
a.click();
|
|
44
|
+
URL.revokeObjectURL(a.href);
|
|
45
|
+
document.body.removeChild(a);
|
|
46
|
+
}
|
|
47
|
+
function createAxle(config = {}) {
|
|
48
|
+
const service = axios.create(config);
|
|
49
|
+
function getHeaders() {
|
|
50
|
+
return service.defaults.headers.common;
|
|
51
|
+
}
|
|
52
|
+
function setHeader(key, value) {
|
|
53
|
+
;
|
|
54
|
+
service.defaults.headers.common[key] = value;
|
|
55
|
+
}
|
|
56
|
+
function removeHeader(key) {
|
|
57
|
+
if (typeof key === "string") {
|
|
58
|
+
Reflect.deleteProperty(service.defaults.headers.common, key);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
key.forEach((k) => Reflect.deleteProperty(service.defaults.headers.common, k));
|
|
62
|
+
}
|
|
63
|
+
function useRequestInterceptor(...interceptors) {
|
|
64
|
+
interceptors.forEach((interceptor) => {
|
|
65
|
+
service.interceptors.request.use(interceptor.onFulfilled, interceptor.onRejected, interceptor.options);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function useResponseInterceptor(...interceptors) {
|
|
69
|
+
interceptors.forEach((interceptor) => {
|
|
70
|
+
service.interceptors.response.use(interceptor.onFulfilled, interceptor.onRejected, interceptor.options);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
get: createFetchRunner(service, "get", "json"),
|
|
75
|
+
getBlob: createFetchRunner(service, "get", "blob"),
|
|
76
|
+
getDocument: createFetchRunner(service, "get", "document"),
|
|
77
|
+
getArrayBuffer: createFetchRunner(service, "get", "arraybuffer"),
|
|
78
|
+
getText: createFetchRunner(service, "get", "text"),
|
|
79
|
+
getStream: createFetchRunner(service, "get", "stream"),
|
|
80
|
+
head: createFetchRunner(service, "head", "json"),
|
|
81
|
+
headBlob: createFetchRunner(service, "head", "blob"),
|
|
82
|
+
headDocument: createFetchRunner(service, "head", "document"),
|
|
83
|
+
headArrayBuffer: createFetchRunner(service, "head", "arraybuffer"),
|
|
84
|
+
headText: createFetchRunner(service, "head", "text"),
|
|
85
|
+
headStream: createFetchRunner(service, "head", "stream"),
|
|
86
|
+
options: createFetchRunner(service, "options", "json"),
|
|
87
|
+
optionsBlob: createFetchRunner(service, "options", "blob"),
|
|
88
|
+
optionsDocument: createFetchRunner(service, "options", "document"),
|
|
89
|
+
optionsArrayBuffer: createFetchRunner(service, "options", "arraybuffer"),
|
|
90
|
+
optionsText: createFetchRunner(service, "options", "text"),
|
|
91
|
+
optionsStream: createFetchRunner(service, "options", "stream"),
|
|
92
|
+
delete: createFetchRunner(service, "delete", "json"),
|
|
93
|
+
deleteBlob: createFetchRunner(service, "delete", "blob"),
|
|
94
|
+
deleteDocument: createFetchRunner(service, "delete", "document"),
|
|
95
|
+
deleteArrayBuffer: createFetchRunner(service, "delete", "arraybuffer"),
|
|
96
|
+
deleteText: createFetchRunner(service, "delete", "text"),
|
|
97
|
+
deleteStream: createFetchRunner(service, "delete", "stream"),
|
|
98
|
+
post: createModifyRunner(service, "post", "application/json"),
|
|
99
|
+
postUrlEncode: createModifyRunner(service, "post", "application/x-www-form-urlencoded"),
|
|
100
|
+
postMultipart: createModifyRunner(service, "post", "multipart/form-data"),
|
|
101
|
+
put: createModifyRunner(service, "put", "application/json"),
|
|
102
|
+
putUrlEncode: createModifyRunner(service, "put", "application/x-www-form-urlencoded"),
|
|
103
|
+
putMultipart: createModifyRunner(service, "put", "multipart/form-data"),
|
|
104
|
+
patch: createModifyRunner(service, "patch", "application/json"),
|
|
105
|
+
patchUrlEncode: createModifyRunner(service, "patch", "application/x-www-form-urlencoded"),
|
|
106
|
+
patchMultipart: createModifyRunner(service, "patch", "multipart/form-data"),
|
|
107
|
+
getHeaders,
|
|
108
|
+
setHeader,
|
|
109
|
+
removeHeader,
|
|
110
|
+
useRequestInterceptor,
|
|
111
|
+
useResponseInterceptor,
|
|
112
|
+
axios: service
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/interceptors/requestHeadersInterceptor.ts
|
|
117
|
+
import { isFunction } from "@varlet/shared";
|
|
118
|
+
|
|
119
|
+
// src/matcher.ts
|
|
120
|
+
import { minimatch } from "minimatch";
|
|
121
|
+
function matchPattern(pattern, method, url) {
|
|
122
|
+
return pattern.startsWith("method:") ? pattern.replace("method:", "").trim() === method : minimatch(url != null ? url : "", pattern);
|
|
123
|
+
}
|
|
124
|
+
function createMatcher(include, exclude) {
|
|
125
|
+
function matcher(method, url) {
|
|
126
|
+
if (!include && !exclude) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
const isExclude = (exclude != null ? exclude : []).some((pattern) => matchPattern(pattern, method, url));
|
|
130
|
+
if (isExclude) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (!include) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
const isInclude = (include != null ? include : []).some((pattern) => matchPattern(pattern, method, url));
|
|
137
|
+
return isInclude;
|
|
138
|
+
}
|
|
139
|
+
return matcher;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/interceptors/requestHeadersInterceptor.ts
|
|
143
|
+
function requestHeadersInterceptor(options = {}) {
|
|
144
|
+
const { headers: headersOrGetter } = options;
|
|
145
|
+
return {
|
|
146
|
+
onFulfilled(config) {
|
|
147
|
+
var _a, _b, _c;
|
|
148
|
+
const matcher = createMatcher(options.include, options.exclude);
|
|
149
|
+
if (!matcher((_a = config.method) != null ? _a : "", (_b = config.url) != null ? _b : "")) {
|
|
150
|
+
return config;
|
|
151
|
+
}
|
|
152
|
+
const headers = (_c = isFunction(headersOrGetter) ? headersOrGetter() : headersOrGetter) != null ? _c : {};
|
|
153
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
154
|
+
config.headers[key] = value;
|
|
155
|
+
});
|
|
156
|
+
return config;
|
|
157
|
+
},
|
|
158
|
+
onRejected(error) {
|
|
159
|
+
return Promise.reject(error);
|
|
160
|
+
},
|
|
161
|
+
options: options.axiosInterceptorOptions
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/interceptors/responseBlobInterceptor.ts
|
|
166
|
+
function responseBlobInterceptor(options = {}) {
|
|
167
|
+
return {
|
|
168
|
+
onFulfilled(response) {
|
|
169
|
+
var _a, _b, _c, _d;
|
|
170
|
+
const matcher = createMatcher(options.include, options.exclude);
|
|
171
|
+
if (!matcher((_a = response.config.method) != null ? _a : "", (_b = response.config.url) != null ? _b : "")) {
|
|
172
|
+
return response;
|
|
173
|
+
}
|
|
174
|
+
if (response.request.responseType === "blob") {
|
|
175
|
+
return (_d = (_c = options.onResponse) == null ? void 0 : _c.call(options, response)) != null ? _d : response;
|
|
176
|
+
}
|
|
177
|
+
return response;
|
|
178
|
+
},
|
|
179
|
+
onRejected(error) {
|
|
180
|
+
return Promise.reject(error);
|
|
181
|
+
},
|
|
182
|
+
options: options.axiosInterceptorOptions
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/interceptors/responseTimeoutInterceptor.ts
|
|
187
|
+
function responseTimeoutInterceptor(options = {}) {
|
|
188
|
+
return {
|
|
189
|
+
onFulfilled(response) {
|
|
190
|
+
return response;
|
|
191
|
+
},
|
|
192
|
+
onRejected(error) {
|
|
193
|
+
var _a, _b, _c;
|
|
194
|
+
const matcher = createMatcher(options.include, options.exclude);
|
|
195
|
+
if (!matcher((_a = error.config.method) != null ? _a : "", (_b = error.config.url) != null ? _b : "")) {
|
|
196
|
+
return Promise.reject(error);
|
|
197
|
+
}
|
|
198
|
+
if (error.code === "ECONNABORTED" && error.message.includes("timeout") || error.code === "ETIMEDOUT") {
|
|
199
|
+
error.code = (_c = options == null ? void 0 : options.normalizeErrorCode) != null ? _c : "TIMEOUT";
|
|
200
|
+
}
|
|
201
|
+
return Promise.reject(error);
|
|
202
|
+
},
|
|
203
|
+
options: options.axiosInterceptorOptions
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
createAxle,
|
|
208
|
+
createFetchRunner,
|
|
209
|
+
createModifyRunner,
|
|
210
|
+
download,
|
|
211
|
+
requestHeadersInterceptor,
|
|
212
|
+
responseBlobInterceptor,
|
|
213
|
+
responseTimeoutInterceptor
|
|
214
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse, AxiosInterceptorOptions, InternalAxiosRequestConfig, HeadersDefaults, AxiosInstance, ResponseType } from 'axios';
|
|
2
|
+
|
|
3
|
+
type AxleRequestConfig = AxiosRequestConfig & {
|
|
4
|
+
exceptionMessage?: any;
|
|
5
|
+
};
|
|
6
|
+
type FetchRunner = <T = any, R = AxiosResponse<T>>(url: string, params?: any, config?: AxleRequestConfig) => Promise<R>;
|
|
7
|
+
type ModifyRunner = <T = any, R = AxiosResponse<T>>(url: string, params?: any, config?: AxleRequestConfig) => Promise<R>;
|
|
8
|
+
type FetchMethod = 'get' | 'delete' | 'options' | 'head';
|
|
9
|
+
type ModifyMethod = 'post' | 'put' | 'patch';
|
|
10
|
+
type RunnerMethod = keyof Omit<AxleInstance, 'axios' | 'getHeaders' | 'setHeader' | 'removeHeader' | 'useRequestInterceptor' | 'useResponseInterceptor'>;
|
|
11
|
+
interface Interceptor<V> {
|
|
12
|
+
onFulfilled?: ((value: V) => any) | null;
|
|
13
|
+
onRejected?: ((error: any) => any) | null;
|
|
14
|
+
options?: AxiosInterceptorOptions;
|
|
15
|
+
}
|
|
16
|
+
type RequestInterceptor = Interceptor<InternalAxiosRequestConfig>;
|
|
17
|
+
type ResponseInterceptor<V = AxiosResponse<any, any>> = Interceptor<V>;
|
|
18
|
+
type AxleInstance = {
|
|
19
|
+
get: FetchRunner;
|
|
20
|
+
getBlob: FetchRunner;
|
|
21
|
+
getDocument: FetchRunner;
|
|
22
|
+
getText: FetchRunner;
|
|
23
|
+
getArrayBuffer: FetchRunner;
|
|
24
|
+
getStream: FetchRunner;
|
|
25
|
+
head: FetchRunner;
|
|
26
|
+
headBlob: FetchRunner;
|
|
27
|
+
headDocument: FetchRunner;
|
|
28
|
+
headText: FetchRunner;
|
|
29
|
+
headArrayBuffer: FetchRunner;
|
|
30
|
+
headStream: FetchRunner;
|
|
31
|
+
options: FetchRunner;
|
|
32
|
+
optionsBlob: FetchRunner;
|
|
33
|
+
optionsDocument: FetchRunner;
|
|
34
|
+
optionsText: FetchRunner;
|
|
35
|
+
optionsArrayBuffer: FetchRunner;
|
|
36
|
+
optionsStream: FetchRunner;
|
|
37
|
+
delete: FetchRunner;
|
|
38
|
+
deleteBlob: FetchRunner;
|
|
39
|
+
deleteDocument: FetchRunner;
|
|
40
|
+
deleteText: FetchRunner;
|
|
41
|
+
deleteArrayBuffer: FetchRunner;
|
|
42
|
+
deleteStream: FetchRunner;
|
|
43
|
+
post: ModifyRunner;
|
|
44
|
+
postUrlEncode: ModifyRunner;
|
|
45
|
+
postMultipart: ModifyRunner;
|
|
46
|
+
put: ModifyRunner;
|
|
47
|
+
putUrlEncode: ModifyRunner;
|
|
48
|
+
putMultipart: ModifyRunner;
|
|
49
|
+
patch: ModifyRunner;
|
|
50
|
+
patchUrlEncode: ModifyRunner;
|
|
51
|
+
patchMultipart: ModifyRunner;
|
|
52
|
+
getHeaders(): HeadersDefaults['common'];
|
|
53
|
+
setHeader(key: string, value: string): void;
|
|
54
|
+
removeHeader(key: string | string[]): void;
|
|
55
|
+
useRequestInterceptor(...interceptors: RequestInterceptor[]): void;
|
|
56
|
+
useResponseInterceptor(...interceptors: ResponseInterceptor[]): void;
|
|
57
|
+
axios: AxiosInstance;
|
|
58
|
+
};
|
|
59
|
+
declare function createFetchRunner(service: AxiosInstance, method: FetchMethod, responseType: ResponseType): <T, R = AxiosResponse<T, any>>(url: string, params?: any, config?: AxleRequestConfig) => Promise<R>;
|
|
60
|
+
declare function createModifyRunner(service: AxiosInstance, method: ModifyMethod, contentType: 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded'): <T, R = AxiosResponse<T, any>>(url: string, params?: any, config?: AxleRequestConfig) => Promise<R>;
|
|
61
|
+
declare function download(url: string | Blob, filename: string): void;
|
|
62
|
+
declare function createAxle(config?: AxiosRequestConfig): AxleInstance;
|
|
63
|
+
|
|
64
|
+
export { AxleRequestConfig as A, FetchRunner as F, Interceptor as I, ModifyRunner as M, RequestInterceptor as R, ResponseInterceptor as a, FetchMethod as b, ModifyMethod as c, RunnerMethod as d, AxleInstance as e, createFetchRunner as f, createModifyRunner as g, download as h, createAxle as i };
|
package/es/use.d.ts
CHANGED
|
@@ -1,60 +1,6 @@
|
|
|
1
1
|
import { Ref, WritableComputedRef } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type AxleRequestConfig = AxiosRequestConfig & {
|
|
5
|
-
exceptionMessage?: any;
|
|
6
|
-
};
|
|
7
|
-
type FetchRunner = <T = any, R = AxiosResponse<T>>(url: string, params?: any, config?: AxleRequestConfig) => Promise<R>;
|
|
8
|
-
type ModifyRunner = <T = any, R = AxiosResponse<T>>(url: string, params?: any, config?: AxleRequestConfig) => Promise<R>;
|
|
9
|
-
type RunnerMethod = keyof Omit<AxleInstance, 'axios' | 'getHeaders' | 'setHeader' | 'removeHeader' | 'useRequestInterceptor' | 'useResponseInterceptor'>;
|
|
10
|
-
interface Interceptor<V> {
|
|
11
|
-
onFulfilled?: ((value: V) => any) | null;
|
|
12
|
-
onRejected?: ((error: any) => any) | null;
|
|
13
|
-
options?: AxiosInterceptorOptions;
|
|
14
|
-
}
|
|
15
|
-
type RequestInterceptor = Interceptor<InternalAxiosRequestConfig>;
|
|
16
|
-
type ResponseInterceptor<V = AxiosResponse<any, any>> = Interceptor<V>;
|
|
17
|
-
type AxleInstance = {
|
|
18
|
-
get: FetchRunner;
|
|
19
|
-
getBlob: FetchRunner;
|
|
20
|
-
getDocument: FetchRunner;
|
|
21
|
-
getText: FetchRunner;
|
|
22
|
-
getArrayBuffer: FetchRunner;
|
|
23
|
-
getStream: FetchRunner;
|
|
24
|
-
head: FetchRunner;
|
|
25
|
-
headBlob: FetchRunner;
|
|
26
|
-
headDocument: FetchRunner;
|
|
27
|
-
headText: FetchRunner;
|
|
28
|
-
headArrayBuffer: FetchRunner;
|
|
29
|
-
headStream: FetchRunner;
|
|
30
|
-
options: FetchRunner;
|
|
31
|
-
optionsBlob: FetchRunner;
|
|
32
|
-
optionsDocument: FetchRunner;
|
|
33
|
-
optionsText: FetchRunner;
|
|
34
|
-
optionsArrayBuffer: FetchRunner;
|
|
35
|
-
optionsStream: FetchRunner;
|
|
36
|
-
delete: FetchRunner;
|
|
37
|
-
deleteBlob: FetchRunner;
|
|
38
|
-
deleteDocument: FetchRunner;
|
|
39
|
-
deleteText: FetchRunner;
|
|
40
|
-
deleteArrayBuffer: FetchRunner;
|
|
41
|
-
deleteStream: FetchRunner;
|
|
42
|
-
post: ModifyRunner;
|
|
43
|
-
postUrlEncode: ModifyRunner;
|
|
44
|
-
postMultipart: ModifyRunner;
|
|
45
|
-
put: ModifyRunner;
|
|
46
|
-
putUrlEncode: ModifyRunner;
|
|
47
|
-
putMultipart: ModifyRunner;
|
|
48
|
-
patch: ModifyRunner;
|
|
49
|
-
patchUrlEncode: ModifyRunner;
|
|
50
|
-
patchMultipart: ModifyRunner;
|
|
51
|
-
getHeaders(): HeadersDefaults['common'];
|
|
52
|
-
setHeader(key: string, value: string): void;
|
|
53
|
-
removeHeader(key: string | string[]): void;
|
|
54
|
-
useRequestInterceptor(...interceptors: RequestInterceptor[]): void;
|
|
55
|
-
useResponseInterceptor(...interceptors: ResponseInterceptor[]): void;
|
|
56
|
-
axios: AxiosInstance;
|
|
57
|
-
};
|
|
2
|
+
import { A as AxleRequestConfig, d as RunnerMethod, e as AxleInstance } from './instance-8e68a761.js';
|
|
3
|
+
import 'axios';
|
|
58
4
|
|
|
59
5
|
declare function useValues<T extends Ref<any>[]>(...valueCollection: T): WritableComputedRef<T[number]['value'][]>;
|
|
60
6
|
|
package/es/use.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-KLNSLHAC.js";
|
|
20
5
|
|
|
21
6
|
// src/use.ts
|
|
22
7
|
import { ref as ref3 } from "vue";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/axle",
|
|
3
|
-
"version": "0.2.7-alpha.
|
|
3
|
+
"version": "0.2.7-alpha.1701536208987",
|
|
4
4
|
"description": "Progressive request tool based on axios",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "es/index.js",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"preinstall": "npx only-allow pnpm",
|
|
80
80
|
"postinstall": "simple-git-hooks",
|
|
81
81
|
"bootstrap": "pnpm i && pnpm build && pnpm --filter ./playground i",
|
|
82
|
-
"dev": "tsup src/index.ts
|
|
83
|
-
"build": "tsup src/index.ts
|
|
82
|
+
"dev": "tsup src/index.ts src/use.ts --format esm --out-dir=es --watch --dts",
|
|
83
|
+
"build": "tsup src/index.ts src/use.ts --format esm --out-dir=es --dts --clean",
|
|
84
84
|
"dev:play": "pnpm --dir ./playground dev",
|
|
85
85
|
"lint": "eslint . --fix",
|
|
86
86
|
"format": "prettier --write .",
|