@gardenfi/wallet-connectors 0.1.0-beta.1
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/README.md +0 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +9 -0
- package/dist/index10.cjs +1 -0
- package/dist/index10.js +134 -0
- package/dist/index11.cjs +1 -0
- package/dist/index11.js +46 -0
- package/dist/index12.cjs +1 -0
- package/dist/index12.js +233 -0
- package/dist/index13.cjs +1 -0
- package/dist/index13.js +8 -0
- package/dist/index14.cjs +2 -0
- package/dist/index14.js +133 -0
- package/dist/index15.cjs +1 -0
- package/dist/index15.js +70 -0
- package/dist/index16.cjs +1 -0
- package/dist/index16.js +89 -0
- package/dist/index17.cjs +1 -0
- package/dist/index17.js +31 -0
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +11 -0
- package/dist/index19.cjs +1 -0
- package/dist/index19.js +77 -0
- package/dist/index2.cjs +1 -0
- package/dist/index2.js +106 -0
- package/dist/index20.cjs +1 -0
- package/dist/index20.js +6 -0
- package/dist/index21.cjs +1 -0
- package/dist/index21.js +4 -0
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +83 -0
- package/dist/index23.cjs +1 -0
- package/dist/index23.js +54 -0
- package/dist/index24.cjs +1 -0
- package/dist/index24.js +8 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +7 -0
- package/dist/index26.cjs +2 -0
- package/dist/index26.js +173 -0
- package/dist/index27.cjs +3 -0
- package/dist/index27.js +53 -0
- package/dist/index28.cjs +1 -0
- package/dist/index28.js +71 -0
- package/dist/index29.cjs +1 -0
- package/dist/index29.js +19 -0
- package/dist/index3.cjs +1 -0
- package/dist/index3.js +30 -0
- package/dist/index30.cjs +1 -0
- package/dist/index30.js +58 -0
- package/dist/index31.cjs +1 -0
- package/dist/index31.js +31 -0
- package/dist/index32.cjs +1 -0
- package/dist/index32.js +8 -0
- package/dist/index33.cjs +1 -0
- package/dist/index33.js +51 -0
- package/dist/index34.cjs +1 -0
- package/dist/index34.js +8 -0
- package/dist/index35.cjs +1 -0
- package/dist/index35.js +13 -0
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +9 -0
- package/dist/index37.cjs +2 -0
- package/dist/index37.js +30 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +4 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +71 -0
- package/dist/index4.cjs +1 -0
- package/dist/index4.js +30 -0
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +141 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +15 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +9 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +33 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +13 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +6 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +6 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +14 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +7 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +35 -0
- package/dist/index5.cjs +1 -0
- package/dist/index5.js +5 -0
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +33 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +30 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +63 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +5 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +4 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +4 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +19 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +15 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +37 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +32 -0
- package/dist/index6.cjs +1 -0
- package/dist/index6.js +69 -0
- package/dist/index7.cjs +1 -0
- package/dist/index7.js +69 -0
- package/dist/index8.cjs +1 -0
- package/dist/index8.js +61 -0
- package/dist/index9.cjs +1 -0
- package/dist/index9.js +95 -0
- package/dist/src/bitcoin/bitcoin.types.d.ts +53 -0
- package/dist/src/bitcoin/btcWalletsProvider.d.ts +41 -0
- package/dist/src/bitcoin/constants.d.ts +27 -0
- package/dist/src/bitcoin/index.d.ts +3 -0
- package/dist/src/bitcoin/providers/okx/okx.types.d.ts +33 -0
- package/dist/src/bitcoin/providers/okx/provider.d.ts +28 -0
- package/dist/src/bitcoin/providers/phantom/phantom.types.d.ts +30 -0
- package/dist/src/bitcoin/providers/phantom/provider.d.ts +31 -0
- package/dist/src/bitcoin/providers/unisat/provider.d.ts +27 -0
- package/dist/src/bitcoin/providers/unisat/unisat.types.d.ts +19 -0
- package/dist/src/bitcoin/providers/xdefi/provider.d.ts +24 -0
- package/dist/src/bitcoin/providers/xdefi/xdefi.types.d.ts +17 -0
- package/dist/src/bitcoin/providers/xverse/provider.d.ts +30 -0
- package/dist/src/bitcoin/providers/xverse/xverse.types.d.ts +7 -0
- package/dist/src/bitcoin/utils.d.ts +4 -0
- package/dist/src/index.d.ts +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
File without changes
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index2.cjs"),t=require("./index3.cjs"),l=require("./index4.cjs");exports.BTCWalletProvider=e.BTCWalletProvider;exports.useBitcoinWallet=e.useBitcoinWallet;exports.SupportedWallets=t.SupportedWallets;exports.getBalance=l.getBalance;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BTCWalletProvider as r, useBitcoinWallet as t } from "./index2.js";
|
|
2
|
+
import { SupportedWallets as a } from "./index3.js";
|
|
3
|
+
import { getBalance as f } from "./index4.js";
|
|
4
|
+
export {
|
|
5
|
+
r as BTCWalletProvider,
|
|
6
|
+
a as SupportedWallets,
|
|
7
|
+
f as getBalance,
|
|
8
|
+
t as useBitcoinWallet
|
|
9
|
+
};
|
package/dist/index10.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=r=>{throw TypeError(r)};var b=(r,t,e)=>t.has(r)||y("Cannot "+e);var i=(r,t,e)=>(b(r,t,"read from private field"),e?e.call(r):t.get(r)),E=(r,t,e)=>t.has(r)?y("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),h=(r,t,e,o)=>(b(r,t,"write to private field"),o?o.call(r,e):t.set(r,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./index5.cjs"),n=require("@catalogfi/utils"),x=require("bitcoinjs-lib"),k=require("./index11.cjs"),I=require("@bitcoinerlab/secp256k1");function A(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const u=A(x),v=A(I);x.initEccLib(v);var s;const p=class p{constructor(t){E(this,s);this.address="",this.mempoolApiBaseUrl="https://mempool.space/api",this.disconnect=()=>(this.address="",Promise.resolve(n.Ok("Disconnected Phantom wallet"))),h(this,s,t)}async connect(t){t||(t=P.Network.MAINNET);try{const e=await i(this,s).requestAccounts();if(!window.phantom)return n.Err("phantom wallet not found");if(e.length===0)return n.Err("No accounts found");const o=new p(window.phantom.bitcoin);h(this,s,i(o,s));for(const c of e)c.purpose==="payment"&&(this.address=c.address);if(this.address==="")return n.Err("Could not connect to Phantom bitcoin payment account");const a=await this.getNetwork();return a.error?n.Err("Could not get network: "+a.error):n.Ok({address:this.address,provider:o,network:a.val})}catch(e){return n.Err("Error while connecting to Phantom wallet: "+e)}}async requestAccounts(){return await n.executeWithTryCatch(async()=>{const t=await i(this,s).requestAccounts();return t.length>0&&(this.address=t[0].address),t.map(e=>e.address)},"Error while requesting accounts from Phantom wallet")}async getAccounts(){return this.requestAccounts()}async getNetwork(){return n.Ok(P.Network.MAINNET)}async switchNetwork(){return n.Err("Phantom wallet does not support testnet")}async getBalance(){return await n.executeWithTryCatch(async()=>await i(this,s).getBalance(),"Error while getting balance from Phantom wallet")}async sendBitcoin(t,e){return await n.executeWithTryCatch(async()=>{const o=u.networks.bitcoin,a=new u.Psbt({network:o}),c=await this.getUnspentOutputs();let f=0;c.forEach(d=>{a.addInput({hash:d.txid,index:d.vout,witnessUtxo:{script:u.address.toOutputScript(this.address,o),value:BigInt(d.value)}}),f+=d.value}),a.addOutput({address:t,value:BigInt(e)});const w=f-e-1e3;w>0&&a.addOutput({address:this.address,value:BigInt(w)});const O=a.toHex(),T=await i(this,s).signPSBT(this.fromHexString(O),{inputsToSign:[{address:this.address,signingIndexes:Array.from(Array(c.length).keys()),sigHash:u.Transaction.SIGHASH_ALL}]}),g=u.Psbt.fromBuffer(Buffer.from(T));g.finalizeAllInputs();const m=g.extractTransaction(),B=m.getId();return await this.broadcastTransaction(m.toHex()),B},"Error while sending bitcoin from Phantom wallet")}async getUnspentOutputs(){try{return(await k.get(`${this.mempoolApiBaseUrl}/address/${this.address}/utxo`)).data}catch(t){throw console.error("Error fetching UTXOs:",t),new Error("Failed to fetch unspent outputs")}}async broadcastTransaction(t){try{await k.post(`${this.mempoolApiBaseUrl}/tx`,t,{headers:{"Content-Type":"text/plain"}})}catch(e){throw console.error("Error broadcasting transaction:",e),new Error("Failed to broadcast transaction")}}fromHexString(t){return Uint8Array.from(t.match(/.{1,2}/g).map(e=>parseInt(e,16)))}on(t,e){i(this,s).on(t,e)}off(t,e){i(this,s).off(t,e)}};s=new WeakMap;let l=p;exports.PhantomProvider=l;
|
package/dist/index10.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var b = (s) => {
|
|
2
|
+
throw TypeError(s);
|
|
3
|
+
};
|
|
4
|
+
var A = (s, t, r) => t.has(s) || b("Cannot " + r);
|
|
5
|
+
var a = (s, t, r) => (A(s, t, "read from private field"), r ? r.call(s) : t.get(s)), x = (s, t, r) => t.has(s) ? b("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, r), h = (s, t, r, n) => (A(s, t, "write to private field"), n ? n.call(s, r) : t.set(s, r), r);
|
|
6
|
+
import { Network as B } from "./index5.js";
|
|
7
|
+
import { Ok as p, Err as i, executeWithTryCatch as l } from "@catalogfi/utils";
|
|
8
|
+
import * as d from "bitcoinjs-lib";
|
|
9
|
+
import { initEccLib as v } from "bitcoinjs-lib";
|
|
10
|
+
import E from "./index11.js";
|
|
11
|
+
import * as N from "@bitcoinerlab/secp256k1";
|
|
12
|
+
v(N);
|
|
13
|
+
var e;
|
|
14
|
+
const m = class m {
|
|
15
|
+
constructor(t) {
|
|
16
|
+
x(this, e);
|
|
17
|
+
this.address = "", this.mempoolApiBaseUrl = "https://mempool.space/api", this.disconnect = () => (this.address = "", Promise.resolve(p("Disconnected Phantom wallet"))), h(this, e, t);
|
|
18
|
+
}
|
|
19
|
+
async connect(t) {
|
|
20
|
+
t || (t = B.MAINNET);
|
|
21
|
+
try {
|
|
22
|
+
const r = await a(this, e).requestAccounts();
|
|
23
|
+
if (!window.phantom) return i("phantom wallet not found");
|
|
24
|
+
if (r.length === 0) return i("No accounts found");
|
|
25
|
+
const n = new m(window.phantom.bitcoin);
|
|
26
|
+
h(this, e, a(n, e));
|
|
27
|
+
for (const c of r)
|
|
28
|
+
c.purpose === "payment" && (this.address = c.address);
|
|
29
|
+
if (this.address === "")
|
|
30
|
+
return i("Could not connect to Phantom bitcoin payment account");
|
|
31
|
+
const o = await this.getNetwork();
|
|
32
|
+
return o.error ? i("Could not get network: " + o.error) : p({
|
|
33
|
+
address: this.address,
|
|
34
|
+
provider: n,
|
|
35
|
+
network: o.val
|
|
36
|
+
});
|
|
37
|
+
} catch (r) {
|
|
38
|
+
return i("Error while connecting to Phantom wallet: " + r);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async requestAccounts() {
|
|
42
|
+
return await l(async () => {
|
|
43
|
+
const t = await a(this, e).requestAccounts();
|
|
44
|
+
return t.length > 0 && (this.address = t[0].address), t.map((r) => r.address);
|
|
45
|
+
}, "Error while requesting accounts from Phantom wallet");
|
|
46
|
+
}
|
|
47
|
+
async getAccounts() {
|
|
48
|
+
return this.requestAccounts();
|
|
49
|
+
}
|
|
50
|
+
// bitcoin testnet is not supported in Phantom wallet
|
|
51
|
+
async getNetwork() {
|
|
52
|
+
return p(B.MAINNET);
|
|
53
|
+
}
|
|
54
|
+
async switchNetwork() {
|
|
55
|
+
return i("Phantom wallet does not support testnet");
|
|
56
|
+
}
|
|
57
|
+
async getBalance() {
|
|
58
|
+
return await l(async () => await a(this, e).getBalance(), "Error while getting balance from Phantom wallet");
|
|
59
|
+
}
|
|
60
|
+
async sendBitcoin(t, r) {
|
|
61
|
+
return await l(async () => {
|
|
62
|
+
const n = d.networks.bitcoin, o = new d.Psbt({ network: n }), c = await this.getUnspentOutputs();
|
|
63
|
+
let w = 0;
|
|
64
|
+
c.forEach((u) => {
|
|
65
|
+
o.addInput({
|
|
66
|
+
hash: u.txid,
|
|
67
|
+
index: u.vout,
|
|
68
|
+
witnessUtxo: {
|
|
69
|
+
script: d.address.toOutputScript(this.address, n),
|
|
70
|
+
value: BigInt(u.value)
|
|
71
|
+
}
|
|
72
|
+
}), w += u.value;
|
|
73
|
+
}), o.addOutput({
|
|
74
|
+
address: t,
|
|
75
|
+
value: BigInt(r)
|
|
76
|
+
});
|
|
77
|
+
const f = w - r - 1e3;
|
|
78
|
+
f > 0 && o.addOutput({
|
|
79
|
+
address: this.address,
|
|
80
|
+
// change goes back to sender
|
|
81
|
+
value: BigInt(f)
|
|
82
|
+
});
|
|
83
|
+
const P = o.toHex(), k = await a(this, e).signPSBT(
|
|
84
|
+
this.fromHexString(P),
|
|
85
|
+
{
|
|
86
|
+
inputsToSign: [
|
|
87
|
+
{
|
|
88
|
+
address: this.address,
|
|
89
|
+
signingIndexes: Array.from(Array(c.length).keys()),
|
|
90
|
+
sigHash: d.Transaction.SIGHASH_ALL
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
), g = d.Psbt.fromBuffer(Buffer.from(k));
|
|
95
|
+
g.finalizeAllInputs();
|
|
96
|
+
const y = g.extractTransaction(), T = y.getId();
|
|
97
|
+
return await this.broadcastTransaction(y.toHex()), T;
|
|
98
|
+
}, "Error while sending bitcoin from Phantom wallet");
|
|
99
|
+
}
|
|
100
|
+
async getUnspentOutputs() {
|
|
101
|
+
try {
|
|
102
|
+
return (await E.get(
|
|
103
|
+
`${this.mempoolApiBaseUrl}/address/${this.address}/utxo`
|
|
104
|
+
)).data;
|
|
105
|
+
} catch (t) {
|
|
106
|
+
throw console.error("Error fetching UTXOs:", t), new Error("Failed to fetch unspent outputs");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async broadcastTransaction(t) {
|
|
110
|
+
try {
|
|
111
|
+
await E.post(`${this.mempoolApiBaseUrl}/tx`, t, {
|
|
112
|
+
headers: { "Content-Type": "text/plain" }
|
|
113
|
+
});
|
|
114
|
+
} catch (r) {
|
|
115
|
+
throw console.error("Error broadcasting transaction:", r), new Error("Failed to broadcast transaction");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
fromHexString(t) {
|
|
119
|
+
return Uint8Array.from(
|
|
120
|
+
t.match(/.{1,2}/g).map((r) => parseInt(r, 16))
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
on(t, r) {
|
|
124
|
+
a(this, e).on(t, r);
|
|
125
|
+
}
|
|
126
|
+
off(t, r) {
|
|
127
|
+
a(this, e).off(t, r);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
e = new WeakMap();
|
|
131
|
+
let I = m;
|
|
132
|
+
export {
|
|
133
|
+
I as PhantomProvider
|
|
134
|
+
};
|
package/dist/index11.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("./index12.cjs"),u=require("./index13.cjs"),n=require("./index14.cjs"),a=require("./index15.cjs"),l=require("./index16.cjs"),q=require("./index17.cjs"),d=require("./index18.cjs"),x=require("./index19.cjs"),p=require("./index20.cjs"),C=require("./index21.cjs"),A=require("./index22.cjs"),m=require("./index23.cjs"),E=require("./index24.cjs"),f=require("./index25.cjs"),O=require("./index26.cjs"),S=require("./index27.cjs"),H=require("./index28.cjs");function i(r){const t=new n(r),o=u(n.prototype.request,t);return s.extend(o,n.prototype,t,{allOwnKeys:!0}),s.extend(o,t,null,{allOwnKeys:!0}),o.create=function(c){return i(a(r,c))},o}const e=i(l);e.Axios=n;e.CanceledError=d;e.CancelToken=x;e.isCancel=p;e.VERSION=C.VERSION;e.toFormData=A;e.AxiosError=m;e.Cancel=e.CanceledError;e.all=function(t){return Promise.all(t)};e.spread=E;e.isAxiosError=f;e.mergeConfig=a;e.AxiosHeaders=O;e.formToJSON=r=>q(s.isHTMLForm(r)?new FormData(r):r);e.getAdapter=S.getAdapter;e.HttpStatusCode=H;e.default=e;module.exports=e;
|
package/dist/index11.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import a from "./index12.js";
|
|
2
|
+
import p from "./index13.js";
|
|
3
|
+
import m from "./index14.js";
|
|
4
|
+
import i from "./index15.js";
|
|
5
|
+
import f from "./index16.js";
|
|
6
|
+
import l from "./index17.js";
|
|
7
|
+
import c from "./index18.js";
|
|
8
|
+
import d from "./index19.js";
|
|
9
|
+
import u from "./index20.js";
|
|
10
|
+
import { VERSION as x } from "./index21.js";
|
|
11
|
+
import C from "./index22.js";
|
|
12
|
+
import A from "./index23.js";
|
|
13
|
+
import E from "./index24.js";
|
|
14
|
+
import O from "./index25.js";
|
|
15
|
+
import S from "./index26.js";
|
|
16
|
+
import H from "./index27.js";
|
|
17
|
+
import T from "./index28.js";
|
|
18
|
+
function n(o) {
|
|
19
|
+
const t = new m(o), e = p(m.prototype.request, t);
|
|
20
|
+
return a.extend(e, m.prototype, t, { allOwnKeys: !0 }), a.extend(e, t, null, { allOwnKeys: !0 }), e.create = function(s) {
|
|
21
|
+
return n(i(o, s));
|
|
22
|
+
}, e;
|
|
23
|
+
}
|
|
24
|
+
const r = n(f);
|
|
25
|
+
r.Axios = m;
|
|
26
|
+
r.CanceledError = c;
|
|
27
|
+
r.CancelToken = d;
|
|
28
|
+
r.isCancel = u;
|
|
29
|
+
r.VERSION = x;
|
|
30
|
+
r.toFormData = C;
|
|
31
|
+
r.AxiosError = A;
|
|
32
|
+
r.Cancel = r.CanceledError;
|
|
33
|
+
r.all = function(t) {
|
|
34
|
+
return Promise.all(t);
|
|
35
|
+
};
|
|
36
|
+
r.spread = E;
|
|
37
|
+
r.isAxiosError = O;
|
|
38
|
+
r.mergeConfig = i;
|
|
39
|
+
r.AxiosHeaders = S;
|
|
40
|
+
r.formToJSON = (o) => l(a.isHTMLForm(o) ? new FormData(o) : o);
|
|
41
|
+
r.getAdapter = H.getAdapter;
|
|
42
|
+
r.HttpStatusCode = T;
|
|
43
|
+
r.default = r;
|
|
44
|
+
export {
|
|
45
|
+
r as default
|
|
46
|
+
};
|
package/dist/index12.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const C=require("./index13.cjs"),{toString:I}=Object.prototype,{getPrototypeOf:h}=Object,m=(e=>t=>{const r=I.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),l=e=>(e=e.toLowerCase(),t=>m(t)===e),g=e=>t=>typeof t===e,{isArray:a}=Array,p=g("undefined");function M(e){return e!==null&&!p(e)&&e.constructor!==null&&!p(e.constructor)&&c(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const x=l("ArrayBuffer");function R(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&x(e.buffer),t}const H=g("string"),c=g("function"),L=g("number"),w=e=>e!==null&&typeof e=="object",k=e=>e===!0||e===!1,y=e=>{if(m(e)!=="object")return!1;const t=h(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},N=l("Date"),U=l("File"),q=l("Blob"),_=l("FileList"),V=e=>w(e)&&c(e.pipe),z=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||c(e.append)&&((t=m(e))==="formdata"||t==="object"&&c(e.toString)&&e.toString()==="[object FormData]"))},G=l("URLSearchParams"),[J,K,$,W]=["ReadableStream","Request","Response","Headers"].map(l),Q=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function d(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),a(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let f;for(n=0;n<i;n++)f=o[n],t.call(null,e[f],f,e)}}function P(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,s;for(;n-- >0;)if(s=r[n],t===s.toLowerCase())return s;return null}const u=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,T=e=>!p(e)&&e!==u;function F(){const{caseless:e}=T(this)&&this||{},t={},r=(n,s)=>{const o=e&&P(t,s)||s;y(t[o])&&y(n)?t[o]=F(t[o],n):y(n)?t[o]=F({},n):a(n)?t[o]=n.slice():t[o]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&d(arguments[n],r);return t}const X=(e,t,r,{allOwnKeys:n}={})=>(d(t,(s,o)=>{r&&c(s)?e[o]=C(s,r):e[o]=s},{allOwnKeys:n}),e),Y=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Z=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},j=(e,t,r,n)=>{let s,o,i;const f={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!n||n(i,e,t))&&!f[i]&&(t[i]=e[i],f[i]=!0);e=r!==!1&&h(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},v=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},ee=e=>{if(!e)return null;if(a(e))return e;let t=e.length;if(!L(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},te=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&h(Uint8Array)),ne=(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=n.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},re=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},se=l("HTMLFormElement"),oe=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),S=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ie=l("RegExp"),B=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};d(r,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(n[o]=i||s)}),Object.defineProperties(e,n)},ce=e=>{B(e,(t,r)=>{if(c(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(c(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},le=(e,t)=>{const r={},n=s=>{s.forEach(o=>{r[o]=!0})};return a(e)?n(e):n(String(e).split(t)),r},fe=()=>{},ue=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,A="abcdefghijklmnopqrstuvwxyz",b="0123456789",D={DIGIT:b,ALPHA:A,ALPHA_DIGIT:A+A.toUpperCase()+b},ae=(e=16,t=D.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function pe(e){return!!(e&&c(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const de=e=>{const t=new Array(10),r=(n,s)=>{if(w(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[s]=n;const o=a(n)?[]:{};return d(n,(i,f)=>{const O=r(i,s+1);!p(O)&&(o[f]=O)}),t[s]=void 0,o}}return n};return r(e,0)},ye=l("AsyncFunction"),me=e=>e&&(w(e)||c(e))&&c(e.then)&&c(e.catch),E=((e,t)=>e?setImmediate:t?((r,n)=>(u.addEventListener("message",({source:s,data:o})=>{s===u&&o===r&&n.length&&n.shift()()},!1),s=>{n.push(s),u.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",c(u.postMessage)),ge=typeof queueMicrotask<"u"?queueMicrotask.bind(u):typeof process<"u"&&process.nextTick||E,we={isArray:a,isArrayBuffer:x,isBuffer:M,isFormData:z,isArrayBufferView:R,isString:H,isNumber:L,isBoolean:k,isObject:w,isPlainObject:y,isReadableStream:J,isRequest:K,isResponse:$,isHeaders:W,isUndefined:p,isDate:N,isFile:U,isBlob:q,isRegExp:ie,isFunction:c,isStream:V,isURLSearchParams:G,isTypedArray:te,isFileList:_,forEach:d,merge:F,extend:X,trim:Q,stripBOM:Y,inherits:Z,toFlatObject:j,kindOf:m,kindOfTest:l,endsWith:v,toArray:ee,forEachEntry:ne,matchAll:re,isHTMLForm:se,hasOwnProperty:S,hasOwnProp:S,reduceDescriptors:B,freezeMethods:ce,toObjectSet:le,toCamelCase:oe,noop:fe,toFiniteNumber:ue,findKey:P,global:u,isContextDefined:T,ALPHABET:D,generateString:ae,isSpecCompliantForm:pe,toJSONObject:de,isAsyncFn:ye,isThenable:me,setImmediate:E,asap:ge};module.exports=we;
|
package/dist/index12.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import C from "./index13.js";
|
|
2
|
+
const { toString: I } = Object.prototype, { getPrototypeOf: h } = Object, y = /* @__PURE__ */ ((e) => (t) => {
|
|
3
|
+
const r = I.call(t);
|
|
4
|
+
return e[r] || (e[r] = r.slice(8, -1).toLowerCase());
|
|
5
|
+
})(/* @__PURE__ */ Object.create(null)), l = (e) => (e = e.toLowerCase(), (t) => y(t) === e), g = (e) => (t) => typeof t === e, { isArray: u } = Array, p = g("undefined");
|
|
6
|
+
function M(e) {
|
|
7
|
+
return e !== null && !p(e) && e.constructor !== null && !p(e.constructor) && c(e.constructor.isBuffer) && e.constructor.isBuffer(e);
|
|
8
|
+
}
|
|
9
|
+
const x = l("ArrayBuffer");
|
|
10
|
+
function R(e) {
|
|
11
|
+
let t;
|
|
12
|
+
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && x(e.buffer), t;
|
|
13
|
+
}
|
|
14
|
+
const H = g("string"), c = g("function"), L = g("number"), w = (e) => e !== null && typeof e == "object", k = (e) => e === !0 || e === !1, m = (e) => {
|
|
15
|
+
if (y(e) !== "object")
|
|
16
|
+
return !1;
|
|
17
|
+
const t = h(e);
|
|
18
|
+
return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Symbol.toStringTag in e) && !(Symbol.iterator in e);
|
|
19
|
+
}, N = l("Date"), U = l("File"), _ = l("Blob"), q = l("FileList"), V = (e) => w(e) && c(e.pipe), z = (e) => {
|
|
20
|
+
let t;
|
|
21
|
+
return e && (typeof FormData == "function" && e instanceof FormData || c(e.append) && ((t = y(e)) === "formdata" || // detect form-data instance
|
|
22
|
+
t === "object" && c(e.toString) && e.toString() === "[object FormData]"));
|
|
23
|
+
}, G = l("URLSearchParams"), [J, K, $, W] = ["ReadableStream", "Request", "Response", "Headers"].map(l), Q = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
24
|
+
function d(e, t, { allOwnKeys: r = !1 } = {}) {
|
|
25
|
+
if (e === null || typeof e > "u")
|
|
26
|
+
return;
|
|
27
|
+
let n, s;
|
|
28
|
+
if (typeof e != "object" && (e = [e]), u(e))
|
|
29
|
+
for (n = 0, s = e.length; n < s; n++)
|
|
30
|
+
t.call(null, e[n], n, e);
|
|
31
|
+
else {
|
|
32
|
+
const o = r ? Object.getOwnPropertyNames(e) : Object.keys(e), i = o.length;
|
|
33
|
+
let f;
|
|
34
|
+
for (n = 0; n < i; n++)
|
|
35
|
+
f = o[n], t.call(null, e[f], f, e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function P(e, t) {
|
|
39
|
+
t = t.toLowerCase();
|
|
40
|
+
const r = Object.keys(e);
|
|
41
|
+
let n = r.length, s;
|
|
42
|
+
for (; n-- > 0; )
|
|
43
|
+
if (s = r[n], t === s.toLowerCase())
|
|
44
|
+
return s;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const a = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, T = (e) => !p(e) && e !== a;
|
|
48
|
+
function F() {
|
|
49
|
+
const { caseless: e } = T(this) && this || {}, t = {}, r = (n, s) => {
|
|
50
|
+
const o = e && P(t, s) || s;
|
|
51
|
+
m(t[o]) && m(n) ? t[o] = F(t[o], n) : m(n) ? t[o] = F({}, n) : u(n) ? t[o] = n.slice() : t[o] = n;
|
|
52
|
+
};
|
|
53
|
+
for (let n = 0, s = arguments.length; n < s; n++)
|
|
54
|
+
arguments[n] && d(arguments[n], r);
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
const X = (e, t, r, { allOwnKeys: n } = {}) => (d(t, (s, o) => {
|
|
58
|
+
r && c(s) ? e[o] = C(s, r) : e[o] = s;
|
|
59
|
+
}, { allOwnKeys: n }), e), Y = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), Z = (e, t, r, n) => {
|
|
60
|
+
e.prototype = Object.create(t.prototype, n), e.prototype.constructor = e, Object.defineProperty(e, "super", {
|
|
61
|
+
value: t.prototype
|
|
62
|
+
}), r && Object.assign(e.prototype, r);
|
|
63
|
+
}, j = (e, t, r, n) => {
|
|
64
|
+
let s, o, i;
|
|
65
|
+
const f = {};
|
|
66
|
+
if (t = t || {}, e == null) return t;
|
|
67
|
+
do {
|
|
68
|
+
for (s = Object.getOwnPropertyNames(e), o = s.length; o-- > 0; )
|
|
69
|
+
i = s[o], (!n || n(i, e, t)) && !f[i] && (t[i] = e[i], f[i] = !0);
|
|
70
|
+
e = r !== !1 && h(e);
|
|
71
|
+
} while (e && (!r || r(e, t)) && e !== Object.prototype);
|
|
72
|
+
return t;
|
|
73
|
+
}, v = (e, t, r) => {
|
|
74
|
+
e = String(e), (r === void 0 || r > e.length) && (r = e.length), r -= t.length;
|
|
75
|
+
const n = e.indexOf(t, r);
|
|
76
|
+
return n !== -1 && n === r;
|
|
77
|
+
}, ee = (e) => {
|
|
78
|
+
if (!e) return null;
|
|
79
|
+
if (u(e)) return e;
|
|
80
|
+
let t = e.length;
|
|
81
|
+
if (!L(t)) return null;
|
|
82
|
+
const r = new Array(t);
|
|
83
|
+
for (; t-- > 0; )
|
|
84
|
+
r[t] = e[t];
|
|
85
|
+
return r;
|
|
86
|
+
}, te = /* @__PURE__ */ ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && h(Uint8Array)), ne = (e, t) => {
|
|
87
|
+
const n = (e && e[Symbol.iterator]).call(e);
|
|
88
|
+
let s;
|
|
89
|
+
for (; (s = n.next()) && !s.done; ) {
|
|
90
|
+
const o = s.value;
|
|
91
|
+
t.call(e, o[0], o[1]);
|
|
92
|
+
}
|
|
93
|
+
}, re = (e, t) => {
|
|
94
|
+
let r;
|
|
95
|
+
const n = [];
|
|
96
|
+
for (; (r = e.exec(t)) !== null; )
|
|
97
|
+
n.push(r);
|
|
98
|
+
return n;
|
|
99
|
+
}, se = l("HTMLFormElement"), oe = (e) => e.toLowerCase().replace(
|
|
100
|
+
/[-_\s]([a-z\d])(\w*)/g,
|
|
101
|
+
function(r, n, s) {
|
|
102
|
+
return n.toUpperCase() + s;
|
|
103
|
+
}
|
|
104
|
+
), S = (({ hasOwnProperty: e }) => (t, r) => e.call(t, r))(Object.prototype), ie = l("RegExp"), B = (e, t) => {
|
|
105
|
+
const r = Object.getOwnPropertyDescriptors(e), n = {};
|
|
106
|
+
d(r, (s, o) => {
|
|
107
|
+
let i;
|
|
108
|
+
(i = t(s, o, e)) !== !1 && (n[o] = i || s);
|
|
109
|
+
}), Object.defineProperties(e, n);
|
|
110
|
+
}, ce = (e) => {
|
|
111
|
+
B(e, (t, r) => {
|
|
112
|
+
if (c(e) && ["arguments", "caller", "callee"].indexOf(r) !== -1)
|
|
113
|
+
return !1;
|
|
114
|
+
const n = e[r];
|
|
115
|
+
if (c(n)) {
|
|
116
|
+
if (t.enumerable = !1, "writable" in t) {
|
|
117
|
+
t.writable = !1;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
t.set || (t.set = () => {
|
|
121
|
+
throw Error("Can not rewrite read-only method '" + r + "'");
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}, le = (e, t) => {
|
|
126
|
+
const r = {}, n = (s) => {
|
|
127
|
+
s.forEach((o) => {
|
|
128
|
+
r[o] = !0;
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
return u(e) ? n(e) : n(String(e).split(t)), r;
|
|
132
|
+
}, fe = () => {
|
|
133
|
+
}, ae = (e, t) => e != null && Number.isFinite(e = +e) ? e : t, A = "abcdefghijklmnopqrstuvwxyz", b = "0123456789", D = {
|
|
134
|
+
DIGIT: b,
|
|
135
|
+
ALPHA: A,
|
|
136
|
+
ALPHA_DIGIT: A + A.toUpperCase() + b
|
|
137
|
+
}, ue = (e = 16, t = D.ALPHA_DIGIT) => {
|
|
138
|
+
let r = "";
|
|
139
|
+
const { length: n } = t;
|
|
140
|
+
for (; e--; )
|
|
141
|
+
r += t[Math.random() * n | 0];
|
|
142
|
+
return r;
|
|
143
|
+
};
|
|
144
|
+
function pe(e) {
|
|
145
|
+
return !!(e && c(e.append) && e[Symbol.toStringTag] === "FormData" && e[Symbol.iterator]);
|
|
146
|
+
}
|
|
147
|
+
const de = (e) => {
|
|
148
|
+
const t = new Array(10), r = (n, s) => {
|
|
149
|
+
if (w(n)) {
|
|
150
|
+
if (t.indexOf(n) >= 0)
|
|
151
|
+
return;
|
|
152
|
+
if (!("toJSON" in n)) {
|
|
153
|
+
t[s] = n;
|
|
154
|
+
const o = u(n) ? [] : {};
|
|
155
|
+
return d(n, (i, f) => {
|
|
156
|
+
const O = r(i, s + 1);
|
|
157
|
+
!p(O) && (o[f] = O);
|
|
158
|
+
}), t[s] = void 0, o;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return n;
|
|
162
|
+
};
|
|
163
|
+
return r(e, 0);
|
|
164
|
+
}, me = l("AsyncFunction"), ye = (e) => e && (w(e) || c(e)) && c(e.then) && c(e.catch), E = ((e, t) => e ? setImmediate : t ? ((r, n) => (a.addEventListener("message", ({ source: s, data: o }) => {
|
|
165
|
+
s === a && o === r && n.length && n.shift()();
|
|
166
|
+
}, !1), (s) => {
|
|
167
|
+
n.push(s), a.postMessage(r, "*");
|
|
168
|
+
}))(`axios@${Math.random()}`, []) : (r) => setTimeout(r))(
|
|
169
|
+
typeof setImmediate == "function",
|
|
170
|
+
c(a.postMessage)
|
|
171
|
+
), ge = typeof queueMicrotask < "u" ? queueMicrotask.bind(a) : typeof process < "u" && process.nextTick || E, Ae = {
|
|
172
|
+
isArray: u,
|
|
173
|
+
isArrayBuffer: x,
|
|
174
|
+
isBuffer: M,
|
|
175
|
+
isFormData: z,
|
|
176
|
+
isArrayBufferView: R,
|
|
177
|
+
isString: H,
|
|
178
|
+
isNumber: L,
|
|
179
|
+
isBoolean: k,
|
|
180
|
+
isObject: w,
|
|
181
|
+
isPlainObject: m,
|
|
182
|
+
isReadableStream: J,
|
|
183
|
+
isRequest: K,
|
|
184
|
+
isResponse: $,
|
|
185
|
+
isHeaders: W,
|
|
186
|
+
isUndefined: p,
|
|
187
|
+
isDate: N,
|
|
188
|
+
isFile: U,
|
|
189
|
+
isBlob: _,
|
|
190
|
+
isRegExp: ie,
|
|
191
|
+
isFunction: c,
|
|
192
|
+
isStream: V,
|
|
193
|
+
isURLSearchParams: G,
|
|
194
|
+
isTypedArray: te,
|
|
195
|
+
isFileList: q,
|
|
196
|
+
forEach: d,
|
|
197
|
+
merge: F,
|
|
198
|
+
extend: X,
|
|
199
|
+
trim: Q,
|
|
200
|
+
stripBOM: Y,
|
|
201
|
+
inherits: Z,
|
|
202
|
+
toFlatObject: j,
|
|
203
|
+
kindOf: y,
|
|
204
|
+
kindOfTest: l,
|
|
205
|
+
endsWith: v,
|
|
206
|
+
toArray: ee,
|
|
207
|
+
forEachEntry: ne,
|
|
208
|
+
matchAll: re,
|
|
209
|
+
isHTMLForm: se,
|
|
210
|
+
hasOwnProperty: S,
|
|
211
|
+
hasOwnProp: S,
|
|
212
|
+
// an alias to avoid ESLint no-prototype-builtins detection
|
|
213
|
+
reduceDescriptors: B,
|
|
214
|
+
freezeMethods: ce,
|
|
215
|
+
toObjectSet: le,
|
|
216
|
+
toCamelCase: oe,
|
|
217
|
+
noop: fe,
|
|
218
|
+
toFiniteNumber: ae,
|
|
219
|
+
findKey: P,
|
|
220
|
+
global: a,
|
|
221
|
+
isContextDefined: T,
|
|
222
|
+
ALPHABET: D,
|
|
223
|
+
generateString: ue,
|
|
224
|
+
isSpecCompliantForm: pe,
|
|
225
|
+
toJSONObject: de,
|
|
226
|
+
isAsyncFn: me,
|
|
227
|
+
isThenable: ye,
|
|
228
|
+
setImmediate: E,
|
|
229
|
+
asap: ge
|
|
230
|
+
};
|
|
231
|
+
export {
|
|
232
|
+
Ae as default
|
|
233
|
+
};
|
package/dist/index13.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function t(n,r){return function(){return n.apply(r,arguments)}}module.exports=t;
|
package/dist/index13.js
ADDED
package/dist/index14.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const d=require("./index12.cjs"),R=require("./index29.cjs"),b=require("./index30.cjs"),S=require("./index31.cjs"),m=require("./index15.cjs"),C=require("./index32.cjs"),k=require("./index33.cjs"),I=require("./index26.cjs"),l=k.validators;class q{constructor(t){this.defaults=t,this.interceptors={request:new b,response:new b}}async request(t,e){try{return await this._request(t,e)}catch(s){if(s instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;const a=o.stack?o.stack.replace(/^.+\n/,""):"";try{s.stack?a&&!String(s.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
|
2
|
+
`+a):s.stack=a}catch{}}throw s}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=m(this.defaults,e);const{transitional:s,paramsSerializer:o,headers:a}=e;s!==void 0&&k.assertOptions(s,{silentJSONParsing:l.transitional(l.boolean),forcedJSONParsing:l.transitional(l.boolean),clarifyTimeoutError:l.transitional(l.boolean)},!1),o!=null&&(d.isFunction(o)?e.paramsSerializer={serialize:o}:k.assertOptions(o,{encode:l.function,serialize:l.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let f=a&&d.merge(a.common,a[e.method]);a&&d.forEach(["delete","get","head","post","put","patch","common"],r=>{delete a[r]}),e.headers=I.concat(f,a);const c=[];let y=!0;this.interceptors.request.forEach(function(i){typeof i.runWhen=="function"&&i.runWhen(e)===!1||(y=y&&i.synchronous,c.unshift(i.fulfilled,i.rejected))});const p=[];this.interceptors.response.forEach(function(i){p.push(i.fulfilled,i.rejected)});let u,n=0,h;if(!y){const r=[S.bind(this),void 0];for(r.unshift.apply(r,c),r.push.apply(r,p),h=r.length,u=Promise.resolve(e);n<h;)u=u.then(r[n++],r[n++]);return u}h=c.length;let E=e;for(n=0;n<h;){const r=c[n++],i=c[n++];try{E=r(E)}catch(P){i.call(this,P);break}}try{u=S.call(this,E)}catch(r){return Promise.reject(r)}for(n=0,h=p.length;n<h;)u=u.then(p[n++],p[n++]);return u}getUri(t){t=m(this.defaults,t);const e=C(t.baseURL,t.url);return R(e,t.params,t.paramsSerializer)}}d.forEach(["delete","get","head","options"],function(t){q.prototype[t]=function(e,s){return this.request(m(s||{},{method:t,url:e,data:(s||{}).data}))}});d.forEach(["post","put","patch"],function(t){function e(s){return function(a,f,c){return this.request(m(c||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:f}))}}q.prototype[t]=e(),q.prototype[t+"Form"]=e(!0)});module.exports=q;
|
package/dist/index14.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import d from "./index12.js";
|
|
2
|
+
import R from "./index29.js";
|
|
3
|
+
import b from "./index30.js";
|
|
4
|
+
import S from "./index31.js";
|
|
5
|
+
import m from "./index15.js";
|
|
6
|
+
import C from "./index32.js";
|
|
7
|
+
import q from "./index33.js";
|
|
8
|
+
import I from "./index26.js";
|
|
9
|
+
const u = q.validators;
|
|
10
|
+
class k {
|
|
11
|
+
constructor(t) {
|
|
12
|
+
this.defaults = t, this.interceptors = {
|
|
13
|
+
request: new b(),
|
|
14
|
+
response: new b()
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Dispatch a request
|
|
19
|
+
*
|
|
20
|
+
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
21
|
+
* @param {?Object} config
|
|
22
|
+
*
|
|
23
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
24
|
+
*/
|
|
25
|
+
async request(t, e) {
|
|
26
|
+
try {
|
|
27
|
+
return await this._request(t, e);
|
|
28
|
+
} catch (s) {
|
|
29
|
+
if (s instanceof Error) {
|
|
30
|
+
let n;
|
|
31
|
+
Error.captureStackTrace ? Error.captureStackTrace(n = {}) : n = new Error();
|
|
32
|
+
const a = n.stack ? n.stack.replace(/^.+\n/, "") : "";
|
|
33
|
+
try {
|
|
34
|
+
s.stack ? a && !String(s.stack).endsWith(a.replace(/^.+\n.+\n/, "")) && (s.stack += `
|
|
35
|
+
` + a) : s.stack = a;
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw s;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_request(t, e) {
|
|
43
|
+
typeof t == "string" ? (e = e || {}, e.url = t) : e = t || {}, e = m(this.defaults, e);
|
|
44
|
+
const { transitional: s, paramsSerializer: n, headers: a } = e;
|
|
45
|
+
s !== void 0 && q.assertOptions(s, {
|
|
46
|
+
silentJSONParsing: u.transitional(u.boolean),
|
|
47
|
+
forcedJSONParsing: u.transitional(u.boolean),
|
|
48
|
+
clarifyTimeoutError: u.transitional(u.boolean)
|
|
49
|
+
}, !1), n != null && (d.isFunction(n) ? e.paramsSerializer = {
|
|
50
|
+
serialize: n
|
|
51
|
+
} : q.assertOptions(n, {
|
|
52
|
+
encode: u.function,
|
|
53
|
+
serialize: u.function
|
|
54
|
+
}, !0)), e.method = (e.method || this.defaults.method || "get").toLowerCase();
|
|
55
|
+
let f = a && d.merge(
|
|
56
|
+
a.common,
|
|
57
|
+
a[e.method]
|
|
58
|
+
);
|
|
59
|
+
a && d.forEach(
|
|
60
|
+
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
61
|
+
(r) => {
|
|
62
|
+
delete a[r];
|
|
63
|
+
}
|
|
64
|
+
), e.headers = I.concat(f, a);
|
|
65
|
+
const h = [];
|
|
66
|
+
let y = !0;
|
|
67
|
+
this.interceptors.request.forEach(function(i) {
|
|
68
|
+
typeof i.runWhen == "function" && i.runWhen(e) === !1 || (y = y && i.synchronous, h.unshift(i.fulfilled, i.rejected));
|
|
69
|
+
});
|
|
70
|
+
const p = [];
|
|
71
|
+
this.interceptors.response.forEach(function(i) {
|
|
72
|
+
p.push(i.fulfilled, i.rejected);
|
|
73
|
+
});
|
|
74
|
+
let l, o = 0, c;
|
|
75
|
+
if (!y) {
|
|
76
|
+
const r = [S.bind(this), void 0];
|
|
77
|
+
for (r.unshift.apply(r, h), r.push.apply(r, p), c = r.length, l = Promise.resolve(e); o < c; )
|
|
78
|
+
l = l.then(r[o++], r[o++]);
|
|
79
|
+
return l;
|
|
80
|
+
}
|
|
81
|
+
c = h.length;
|
|
82
|
+
let E = e;
|
|
83
|
+
for (o = 0; o < c; ) {
|
|
84
|
+
const r = h[o++], i = h[o++];
|
|
85
|
+
try {
|
|
86
|
+
E = r(E);
|
|
87
|
+
} catch (P) {
|
|
88
|
+
i.call(this, P);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
l = S.call(this, E);
|
|
94
|
+
} catch (r) {
|
|
95
|
+
return Promise.reject(r);
|
|
96
|
+
}
|
|
97
|
+
for (o = 0, c = p.length; o < c; )
|
|
98
|
+
l = l.then(p[o++], p[o++]);
|
|
99
|
+
return l;
|
|
100
|
+
}
|
|
101
|
+
getUri(t) {
|
|
102
|
+
t = m(this.defaults, t);
|
|
103
|
+
const e = C(t.baseURL, t.url);
|
|
104
|
+
return R(e, t.params, t.paramsSerializer);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
d.forEach(["delete", "get", "head", "options"], function(t) {
|
|
108
|
+
k.prototype[t] = function(e, s) {
|
|
109
|
+
return this.request(m(s || {}, {
|
|
110
|
+
method: t,
|
|
111
|
+
url: e,
|
|
112
|
+
data: (s || {}).data
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
d.forEach(["post", "put", "patch"], function(t) {
|
|
117
|
+
function e(s) {
|
|
118
|
+
return function(a, f, h) {
|
|
119
|
+
return this.request(m(h || {}, {
|
|
120
|
+
method: t,
|
|
121
|
+
headers: s ? {
|
|
122
|
+
"Content-Type": "multipart/form-data"
|
|
123
|
+
} : {},
|
|
124
|
+
url: a,
|
|
125
|
+
data: f
|
|
126
|
+
}));
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
k.prototype[t] = e(), k.prototype[t + "Form"] = e(!0);
|
|
130
|
+
});
|
|
131
|
+
export {
|
|
132
|
+
k as default
|
|
133
|
+
};
|
package/dist/index15.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("./index12.cjs"),h=require("./index26.cjs"),m=s=>s instanceof h?{...s}:s;function U(s,o){o=o||{};const f={};function d(t,e,r){return i.isPlainObject(t)&&i.isPlainObject(e)?i.merge.call({caseless:r},t,e):i.isPlainObject(e)?i.merge({},e):i.isArray(e)?e.slice():e}function u(t,e,r){if(i.isUndefined(e)){if(!i.isUndefined(t))return d(void 0,t,r)}else return d(t,e,r)}function a(t,e){if(!i.isUndefined(e))return d(void 0,e)}function n(t,e){if(i.isUndefined(e)){if(!i.isUndefined(t))return d(void 0,t)}else return d(void 0,e)}function l(t,e,r){if(r in o)return d(t,e);if(r in s)return d(void 0,t)}const g={url:a,method:a,data:a,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,withXSRFToken:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,beforeRedirect:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:l,headers:(t,e)=>u(m(t),m(e),!0)};return i.forEach(Object.keys(Object.assign({},s,o)),function(e){const r=g[e]||u,c=r(s[e],o[e],e);i.isUndefined(c)&&r!==l||(f[e]=c)}),f}module.exports=U;
|