hanbiro-react16-sdk 1.0.19 → 1.0.21

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 (60) hide show
  1. package/dist/components/ChatAIDraft/SettingPopper.js +5 -5
  2. package/dist/components/CountryFlag/flags/KRFlag.js +1 -1
  3. package/dist/hanbiro-react16-sdk.style.css +1 -1
  4. package/dist/hanbiro-react16-sdk.umd.js +2 -2
  5. package/dist/index.js +10 -10
  6. package/dist/utils/api.d.ts +9 -0
  7. package/dist/utils/api.js +55 -0
  8. package/package.json +9 -7
  9. package/dist/node_modules/axios/index.js +0 -38
  10. package/dist/node_modules/axios/lib/adapters/adapters.js +0 -71
  11. package/dist/node_modules/axios/lib/adapters/fetch.js +0 -272
  12. package/dist/node_modules/axios/lib/adapters/xhr.js +0 -153
  13. package/dist/node_modules/axios/lib/axios.js +0 -50
  14. package/dist/node_modules/axios/lib/cancel/CancelToken.js +0 -99
  15. package/dist/node_modules/axios/lib/cancel/CanceledError.js +0 -20
  16. package/dist/node_modules/axios/lib/cancel/isCancel.js +0 -6
  17. package/dist/node_modules/axios/lib/core/Axios.js +0 -220
  18. package/dist/node_modules/axios/lib/core/AxiosError.js +0 -76
  19. package/dist/node_modules/axios/lib/core/AxiosHeaders.js +0 -238
  20. package/dist/node_modules/axios/lib/core/InterceptorManager.js +0 -66
  21. package/dist/node_modules/axios/lib/core/buildFullPath.js +0 -12
  22. package/dist/node_modules/axios/lib/core/dispatchRequest.js +0 -48
  23. package/dist/node_modules/axios/lib/core/mergeConfig.js +0 -100
  24. package/dist/node_modules/axios/lib/core/settle.js +0 -20
  25. package/dist/node_modules/axios/lib/core/transformData.js +0 -17
  26. package/dist/node_modules/axios/lib/defaults/index.js +0 -120
  27. package/dist/node_modules/axios/lib/defaults/transitional.js +0 -9
  28. package/dist/node_modules/axios/lib/env/data.js +0 -4
  29. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -34
  30. package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -77
  31. package/dist/node_modules/axios/lib/helpers/bind.js +0 -8
  32. package/dist/node_modules/axios/lib/helpers/buildURL.js +0 -32
  33. package/dist/node_modules/axios/lib/helpers/combineURLs.js +0 -6
  34. package/dist/node_modules/axios/lib/helpers/composeSignals.js +0 -41
  35. package/dist/node_modules/axios/lib/helpers/cookies.js +0 -49
  36. package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +0 -54
  37. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -9
  38. package/dist/node_modules/axios/lib/helpers/isAxiosError.js +0 -7
  39. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -11
  40. package/dist/node_modules/axios/lib/helpers/null.js +0 -4
  41. package/dist/node_modules/axios/lib/helpers/parseHeaders.js +0 -47
  42. package/dist/node_modules/axios/lib/helpers/parseProtocol.js +0 -7
  43. package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +0 -44
  44. package/dist/node_modules/axios/lib/helpers/resolveConfig.js +0 -52
  45. package/dist/node_modules/axios/lib/helpers/speedometer.js +0 -36
  46. package/dist/node_modules/axios/lib/helpers/spread.js +0 -8
  47. package/dist/node_modules/axios/lib/helpers/throttle.js +0 -35
  48. package/dist/node_modules/axios/lib/helpers/toFormData.js +0 -120
  49. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -33
  50. package/dist/node_modules/axios/lib/helpers/trackStream.js +0 -169
  51. package/dist/node_modules/axios/lib/helpers/validator.js +0 -70
  52. package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -4
  53. package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -4
  54. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
  55. package/dist/node_modules/axios/lib/platform/browser/index.js +0 -15
  56. package/dist/node_modules/axios/lib/platform/common/utils.js +0 -15
  57. package/dist/node_modules/axios/lib/platform/index.js +0 -22
  58. package/dist/node_modules/axios/lib/utils.js +0 -429
  59. package/dist/utils/axiosAPI.d.ts +0 -1
  60. package/dist/utils/axiosAPI.js +0 -89
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  /*!
2
- * hanbiro-react16-sdk v1.0.19
2
+ * hanbiro-react16-sdk v1.0.21
3
3
  * Build Date: 2026-04-02
4
4
  */
