Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
1453abcd5f | |||
99afb573cd | |||
94360ff1da | |||
3fd2075c26 | |||
71782672d7 | |||
9dec755ea5 |
7608
package-lock.json
generated
7608
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/webrequest",
|
"name": "@pushrocks/webrequest",
|
||||||
"version": "2.0.7",
|
"version": "2.0.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "securely request from browsers",
|
"description": "securely request from browsers",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -9,21 +9,23 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)",
|
"build": "(tsbuild --web && tsbundle npm)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"@gitzone/tstest": "^1.0.33",
|
"@gitzone/tsbundle": "^1.0.72",
|
||||||
"@pushrocks/smartexpress": "^3.0.72",
|
"@gitzone/tstest": "^1.0.38",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@pushrocks/smartexpress": "^3.0.73",
|
||||||
"@types/node": "^14.0.14",
|
"@pushrocks/tapbundle": "^3.2.7",
|
||||||
"node-fetch": "^2.6.0",
|
"@types/node": "^14.0.19",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.2",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.9"
|
"@pushrocks/smartdelay": "^2.0.9",
|
||||||
|
"@pushrocks/smartenv": "^4.0.10",
|
||||||
|
"node-fetch": "^2.6.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -36,5 +38,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ Platform support | [ or [contribute monthly](https://lossless.link/contribute). :)
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
16
test/test.browser.ts
Normal file
16
test/test.browser.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as webrequest from '../ts/index';
|
||||||
|
|
||||||
|
tap.test('first test', async tools => {
|
||||||
|
const done = tools.defer();
|
||||||
|
const response = await new webrequest.WebRequest().request([
|
||||||
|
'https://lossless.com'
|
||||||
|
], {
|
||||||
|
method: 'GET'
|
||||||
|
}).catch(e => {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
await done.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -6,11 +6,10 @@ import * as plugins from './webrequest.plugins';
|
|||||||
export class WebRequest {
|
export class WebRequest {
|
||||||
private static polyfillsLoaded = false;
|
private static polyfillsLoaded = false;
|
||||||
public static loadNeededPolyfills() {
|
public static loadNeededPolyfills() {
|
||||||
if (!this.polyfillsLoaded) {
|
const smartenv = new plugins.smartenv.Smartenv();
|
||||||
|
if (!smartenv.isBrowser && !this.polyfillsLoaded) {
|
||||||
this.polyfillsLoaded = true;
|
this.polyfillsLoaded = true;
|
||||||
// tslint:disable-next-line: no-eval
|
globalThis.fetch = smartenv.getSafeNodeModule('node-fetch');
|
||||||
const loadFetchPolyfill = eval(`globalThis.fetch = require('node-fetch')`);
|
|
||||||
loadFetchPolyfill();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +122,6 @@ export class WebRequest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const finalResponse: Response = await doRequest(allUrls[usedUrlIndex]);
|
const finalResponse: Response = await doRequest(allUrls[usedUrlIndex]);
|
||||||
console.log(finalResponse);
|
|
||||||
return finalResponse;
|
return finalResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartenv from '@pushrocks/smartenv';
|
||||||
|
|
||||||
export { smartdelay };
|
export { smartdelay, smartenv };
|
||||||
|
Reference in New Issue
Block a user