Compare commits

...

6 Commits

Author SHA1 Message Date
1453abcd5f 2.0.10 2020-07-08 02:15:14 +00:00
99afb573cd fix(core): update 2020-07-08 02:15:14 +00:00
94360ff1da 2.0.9 2020-06-25 23:40:30 +00:00
3fd2075c26 fix(core): update 2020-06-25 23:40:29 +00:00
71782672d7 2.0.8 2020-06-25 23:35:00 +00:00
9dec755ea5 fix(core): update 2020-06-25 23:34:59 +00:00
6 changed files with 6800 additions and 873 deletions

7624
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/webrequest",
"version": "2.0.7",
"version": "2.0.10",
"private": false,
"description": "securely request from browsers",
"main": "dist_ts/index.js",
@ -9,21 +9,23 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"build": "(tsbuild --web && tsbundle npm)",
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.24",
"@gitzone/tstest": "^1.0.33",
"@pushrocks/smartexpress": "^3.0.72",
"@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^14.0.14",
"node-fetch": "^2.6.0",
"@gitzone/tsbundle": "^1.0.72",
"@gitzone/tstest": "^1.0.38",
"@pushrocks/smartexpress": "^3.0.73",
"@pushrocks/tapbundle": "^3.2.7",
"@types/node": "^14.0.19",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/smartdelay": "^2.0.9"
"@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartenv": "^4.0.10",
"node-fetch": "^2.6.0"
},
"files": [
"ts/**/*",
@ -36,5 +38,8 @@
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

View File

@ -27,7 +27,6 @@ Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20W
Use TypeScript for best in class intellisense.
## Contribution
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
View 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();

View File

@ -6,11 +6,10 @@ import * as plugins from './webrequest.plugins';
export class WebRequest {
private static polyfillsLoaded = false;
public static loadNeededPolyfills() {
if (!this.polyfillsLoaded) {
const smartenv = new plugins.smartenv.Smartenv();
if (!smartenv.isBrowser && !this.polyfillsLoaded) {
this.polyfillsLoaded = true;
// tslint:disable-next-line: no-eval
const loadFetchPolyfill = eval(`globalThis.fetch = require('node-fetch')`);
loadFetchPolyfill();
globalThis.fetch = smartenv.getSafeNodeModule('node-fetch');
}
}
@ -123,7 +122,6 @@ export class WebRequest {
};
const finalResponse: Response = await doRequest(allUrls[usedUrlIndex]);
console.log(finalResponse);
return finalResponse;
}
}

View File

@ -1,3 +1,4 @@
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartenv from '@pushrocks/smartenv';
export { smartdelay };
export { smartdelay, smartenv };