@vef-framework/core 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/api/client.cjs +1 -171
  2. package/dist/cjs/api/constants.cjs +1 -13
  3. package/dist/cjs/api/helpers.cjs +1 -12
  4. package/dist/cjs/api/index.cjs +1 -14
  5. package/dist/cjs/auth/helpers.cjs +1 -19
  6. package/dist/cjs/auth/index.cjs +1 -10
  7. package/dist/cjs/common/index.cjs +1 -3
  8. package/dist/cjs/context/api-client.cjs +1 -25
  9. package/dist/cjs/context/app.cjs +1 -15
  10. package/dist/cjs/context/context-selector.cjs +1 -65
  11. package/dist/cjs/context/disabled.cjs +1 -15
  12. package/dist/cjs/context/index.cjs +1 -19
  13. package/dist/cjs/dnd/index.cjs +1 -102
  14. package/dist/cjs/http/client.cjs +1 -445
  15. package/dist/cjs/http/errors.cjs +1 -23
  16. package/dist/cjs/http/helpers.cjs +1 -17
  17. package/dist/cjs/http/index.cjs +1 -17
  18. package/dist/cjs/immer/index.cjs +1 -40
  19. package/dist/cjs/index.cjs +1 -306
  20. package/dist/cjs/motion/features.cjs +1 -13
  21. package/dist/cjs/motion/index.cjs +1 -48
  22. package/dist/cjs/motion/motion-provider.cjs +1 -29
  23. package/dist/cjs/query/constants.cjs +1 -8
  24. package/dist/cjs/query/helpers.cjs +1 -67
  25. package/dist/cjs/query/hooks.cjs +1 -52
  26. package/dist/cjs/query/index.cjs +1 -20
  27. package/dist/cjs/state/index.cjs +1 -41
  28. package/dist/cjs/state-machine/index.cjs +1 -35
  29. package/dist/cjs/store/bound.cjs +1 -42
  30. package/dist/cjs/store/index.cjs +1 -20
  31. package/dist/cjs/store/unbound.cjs +2 -73
  32. package/dist/cjs/store/use-deep.cjs +1 -17
  33. package/dist/es/api/client.js +72 -90
  34. package/dist/es/api/constants.js +7 -8
  35. package/dist/es/api/helpers.js +6 -7
  36. package/dist/es/api/index.js +8 -4
  37. package/dist/es/auth/helpers.js +9 -14
  38. package/dist/es/auth/index.js +4 -2
  39. package/dist/es/common/index.js +1 -1
  40. package/dist/es/context/api-client.js +16 -17
  41. package/dist/es/context/app.js +8 -9
  42. package/dist/es/context/context-selector.js +30 -39
  43. package/dist/es/context/disabled.js +9 -9
  44. package/dist/es/context/index.js +13 -5
  45. package/dist/es/dnd/index.js +30 -7
  46. package/dist/es/http/client.js +173 -253
  47. package/dist/es/http/errors.js +6 -9
  48. package/dist/es/http/helpers.js +10 -10
  49. package/dist/es/http/index.js +11 -4
  50. package/dist/es/immer/index.js +15 -8
  51. package/dist/es/index.js +122 -43
  52. package/dist/es/motion/features.js +4 -2
  53. package/dist/es/motion/index.js +11 -5
  54. package/dist/es/motion/motion-provider.js +15 -17
  55. package/dist/es/query/constants.js +4 -4
  56. package/dist/es/query/helpers.js +40 -45
  57. package/dist/es/query/hooks.js +29 -20
  58. package/dist/es/query/index.js +14 -4
  59. package/dist/es/state/index.js +11 -2
  60. package/dist/es/state-machine/index.js +14 -11
  61. package/dist/es/store/bound.js +24 -26
  62. package/dist/es/store/index.js +11 -5
  63. package/dist/es/store/unbound.js +44 -63
  64. package/dist/es/store/use-deep.js +10 -11
  65. package/package.json +3 -3
