{"version":3,"file":"interceptors.mjs","sources":["../../../../../src/axios/types/interceptors.ts"],"sourcesContent":["import type { FastAxiosRequestConfig } from \"./options\";\nimport type { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from \"axios\";\n\ntype InterceptorsRequestHandle = <Input = any>(config: InternalAxiosRequestConfig<Input>) => void;\ntype InterceptorsRequestUseHandle = { use: (fn: InterceptorsRequestHandle) => void };\ntype InterceptorsResponseHandle = <Output = any, Input = any>(\n\tresponse: AxiosResponse<Output, Input>,\n\toptions: FastAxiosRequestConfig<Input>\n) => any | void;\ntype InterceptorsResponseUseHandle = { use: (fn: InterceptorsResponseHandle) => void };\ntype InterceptorsResponseErrorHandle = (error: AxiosError | any, options: FastAxiosRequestConfig<any>) => any | void;\ntype InterceptorsResponseErrorUseHandle = { use: (fn: InterceptorsResponseErrorHandle) => void };\n\nexport class InterceptorsManage {\n\tprivate _handle: {\n\t\trequest: InterceptorsRequestHandle;\n\t\tresponse: InterceptorsResponseHandle;\n\t\tresponseError: InterceptorsResponseErrorHandle;\n\t};\n\n\t/** 请求拦截器 */\n\treadonly request: InterceptorsRequestHandle & InterceptorsRequestUseHandle;\n\t/** 响应拦截器 */\n\treadonly response: InterceptorsResponseHandle & InterceptorsResponseUseHandle;\n\t/** 响应错误处理 */\n\treadonly responseError: InterceptorsResponseErrorHandle & InterceptorsResponseErrorUseHandle;\n\n\tconstructor() {\n\t\tthis._handle = {\n\t\t\trequest: <Input = any>(config: InternalAxiosRequestConfig<Input>): void => {\n\t\t\t\treturn;\n\t\t\t},\n\t\t\tresponse: <Output = any, Input = any>(response: AxiosResponse<Output, Input>, options: FastAxiosRequestConfig<Input>): any | void => {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tresponseError: (error: AxiosError | any, options: FastAxiosRequestConfig<any>): any | void => {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t};\n\n\t\tconst requestProxy: InterceptorsRequestHandle & InterceptorsRequestUseHandle = <Input = any>(\n\t\t\tconfig: InternalAxiosRequestConfig<Input>\n\t\t): void => {\n\t\t\tthis._handle.request(config);\n\t\t};\n\t\trequestProxy.use = (fn: InterceptorsRequestHandle): void => {\n\t\t\tthis._handle.request = fn;\n\t\t};\n\t\tthis.request = requestProxy;\n\n\t\tconst responseProxy: InterceptorsResponseHandle & InterceptorsResponseUseHandle = <Output = any, Input = any>(\n\t\t\tresponse: AxiosResponse<Output, Input>,\n\t\t\toptions: FastAxiosRequestConfig<Input>\n\t\t): any | void => {\n\t\t\tthis._handle.response(response, options);\n\t\t};\n\t\tresponseProxy.use = (fn: InterceptorsResponseHandle): void => {\n\t\t\tthis._handle.response = fn;\n\t\t};\n\t\tthis.response = responseProxy;\n\n\t\tconst responseErrorProxy: InterceptorsResponseErrorHandle & InterceptorsResponseErrorUseHandle = (\n\t\t\terror: AxiosError | any,\n\t\t\toptions: FastAxiosRequestConfig<any>\n\t\t): any | void => {\n\t\t\tthis._handle.responseError(error, options);\n\t\t};\n\t\tresponseErrorProxy.use = (fn: InterceptorsResponseErrorHandle): void => {\n\t\t\tthis._handle.responseError = fn;\n\t\t};\n\t\tthis.responseError = responseErrorProxy;\n\t}\n}\n"],"names":["InterceptorsManage","_handle","request","response","responseError","constructor","this","config","options","error","requestProxy","use","fn","responseProxy","responseErrorProxy"],"mappings":"AAaO,MAAMA,EACJC,QAOCC,QAEAC,SAEAC,cAET,WAAAC,GACCC,KAAKL,QAAU,CACdC,QAAuBK,MAGvBJ,SAAU,CAA4BA,EAAwCK,IACtE,KAERJ,cAAe,CAACK,EAAyBD,IACjC,MAIT,MAAME,EACLH,IAEAD,KAAKL,QAAQC,QAAQK,IAEtBG,EAAaC,IAAOC,IACnBN,KAAKL,QAAQC,QAAUU,GAExBN,KAAKJ,QAAUQ,EAEf,MAAMG,EAA4E,CACjFV,EACAK,KAEAF,KAAKL,QAAQE,SAASA,EAAUK,IAEjCK,EAAcF,IAAOC,IACpBN,KAAKL,QAAQE,SAAWS,GAEzBN,KAAKH,SAAWU,EAEhB,MAAMC,EAA2F,CAChGL,EACAD,KAEAF,KAAKL,QAAQG,cAAcK,EAAOD,IAEnCM,EAAmBH,IAAOC,IACzBN,KAAKL,QAAQG,cAAgBQ,GAE9BN,KAAKF,cAAgBU,CACtB"}