@andbridge/glowpod 1.1.11 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/core/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options } from "../model/model";
|
|
2
|
-
import { AxiosInstance, CreateAxiosDefaults } from "axios";
|
|
2
|
+
import type { AxiosInstance, CreateAxiosDefaults } from "axios";
|
|
3
3
|
export declare class Core {
|
|
4
4
|
protected instance: AxiosInstance;
|
|
5
5
|
constructor(options: CreateAxiosDefaults);
|
package/build/glowpod.d.ts
CHANGED
package/build/glowpod.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";class a{constructor(a){this.getInstance=()=>this.instance
|
|
1
|
+
import e from"axios";class a{instance;constructor(a){this.instance=e.create(a)}getInstance=()=>this.instance;Get=async e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others});Put=async e=>this.instance({method:"PUT",url:e.url,data:e.params,headers:{...e.headers},...e.others});Delete=async e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others});Post=async e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others})}const s=200,t=299,r=({instance:e,authFailedCaller:a=()=>{},networkSuccessCode:r=200,authFailedCode:o=401,networkFailedCaller:n=()=>{},serverKillCaller:d=()=>{},responseStruct:c={codeName:"code",messageName:"message",dataName:"data"},setHeaders:l=async e=>{}})=>{let i=null,h=!0;const u=e=>(i&&clearTimeout(i),i=setTimeout(()=>{if(h)return e.status<=s&&e.status>=t?d(e):e.data?.[c.codeName]==o?a(e.data):e.data?.[c.codeName]!=r?n(e.data):d(e)},0),()=>h=!1);e.interceptors.request.use(async e=>(e.headers&&await(l?.(e.headers)),e),e=>(console.log("请求错误拦截器:",e),u(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[c.codeName]===r)return e.data?.[c.dataName];{const a=u(e);throw{...e,hiddenDefaultErrorHandler:a}}},e=>{const a=u(e);throw{...e,hiddenDefaultErrorHandler:a}})};export{a as GlowPod,r as setupInterceptors};
|
package/build/glowpod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("axios");const a=200,s=299;exports.GlowPod=class{constructor(a){this.getInstance=()=>this.instance
|
|
1
|
+
"use strict";var e=require("axios");const a=200,s=299;exports.GlowPod=class{instance;constructor(a){this.instance=e.create(a)}getInstance=()=>this.instance;Get=async e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others});Put=async e=>this.instance({method:"PUT",url:e.url,data:e.params,headers:{...e.headers},...e.others});Delete=async e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others});Post=async e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others})},exports.setupInterceptors=({instance:e,authFailedCaller:t=()=>{},networkSuccessCode:r=200,authFailedCode:n=401,networkFailedCaller:o=()=>{},serverKillCaller:d=()=>{},responseStruct:c={codeName:"code",messageName:"message",dataName:"data"},setHeaders:i=async e=>{}})=>{let l=null,h=!0;const u=e=>(l&&clearTimeout(l),l=setTimeout(()=>{if(h)return e.status<=a&&e.status>=s?d(e):e.data?.[c.codeName]==n?t(e.data):e.data?.[c.codeName]!=r?o(e.data):d(e)},0),()=>h=!1);e.interceptors.request.use(async e=>(e.headers&&await(i?.(e.headers)),e),e=>(console.log("请求错误拦截器:",e),u(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[c.codeName]===r)return e.data?.[c.dataName];{const a=u(e);throw{...e,hiddenDefaultErrorHandler:a}}},e=>{const a=u(e);throw{...e,hiddenDefaultErrorHandler:a}})};
|
package/build/glowpod.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],a):a((e="undefined"!=typeof globalThis?globalThis:e||self).GlowPod={},e.axios)}(this,function(e,a){"use strict";const t=200,s=299;e.GlowPod=class{instance;constructor(e){this.instance=a.create(e)}getInstance=()=>this.instance;Get=async e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others});Put=async e=>this.instance({method:"PUT",url:e.url,data:e.params,headers:{...e.headers},...e.others});Delete=async e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others});Post=async e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others})},e.setupInterceptors=({instance:e,authFailedCaller:a=()=>{},networkSuccessCode:r=200,authFailedCode:o=401,networkFailedCaller:n=()=>{},serverKillCaller:d=()=>{},responseStruct:i={codeName:"code",messageName:"message",dataName:"data"},setHeaders:c=async e=>{}})=>{let l=null,u=!0;const h=e=>(l&&clearTimeout(l),l=setTimeout(()=>{if(u)return e.status<=t&&e.status>=s?d(e):e.data?.[i.codeName]==o?a(e.data):e.data?.[i.codeName]!=r?n(e.data):d(e)},0),()=>u=!1);e.interceptors.request.use(async e=>(e.headers&&await(c?.(e.headers)),e),e=>(console.log("请求错误拦截器:",e),h(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[i.codeName]===r)return e.data?.[i.dataName];{const a=h(e);throw{...e,hiddenDefaultErrorHandler:a}}},e=>{const a=h(e);throw{...e,hiddenDefaultErrorHandler:a}})}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestHeaders, AxiosResponse } from "axios";
|
|
2
|
-
import { InterceptorsOptions } from "../model/model";
|
|
1
|
+
import type { AxiosInstance, AxiosRequestHeaders, AxiosResponse } from "axios";
|
|
2
|
+
import type { InterceptorsOptions } from "../model/model";
|
|
3
3
|
/**
|
|
4
4
|
* 设置拦截器
|
|
5
5
|
* @param instance 实例
|
package/build/model/model.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andbridge/glowpod",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A axios-based HTTP client library",
|
|
5
5
|
"main": "build/glowpod.js",
|
|
6
6
|
"module": "build/glowpod.esm.js",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./build/glowpod.esm.js",
|
|
14
14
|
"require": "./build/glowpod.js",
|
|
15
|
-
"types": "./build/glowpod.d.ts"
|
|
16
|
-
"development": "./glowpod.ts"
|
|
15
|
+
"types": "./build/glowpod.d.ts"
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
18
|
"scripts": {
|
|
@@ -35,6 +34,7 @@
|
|
|
35
34
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
36
35
|
"rollup": "^4.53.2",
|
|
37
36
|
"rollup-plugin-terser": "^7.0.2",
|
|
37
|
+
"@types/node": "^22.15.0",
|
|
38
38
|
"tslib": "^2.8.1",
|
|
39
39
|
"typescript": "~5.9.3"
|
|
40
40
|
},
|