@myun/gimi-chat 0.0.2 → 0.0.4

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 (206) hide show
  1. package/dist/apis/fetch.d.ts +64 -0
  2. package/dist/apis/fetch.js +512 -0
  3. package/dist/apis/useApi.d.ts +57 -0
  4. package/dist/apis/useApi.js +378 -0
  5. package/dist/assets/image/Subtract.png +0 -0
  6. package/dist/assets/image/ai-logo.png +0 -0
  7. package/dist/assets/image/copyIcon.png +0 -0
  8. package/dist/assets/image/deepthinkActive.png +0 -0
  9. package/dist/assets/image/empty-img-dark.png +0 -0
  10. package/dist/assets/image/empty-img.png +0 -0
  11. package/dist/assets/image/like_active.png +0 -0
  12. package/dist/assets/image/love.png +0 -0
  13. package/dist/assets/image/retry.png +0 -0
  14. package/dist/assets/image/soundOut.png +0 -0
  15. package/dist/assets/image/unlike_active.png +0 -0
  16. package/dist/assets/image/unlove.png +0 -0
  17. package/dist/assets/lottie/ai-bg.json +1704 -0
  18. package/dist/assets/lottie/ai-loading.json +192 -0
  19. package/dist/assets/lottie/ai-output-loading.json +272 -0
  20. package/dist/assets/lottie/ai-output-normal.json +17694 -0
  21. package/dist/assets/lottie/ai-output-strengthen.json +17321 -0
  22. package/dist/assets/lottie/ai-voice-play.json +1 -0
  23. package/dist/assets/lottie/living.json +705 -0
  24. package/dist/assets/lottie/myun-living.json +726 -0
  25. package/dist/assets/lottie/myun-loading.json +530 -0
  26. package/dist/components/ai-chat-dialogue/index.d.ts +16 -0
  27. package/dist/components/ai-chat-dialogue/index.js +1056 -0
  28. package/dist/components/ai-chat-dialogue/index.module.scss +272 -0
  29. package/dist/components/ai-chat-dialogue/message-parser.d.ts +36 -0
  30. package/dist/components/ai-chat-dialogue/message-parser.js +52 -0
  31. package/dist/components/ai-chat-dialogue/tlv.d.ts +7 -0
  32. package/dist/components/ai-chat-dialogue/tlv.js +32 -0
  33. package/dist/components/ai-chat-dialogue/volc-voice-call-client.d.ts +47 -0
  34. package/dist/components/ai-chat-dialogue/volc-voice-call-client.js +246 -0
  35. package/dist/components/ai-correction/index.d.ts +5 -0
  36. package/dist/components/ai-correction/index.js +45 -0
  37. package/dist/components/ai-loading/index.d.ts +3 -0
  38. package/dist/components/ai-loading/index.js +14 -0
  39. package/dist/components/ai-loading/index.module.scss +11 -0
  40. package/dist/components/answer-item/index.d.ts +27 -0
  41. package/dist/components/answer-item/index.js +194 -0
  42. package/dist/components/answer-item/index.module.scss +295 -0
  43. package/dist/components/ask-card/index.d.ts +10 -0
  44. package/dist/components/ask-card/index.js +76 -0
  45. package/dist/components/ask-card/index.module.scss +125 -0
  46. package/dist/components/chat-input/index.d.ts +31 -0
  47. package/dist/components/chat-input/index.js +433 -0
  48. package/dist/components/chat-input/index.module.scss +44 -0
  49. package/dist/components/chat-voice/VoiceCommunication.d.ts +7 -0
  50. package/dist/components/chat-voice/VoiceCommunication.js +69 -0
  51. package/dist/components/chat-voice/VoiceRecord.d.ts +7 -0
  52. package/dist/components/chat-voice/VoiceRecord.js +34 -0
  53. package/dist/components/conversation-delete/index.d.ts +5 -0
  54. package/dist/components/conversation-delete/index.js +24 -0
  55. package/dist/components/dots-loading/index.d.ts +2 -0
  56. package/dist/components/dots-loading/index.js +11 -0
  57. package/dist/components/dots-loading/index.module.scss +45 -0
  58. package/dist/components/empty/index.d.ts +9 -0
  59. package/dist/components/empty/index.js +32 -0
  60. package/dist/components/empty/index.module.scss +27 -0
  61. package/dist/components/excel-components/ExcelCard.d.ts +11 -0
  62. package/dist/components/excel-components/ExcelCard.js +35 -0
  63. package/dist/components/excel-components/ExcelExcuting.d.ts +10 -0
  64. package/dist/components/excel-components/ExcelExcuting.js +263 -0
  65. package/dist/components/excel-components/ExcelFailCard.d.ts +9 -0
  66. package/dist/components/excel-components/ExcelFailCard.js +20 -0
  67. package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -0
  68. package/dist/components/excel-components/ExcelSuccessCard.js +50 -0
  69. package/dist/components/excel-components/index.module.scss +210 -0
  70. package/dist/components/excel-components/styles.module.scss +186 -0
  71. package/dist/components/file-card/fileCardSidebar.d.ts +8 -0
  72. package/dist/components/file-card/fileCardSidebar.js +56 -0
  73. package/dist/components/file-card/index.d.ts +15 -0
  74. package/dist/components/file-card/index.js +97 -0
  75. package/dist/components/file-card/index.module.scss +139 -0
  76. package/dist/components/file-preview/index.d.ts +3 -0
  77. package/dist/components/file-preview/index.js +229 -0
  78. package/dist/components/file-preview/index.module.scss +120 -0
  79. package/dist/components/file-upload/index.d.ts +16 -0
  80. package/dist/components/file-upload/index.js +238 -0
  81. package/dist/components/file-upload/uploadV1.d.ts +16 -0
  82. package/dist/components/file-upload/uploadV1.js +267 -0
  83. package/dist/components/gimi-sidebar/index.d.ts +17 -0
  84. package/dist/components/gimi-sidebar/index.js +41 -0
  85. package/dist/components/gimi-sidebar/index.module.scss +136 -0
  86. package/dist/components/header/index.d.ts +5 -0
  87. package/dist/components/header/index.js +20 -0
  88. package/dist/components/header/index.module.scss +26 -0
  89. package/dist/components/iconfont-com/index.d.ts +11 -0
  90. package/dist/components/iconfont-com/index.js +29 -0
  91. package/dist/components/index.d.ts +1 -0
  92. package/dist/components/index.js +1 -0
  93. package/dist/components/knowledge-trace/KnowledgeIconComponent.d.ts +7 -0
  94. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +101 -0
  95. package/dist/components/knowledge-trace/classList.d.ts +6 -0
  96. package/dist/components/knowledge-trace/classList.js +72 -0
  97. package/dist/components/knowledge-trace/documentList.d.ts +6 -0
  98. package/dist/components/knowledge-trace/documentList.js +75 -0
  99. package/dist/components/knowledge-trace/index.d.ts +18 -0
  100. package/dist/components/knowledge-trace/index.js +155 -0
  101. package/dist/components/knowledge-trace/index.module.scss +262 -0
  102. package/dist/components/knowledge-trace/interfaces.d.ts +166 -0
  103. package/dist/components/knowledge-trace/interfaces.js +1 -0
  104. package/dist/components/knowledge-trace/videoList.d.ts +6 -0
  105. package/dist/components/knowledge-trace/videoList.js +91 -0
  106. package/dist/components/lottie-img/index.d.ts +8 -0
  107. package/dist/components/lottie-img/index.js +99 -0
  108. package/dist/components/message-actions/CopyButton.d.ts +7 -0
  109. package/dist/components/message-actions/CopyButton.js +33 -0
  110. package/dist/components/message-actions/LikeButton.d.ts +7 -0
  111. package/dist/components/message-actions/LikeButton.js +34 -0
  112. package/dist/components/message-actions/RegenerateButton.d.ts +5 -0
  113. package/dist/components/message-actions/RegenerateButton.js +27 -0
  114. package/dist/components/message-actions/UnLikeButton.d.ts +7 -0
  115. package/dist/components/message-actions/UnLikeButton.js +34 -0
  116. package/dist/components/message-actions/VoicePlay.d.ts +10 -0
  117. package/dist/components/message-actions/VoicePlay.js +74 -0
  118. package/dist/components/message-list/index.d.ts +19 -0
  119. package/dist/components/message-list/index.js +167 -0
  120. package/dist/components/message-list/index.module.scss +304 -0
  121. package/dist/components/no-microphone-root/index.d.ts +6 -0
  122. package/dist/components/no-microphone-root/index.js +36 -0
  123. package/dist/components/no-microphone-root/index.module.scss +42 -0
  124. package/dist/components/preset-agent-content/index.d.ts +8 -0
  125. package/dist/components/preset-agent-content/index.js +24 -0
  126. package/dist/components/preset-agent-content/index.module.scss +48 -0
  127. package/dist/components/quoted-content/index.d.ts +0 -0
  128. package/dist/components/quoted-content/index.js +171 -0
  129. package/dist/components/quoted-content/index.module.scss +76 -0
  130. package/dist/components/reasoning-content/index.d.ts +6 -0
  131. package/dist/components/reasoning-content/index.js +116 -0
  132. package/dist/components/reasoning-content/index.module.scss +164 -0
  133. package/dist/components/reference-content/index.d.ts +28 -0
  134. package/dist/components/reference-content/index.js +125 -0
  135. package/dist/components/reference-content/index.module.scss +73 -0
  136. package/dist/components/templates/CommonChat.d.ts +5 -0
  137. package/dist/components/templates/CommonChat.js +218 -0
  138. package/dist/components/templates/GimiChatComponent.d.ts +4 -0
  139. package/dist/components/templates/GimiChatComponent.js +23 -0
  140. package/dist/components/templates/demo/demo.d.ts +2 -0
  141. package/dist/components/templates/demo/demo.js +110 -0
  142. package/dist/components/templates/index.module.scss +119 -0
  143. package/dist/components/upload-list/index.d.ts +15 -0
  144. package/dist/components/upload-list/index.js +90 -0
  145. package/dist/components/upload-list/index.module.scss +119 -0
  146. package/dist/components/voice-bars/index.d.ts +4 -0
  147. package/dist/components/voice-bars/index.js +174 -0
  148. package/dist/components/voice-check-dialog/index.d.ts +8 -0
  149. package/dist/components/voice-check-dialog/index.js +163 -0
  150. package/dist/components/voice-check-dialog/index.module.scss +9 -0
  151. package/dist/components/voice-recording/index.d.ts +9 -0
  152. package/dist/components/voice-recording/index.js +54 -0
  153. package/dist/components/voice-recording/index.module.scss +41 -0
  154. package/dist/components/work-flow-content/demo.d.ts +3 -0
  155. package/dist/components/work-flow-content/demo.js +11 -0
  156. package/dist/components/work-flow-content/index.d.ts +6 -0
  157. package/dist/components/work-flow-content/index.js +55 -0
  158. package/dist/components/work-flow-content/index.module.scss +23 -0
  159. package/dist/constants.d.ts +24 -0
  160. package/dist/constants.js +24 -0
  161. package/dist/hooks/useChatActions.d.ts +12 -0
  162. package/dist/hooks/useChatActions.js +207 -0
  163. package/dist/hooks/useChatHistory.d.ts +8 -0
  164. package/dist/hooks/useChatHistory.js +225 -0
  165. package/dist/hooks/useChatMessage.d.ts +49 -0
  166. package/dist/hooks/useChatMessage.js +87 -0
  167. package/dist/hooks/useChatRecommend.d.ts +8 -0
  168. package/dist/hooks/useChatRecommend.js +126 -0
  169. package/dist/hooks/useChatStream.d.ts +20 -0
  170. package/dist/hooks/useChatStream.js +244 -0
  171. package/dist/hooks/useChatUI.d.ts +32 -0
  172. package/dist/hooks/useChatUI.js +134 -0
  173. package/dist/hooks/useChatVoice.d.ts +11 -0
  174. package/dist/hooks/useChatVoice.js +379 -0
  175. package/dist/hooks/useCommonChatAPI.d.ts +27 -0
  176. package/dist/hooks/useCommonChatAPI.js +1276 -0
  177. package/dist/hooks/useFile.d.ts +13 -0
  178. package/dist/hooks/useFile.js +288 -0
  179. package/dist/hooks/useKnowledgeService.d.ts +17 -0
  180. package/dist/hooks/useKnowledgeService.js +210 -0
  181. package/dist/hooks/useLastEventId.d.ts +8 -0
  182. package/dist/hooks/useLastEventId.js +66 -0
  183. package/dist/hooks/useLongPoll.d.ts +3 -0
  184. package/dist/hooks/useLongPoll.js +111 -0
  185. package/dist/hooks/useScroll.d.ts +4 -0
  186. package/dist/hooks/useScroll.js +172 -0
  187. package/dist/index.d.ts +1 -0
  188. package/dist/index.js +1 -0
  189. package/dist/interfaces/chatMessage.d.ts +139 -0
  190. package/dist/interfaces/fileInterface.d.ts +10 -0
  191. package/dist/interfaces/fileInterface.js +11 -0
  192. package/dist/interfaces/knowledgeTrace.d.ts +177 -0
  193. package/dist/store/hooks.d.ts +4 -0
  194. package/dist/store/hooks.js +3 -0
  195. package/dist/store/index.d.ts +7 -0
  196. package/dist/store/index.js +7 -0
  197. package/dist/store/slices/gimiMenuSlice.d.ts +95 -0
  198. package/dist/store/slices/gimiMenuSlice.js +251 -0
  199. package/dist/utils/chatInputUtil.d.ts +19 -0
  200. package/dist/utils/chatInputUtil.js +45 -0
  201. package/dist/utils/tools.d.ts +50 -0
  202. package/dist/utils/tools.js +474 -0
  203. package/dist/utils/voice-stream.d.ts +119 -0
  204. package/dist/utils/voice-stream.js +1162 -0
  205. package/package.json +2 -3
  206. package/LICENSE +0 -21