@@ -1,5 +1,13 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- export { ApiClientProvider, useApiClient } from './api-client.js';
3
- export { AppContextProvider, useAppContext } from './app.js';
4
- export { createContextWithSelector } from './context-selector.js';
5
- export { DisabledProvider, useDisabled } from './disabled.js';
1
+ import { ApiClientProvider as o, useApiClient as t } from "./api-client.js";
2
+ import { AppContextProvider as p, useAppContext as x } from "./app.js";
3
+ import { createContextWithSelector as l } from "./context-selector.js";
4
+ import { DisabledProvider as s, useDisabled as C } from "./disabled.js";
5
+ export {
6
+ o as ApiClientProvider,
7
+ p as AppContextProvider,
8
+ s as DisabledProvider,
9
+ l as createContextWithSelector,
10
+ t as useApiClient,
11
+ x as useAppContext,
12
+ C as useDisabled
13
+ };
@@ -1,7 +1,30 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- export { AxisModifier, RestrictToHorizontalAxis, RestrictToVerticalAxis, SnapModifier, restrictShapeToBoundingRectangle } from '@dnd-kit/abstract/modifiers';
3
- export { RestrictToElement, RestrictToWindow } from '@dnd-kit/dom/modifiers';
4
- export { arrayMove as moveArrayItem, move as moveDragItem, arraySwap as swapArrayItem, swap as swapDragItem } from '@dnd-kit/helpers';
5
- export { DragDropProvider, DragOverlay, KeyboardSensor, PointerSensor, useDragDropMonitor, useDraggable, useDroppable } from '@dnd-kit/react';
6
- export { useSortable } from '@dnd-kit/react/sortable';
7
- export { DragDropContext, Draggable, Droppable } from '@hello-pangea/dnd';
1
+ import { AxisModifier as o, RestrictToHorizontalAxis as a, RestrictToVerticalAxis as t, SnapModifier as s, restrictShapeToBoundingRectangle as i } from "@dnd-kit/abstract/modifiers";
2
+ import { RestrictToElement as m, RestrictToWindow as D } from "@dnd-kit/dom/modifiers";
3
+ import { arrayMove as n, move as l, arraySwap as x, swap as f } from "@dnd-kit/helpers";
4
+ import { DragDropProvider as b, DragOverlay as d, KeyboardSensor as v, PointerSensor as y, useDragDropMonitor as S, useDraggable as u, useDroppable as w } from "@dnd-kit/react";
5
+ import { useSortable as R } from "@dnd-kit/react/sortable";
6
+ import { DragDropContext as I, Draggable as M, Droppable as P } from "@hello-pangea/dnd";
7
+ export {
8
+ o as AxisModifier,
9
+ I as DragDropContext,
10
+ b as DragDropProvider,
11
+ d as DragOverlay,
12
+ M as Draggable,
13
+ P as Droppable,
14
+ v as KeyboardSensor,
15
+ y as PointerSensor,
16
+ m as RestrictToElement,
17
+ a as RestrictToHorizontalAxis,
18
+ t as RestrictToVerticalAxis,
19
+ D as RestrictToWindow,
20
+ s as SnapModifier,
21
+ n as moveArrayItem,
22
+ l as moveDragItem,
23
+ i as restrictShapeToBoundingRectangle,
24
+ x as swapArrayItem,
25
+ f as swapDragItem,
26
+ S as useDragDropMonitor,
27
+ u as useDraggable,
28
+ w as useDroppable,
29
+ R as useSortable
30
+ };
@@ -1,66 +1,59 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { encodeQueryString, isArray, isNullish, isFunction, isString } from '@vef-framework/shared';
3
- import axios, { CanceledError } from 'axios';
4
- import { BusinessError } from './errors.js';
5
-
6
- const pathParamRegex = /:(?<key>\w+)/g;
7
- const filenameRegex = /filename[^;=\n]*=(?<name>(?<quote>['"]).*?\2|[^;\n]*)/;
8
- const skipAuthenticationHeader = "X-Skip-Authentication";
9
- const skipAuthenticationValue = "1";
10
- class HttpClient {
1
+ import { encodeQueryString as m, isArray as k, isNullish as y, isFunction as d, isString as $ } from "@vef-framework/shared";
2
+ import R, { CanceledError as C } from "axios";
3
+ import { BusinessError as T } from "./errors.js";
4
+ const w = /:(?<key>\w+)/g, b = /filename[^;=\n]*=(?<name>(?<quote>['"]).*?\2|[^;\n]*)/, g = "X-Skip-Authentication", E = "1";
5
+ class O {
11
6
  /**
12
7
  * The axios instance.
13
8
  */
14
- #axiosInstance;
9
+ #e;
15
10
  /**
16
11
  * The http client options.
17
12
  */
18
- #options;
13
+ #s;
19
14
  /**
20
15
  * Indicates whether a token refresh is in progress.
21
16
  */
22
- #isRefreshing = false;
17
+ #t = !1;
23
18
  /**
24
19
  * Queue of pending requests waiting for token refresh to complete.
25
20
  */
26
- #waitingQueue = [];
27
- constructor(options) {
28
- this.#options = options;
21
+ #n = [];
22
+ constructor(e) {
23
+ this.#s = e;
29
24
  const {
30
- baseUrl,
31
- timeout = 1e3 * 30
32
- } = options;
33
- this.#axiosInstance = axios.create({
34
- baseURL: baseUrl,
35
- allowAbsoluteUrls: true,
36
- timeout,
25
+ baseUrl: s,
26
+ timeout: n = 1e3 * 30
27
+ } = e;
28
+ this.#e = R.create({
29
+ baseURL: s,
30
+ allowAbsoluteUrls: !0,
31
+ timeout: n,
37
32
  headers: {
38
33
  "Content-Type": "application/json"
39
34
  },
40
- paramsSerializer: (params) => encodeQueryString(
41
- params,
35
+ paramsSerializer: (t) => m(
36
+ t,
42
37
  {
43
38
  arrayFormat: "repeat",
44
- skipNulls: true,
39
+ skipNulls: !0,
45
40
  charset: "utf-8"
46
41
  }
47
42
  ),
48
43
  responseType: "json",
49
44
  responseEncoding: "utf-8",
50
- validateStatus(status) {
51
- return status >= 200 && status < 300;
45
+ validateStatus(t) {
46
+ return t >= 200 && t < 300;
52
47
  },
53
- withCredentials: false,
48
+ withCredentials: !1,
54
49
  timeoutErrorMessage: "请求超时"
55
- });
56
- this.initInterceptors();
50
+ }), this.initInterceptors();
57
51
  }
58
52
  initInterceptors() {
59
- this.#axiosInstance.interceptors.request.use(
53
+ this.#e.interceptors.request.use(
60
54
  this.handleRequest.bind(this),
61
55
  this.handleRequestError.bind(this)
62
- );
63
- this.#axiosInstance.interceptors.response.use(
56
+ ), this.#e.interceptors.response.use(
64
57
  this.handleResponse.bind(this),
65
58
  this.handleResponseError.bind(this)
66
59
  );
@@ -72,11 +65,8 @@ class HttpClient {
72
65
  * @param target - The target.
73
66
  * @returns The result.
74
67
  */
75
- isBelongsTo(code, target) {
76
- if (isArray(target)) {
77
- return target.includes(code);
78
- }
79
- return code === target;
68
+ isBelongsTo(e, s) {
69
+ return k(s) ? s.includes(e) : e === s;
80
70
  }
81
71
  /**
82
72
  * Handle the request.
@@ -84,38 +74,22 @@ class HttpClient {
84
74
  * @param config - The axios request config.
85
75
  * @returns The axios request config.
86
76
  */
87
- async handleRequest(config) {
88
- const skipAuthentication = config.headers[skipAuthenticationHeader] === skipAuthenticationValue;
89
- if (this.#isRefreshing && !skipAuthentication) {
90
- const isSuccess = await new Promise((resolve) => {
91
- this.#waitingQueue.push(resolve);
92
- });
93
- if (!isSuccess) {
94
- throw new Error("登录已过期, 请重新登录");
95
- }
96
- }
97
- if (skipAuthentication) {
98
- delete config.headers[skipAuthenticationHeader];
99
- } else {
100
- await this.setAccessToken(config);
101
- }
102
- this.replacePathParams(config);
103
- return config;
77
+ async handleRequest(e) {
78
+ const s = e.headers[g] === E;
79
+ if (this.#t && !s && !await new Promise((t) => {
80
+ this.#n.push(t);
81
+ }))
82
+ throw new Error("登录已过期, 请重新登录");
83
+ return s ? delete e.headers[g] : await this.setAccessToken(e), this.replacePathParams(e), e;
104
84
  }
105
85
  /**
106
86
  * Handle the request error.
107
87
  *
108
88
  * @param error - The axios error.
109
89
  */
110
- handleRequestError(error) {
111
- const { showErrorMessage } = this.#options;
112
- const message = error instanceof Error ? error.message : String(error);
113
- if (showErrorMessage) {
114
- showErrorMessage(`发起请求失败: ${message || "未知错误"}`);
115
- } else {
116
- console.error(`[HttpClient] ❌ 发起请求失败: ${message || "未知错误"}`);
117
- }
118
- return Promise.reject(error);
90
+ handleRequestError(e) {
91
+ const { showErrorMessage: s } = this.#s, n = e instanceof Error ? e.message : String(e);
92
+ return s ? s(`发起请求失败: ${n || "未知错误"}`) : console.error(`[HttpClient] 发起请求失败: ${n || "未知错误"}`), Promise.reject(e);
119
93
  }
120
94
  /**
121
95
  * Handle the response.
@@ -123,117 +97,85 @@ class HttpClient {
123
97
  * @param response - The axios response.
124
98
  * @returns The axios response.
125
99
  */
126
- handleResponse(response) {
100
+ handleResponse(e) {
127
101
  const {
128
- showWarningMessage,
129
- okCode = 0
130
- } = this.#options;
131
- const {
132
- code,
133
- message,
134
- data
135
- } = response.data;
136
- if (this.isBelongsTo(code, okCode)) {
137
- return response;
138
- }
139
- if (showWarningMessage) {
140
- showWarningMessage(message);
141
- } else {
142
- console.warn(`[HttpClient] ⚠️ [${response.config.method}: ${response.config.url}] 返回错误: ${message}`);
143
- }
144
- throw new BusinessError(code, message, data);
102
+ showWarningMessage: s,
103
+ okCode: n = 0
104
+ } = this.#s, {
105
+ code: t,
106
+ message: o,
107
+ data: r
108
+ } = e.data;
109
+ if (this.isBelongsTo(t, n))
110
+ return e;
111
+ throw s ? s(o) : console.warn(`[HttpClient] ⚠️ [${e.config.method}: ${e.config.url}] 返回错误: ${o}`), new T(t, o, r);
145
112
  }
146
113
  /**
147
114
  * Handle the response error.
148
115
  *
149
116
  * @param error - The axios error.
150
117
  */
151
- async handleResponseError(error) {
118
+ async handleResponseError(e) {
152
119
  const {
153
- showInfoMessage,
154
- showWarningMessage,
155
- showErrorMessage,
156
- tokenExpiredCode = []
157
- } = this.#options;
158
- if (error instanceof CanceledError) {
159
- if (error.response) {
160
- const { method, url } = error.response.config;
161
- console.warn(`[HttpClient] ⚠️ [${method}: ${url}] 被取消`);
120
+ showInfoMessage: s,
121
+ showWarningMessage: n,
122
+ showErrorMessage: t,
123
+ tokenExpiredCode: o = []
124
+ } = this.#s;
125
+ if (e instanceof C) {
126
+ if (e.response) {
127
+ const { method: i, url: c } = e.response.config;
128
+ console.warn(`[HttpClient] ⚠️ [${i}: ${c}] 被取消`);
162
129
  }
163
130
  return;
164
131
  }
165
- const { response } = error;
166
- if (response) {
132
+ const { response: r } = e;
133
+ if (r) {
167
134
  const {
168
- status,
169
- config,
170
- data
171
- } = response;
172
- const { code, message } = data;
173
- const requestInfo = `[${config.method}: ${config.url}]`;
174
- switch (status) {
135
+ status: i,
136
+ config: c,
137
+ data: l
138
+ } = r, { code: p, message: a } = l, h = `[${c.method}: ${c.url}]`;
139
+ switch (i) {
175
140
  case 401: {
176
- if (this.isBelongsTo(code, tokenExpiredCode)) {
177
- const success = await this.tryRefreshToken();
178
- if (success) {
179
- await this.retryRequest(config);
141
+ if (this.isBelongsTo(p, o)) {
142
+ if (await this.tryRefreshToken()) {
143
+ await this.retryRequest(c);
180
144
  return;
181
145
  }
182
- const expiredMessage = "登录已过期, 请重新登录";
183
- if (showInfoMessage) {
184
- showInfoMessage(expiredMessage);
185
- } else {
186
- console.info(`[HttpClient] ℹ️ ${expiredMessage}`);
187
- }
146
+ const f = "登录已过期, 请重新登录";
147
+ s ? s(f) : console.info(`[HttpClient] ℹ️ ${f}`);
188
148
  }
189
- await this.#options.onUnauthenticated?.();
149
+ await this.#s.onUnauthenticated?.();
190
150
  break;
191
151
  }
192
152
  case 403: {
193
- showWarningMessage?.(`${message}, 请联系管理员为您开通`);
194
- console.warn(`[HttpClient] ⚠️ ${requestInfo} 访问被拒绝: ${message}`);
195
- await this.#options.onAccessDenied?.();
153
+ n?.(`${a}, 请联系管理员为您开通`), console.warn(`[HttpClient] ⚠️ ${h} 访问被拒绝: ${a}`), await this.#s.onAccessDenied?.();
196
154
  break;
197
155
  }
198
156
  case 400: {
199
- if (showWarningMessage) {
200
- showWarningMessage(message);
201
- } else {
202
- console.warn(`[HttpClient] ⚠️ ${requestInfo} 参数错误: ${message}`);
203
- }
157
+ n ? n(a) : console.warn(`[HttpClient] ⚠️ ${h} 参数错误: ${a}`);
204
158
  break;
205
159
  }
206
- default: {
207
- if (showErrorMessage) {
208
- showErrorMessage(message);
209
- } else {
210
- console.error(`[HttpClient] ❌ ${requestInfo} 返回错误: ${message}`);
211
- }
212
- }
160
+ default:
161
+ t ? t(a) : console.error(`[HttpClient] ❌ ${h} 返回错误: ${a}`);
213
162
  }
214
163
  } else {
215
- const errorMessage = `请求失败: ${error.message || "未知错误"}`;
216
- if (showErrorMessage) {
217
- showErrorMessage(errorMessage);
218
- } else {
219
- console.error(`[HttpClient] ❌ ${errorMessage}`);
220
- }
164
+ const i = `请求失败: ${e.message || "未知错误"}`;
165
+ t ? t(i) : console.error(`[HttpClient] ❌ ${i}`);
221
166
  }
222
- throw error;
167
+ throw e;
223
168
  }
224
169
  /**
225
170
  * Injects access token into request Authorization header.
226
171
  *
227
172
  * @param config - The axios request config.
228
173
  */
229
- async setAccessToken(config) {
230
- const { getAuthTokens } = this.#options;
231
- if (getAuthTokens) {
232
- const tokens = await getAuthTokens();
233
- const accessToken = tokens?.accessToken;
234
- if (accessToken) {
235
- config.headers.Authorization = `Bearer ${accessToken}`;
236
- }
174
+ async setAccessToken(e) {
175
+ const { getAuthTokens: s } = this.#s;
176
+ if (s) {
177
+ const t = (await s())?.accessToken;
178
+ t && (e.headers.Authorization = `Bearer ${t}`);
237
179
  }
238
180
  }
239
181
  /**
@@ -242,23 +184,14 @@ class HttpClient {
242
184
  * @param config - The axios request config.
243
185
  * @returns The axios request config.
244
186
  */
245
- replacePathParams(config) {
246
- const { url, params = {} } = config;
247
- if (url && pathParamRegex.test(url)) {
248
- config.url = url.replaceAll(pathParamRegex, (_, key) => {
249
- if (!Object.hasOwn(params, key)) {
250
- console.warn(`[HttpClient] ⚠️ 接口: ${url} 路径参数 ${key} 未在查询参数中定义, 请检查`);
251
- return "unknown";
252
- }
253
- const value = params[key];
254
- if (isNullish(value)) {
255
- console.warn(`[HttpClient] ⚠️ 接口: ${url} 路径参数 ${key} 在查询参数中为空, 请检查`);
256
- return "unknown";
257
- }
258
- return value;
259
- });
260
- }
261
- return config;
187
+ replacePathParams(e) {
188
+ const { url: s, params: n = {} } = e;
189
+ return s && w.test(s) && (e.url = s.replaceAll(w, (t, o) => {
190
+ if (!Object.hasOwn(n, o))
191
+ return console.warn(`[HttpClient] ⚠️ 接口: ${s} 路径参数 ${o} 未在查询参数中定义, 请检查`), "unknown";
192
+ const r = n[o];
193
+ return y(r) ? (console.warn(`[HttpClient] ⚠️ 接口: ${s} 路径参数 ${o} 在查询参数中为空, 请检查`), "unknown") : r;
194
+ })), e;
262
195
  }
263
196
  /**
264
197
  * Try to refresh the token using the provided refresh callback.
@@ -267,32 +200,27 @@ class HttpClient {
267
200
  */
268
201
  async tryRefreshToken() {
269
202
  const {
270
- getAuthTokens,
271
- refreshToken,
272
- setAuthTokens
273
- } = this.#options;
274
- if (!getAuthTokens || !refreshToken || !setAuthTokens) {
275
- return false;
276
- }
277
- this.#isRefreshing = true;
278
- let success = false;
203
+ getAuthTokens: e,
204
+ refreshToken: s,
205
+ setAuthTokens: n
206
+ } = this.#s;
207
+ if (!e || !s || !n)
208
+ return !1;
209
+ this.#t = !0;
210
+ let t = !1;
279
211
  try {
280
- const currentTokens = await getAuthTokens();
281
- if (!currentTokens) {
282
- return false;
283
- }
284
- const newTokens = await refreshToken(currentTokens);
285
- await setAuthTokens(Object.freeze(newTokens));
286
- return success = true;
287
- } catch (error) {
288
- console.error(`[HttpClient] ❌ 刷新令牌失败: ${error}`);
289
- return false;
212
+ const o = await e();
213
+ if (!o)
214
+ return !1;
215
+ const r = await s(o);
216
+ return await n(Object.freeze(r)), t = !0;
217
+ } catch (o) {
218
+ return console.error(`[HttpClient] 刷新令牌失败: ${o}`), !1;
290
219
  } finally {
291
- this.#isRefreshing = false;
292
- for (const resolve of this.#waitingQueue) {
293
- resolve(success);
294
- }
295
- this.#waitingQueue = [];
220
+ this.#t = !1;
221
+ for (const o of this.#n)
222
+ o(t);
223
+ this.#n = [];
296
224
  }
297
225
  }
298
226
  /**
@@ -301,10 +229,9 @@ class HttpClient {
301
229
  * @param config - The axios request config.
302
230
  * @returns The axios response.
303
231
  */
304
- async retryRequest(config) {
305
- const newConfig = { ...config };
306
- await this.setAccessToken(newConfig);
307
- return this.#axiosInstance(newConfig);
232
+ async retryRequest(e) {
233
+ const s = { ...e };
234
+ return await this.setAccessToken(s), this.#e(s);
308
235
  }
309
236
  /**
310
237
  * Get the resource.
@@ -313,12 +240,11 @@ class HttpClient {
313
240
  * @param options - The options for the request.
314
241
  * @returns The response data.
315
242
  */
316
- async get(url, options) {
317
- const response = await this.#axiosInstance.get(
318
- url,
319
- options
320
- );
321
- return response.data;
243
+ async get(e, s) {
244
+ return (await this.#e.get(
245
+ e,
246
+ s
247
+ )).data;
322
248
  }
323
249
  /**
324
250
  * Post the resource.
@@ -327,14 +253,13 @@ class HttpClient {
327
253
  * @param options - The options for the request.
328
254
  * @returns The response data.
329
255
  */
330
- async post(url, options) {
331
- const { data, ...restOptions } = options ?? {};
332
- const response = await this.#axiosInstance.post(
333
- url,
334
- data,
335
- restOptions
336
- );
337
- return response.data;
256
+ async post(e, s) {
257
+ const { data: n, ...t } = s ?? {};
258
+ return (await this.#e.post(
259
+ e,
260
+ n,
261
+ t
262
+ )).data;
338
263
  }
339
264
  /**
340
265
  * Update the resource.
@@ -343,14 +268,13 @@ class HttpClient {
343
268
  * @param options - The options for the request.
344
269
  * @returns The response data.
345
270
  */
346
- async put(url, options) {
347
- const { data, ...restOptions } = options ?? {};
348
- const response = await this.#axiosInstance.put(
349
- url,
350
- data,
351
- restOptions
352
- );
353
- return response.data;
271
+ async put(e, s) {
272
+ const { data: n, ...t } = s ?? {};
273
+ return (await this.#e.put(
274
+ e,
275
+ n,
276
+ t
277
+ )).data;
354
278
  }
355
279
  /**
356
280
  * Delete the resource.
@@ -359,12 +283,11 @@ class HttpClient {
359
283
  * @param options - The options for the request.
360
284
  * @returns The response data.
361
285
  */
362
- async delete(url, options) {
363
- const response = await this.#axiosInstance.delete(
364
- url,
365
- options
366
- );
367
- return response.data;
286
+ async delete(e, s) {
287
+ return (await this.#e.delete(
288
+ e,
289
+ s
290
+ )).data;
368
291
  }
369
292
  /**
370
293
  * Upload the file.
@@ -373,21 +296,20 @@ class HttpClient {
373
296
  * @param options - The options for the request.
374
297
  * @returns The response data.
375
298
  */
376
- async upload(url, options) {
299
+ async upload(e, s) {
377
300
  const {
378
- data,
379
- onProgress,
380
- ...restOptions
381
- } = options ?? {};
382
- const response = await this.#axiosInstance.postForm(
383
- url,
384
- data,
301
+ data: n,
302
+ onProgress: t,
303
+ ...o
304
+ } = s ?? {};
305
+ return (await this.#e.postForm(
306
+ e,
307
+ n,
385
308
  {
386
- ...restOptions,
387
- onUploadProgress: isFunction(onProgress) ? onProgress : void 0
309
+ ...o,
310
+ onUploadProgress: d(t) ? t : void 0
388
311
  }
389
- );
390
- return response.data;
312
+ )).data;
391
313
  }
392
314
  /**
393
315
  * Download the file.
@@ -396,44 +318,42 @@ class HttpClient {
396
318
  * @param options - The options for the request.
397
319
  * @returns The response data.
398
320
  */
399
- async download(url, options) {
321
+ async download(e, s) {
400
322
  const {
401
- onProgress,
402
- filename,
403
- ...restOptions
404
- } = options ?? {};
405
- const { data, headers } = await this.#axiosInstance.get(
406
- url,
323
+ onProgress: n,
324
+ filename: t,
325
+ ...o
326
+ } = s ?? {}, { data: r, headers: i } = await this.#e.get(
327
+ e,
407
328
  {
408
- ...restOptions,
329
+ ...o,
409
330
  responseType: "blob",
410
331
  responseEncoding: "binary",
411
- onDownloadProgress: isFunction(onProgress) ? onProgress : void 0
332
+ onDownloadProgress: d(n) ? n : void 0
412
333
  }
413
334
  );
414
335
  try {
415
- const result = JSON.parse(await data.text());
416
- throw new Error(result.message);
336
+ const l = JSON.parse(await r.text());
337
+ throw new Error(l.message);
417
338
  } catch {
418
339
  }
419
- const contentDisposition = headers["content-disposition"];
420
- if (isString(contentDisposition)) {
421
- const matches = filenameRegex.exec(contentDisposition);
422
- if (matches && matches.groups) {
423
- const { name } = matches.groups;
424
- const original = decodeURIComponent(name);
425
- const objectUrl = URL.createObjectURL(data);
340
+ const c = i["content-disposition"];
341
+ if ($(c)) {
342
+ const l = b.exec(c);
343
+ if (l && l.groups) {
344
+ const { name: p } = l.groups, a = decodeURIComponent(p), h = URL.createObjectURL(r);
426
345
  try {
427
- const a = document.createElement("a");
428
- a.href = objectUrl;
429
- a.download = isFunction(filename) ? filename(original) : filename ?? original;
430
- a.click();
346
+ const u = document.createElement("a");
347
+ u.href = h, u.download = d(t) ? t(a) : t ?? a, u.click();
431
348
  } finally {
432
- URL.revokeObjectURL(objectUrl);
349
+ URL.revokeObjectURL(h);
433
350
  }
434
351
  }
435
352
  }
436
353
  }
437
354
  }
438
-
439
- export { HttpClient, skipAuthenticationHeader, skipAuthenticationValue };
355
+ export {
356
+ O as HttpClient,
357
+ g as skipAuthenticationHeader,
358
+ E as skipAuthenticationValue
359
+ };