httpquick 1.0.0 → 1.1.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/dist/{HttpquickBase-DC1aqqw6.cjs → HttpQuickBase-D0-rw_KI.cjs} +1 -1
- package/dist/{HttpquickBase-DGQ7gXX7.js → HttpQuickBase-E_ukwMwW.js} +7 -2
- package/dist/ajax.cjs +2 -2
- package/dist/ajax.js +2 -2
- package/dist/fetch.cjs +1 -1
- package/dist/fetch.js +2 -2
- package/dist/fibjs.cjs +1 -0
- package/dist/fibjs.js +33 -0
- package/dist/node.cjs +2 -0
- package/dist/node.js +26 -0
- package/dist/uniapp.cjs +1 -1
- package/dist/uniapp.js +2 -2
- package/dist/xcx.cjs +1 -1
- package/dist/xcx.js +2 -2
- package/package.json +16 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var p=(o,e,t)=>e in o?h(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var a=(o,e,t)=>p(o,typeof e!="symbol"?e+"":e,t);class c{constructor(e={}){a(this,"config",{});a(this,"requestId",0);a(this,"middlewares",[]);a(this,"onTimeoutError",function(e,t,s){console.error("http timeout",s),t.status=-4,t.statusText="TIMEOUT",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-1,errmsg:t.response.status+", 网络请求超时!"}:t.body="网络请求超时!"});Object.assign(this.config,e)}updateConfig(e={}){Object.assign(this.config,e)}addMiddleware(e){this.middlewares.push(e.bind(this))}getDefaultRequest(){return{id:0,baseUrl:"",method:"GET",url:"/",headers:{},query:null,json:null,body:null,responseType:"text",dataType:"json",timeout:6e4,fullUrl:""}}getDefaultResponse(){return{status:-1,statusText:"NONE",headers:{},body:null}}obj2query(e){return typeof URLSearchParams<"u"?new URLSearchParams(e).toString():Object.entries(e).map(([t,s])=>encodeURIComponent(t)+"="+encodeURIComponent(s)).join("&")}fillUrl(e){e.fullUrl=(/^https?:\/\//.test(e.url)?e.url:e.baseUrl+e.url)+(e.query?"?"+this.obj2query(e.query):"")}fillHeaders(e){e.responseType=="text"&&e.dataType=="json"&&(e.headers.Accept="application/json")}fillBody(e){var t;(e.method=="POST"||e.method=="PUT")&&(e.filePath||(e.body!==null&&typeof FormData<"u"&&e.body instanceof FormData?typeof process<"u"&&(((t=process==null?void 0:process.versions)==null?void 0:t.node)??"0.0.0")!=="0.0.0"&&(e.headers["content-type"]=e.body.getContentType(),e.body=e.body.toStream()):e.body!==null&&typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.toString()):e.body!==null&&Array.isArray(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.map(s=>encodeURIComponent(s.key)+"="+encodeURIComponent(s.val)).join("&")):e.body!==null&&Object.isObject(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=this.obj2query(e.body)):e.json!==null?(e.headers["content-type"]="application/json; charset=utf-8",e.body=JSON.stringify(e.json)):(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body="")))}get(e){return this.request({...e,method:"GET"})}post(e){return this.request({...e,method:"POST"})}put(e){return this.request({...e,method:"PUT"})}del(e){return this.request({...e,method:"DELETE"})}upload(e){return new Error("unreachable")}download(e){return new Error("unreachable")}onNetworkError(e,t,s){console.error("http error",s),t.status=-1,t.statusText="NETWORK FAIL",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-2,errmsg:t.response.status+", 网络请求错误!"}:t.body="网络请求错误!"}async request(e){const t=Object.assign(this.getDefaultRequest(),this.config,e);let s=this.getDefaultResponse();t.method=t.method.toUpperCase(),Object.defineProperties(t,{response:{value:s,enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(s,{request:{value:t,enumerable:!1,configurable:!0,writable:!0},response:{value:null,enumerable:!1,configurable:!0,writable:!0},parent:{value:null,enumerable:!1,configurable:!0,writable:!0}}),this.fillUrl(t),this.fillHeaders(t),this.fillBody(t);let
|
|
1
|
+
"use strict";var h=Object.defineProperty;var p=(o,e,t)=>e in o?h(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var a=(o,e,t)=>p(o,typeof e!="symbol"?e+"":e,t);class c{constructor(e={}){a(this,"config",{});a(this,"requestId",0);a(this,"middlewares",[]);a(this,"onTimeoutError",function(e,t,s){console.error("http timeout",s),t.status=-4,t.statusText="TIMEOUT",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-1,errmsg:t.response.status+", 网络请求超时!"}:t.body="网络请求超时!"});Object.assign(this.config,e)}updateConfig(e={}){Object.assign(this.config,e)}addMiddleware(e){this.middlewares.push(e.bind(this))}getDefaultRequest(){return{id:0,baseUrl:"",method:"GET",url:"/",headers:{},query:null,json:null,body:null,responseType:"text",dataType:"json",timeout:6e4,fullUrl:""}}getDefaultResponse(){return{status:-1,statusText:"NONE",headers:{},body:null}}obj2query(e){return typeof URLSearchParams<"u"?new URLSearchParams(e).toString():Object.entries(e).map(([t,s])=>encodeURIComponent(t)+"="+encodeURIComponent(s)).join("&")}fillUrl(e){e.fullUrl=(/^https?:\/\//.test(e.url)?e.url:e.baseUrl+e.url)+(e.query?"?"+this.obj2query(e.query):"")}fillHeaders(e){e.responseType=="text"&&e.dataType=="json"&&(e.headers.Accept="application/json")}fillBody(e){var t;(e.method=="POST"||e.method=="PUT")&&(e.filePath||(e.body!==null&&typeof FormData<"u"&&e.body instanceof FormData?typeof process<"u"&&(((t=process==null?void 0:process.versions)==null?void 0:t.node)??"0.0.0")!=="0.0.0"&&(e.headers["content-type"]=e.body.getContentType(),e.body=e.body.toStream()):e.body!==null&&typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.toString()):e.body!==null&&Array.isArray(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.map(s=>encodeURIComponent(s.key)+"="+encodeURIComponent(s.val)).join("&")):e.body!==null&&Object.isObject(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=this.obj2query(e.body)):e.json!==null?(e.headers["content-type"]="application/json; charset=utf-8",e.body=JSON.stringify(e.json)):(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body="")))}get(e){return this.request({...e,method:"GET"})}post(e){return this.request({...e,method:"POST"})}put(e){return this.request({...e,method:"PUT"})}del(e){return this.request({...e,method:"DELETE"})}upload(e){return new Error("unreachable")}download(e){return new Error("unreachable")}onNetworkError(e,t,s){console.error("http error",s),t.status=-1,t.statusText="NETWORK FAIL",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-2,errmsg:t.response.status+", 网络请求错误!"}:t.body="网络请求错误!"}async request(e){const t=Object.assign(this.getDefaultRequest(),this.config,e);let s=this.getDefaultResponse();t.method=t.method.toUpperCase(),Object.defineProperties(t,{response:{value:s,enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(s,{request:{value:t,enumerable:!1,configurable:!0,writable:!0},response:{value:null,enumerable:!1,configurable:!0,writable:!0},parent:{value:null,enumerable:!1,configurable:!0,writable:!0}}),this.fillUrl(t),this.fillHeaders(t),this.fillBody(t);let i=async(n,l)=>await this.send(n,l);for(let n=this.middlewares.length-1;n>=0;n--){const l=i,r=this.middlewares[n].bind(this);i=async(d,u)=>await r(d,u,l)}return await i(t,s),s}send(e,t){}install(e,t={}){e.config.globalProperties.$http=this;for(const s in t)this[s]=t[s]}globalMethods(){globalThis.httpGet=this.get.bind(this),globalThis.httpPost=this.post.bind(this),globalThis.httpPut=this.put.bind(this),globalThis.httpDelete=this.del.bind(this),globalThis.httpUpload=this.upload.bind(this),globalThis.httpDownload=this.download.bind(this)}}exports.HttpQuickBase=c;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
2
|
var p = (o, e, t) => e in o ? h(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
3
|
var a = (o, e, t) => p(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
class
|
|
4
|
+
class b {
|
|
5
5
|
// 构造函数
|
|
6
6
|
constructor(e = {}) {
|
|
7
7
|
// 默认请求
|
|
@@ -116,10 +116,15 @@ class c {
|
|
|
116
116
|
// 发送发送请求 abstract方法 需要子类实现
|
|
117
117
|
send(e, t) {
|
|
118
118
|
}
|
|
119
|
+
install(e, t = {}) {
|
|
120
|
+
e.config.globalProperties.$http = this;
|
|
121
|
+
for (const s in t)
|
|
122
|
+
this[s] = t[s];
|
|
123
|
+
}
|
|
119
124
|
globalMethods() {
|
|
120
125
|
globalThis.httpGet = this.get.bind(this), globalThis.httpPost = this.post.bind(this), globalThis.httpPut = this.put.bind(this), globalThis.httpDelete = this.del.bind(this), globalThis.httpUpload = this.upload.bind(this), globalThis.httpDownload = this.download.bind(this);
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
export {
|
|
124
|
-
|
|
129
|
+
b as H
|
|
125
130
|
};
|
package/dist/ajax.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./
|
|
2
|
-
`).map(s=>[decodeURIComponent(s.substring(0,s.indexOf(": ")).toLowerCase()),decodeURIComponent(s.substring(s.indexOf(": ")+2))])),t.responseType=="text"&&t.dataType=="json"?o.body=JSON.parse(e.responseText):t.responseType=="text"?o.body=e.responseText:o.body=e.response,n()}},t.method=="POST"||t.method=="PUT"?e.send(t.body):e.send(),r}}exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./HttpQuickBase-D0-rw_KI.cjs");class u extends a.HttpQuickBase{send(t,o){let n=null,r=new Promise(s=>n=s);const e=o.response=new XMLHttpRequest;e.open(t.method,t.fullUrl,!0),e.timeout=t.timeout,e.withCredentials=t.withCredentials||!1,e.responseType=t.responseType;for(const[s,i]of Object.entries(t.headers))e.setRequestHeader(s,i);return e.ontimeout=s=>{this.onTimeoutError(t,o,s),n()},e.onerror=s=>{this.onNetworkError(t,o,s),n()},e.onreadystatechange=()=>{if(!(e.readyState!==4||e.status==0)){if(e.status!=200)return this.onNetworkError(t,o,null),n();o.status=e.status,o.statusText=e.statusText,o.headers=Object.fromEntries(e.getAllResponseHeaders().trim().replaceAll("\r","").split(`
|
|
2
|
+
`).map(s=>[decodeURIComponent(s.substring(0,s.indexOf(": ")).toLowerCase()),decodeURIComponent(s.substring(s.indexOf(": ")+2))])),t.responseType=="text"&&t.dataType=="json"?o.body=JSON.parse(e.responseText):t.responseType=="text"?o.body=e.responseText:o.body=e.response,n()}},t.method=="POST"||t.method=="PUT"?e.send(t.body):e.send(),r}}exports.HttpQuickAjax=u;
|
package/dist/ajax.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as i } from "./
|
|
1
|
+
import { H as i } from "./HttpQuickBase-E_ukwMwW.js";
|
|
2
2
|
class u extends i {
|
|
3
3
|
// 发送请求
|
|
4
4
|
send(t, o) {
|
|
@@ -22,5 +22,5 @@ class u extends i {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
export {
|
|
25
|
-
u as
|
|
25
|
+
u as HttpQuickAjax
|
|
26
26
|
};
|
package/dist/fetch.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./HttpQuickBase-D0-rw_KI.cjs");class r extends l.HttpQuickBase{async send(t,e){try{const s=new AbortController,n=setTimeout(()=>s.abort(),t.timeout),i={method:t.method,headers:t.headers,cache:"no-cache",signal:s.signal,body:t.method=="POST"||t.method=="PUT"?t.body:null},o=e.response=await fetch(t.fullUrl,i);if(clearTimeout(n),o.status!=200)return this.onNetworkError(t,e,null);e.status=o.status,e.statusText=o.statusText;for(let[a,c]of o.headers.entries()){a=a.toLowerCase();for(const u of c.split(", "))e.headers[a]=u}t.responseType=="text"&&t.dataType=="json"?e.body=await o.json():t.responseType=="text"?e.body=await o.text():e.body=o.body}catch(s){return s.code==20?this.onTimeoutError(t,e,s):this.onNetworkError(t,e,s)}}}exports.HttpQuickFetch=r;
|
package/dist/fetch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as c } from "./
|
|
1
|
+
import { H as c } from "./HttpQuickBase-E_ukwMwW.js";
|
|
2
2
|
class h extends c {
|
|
3
3
|
// 发送请求
|
|
4
4
|
async send(t, o) {
|
|
@@ -25,5 +25,5 @@ class h extends c {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
h as
|
|
28
|
+
h as HttpQuickFetch
|
|
29
29
|
};
|
package/dist/fibjs.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./HttpQuickBase-D0-rw_KI.cjs"),i=require("http"),n=require("util");class d extends u.HttpQuickBase{send(e,s){try{const t=i.request(e.method,e.fullUrl,{headers:e.headers,body:e.body||""});if(t.status!==200)return this.onNetworkError(e,s,null);s.status=t.statusCode,s.statusText=t.statusMessage;for(let a of t.headers.keys()){let o=t.headers.first(a);a=a.toLowerCase();for(const r of o)s.headers[a]=r}e.responseType=="text"&&e.dataType=="json"?s.body=Buffer.isBuffer(t.data)?JSON.parse(t.data.toString("utf8")):typeof t.data=="string"?JSON.parse(t.data):t.data:e.responseType=="text"?s.body=t.data.toString("utf8"):s.body=t.data}catch(t){return this.onTimeoutError(e,s,t)}}request(e){return n.sync(async s=>await super.request(s))(e)}}exports.HttpQuickFibjs=d;
|
package/dist/fibjs.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { H as u } from "./HttpQuickBase-E_ukwMwW.js";
|
|
2
|
+
import d from "http";
|
|
3
|
+
import n from "util";
|
|
4
|
+
class y extends u {
|
|
5
|
+
// 发送请求
|
|
6
|
+
send(e, s) {
|
|
7
|
+
try {
|
|
8
|
+
const t = d.request(e.method, e.fullUrl, {
|
|
9
|
+
headers: e.headers,
|
|
10
|
+
body: e.body || ""
|
|
11
|
+
});
|
|
12
|
+
if (t.status !== 200)
|
|
13
|
+
return this.onNetworkError(e, s, null);
|
|
14
|
+
s.status = t.statusCode, s.statusText = t.statusMessage;
|
|
15
|
+
for (let a of t.headers.keys()) {
|
|
16
|
+
let o = t.headers.first(a);
|
|
17
|
+
a = a.toLowerCase();
|
|
18
|
+
for (const r of o)
|
|
19
|
+
s.headers[a] = r;
|
|
20
|
+
}
|
|
21
|
+
e.responseType == "text" && e.dataType == "json" ? s.body = Buffer.isBuffer(t.data) ? JSON.parse(t.data.toString("utf8")) : typeof t.data == "string" ? JSON.parse(t.data) : t.data : e.responseType == "text" ? s.body = t.data.toString("utf8") : s.body = t.data;
|
|
22
|
+
} catch (t) {
|
|
23
|
+
return this.onTimeoutError(e, s, t);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// 同步请求
|
|
27
|
+
request(e) {
|
|
28
|
+
return n.sync(async (s) => await super.request(s))(e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
y as HttpQuickFibjs
|
|
33
|
+
};
|
package/dist/node.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./HttpQuickBase-D0-rw_KI.cjs");class u extends a.HttpQuickBase{send(t,o){let n=null,r=new Promise(s=>n=s);const e=o.response=new XMLHttpRequest;e.open(t.method,t.fullUrl,!0),e.timeout=t.timeout,e.withCredentials=t.withCredentials||!1,e.responseType=t.responseType;for(const[s,i]of Object.entries(t.headers))e.setRequestHeader(s,i);return e.ontimeout=s=>{this.onTimeoutError(t,o,s),n()},e.onerror=s=>{this.onNetworkError(t,o,s),n()},e.onreadystatechange=()=>{if(!(e.readyState!==4||e.status==0)){if(e.status!=200)return this.onNetworkError(t,o,null),n();o.status=e.status,o.statusText=e.statusText,o.headers=Object.fromEntries(e.getAllResponseHeaders().trim().replaceAll("\r","").split(`
|
|
2
|
+
`).map(s=>[decodeURIComponent(s.substring(0,s.indexOf(": ")).toLowerCase()),decodeURIComponent(s.substring(s.indexOf(": ")+2))])),t.responseType=="text"&&t.dataType=="json"?o.body=JSON.parse(e.responseText):t.responseType=="text"?o.body=e.responseText:o.body=e.response,n()}},t.method=="POST"||t.method=="PUT"?e.send(t.body):e.send(),r}}exports.HttpQuickAjax=u;
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { H as i } from "./HttpQuickBase-E_ukwMwW.js";
|
|
2
|
+
class u extends i {
|
|
3
|
+
// 发送请求
|
|
4
|
+
send(t, o) {
|
|
5
|
+
let n = null, r = new Promise((s) => n = s);
|
|
6
|
+
const e = o.response = new XMLHttpRequest();
|
|
7
|
+
e.open(t.method, t.fullUrl, !0), e.timeout = t.timeout, e.withCredentials = t.withCredentials || !1, e.responseType = t.responseType;
|
|
8
|
+
for (const [s, a] of Object.entries(t.headers))
|
|
9
|
+
e.setRequestHeader(s, a);
|
|
10
|
+
return e.ontimeout = (s) => {
|
|
11
|
+
this.onTimeoutError(t, o, s), n();
|
|
12
|
+
}, e.onerror = (s) => {
|
|
13
|
+
this.onNetworkError(t, o, s), n();
|
|
14
|
+
}, e.onreadystatechange = () => {
|
|
15
|
+
if (!(e.readyState !== 4 || e.status == 0)) {
|
|
16
|
+
if (e.status != 200)
|
|
17
|
+
return this.onNetworkError(t, o, null), n();
|
|
18
|
+
o.status = e.status, o.statusText = e.statusText, o.headers = Object.fromEntries(e.getAllResponseHeaders().trim().replaceAll("\r", "").split(`
|
|
19
|
+
`).map((s) => [decodeURIComponent(s.substring(0, s.indexOf(": ")).toLowerCase()), decodeURIComponent(s.substring(s.indexOf(": ") + 2))])), t.responseType == "text" && t.dataType == "json" ? o.body = JSON.parse(e.responseText) : t.responseType == "text" ? o.body = e.responseText : o.body = e.response, n();
|
|
20
|
+
}
|
|
21
|
+
}, t.method == "POST" || t.method == "PUT" ? e.send(t.body) : e.send(), r;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
u as HttpQuickAjax
|
|
26
|
+
};
|
package/dist/uniapp.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var d=(r,s,t)=>s in r?l(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var i=(r,s,t)=>d(r,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./
|
|
1
|
+
"use strict";var l=Object.defineProperty;var d=(r,s,t)=>s in r?l(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var i=(r,s,t)=>d(r,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./HttpQuickBase-D0-rw_KI.cjs");class p extends f.HttpQuickBase{constructor(t={}){super(t);i(this,"platform",null);if(typeof uni<"u")this.setPlatform(uni),this.setPlatform(uni.$h5);else if(typeof wx<"u")this.setPlatform(wx);else throw new Error("unknown platform")}setPlatform(t=null){return this.platform=t,this}upload(t){return this.request({...t,method:"POST",func:"uploadFile"})}download(t){return this.request({...t,method:"POST",func:"downloadFile"})}async send(t,e){const[u,n,h]=Promise.channel();this.platform[t.func||"req"]({method:t.method,url:t.fullUrl,header:t.headers,data:t.body,formData:t.formData,name:t.name||"file",filePath:t.filePath,responseType:t.responseType,dataType:"",timeout:t.timeout,success:a=>n({...a,err:!1}),fail:a=>n({...a,err:!0})});const o=e.response=await u;if(e.err=o.err,o.err&&o.errMsg=="request:fail timeout")return this.onTimeoutError(t,e);if(o.err)return this.onNetworkError(t,e);if(o.statusCode!=200)return this.onNetworkError(t,e,null);e.status=o.statusCode,e.statusText="OK";for(const a in o.header)e.headers[a.toLowerCase()]=o.header[a];t.responseType=="text"&&t.dataType=="json"?e.body=JSON.parse(o.data):(t.responseType=="text",e.body=o.data)}}exports.HttpQuickXcx=p;
|
package/dist/uniapp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var l = Object.defineProperty;
|
|
2
2
|
var d = (r, s, t) => s in r ? l(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
3
|
var i = (r, s, t) => d(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { H as f } from "./
|
|
4
|
+
import { H as f } from "./HttpQuickBase-E_ukwMwW.js";
|
|
5
5
|
class c extends f {
|
|
6
6
|
// 构造函数
|
|
7
7
|
constructor(t = {}) {
|
|
@@ -62,5 +62,5 @@ class c extends f {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export {
|
|
65
|
-
c as
|
|
65
|
+
c as HttpQuickXcx
|
|
66
66
|
};
|
package/dist/xcx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var d=(r,s,t)=>s in r?l(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var i=(r,s,t)=>d(r,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./
|
|
1
|
+
"use strict";var l=Object.defineProperty;var d=(r,s,t)=>s in r?l(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var i=(r,s,t)=>d(r,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./HttpQuickBase-D0-rw_KI.cjs");class p extends f.HttpQuickBase{constructor(t={}){super(t);i(this,"platform",null);if(typeof uni<"u")this.setPlatform(uni),this.setPlatform(uni.$h5);else if(typeof wx<"u")this.setPlatform(wx);else throw new Error("unknown platform")}setPlatform(t=null){return this.platform=t,this}upload(t){return this.request({...t,method:"POST",func:"uploadFile"})}download(t){return this.request({...t,method:"POST",func:"downloadFile"})}async send(t,e){const[u,n,h]=Promise.channel();this.platform[t.func||"req"]({method:t.method,url:t.fullUrl,header:t.headers,data:t.body,formData:t.formData,name:t.name||"file",filePath:t.filePath,responseType:t.responseType,dataType:"",timeout:t.timeout,success:a=>n({...a,err:!1}),fail:a=>n({...a,err:!0})});const o=e.response=await u;if(e.err=o.err,o.err&&o.errMsg=="request:fail timeout")return this.onTimeoutError(t,e);if(o.err)return this.onNetworkError(t,e);if(o.statusCode!=200)return this.onNetworkError(t,e,null);e.status=o.statusCode,e.statusText="OK";for(const a in o.header)e.headers[a.toLowerCase()]=o.header[a];t.responseType=="text"&&t.dataType=="json"?e.body=JSON.parse(o.data):(t.responseType=="text",e.body=o.data)}}exports.HttpQuickXcx=p;
|
package/dist/xcx.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var l = Object.defineProperty;
|
|
2
2
|
var d = (r, s, t) => s in r ? l(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
3
|
var i = (r, s, t) => d(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { H as f } from "./
|
|
4
|
+
import { H as f } from "./HttpQuickBase-E_ukwMwW.js";
|
|
5
5
|
class c extends f {
|
|
6
6
|
// 构造函数
|
|
7
7
|
constructor(t = {}) {
|
|
@@ -62,5 +62,5 @@ class c extends f {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export {
|
|
65
|
-
c as
|
|
65
|
+
c as HttpQuickXcx
|
|
66
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "httpquick",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "js http quick request",
|
|
5
5
|
"author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
|
|
6
6
|
"homepage": "https://github.com/dotcoo/httpquick#readme",
|
|
@@ -19,26 +19,31 @@
|
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
21
|
"main": "dist/ajax.js",
|
|
22
|
+
"import": "dist/ajax.js",
|
|
23
|
+
"require": "dist/node.cjs",
|
|
22
24
|
"exports": {
|
|
23
25
|
".": {
|
|
24
|
-
"import": "dist/ajax.js"
|
|
25
|
-
"require": "dist/ajax.cjs"
|
|
26
|
+
"import": "dist/ajax.js"
|
|
26
27
|
},
|
|
27
28
|
"./ajax": {
|
|
28
|
-
"import": "dist/ajax.js"
|
|
29
|
-
"require": "dist/ajax.cjs"
|
|
29
|
+
"import": "dist/ajax.js"
|
|
30
30
|
},
|
|
31
31
|
"./fetch": {
|
|
32
|
-
"import": "dist/fetch.js"
|
|
33
|
-
"require": "dist/fetch.cjs"
|
|
32
|
+
"import": "dist/fetch.js"
|
|
34
33
|
},
|
|
35
34
|
"./uniapp": {
|
|
36
|
-
"import": "dist/uniapp.js"
|
|
37
|
-
"require": "dist/uniapp.cjs"
|
|
35
|
+
"import": "dist/uniapp.js"
|
|
38
36
|
},
|
|
39
37
|
"./xcx": {
|
|
40
|
-
"import": "dist/xcx.js"
|
|
41
|
-
|
|
38
|
+
"import": "dist/xcx.js"
|
|
39
|
+
},
|
|
40
|
+
"./node": {
|
|
41
|
+
"import": "dist/node.js",
|
|
42
|
+
"require": "dist/node.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./fibjs": {
|
|
45
|
+
"import": "dist/fibjs.js",
|
|
46
|
+
"require": "dist/fibjs.cjs"
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
"scripts": {
|