5
5
  /* empty css */
6
+ import { AI_LANG_FLAGS } from "./constants/index.js";
6
7
  import { default as default2 } from "./components/ChatAIDraft/index.js";
7
- import { default as default3 } from "./components/LoadingCircular/index.js";
8
- import { default as default4 } from "./components/LoadingContainer/index.js";
9
- import { default as default5 } from "./components/Tooltip/index.js";
10
- import { default as default6 } from "./components/CountryFlag/index.js";
8
+ import { default as default3 } from "./components/CountryFlag/index.js";
9
+ import { default as default4 } from "./components/LoadingCircular/index.js";
10
+ import { default as default5 } from "./components/LoadingContainer/index.js";
11
+ import { default as default6 } from "./components/Tooltip/index.js";
11
12
  import { getBaseUrl, getGroupwareUrl, initHanbiroReactSDK } from "./utils/url.js";
12
- import { AI_LANG_FLAGS } from "./constants/index.js";
13
13
  export {
14
14
  AI_LANG_FLAGS,
15
15
  default2 as ChatAIDraft,
16
- default6 as CountryFlag,
17
- default3 as LoadingCircular,
18
- default4 as LoadingContainer,
19
- default5 as Tooltip,
16
+ default3 as CountryFlag,
17
+ default4 as LoadingCircular,
18
+ default5 as LoadingContainer,
19
+ default6 as Tooltip,
20
20
  getBaseUrl,
21
21
  getGroupwareUrl,
22
22
  initHanbiroReactSDK
@@ -0,0 +1,9 @@
1
+ interface apiGetOptions {
2
+ headers: any;
3
+ }
4
+ export declare const apiGet: (url: string, opts?: apiGetOptions) => Promise<{
5
+ data: any;
6
+ code: number;
7
+ ok: boolean;
8
+ }>;
9
+ export {};
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
37
+ import { getBaseUrl } from "./url.js";
38
+ const apiGet = (url, opts) => __async(void 0, null, function* () {
39
+ const response = yield fetch(getBaseUrl() + url, {
40
+ headers: __spreadValues({
41
+ Accept: "application/json, text/plain, */*",
42
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
43
+ }, opts == null ? void 0 : opts.headers)
44
+ });
45
+ let data = null;
46
+ if (response.ok) {
47
+ data = yield response.json();
48
+ } else {
49
+ console.error(`HTTP error! status: ${response.status}`);
50
+ }
51
+ return { data, code: response.status, ok: response.ok };
52
+ });
53
+ export {
54
+ apiGet
55
+ };
package/package.json CHANGED
@@ -1,29 +1,32 @@
1
1
  {
2
2
  "name": "hanbiro-react16-sdk",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "React 16.2.0 compatible UI components for Hanbiro",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/hanbiro-react16-sdk.umd.js",
7
- "module": "./dist/hanbiro-react16-sdk.es.js",
7
+ "module": "./dist/index.js",
8
+ "sideEffects": [
9
+ "**/*.css"
10
+ ],
8
11
  "exports": {
9
12
  ".": {
10
13
  "types": "./dist/index.d.ts",
11
- "import": "./dist/hanbiro-react16-sdk.es.js",
14
+ "import": "./dist/index.js",
12
15
  "require": "./dist/hanbiro-react16-sdk.umd.js"
13
16
  },
14
17
  "./components": {
15
18
  "types": "./dist/components/index.d.ts",
16
- "import": "./dist/hanbiro-react16-sdk.es.js",
19
+ "import": "./dist/index.js",
17
20
  "require": "./dist/hanbiro-react16-sdk.umd.js"
18
21
  },
19
22
  "./utils": {
20
23
  "types": "./dist/utils/index.d.ts",
21
- "import": "./dist/hanbiro-react16-sdk.es.js",
24
+ "import": "./dist/index.js",
22
25
  "require": "./dist/hanbiro-react16-sdk.umd.js"
23
26
  },
24
27
  "./constants": {
25
28
  "types": "./dist/constants/index.d.ts",
26
- "import": "./dist/hanbiro-react16-sdk.es.js",
29
+ "import": "./dist/index.js",
27
30
  "require": "./dist/hanbiro-react16-sdk.umd.js"
28
31
  },
29
32
  "./style.css": "./dist/hanbiro-react16-sdk.style.css"
@@ -75,7 +78,6 @@
75
78
  },
76
79
  "dependencies": {
77
80
  "@tinymce/tinymce-react": "^4.3.0",
78
- "axios": "^1.13.6",
79
81
  "marked": "^15.0.12",
80
82
  "react-feather": "^2.0.10",
81
83
  "uuid": "^9.0.0"
@@ -1,38 +0,0 @@
1
- import axios from "./lib/axios.js";
2
- const {
3
- Axios,
4
- AxiosError,
5
- CanceledError,
6
- isCancel,
7
- CancelToken,
8
- VERSION,
9
- all,
10
- Cancel,
11
- isAxiosError,
12
- spread,
13
- toFormData,
14
- AxiosHeaders,
15
- HttpStatusCode,
16
- formToJSON,
17
- getAdapter,
18
- mergeConfig
19
- } = axios;
20
- export {
21
- Axios,
22
- AxiosError,
23
- AxiosHeaders,
24
- Cancel,
25
- CancelToken,
26
- CanceledError,
27
- HttpStatusCode,
28
- VERSION,
29
- all,
30
- axios as default,
31
- formToJSON,
32
- getAdapter,
33
- isAxiosError,
34
- isCancel,
35
- mergeConfig,
36
- spread,
37
- toFormData
38
- };
@@ -1,71 +0,0 @@
1
- import utils from "../utils.js";
2
- import httpAdapter from "../helpers/null.js";
3
- import xhrAdapter from "./xhr.js";
4
- import { getFetch } from "./fetch.js";
5
- import AxiosError from "../core/AxiosError.js";
6
- const knownAdapters = {
7
- http: httpAdapter,
8
- xhr: xhrAdapter,
9
- fetch: {
10
- get: getFetch
11
- }
12
- };
13
- utils.forEach(knownAdapters, (fn, value) => {
14
- if (fn) {
15
- try {
16
- Object.defineProperty(fn, "name", { value });
17
- } catch (e) {
18
- }
19
- Object.defineProperty(fn, "adapterName", { value });
20
- }
21
- });
22
- const renderReason = (reason) => `- ${reason}`;
23
- const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
24
- function getAdapter(adapters2, config) {
25
- adapters2 = utils.isArray(adapters2) ? adapters2 : [adapters2];
26
- const { length } = adapters2;
27
- let nameOrAdapter;
28
- let adapter;
29
- const rejectedReasons = {};
30
- for (let i = 0; i < length; i++) {
31
- nameOrAdapter = adapters2[i];
32
- let id;
33
- adapter = nameOrAdapter;
34
- if (!isResolvedHandle(nameOrAdapter)) {
35
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
36
- if (adapter === void 0) {
37
- throw new AxiosError(`Unknown adapter '${id}'`);
38
- }
39
- }
40
- if (adapter && (utils.isFunction(adapter) || (adapter = adapter.get(config)))) {
41
- break;
42
- }
43
- rejectedReasons[id || "#" + i] = adapter;
44
- }
45
- if (!adapter) {
46
- const reasons = Object.entries(rejectedReasons).map(
47
- ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
48
- );
49
- let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
50
- throw new AxiosError(
51
- `There is no suitable adapter to dispatch the request ` + s,
52
- "ERR_NOT_SUPPORT"
53
- );
54
- }
55
- return adapter;
56
- }
57
- const adapters = {
58
- /**
59
- * Resolve an adapter from a list of adapter names or functions.
60
- * @type {Function}
61
- */
62
- getAdapter,
63
- /**
64
- * Exposes all known adapters
65
- * @type {Object<string, Function|Object>}
66
- */
67
- adapters: knownAdapters
68
- };
69
- export {
70
- adapters as default
71
- };
@@ -1,272 +0,0 @@
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
- var __async = (__this, __arguments, generator) => {
21
- return new Promise((resolve, reject) => {
22
- var fulfilled = (value) => {
23
- try {
24
- step(generator.next(value));
25
- } catch (e) {
26
- reject(e);
27
- }
28
- };
29
- var rejected = (value) => {
30
- try {
31
- step(generator.throw(value));
32
- } catch (e) {
33
- reject(e);
34
- }
35
- };
36
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
- step((generator = generator.apply(__this, __arguments)).next());
38
- });
39
- };
40
- import platform from "../platform/index.js";
41
- import utils from "../utils.js";
42
- import AxiosError from "../core/AxiosError.js";
43
- import composeSignals from "../helpers/composeSignals.js";
44
- import { trackStream } from "../helpers/trackStream.js";
45
- import AxiosHeaders from "../core/AxiosHeaders.js";
46
- import { progressEventDecorator, progressEventReducer, asyncDecorator } from "../helpers/progressEventReducer.js";
47
- import resolveConfig from "../helpers/resolveConfig.js";
48
- import settle from "../core/settle.js";
49
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
50
- const { isFunction } = utils;
51
- const globalFetchAPI = (({ Request, Response }) => ({
52
- Request,
53
- Response
54
- }))(utils.global);
55
- const { ReadableStream, TextEncoder } = utils.global;
56
- const test = (fn, ...args) => {
57
- try {
58
- return !!fn(...args);
59
- } catch (e) {
60
- return false;
61
- }
62
- };
63
- const factory = (env) => {
64
- env = utils.merge.call(
65
- {
66
- skipUndefined: true
67
- },
68
- globalFetchAPI,
69
- env
70
- );
71
- const { fetch: envFetch, Request, Response } = env;
72
- const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === "function";
73
- const isRequestSupported = isFunction(Request);
74
- const isResponseSupported = isFunction(Response);
75
- if (!isFetchSupported) {
76
- return false;
77
- }
78
- const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
79
- const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : (str) => __async(void 0, null, function* () {
80
- return new Uint8Array(yield new Request(str).arrayBuffer());
81
- }));
82
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
83
- let duplexAccessed = false;
84
- const hasContentType = new Request(platform.origin, {
85
- body: new ReadableStream(),
86
- method: "POST",
87
- get duplex() {
88
- duplexAccessed = true;
89
- return "half";
90
- }
91
- }).headers.has("Content-Type");
92
- return duplexAccessed && !hasContentType;
93
- });
94
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils.isReadableStream(new Response("").body));
95
- const resolvers = {
96
- stream: supportsResponseStream && ((res) => res.body)
97
- };
98
- isFetchSupported && (() => {
99
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
100
- !resolvers[type] && (resolvers[type] = (res, config) => {
101
- let method = res && res[type];
102
- if (method) {
103
- return method.call(res);
104
- }
105
- throw new AxiosError(
106
- `Response type '${type}' is not supported`,
107
- AxiosError.ERR_NOT_SUPPORT,
108
- config
109
- );
110
- });
111
- });
112
- })();
113
- const getBodyLength = (body) => __async(void 0, null, function* () {
114
- if (body == null) {
115
- return 0;
116
- }
117
- if (utils.isBlob(body)) {
118
- return body.size;
119
- }
120
- if (utils.isSpecCompliantForm(body)) {
121
- const _request = new Request(platform.origin, {
122
- method: "POST",
123
- body
124
- });
125
- return (yield _request.arrayBuffer()).byteLength;
126
- }
127
- if (utils.isArrayBufferView(body) || utils.isArrayBuffer(body)) {
128
- return body.byteLength;
129
- }
130
- if (utils.isURLSearchParams(body)) {
131
- body = body + "";
132
- }
133
- if (utils.isString(body)) {
134
- return (yield encodeText(body)).byteLength;
135
- }
136
- });
137
- const resolveBodyLength = (headers, body) => __async(void 0, null, function* () {
138
- const length = utils.toFiniteNumber(headers.getContentLength());
139
- return length == null ? getBodyLength(body) : length;
140
- });
141
- return (config) => __async(void 0, null, function* () {
142
- let {
143
- url,
144
- method,
145
- data,
146
- signal,
147
- cancelToken,
148
- timeout,
149
- onDownloadProgress,
150
- onUploadProgress,
151
- responseType,
152
- headers,
153
- withCredentials = "same-origin",
154
- fetchOptions
155
- } = resolveConfig(config);
156
- let _fetch = envFetch || fetch;
157
- responseType = responseType ? (responseType + "").toLowerCase() : "text";
158
- let composedSignal = composeSignals(
159
- [signal, cancelToken && cancelToken.toAbortSignal()],
160
- timeout
161
- );
162
- let request = null;
163
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
164
- composedSignal.unsubscribe();
165
- });
166
- let requestContentLength;
167
- try {
168
- if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = yield resolveBodyLength(headers, data)) !== 0) {
169
- let _request = new Request(url, {
170
- method: "POST",
171
- body: data,
172
- duplex: "half"
173
- });
174
- let contentTypeHeader;
175
- if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
176
- headers.setContentType(contentTypeHeader);
177
- }
178
- if (_request.body) {
179
- const [onProgress, flush] = progressEventDecorator(
180
- requestContentLength,
181
- progressEventReducer(asyncDecorator(onUploadProgress))
182
- );
183
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
184
- }
185
- }
186
- if (!utils.isString(withCredentials)) {
187
- withCredentials = withCredentials ? "include" : "omit";
188
- }
189
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
190
- const resolvedOptions = __spreadProps(__spreadValues({}, fetchOptions), {
191
- signal: composedSignal,
192
- method: method.toUpperCase(),
193
- headers: headers.normalize().toJSON(),
194
- body: data,
195
- duplex: "half",
196
- credentials: isCredentialsSupported ? withCredentials : void 0
197
- });
198
- request = isRequestSupported && new Request(url, resolvedOptions);
199
- let response = yield isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
200
- const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
201
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
202
- const options = {};
203
- ["status", "statusText", "headers"].forEach((prop) => {
204
- options[prop] = response[prop];
205
- });
206
- const responseContentLength = utils.toFiniteNumber(response.headers.get("content-length"));
207
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
208
- responseContentLength,
209
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
210
- ) || [];
211
- response = new Response(
212
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
213
- flush && flush();
214
- unsubscribe && unsubscribe();
215
- }),
216
- options
217
- );
218
- }
219
- responseType = responseType || "text";
220
- let responseData = yield resolvers[utils.findKey(resolvers, responseType) || "text"](
221
- response,
222
- config
223
- );
224
- !isStreamResponse && unsubscribe && unsubscribe();
225
- return yield new Promise((resolve, reject) => {
226
- settle(resolve, reject, {
227
- data: responseData,
228
- headers: AxiosHeaders.from(response.headers),
229
- status: response.status,
230
- statusText: response.statusText,
231
- config,
232
- request
233
- });
234
- });
235
- } catch (err) {
236
- unsubscribe && unsubscribe();
237
- if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
238
- throw Object.assign(
239
- new AxiosError(
240
- "Network Error",
241
- AxiosError.ERR_NETWORK,
242
- config,
243
- request,
244
- err && err.response
245
- ),
246
- {
247
- cause: err.cause || err
248
- }
249
- );
250
- }
251
- throw AxiosError.from(err, err && err.code, config, request, err && err.response);
252
- }
253
- });
254
- };
255
- const seedCache = /* @__PURE__ */ new Map();
256
- const getFetch = (config) => {
257
- let env = config && config.env || {};
258
- const { fetch: fetch2, Request, Response } = env;
259
- const seeds = [Request, Response, fetch2];
260
- let len = seeds.length, i = len, seed, target, map = seedCache;
261
- while (i--) {
262
- seed = seeds[i];
263
- target = map.get(seed);
264
- target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
265
- map = target;
266
- }
267
- return target;
268
- };
269
- getFetch();
270
- export {
271
- getFetch
272
- };
@@ -1,153 +0,0 @@
1
- import utils from "../utils.js";
2
- import settle from "../core/settle.js";
3
- import transitionalDefaults from "../defaults/transitional.js";
4
- import AxiosError from "../core/AxiosError.js";
5
- import CanceledError from "../cancel/CanceledError.js";
6
- import parseProtocol from "../helpers/parseProtocol.js";
7
- import platform from "../platform/index.js";
8
- import AxiosHeaders from "../core/AxiosHeaders.js";
9
- import { progressEventReducer } from "../helpers/progressEventReducer.js";
10
- import resolveConfig from "../helpers/resolveConfig.js";
11
- const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
12
- const xhrAdapter = isXHRAdapterSupported && function(config) {
13
- return new Promise(function dispatchXhrRequest(resolve, reject) {
14
- const _config = resolveConfig(config);
15
- let requestData = _config.data;
16
- const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
17
- let { responseType, onUploadProgress, onDownloadProgress } = _config;
18
- let onCanceled;
19
- let uploadThrottled, downloadThrottled;
20
- let flushUpload, flushDownload;
21
- function done() {
22
- flushUpload && flushUpload();
23
- flushDownload && flushDownload();
24
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
25
- _config.signal && _config.signal.removeEventListener("abort", onCanceled);
26
- }
27
- let request = new XMLHttpRequest();
28
- request.open(_config.method.toUpperCase(), _config.url, true);
29
- request.timeout = _config.timeout;
30
- function onloadend() {
31
- if (!request) {
32
- return;
33
- }
34
- const responseHeaders = AxiosHeaders.from(
35
- "getAllResponseHeaders" in request && request.getAllResponseHeaders()
36
- );
37
- const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
38
- const response = {
39
- data: responseData,
40
- status: request.status,
41
- statusText: request.statusText,
42
- headers: responseHeaders,
43
- config,
44
- request
45
- };
46
- settle(
47
- function _resolve(value) {
48
- resolve(value);
49
- done();
50
- },
51
- function _reject(err) {
52
- reject(err);
53
- done();
54
- },
55
- response
56
- );
57
- request = null;
58
- }
59
- if ("onloadend" in request) {
60
- request.onloadend = onloadend;
61
- } else {
62
- request.onreadystatechange = function handleLoad() {
63
- if (!request || request.readyState !== 4) {
64
- return;
65
- }
66
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
67
- return;
68
- }
69
- setTimeout(onloadend);
70
- };
71
- }
72
- request.onabort = function handleAbort() {
73
- if (!request) {
74
- return;
75
- }
76
- reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, config, request));
77
- request = null;
78
- };
79
- request.onerror = function handleError(event) {
80
- const msg = event && event.message ? event.message : "Network Error";
81
- const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
82
- err.event = event || null;
83
- reject(err);
84
- request = null;
85
- };
86
- request.ontimeout = function handleTimeout() {
87
- let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
88
- const transitional = _config.transitional || transitionalDefaults;
89
- if (_config.timeoutErrorMessage) {
90
- timeoutErrorMessage = _config.timeoutErrorMessage;
91
- }
92
- reject(
93
- new AxiosError(
94
- timeoutErrorMessage,
95
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
96
- config,
97
- request
98
- )
99
- );
100
- request = null;
101
- };
102
- requestData === void 0 && requestHeaders.setContentType(null);
103
- if ("setRequestHeader" in request) {
104
- utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
105
- request.setRequestHeader(key, val);
106
- });
107
- }
108
- if (!utils.isUndefined(_config.withCredentials)) {
109
- request.withCredentials = !!_config.withCredentials;
110
- }
111
- if (responseType && responseType !== "json") {
112
- request.responseType = _config.responseType;
113
- }
114
- if (onDownloadProgress) {
115
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
116
- request.addEventListener("progress", downloadThrottled);
117
- }
118
- if (onUploadProgress && request.upload) {
119
- [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
120
- request.upload.addEventListener("progress", uploadThrottled);
121
- request.upload.addEventListener("loadend", flushUpload);
122
- }
123
- if (_config.cancelToken || _config.signal) {
124
- onCanceled = (cancel) => {
125
- if (!request) {
126
- return;
127
- }
128
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
129
- request.abort();
130
- request = null;
131
- };
132
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
133
- if (_config.signal) {
134
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
135
- }
136
- }
137
- const protocol = parseProtocol(_config.url);
138
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
139
- reject(
140
- new AxiosError(
141
- "Unsupported protocol " + protocol + ":",
142
- AxiosError.ERR_BAD_REQUEST,
143
- config
144
- )
145
- );
146
- return;
147
- }
148
- request.send(requestData || null);
149
- });
150
- };
151
- export {
152
- xhrAdapter as default
153
- };