@@ -0,0 +1,64 @@
1
+ interface FetchConfig extends RequestInit {
2
+ baseURL?: string;
3
+ timeout?: number;
4
+ retries?: number;
5
+ retryDelay?: number;
6
+ params?: Record<string, any>;
7
+ data?: any;
8
+ headers?: Record<string, string>;
9
+ signal?: AbortSignal;
10
+ skipAuth?: boolean;
11
+ skipErrorHandler?: boolean;
12
+ }
13
+ interface FetchResponse<T = any> {
14
+ message: string | null;
15
+ result: T;
16
+ status: number;
17
+ }
18
+ interface FetchError extends Error {
19
+ status?: number;
20
+ statusText?: string;
21
+ response?: FetchResponse;
22
+ config?: FetchConfig;
23
+ }
24
+ declare type RequestInterceptor = (config: FetchConfig) => FetchConfig | Promise<FetchConfig>;
25
+ declare type ResponseInterceptor = (response: FetchResponse) => FetchResponse | Promise<FetchResponse>;
26
+ declare type ErrorInterceptor = (error: FetchError) => FetchError | Promise<FetchError>;
27
+ declare class FetchInstance {
28
+ private baseURL;
29
+ private timeout;
30
+ private retries;
31
+ private retryDelay;
32
+ private defaultHeaders;
33
+ private requestInterceptors;
34
+ private responseInterceptors;
35
+ private errorInterceptors;
36
+ private abortControllers;
37
+ constructor(config?: Partial<FetchConfig>);
38
+ private buildURL;
39
+ private mergeHeaders;
40
+ private executeRequest;
41
+ private handleResponse;
42
+ private request;
43
+ get<T = any>(url: string, config?: FetchConfig): Promise<FetchResponse<T>>;
44
+ post<T = any>(url: string, data?: any, config?: FetchConfig): Promise<FetchResponse<T>>;
45
+ put<T = any>(url: string, data?: any, config?: FetchConfig): Promise<FetchResponse<T>>;
46
+ patch<T = any>(url: string, data?: any, config?: FetchConfig): Promise<FetchResponse<T>>;
47
+ delete<T = any>(url: string, config?: FetchConfig): Promise<FetchResponse<T>>;
48
+ upload<T = any>(url: string, formData: FormData, config?: FetchConfig): Promise<FetchResponse<T>>;
49
+ download<T = any>(url: string, config?: FetchConfig): Promise<FetchResponse<T>>;
50
+ addRequestInterceptor(interceptor: RequestInterceptor): void;
51
+ addResponseInterceptor(interceptor: ResponseInterceptor): void;
52
+ addErrorInterceptor(interceptor: ErrorInterceptor): void;
53
+ setBaseURL(baseURL: string): void;
54
+ setDefaultHeaders(headers: Record<string, string>): void;
55
+ setTimeout(timeout: number): void;
56
+ setRetries(retries: number): void;
57
+ setRetryDelay(retryDelay: number): void;
58
+ abort(requestId: string): void;
59
+ abortAll(): void;
60
+ create(config?: Partial<FetchConfig>): FetchInstance;
61
+ }
62
+ declare const createFetch: (config?: Partial<FetchConfig>) => FetchInstance;
63
+ export { createFetch, FetchInstance };
64
+ export type { FetchConfig, FetchResponse, FetchError, RequestInterceptor, ResponseInterceptor, ErrorInterceptor };
@@ -0,0 +1,512 @@
1
+ var _excluded = ["timeout", "retries", "data"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
19
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
+ var FetchInstance = /*#__PURE__*/function () {
24
+ function FetchInstance() {
25
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ _classCallCheck(this, FetchInstance);
27
+ _defineProperty(this, "baseURL", void 0);
28
+ _defineProperty(this, "timeout", void 0);
29
+ _defineProperty(this, "retries", void 0);
30
+ _defineProperty(this, "retryDelay", void 0);
31
+ _defineProperty(this, "defaultHeaders", void 0);
32
+ _defineProperty(this, "requestInterceptors", void 0);
33
+ _defineProperty(this, "responseInterceptors", void 0);
34
+ _defineProperty(this, "errorInterceptors", void 0);
35
+ _defineProperty(this, "abortControllers", void 0);
36
+ this.baseURL = config.baseURL || '';
37
+ this.timeout = config.timeout || 30000;
38
+ this.retries = config.retries || 3;
39
+ this.retryDelay = config.retryDelay || 1000;
40
+ this.defaultHeaders = config.headers || {
41
+ 'Content-Type': 'application/json'
42
+ };
43
+ this.requestInterceptors = [];
44
+ this.responseInterceptors = [];
45
+ this.errorInterceptors = [];
46
+ this.abortControllers = new Map();
47
+ }
48
+ _createClass(FetchInstance, [{
49
+ key: "buildURL",
50
+ value: function buildURL(url, params) {
51
+ var fullURL = "https://".concat(this.baseURL).concat(url);
52
+ if (!params) return fullURL;
53
+ var searchParams = new URLSearchParams();
54
+ Object.keys(params).forEach(function (key) {
55
+ var value = params[key];
56
+ if (value !== undefined && value !== null) {
57
+ if (Array.isArray(value)) {
58
+ value.forEach(function (item) {
59
+ return searchParams.append(key, String(item));
60
+ });
61
+ } else {
62
+ searchParams.append(key, String(value));
63
+ }
64
+ }
65
+ });
66
+ var queryString = searchParams.toString();
67
+ return queryString ? "".concat(fullURL, "?").concat(queryString) : fullURL;
68
+ }
69
+ }, {
70
+ key: "mergeHeaders",
71
+ value: function mergeHeaders(config) {
72
+ return _objectSpread(_objectSpread({}, this.defaultHeaders), config.headers);
73
+ }
74
+ }, {
75
+ key: "executeRequest",
76
+ value: function () {
77
+ var _executeRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, config) {
78
+ var _this = this;
79
+ var retryCount,
80
+ _config$timeout,
81
+ timeout,
82
+ _config$retries,
83
+ retries,
84
+ data,
85
+ restConfig,
86
+ controller,
87
+ requestId,
88
+ timeoutId,
89
+ fullURL,
90
+ headers,
91
+ requestConfig,
92
+ _headers$ContentType,
93
+ _response,
94
+ responseData,
95
+ fetchResponse,
96
+ _iterator,
97
+ _step,
98
+ interceptor,
99
+ intercepted,
100
+ _fetchError,
101
+ fetchError,
102
+ _iterator2,
103
+ _step2,
104
+ _interceptor,
105
+ _intercepted,
106
+ _args = arguments;
107
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
108
+ while (1) switch (_context.prev = _context.next) {
109
+ case 0:
110
+ retryCount = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0;
111
+ _config$timeout = config.timeout, timeout = _config$timeout === void 0 ? this.timeout : _config$timeout, _config$retries = config.retries, retries = _config$retries === void 0 ? this.retries : _config$retries, data = config.data, restConfig = _objectWithoutProperties(config, _excluded);
112
+ controller = new AbortController();
113
+ requestId = "".concat(Date.now(), "-").concat(Math.random());
114
+ this.abortControllers.set(requestId, controller);
115
+ timeoutId = setTimeout(function () {
116
+ controller.abort();
117
+ }, timeout);
118
+ _context.prev = 6;
119
+ fullURL = this.buildURL(url, config.params);
120
+ headers = this.mergeHeaders(config);
121
+ requestConfig = _objectSpread(_objectSpread({}, restConfig), {}, {
122
+ headers: headers,
123
+ signal: controller.signal
124
+ });
125
+ if (data && requestConfig.method !== 'GET') {
126
+ if ((_headers$ContentType = headers['Content-Type']) !== null && _headers$ContentType !== void 0 && _headers$ContentType.includes('multipart/form-data')) {
127
+ requestConfig.body = data;
128
+ } else {
129
+ requestConfig.body = JSON.stringify(data);
130
+ }
131
+ }
132
+ _context.next = 13;
133
+ return fetch(fullURL, requestConfig);
134
+ case 13:
135
+ _response = _context.sent;
136
+ clearTimeout(timeoutId);
137
+ this.abortControllers.delete(requestId);
138
+ _context.next = 18;
139
+ return this.handleResponse(_response);
140
+ case 18:
141
+ responseData = _context.sent;
142
+ fetchResponse = {
143
+ result: responseData.result,
144
+ status: responseData.status,
145
+ message: responseData.message
146
+ };
147
+ _iterator = _createForOfIteratorHelper(this.responseInterceptors);
148
+ _context.prev = 21;
149
+ _iterator.s();
150
+ case 23:
151
+ if ((_step = _iterator.n()).done) {
152
+ _context.next = 31;
153
+ break;
154
+ }
155
+ interceptor = _step.value;
156
+ _context.next = 27;
157
+ return interceptor(fetchResponse);
158
+ case 27:
159
+ intercepted = _context.sent;
160
+ Object.assign(fetchResponse, intercepted);
161
+ case 29:
162
+ _context.next = 23;
163
+ break;
164
+ case 31:
165
+ _context.next = 36;
166
+ break;
167
+ case 33:
168
+ _context.prev = 33;
169
+ _context.t0 = _context["catch"](21);
170
+ _iterator.e(_context.t0);
171
+ case 36:
172
+ _context.prev = 36;
173
+ _iterator.f();
174
+ return _context.finish(36);
175
+ case 39:
176
+ return _context.abrupt("return", fetchResponse);
177
+ case 42:
178
+ _context.prev = 42;
179
+ _context.t1 = _context["catch"](6);
180
+ clearTimeout(timeoutId);
181
+ this.abortControllers.delete(requestId);
182
+ if (!(_context.t1 instanceof Error && _context.t1.name === 'AbortError')) {
183
+ _context.next = 50;
184
+ break;
185
+ }
186
+ _fetchError = new Error('请求超时');
187
+ _fetchError.status = 408;
188
+ throw _fetchError;
189
+ case 50:
190
+ if (!(retryCount < retries)) {
191
+ _context.next = 54;
192
+ break;
193
+ }
194
+ _context.next = 53;
195
+ return new Promise(function (resolve) {
196
+ setTimeout(resolve, _this.retryDelay * (retryCount + 1));
197
+ });
198
+ case 53:
199
+ return _context.abrupt("return", this.executeRequest(url, config, retryCount + 1));
200
+ case 54:
201
+ fetchError = _context.t1;
202
+ fetchError.config = config;
203
+ _iterator2 = _createForOfIteratorHelper(this.errorInterceptors);
204
+ _context.prev = 57;
205
+ _iterator2.s();
206
+ case 59:
207
+ if ((_step2 = _iterator2.n()).done) {
208
+ _context.next = 67;
209
+ break;
210
+ }
211
+ _interceptor = _step2.value;
212
+ _context.next = 63;
213
+ return _interceptor(fetchError);
214
+ case 63:
215
+ _intercepted = _context.sent;
216
+ Object.assign(fetchError, _intercepted);
217
+ case 65:
218
+ _context.next = 59;
219
+ break;
220
+ case 67:
221
+ _context.next = 72;
222
+ break;
223
+ case 69:
224
+ _context.prev = 69;
225
+ _context.t2 = _context["catch"](57);
226
+ _iterator2.e(_context.t2);
227
+ case 72:
228
+ _context.prev = 72;
229
+ _iterator2.f();
230
+ return _context.finish(72);
231
+ case 75:
232
+ throw fetchError;
233
+ case 76:
234
+ case "end":
235
+ return _context.stop();
236
+ }
237
+ }, _callee, this, [[6, 42], [21, 33, 36, 39], [57, 69, 72, 75]]);
238
+ }));
239
+ function executeRequest(_x, _x2) {
240
+ return _executeRequest.apply(this, arguments);
241
+ }
242
+ return executeRequest;
243
+ }()
244
+ }, {
245
+ key: "handleResponse",
246
+ value: function () {
247
+ var _handleResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(response) {
248
+ var contentType, _error, errorData;
249
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
250
+ while (1) switch (_context2.prev = _context2.next) {
251
+ case 0:
252
+ contentType = response.headers.get('content-type') || '';
253
+ if (response.ok) {
254
+ _context2.next = 17;
255
+ break;
256
+ }
257
+ _error = new Error(response.statusText);
258
+ _error.status = response.status;
259
+ _error.statusText = response.statusText;
260
+ if (!contentType.includes('application/json')) {
261
+ _context2.next = 16;
262
+ break;
263
+ }
264
+ _context2.prev = 6;
265
+ _context2.next = 9;
266
+ return response.json();
267
+ case 9:
268
+ errorData = _context2.sent;
269
+ _error.message = errorData.message || errorData.error || response.statusText;
270
+ _context2.next = 16;
271
+ break;
272
+ case 13:
273
+ _context2.prev = 13;
274
+ _context2.t0 = _context2["catch"](6);
275
+ _error.message = response.statusText;
276
+ case 16:
277
+ throw _error;
278
+ case 17:
279
+ if (!contentType.includes('application/json')) {
280
+ _context2.next = 19;
281
+ break;
282
+ }
283
+ return _context2.abrupt("return", response.json());
284
+ case 19:
285
+ if (!contentType.includes('text')) {
286
+ _context2.next = 21;
287
+ break;
288
+ }
289
+ return _context2.abrupt("return", response.text());
290
+ case 21:
291
+ if (!(contentType.includes('multipart/form-data') || contentType.includes('application/octet-stream'))) {
292
+ _context2.next = 23;
293
+ break;
294
+ }
295
+ return _context2.abrupt("return", response.blob());
296
+ case 23:
297
+ return _context2.abrupt("return", response.json());
298
+ case 24:
299
+ case "end":
300
+ return _context2.stop();
301
+ }
302
+ }, _callee2, null, [[6, 13]]);
303
+ }));
304
+ function handleResponse(_x3) {
305
+ return _handleResponse.apply(this, arguments);
306
+ }
307
+ return handleResponse;
308
+ }()
309
+ }, {
310
+ key: "request",
311
+ value: function () {
312
+ var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url) {
313
+ var config,
314
+ mergedHeaders,
315
+ finalConfig,
316
+ _iterator3,
317
+ _step3,
318
+ interceptor,
319
+ _args3 = arguments;
320
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
321
+ while (1) switch (_context3.prev = _context3.next) {
322
+ case 0:
323
+ config = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
324
+ mergedHeaders = this.mergeHeaders(config);
325
+ finalConfig = _objectSpread(_objectSpread({}, config), {}, {
326
+ headers: mergedHeaders
327
+ });
328
+ _iterator3 = _createForOfIteratorHelper(this.requestInterceptors);
329
+ _context3.prev = 4;
330
+ _iterator3.s();
331
+ case 6:
332
+ if ((_step3 = _iterator3.n()).done) {
333
+ _context3.next = 13;
334
+ break;
335
+ }
336
+ interceptor = _step3.value;
337
+ _context3.next = 10;
338
+ return interceptor(finalConfig);
339
+ case 10:
340
+ finalConfig = _context3.sent;
341
+ case 11:
342
+ _context3.next = 6;
343
+ break;
344
+ case 13:
345
+ _context3.next = 18;
346
+ break;
347
+ case 15:
348
+ _context3.prev = 15;
349
+ _context3.t0 = _context3["catch"](4);
350
+ _iterator3.e(_context3.t0);
351
+ case 18:
352
+ _context3.prev = 18;
353
+ _iterator3.f();
354
+ return _context3.finish(18);
355
+ case 21:
356
+ return _context3.abrupt("return", this.executeRequest(url, finalConfig));
357
+ case 22:
358
+ case "end":
359
+ return _context3.stop();
360
+ }
361
+ }, _callee3, this, [[4, 15, 18, 21]]);
362
+ }));
363
+ function request(_x4) {
364
+ return _request.apply(this, arguments);
365
+ }
366
+ return request;
367
+ }()
368
+ }, {
369
+ key: "get",
370
+ value: function get(url) {
371
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
372
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
373
+ method: 'GET'
374
+ }));
375
+ }
376
+ }, {
377
+ key: "post",
378
+ value: function post(url, data) {
379
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
380
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
381
+ method: 'POST',
382
+ data: data
383
+ }));
384
+ }
385
+ }, {
386
+ key: "put",
387
+ value: function put(url, data) {
388
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
389
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
390
+ method: 'PUT',
391
+ data: data
392
+ }));
393
+ }
394
+ }, {
395
+ key: "patch",
396
+ value: function patch(url, data) {
397
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
398
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
399
+ method: 'PATCH',
400
+ data: data
401
+ }));
402
+ }
403
+ }, {
404
+ key: "delete",
405
+ value: function _delete(url) {
406
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
407
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
408
+ method: 'DELETE'
409
+ }));
410
+ }
411
+ }, {
412
+ key: "upload",
413
+ value: function upload(url, formData) {
414
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
415
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
416
+ method: 'POST',
417
+ data: formData,
418
+ headers: _objectSpread(_objectSpread({}, config.headers), {}, {
419
+ 'Content-Type': 'multipart/form-data'
420
+ })
421
+ }));
422
+ }
423
+ }, {
424
+ key: "download",
425
+ value: function download(url) {
426
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
427
+ return this.request(url, _objectSpread(_objectSpread({}, config), {}, {
428
+ method: 'GET',
429
+ headers: _objectSpread(_objectSpread({}, config.headers), {}, {
430
+ 'Accept': 'application/octet-stream'
431
+ })
432
+ }));
433
+ }
434
+ }, {
435
+ key: "addRequestInterceptor",
436
+ value: function addRequestInterceptor(interceptor) {
437
+ this.requestInterceptors.push(interceptor);
438
+ }
439
+ }, {
440
+ key: "addResponseInterceptor",
441
+ value: function addResponseInterceptor(interceptor) {
442
+ this.responseInterceptors.push(interceptor);
443
+ }
444
+ }, {
445
+ key: "addErrorInterceptor",
446
+ value: function addErrorInterceptor(interceptor) {
447
+ this.errorInterceptors.push(interceptor);
448
+ }
449
+ }, {
450
+ key: "setBaseURL",
451
+ value: function setBaseURL(baseURL) {
452
+ this.baseURL = baseURL;
453
+ }
454
+ }, {
455
+ key: "setDefaultHeaders",
456
+ value: function setDefaultHeaders(headers) {
457
+ this.defaultHeaders = _objectSpread(_objectSpread({}, this.defaultHeaders), headers);
458
+ }
459
+ }, {
460
+ key: "setTimeout",
461
+ value: function setTimeout(timeout) {
462
+ this.timeout = timeout;
463
+ }
464
+ }, {
465
+ key: "setRetries",
466
+ value: function setRetries(retries) {
467
+ this.retries = retries;
468
+ }
469
+ }, {
470
+ key: "setRetryDelay",
471
+ value: function setRetryDelay(retryDelay) {
472
+ this.retryDelay = retryDelay;
473
+ }
474
+ }, {
475
+ key: "abort",
476
+ value: function abort(requestId) {
477
+ var controller = this.abortControllers.get(requestId);
478
+ if (controller) {
479
+ controller.abort();
480
+ this.abortControllers.delete(requestId);
481
+ }
482
+ }
483
+ }, {
484
+ key: "abortAll",
485
+ value: function abortAll() {
486
+ this.abortControllers.forEach(function (controller) {
487
+ return controller.abort();
488
+ });
489
+ this.abortControllers.clear();
490
+ }
491
+ }, {
492
+ key: "create",
493
+ value: function create(config) {
494
+ var instance = new FetchInstance({
495
+ baseURL: (config === null || config === void 0 ? void 0 : config.baseURL) || this.baseURL,
496
+ timeout: (config === null || config === void 0 ? void 0 : config.timeout) || this.timeout,
497
+ retries: (config === null || config === void 0 ? void 0 : config.retries) || this.retries,
498
+ retryDelay: (config === null || config === void 0 ? void 0 : config.retryDelay) || this.retryDelay,
499
+ headers: _objectSpread(_objectSpread({}, this.defaultHeaders), config === null || config === void 0 ? void 0 : config.headers)
500
+ });
501
+ instance.requestInterceptors = _toConsumableArray(this.requestInterceptors);
502
+ instance.responseInterceptors = _toConsumableArray(this.responseInterceptors);
503
+ instance.errorInterceptors = _toConsumableArray(this.errorInterceptors);
504
+ return instance;
505
+ }
506
+ }]);
507
+ return FetchInstance;
508
+ }();
509
+ var createFetch = function createFetch(config) {
510
+ return new FetchInstance(config);
511
+ };
512
+ export { createFetch, FetchInstance };
@@ -0,0 +1,57 @@
1
+ import { FetchResponse } from './fetch';
2
+ import { IProduct, ITeachingModuleResource, IVideoResource } from '../interfaces/knowledgeTrace';
3
+ declare const useApi: () => {
4
+ getSkillData: (requestId: number) => Promise<FetchResponse<any>>;
5
+ getProductList: (params: {
6
+ productIds: string[];
7
+ }) => Promise<FetchResponse<IProduct[]>>;
8
+ getFileResourceList: (params: {
9
+ resourceIds: string[];
10
+ }) => Promise<FetchResponse<ITeachingModuleResource[]>>;
11
+ getVideoSliceList: (params: {
12
+ type: 'teachModel' | 'product';
13
+ sliceQuotes: {
14
+ resourceId: number[];
15
+ sliceId: string;
16
+ }[];
17
+ }) => Promise<FetchResponse<IVideoResource[]>>;
18
+ getMessageTitle: (conversationId: string) => Promise<FetchResponse<any>>;
19
+ getProbeList: (params: {
20
+ messageId: string | number;
21
+ }) => Promise<FetchResponse<any>>;
22
+ getMessageList: (params: {
23
+ pageIndex: number;
24
+ pageSize: number;
25
+ sort: number;
26
+ where: any;
27
+ }) => Promise<FetchResponse<any>>;
28
+ stopStreamOut: (params: {
29
+ messageId: string | number;
30
+ }) => Promise<FetchResponse<any>>;
31
+ createRoomId: (params: any) => Promise<FetchResponse<any>>;
32
+ getRtcConfig: () => Promise<FetchResponse<any>>;
33
+ startVoiceChat: (params: {
34
+ roomId: string;
35
+ taskId: string;
36
+ custom?: string;
37
+ }) => Promise<FetchResponse<any>>;
38
+ stopVoiceChat: (params: {
39
+ appId: string;
40
+ roomId: string;
41
+ taskId: string;
42
+ }) => Promise<FetchResponse<any>>;
43
+ getUserFirstUse: ({ type }: {
44
+ type: string;
45
+ }) => Promise<FetchResponse<any>>;
46
+ handleMark: (params: {
47
+ id: number;
48
+ mark: number;
49
+ }) => Promise<FetchResponse<any>>;
50
+ getAgentDetail: (agentId: number) => Promise<FetchResponse<any>>;
51
+ deleteConversationById: (conversationId: number) => Promise<FetchResponse<any>>;
52
+ getAiCorrection: (params: {
53
+ answerId: number;
54
+ questionId: number;
55
+ }) => Promise<FetchResponse<any>>;
56
+ };
57
+ export default useApi;