mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-03-06 13:16:02 -05:00
Fix missing XMLHttpRequest on node environments
This commit is contained in:
parent
73e14fe5b3
commit
987672fe3b
24
package-lock.json
generated
24
package-lock.json
generated
@ -11,8 +11,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^18.14.2",
|
"@types/node": "^18.14.2",
|
||||||
"console": "^0.7.2",
|
"console": "^0.7.2",
|
||||||
|
"decimal.js": "^10.4.3",
|
||||||
"google-protobuf": "^3.20.3",
|
"google-protobuf": "^3.20.3",
|
||||||
"grpc-web": "^1.4.2"
|
"grpc-web": "^1.4.2",
|
||||||
|
"node-xmlhttprequest": "^1.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.21.0",
|
"@babel/core": "^7.21.0",
|
||||||
@ -22,7 +24,6 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "5.53.0",
|
"@typescript-eslint/eslint-plugin": "5.53.0",
|
||||||
"@typescript-eslint/parser": "^5.53.0",
|
"@typescript-eslint/parser": "^5.53.0",
|
||||||
"babel-jest": "^29.4.3",
|
"babel-jest": "^29.4.3",
|
||||||
"decimal.js": "^10.4.3",
|
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-import-resolver-typescript": "^3.5.3",
|
"eslint-import-resolver-typescript": "^3.5.3",
|
||||||
@ -30,7 +31,6 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.7.1",
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"monero-ts": "^0.11.1",
|
"monero-ts": "^0.11.1",
|
||||||
"node-xmlhttprequest": "^1.0.6",
|
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-jest-resolver": "^2.0.1",
|
"ts-jest-resolver": "^2.0.1",
|
||||||
"typedoc": "^0.23.26",
|
"typedoc": "^0.23.26",
|
||||||
@ -1890,7 +1890,6 @@
|
|||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
|
||||||
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
|
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
@ -3591,9 +3590,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.7.5",
|
"version": "1.7.9",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
||||||
"integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==",
|
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.6",
|
"follow-redirects": "^1.15.6",
|
||||||
@ -4171,9 +4170,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@ -4216,8 +4215,7 @@
|
|||||||
"node_modules/decimal.js": {
|
"node_modules/decimal.js": {
|
||||||
"version": "10.4.3",
|
"version": "10.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
|
||||||
"integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==",
|
"integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/dedent": {
|
"node_modules/dedent": {
|
||||||
"version": "1.5.3",
|
"version": "1.5.3",
|
||||||
@ -8234,7 +8232,6 @@
|
|||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/node-xmlhttprequest/-/node-xmlhttprequest-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/node-xmlhttprequest/-/node-xmlhttprequest-1.0.6.tgz",
|
||||||
"integrity": "sha512-wBcHLcDg0oIyRQNKwPzyF+W5/eqwbvPM6Tbaz9E8lTBN/7OVMGaLTWYkL69Tt8eo6JyjoPtoAaVtZYcNIfRKvw==",
|
"integrity": "sha512-wBcHLcDg0oIyRQNKwPzyF+W5/eqwbvPM6Tbaz9E8lTBN/7OVMGaLTWYkL69Tt8eo6JyjoPtoAaVtZYcNIfRKvw==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici": "6.6.2"
|
"undici": "6.6.2"
|
||||||
}
|
}
|
||||||
@ -9604,7 +9601,6 @@
|
|||||||
"version": "6.6.2",
|
"version": "6.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.6.2.tgz",
|
||||||
"integrity": "sha512-vSqvUE5skSxQJ5sztTZ/CdeJb1Wq0Hf44hlYMciqHghvz+K88U0l7D6u1VsndoFgskDcnU+nG3gYmMzJVzd9Qg==",
|
"integrity": "sha512-vSqvUE5skSxQJ5sztTZ/CdeJb1Wq0Hf44hlYMciqHghvz+K88U0l7D6u1VsndoFgskDcnU+nG3gYmMzJVzd9Qg==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
"console": "^0.7.2",
|
"console": "^0.7.2",
|
||||||
"decimal.js": "^10.4.3",
|
"decimal.js": "^10.4.3",
|
||||||
"google-protobuf": "^3.20.3",
|
"google-protobuf": "^3.20.3",
|
||||||
"grpc-web": "^1.4.2"
|
"grpc-web": "^1.4.2",
|
||||||
|
"node-xmlhttprequest": "^1.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.21.0",
|
"@babel/core": "^7.21.0",
|
||||||
@ -48,7 +49,6 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.7.1",
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"monero-ts": "^0.11.1",
|
"monero-ts": "^0.11.1",
|
||||||
"node-xmlhttprequest": "^1.0.6",
|
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-jest-resolver": "^2.0.1",
|
"ts-jest-resolver": "^2.0.1",
|
||||||
"typedoc": "^0.23.26",
|
"typedoc": "^0.23.26",
|
||||||
|
16
src/index.ts
16
src/index.ts
@ -1,3 +1,19 @@
|
|||||||
|
try {
|
||||||
|
new XMLHttpRequest();
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
const xhr = require('node-xmlhttprequest');
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
global.ProgressEvent = xhr.ProgressEvent;
|
||||||
|
//@ts-ignore
|
||||||
|
global.XMLHttpRequestEventTarget = xhr.XMLHttpRequestEventTarget;
|
||||||
|
//@ts-ignore
|
||||||
|
global.XMLHttpRequestUpload = xhr.XMLHttpRequestUpload;
|
||||||
|
//@ts-ignore
|
||||||
|
global.XMLHttpRequest = xhr.XMLHttpRequest;
|
||||||
|
}
|
||||||
|
|
||||||
import HavenoClient from "./HavenoClient";
|
import HavenoClient from "./HavenoClient";
|
||||||
import HavenoError from "./types/HavenoError";
|
import HavenoError from "./types/HavenoError";
|
||||||
import HavenoUtils from "./utils/HavenoUtils";
|
import HavenoUtils from "./utils/HavenoUtils";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user