node-csfd-api 3.0.0-next.3 → 3.0.0-next.5
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/cjs/fetchers/index.js +7 -5
- package/esm/fetchers/index.js +6 -1
- package/package.json +2 -2
package/cjs/fetchers/index.js
CHANGED
|
@@ -8,12 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
11
|
+
var _a;
|
|
14
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
13
|
exports.fetchPage = void 0;
|
|
16
|
-
|
|
14
|
+
// Check if `fetch` is available in global scope (nodejs 18+) or in window (browser)
|
|
15
|
+
// If not, use cross-fetch polyfill
|
|
16
|
+
const cross_fetch_1 = require("cross-fetch");
|
|
17
|
+
const fetch = (_a = ((typeof global === 'object' && global.fetch) ||
|
|
18
|
+
(typeof window !== 'undefined' && window.fetch))) !== null && _a !== void 0 ? _a : cross_fetch_1.fetch;
|
|
17
19
|
const USER_AGENTS = [
|
|
18
20
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
|
19
21
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1',
|
|
@@ -25,7 +27,7 @@ const headers = {
|
|
|
25
27
|
};
|
|
26
28
|
const fetchPage = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
29
|
try {
|
|
28
|
-
const response = yield (
|
|
30
|
+
const response = yield fetch(url, { headers });
|
|
29
31
|
if (response.status >= 400 && response.status < 600) {
|
|
30
32
|
throw new Error(`node-csfd-api: Bad response ${response.status} for url: ${url}`);
|
|
31
33
|
}
|
package/esm/fetchers/index.js
CHANGED
|
@@ -7,7 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
// Check if `fetch` is available in global scope (nodejs 18+) or in window (browser)
|
|
12
|
+
// If not, use cross-fetch polyfill
|
|
13
|
+
import { fetch as crossFetch } from 'cross-fetch';
|
|
14
|
+
const fetch = (_a = ((typeof global === 'object' && global.fetch) ||
|
|
15
|
+
(typeof window !== 'undefined' && window.fetch))) !== null && _a !== void 0 ? _a : crossFetch;
|
|
11
16
|
const USER_AGENTS = [
|
|
12
17
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
|
13
18
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.5",
|
|
4
4
|
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"author": "BART! <bart@bartweb.cz>",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"lint": "eslint ./src/**/**/* --fix",
|
|
16
16
|
"test": "jest",
|
|
17
17
|
"fix-paths": "yarn json -I -f ./dist/package.json -e \"this.module='./esm/index.js';this.main='./cjs/index.js';this.types='./types/index.d.ts'\"",
|
|
18
|
-
"publish:next": "yarn && yarn build && yarn test --coverage true && cd dist && npm publish --tag
|
|
18
|
+
"publish:next": "yarn && yarn build && yarn test --coverage true && cd dist && npm publish --tag next",
|
|
19
19
|
"postversion": "git push && git push --follow-tags",
|
|
20
20
|
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
21
21
|
"prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
|