rezo 1.0.22 → 1.0.24

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/dist/core/rezo.js CHANGED
@@ -328,13 +328,59 @@ export class Rezo {
328
328
  }
329
329
  }
330
330
  const executeWithHooks = async () => {
331
- const mergedDefaults = this._proxyManager ? { ...defaultOptions, _proxyManager: this._proxyManager } : defaultOptions;
332
- const response = await this.adapter(options, mergedDefaults, jar);
331
+ const startTime = Date.now();
332
+ const beforeRequestContext = {
333
+ retryCount: 0,
334
+ isRedirect: false,
335
+ redirectCount: 0,
336
+ startTime
337
+ };
338
+ if (requestHooks.beforeRequest.length > 0) {
339
+ for (const hook of requestHooks.beforeRequest) {
340
+ const result = await hook(options, beforeRequestContext);
341
+ if (result && typeof result === "object" && "status" in result) {
342
+ return result;
343
+ }
344
+ }
345
+ }
346
+ const mergedDefaults = {
347
+ ...defaultOptions,
348
+ _proxyManager: this._proxyManager || null,
349
+ _hooks: requestHooks
350
+ };
351
+ let response;
352
+ try {
353
+ response = await this.adapter(options, mergedDefaults, jar);
354
+ } catch (error) {
355
+ if (requestHooks.beforeError.length > 0) {
356
+ let transformedError = error;
357
+ for (const hook of requestHooks.beforeError) {
358
+ transformedError = await hook(transformedError);
359
+ }
360
+ throw transformedError;
361
+ }
362
+ throw error;
363
+ }
333
364
  if (jar.cookieFile) {
334
365
  try {
335
366
  jar.saveToFile();
336
367
  } catch (e) {}
337
368
  }
369
+ if (requestHooks.beforeCache.length > 0 && response && typeof response === "object" && "data" in response) {
370
+ const cacheEvent = {
371
+ url: fullUrl,
372
+ status: response.status,
373
+ headers: response.headers,
374
+ cacheKey: `${method}:${fullUrl}`,
375
+ isCacheable: ["GET", "HEAD"].includes(method) && response.status >= 200 && response.status < 300
376
+ };
377
+ for (const hook of requestHooks.beforeCache) {
378
+ const shouldCache = hook(cacheEvent);
379
+ if (shouldCache === false) {
380
+ return response;
381
+ }
382
+ }
383
+ }
338
384
  if (this.responseCache && cacheMode !== "no-store" && response && typeof response === "object" && "data" in response && !(options._isStream || options._isDownload || options._isUpload)) {
339
385
  this.responseCache.set(method, fullUrl, response, requestHeaders);
340
386
  }
@@ -1,5 +1,5 @@
1
- const _mod_svsktw = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_svsktw.Crawler;;
3
- const _mod_hcjbxq = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_hcjbxq.CrawlerOptions;
5
- exports.Domain = _mod_hcjbxq.Domain;;
1
+ const _mod_svweel = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_svweel.Crawler;;
3
+ const _mod_vyrtez = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_vyrtez.CrawlerOptions;
5
+ exports.Domain = _mod_vyrtez.Domain;;
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- const _mod_hre6ec = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_hre6ec.Rezo;
3
- exports.createRezoInstance = _mod_hre6ec.createRezoInstance;
4
- exports.createDefaultInstance = _mod_hre6ec.createDefaultInstance;;
5
- const _mod_wwq78e = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_wwq78e.RezoError;
7
- exports.RezoErrorCode = _mod_wwq78e.RezoErrorCode;;
8
- const _mod_5wpolq = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_5wpolq.RezoHeaders;;
10
- const _mod_yody95 = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_yody95.RezoFormData;;
12
- const _mod_f843yl = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_f843yl.RezoCookieJar;
14
- exports.Cookie = _mod_f843yl.Cookie;;
15
- const _mod_8zpp5z = require('./core/hooks.cjs');
16
- exports.createDefaultHooks = _mod_8zpp5z.createDefaultHooks;
17
- exports.mergeHooks = _mod_8zpp5z.mergeHooks;;
18
- const _mod_60gu5s = require('./proxy/manager.cjs');
19
- exports.ProxyManager = _mod_60gu5s.ProxyManager;;
20
- const _mod_zuny9f = require('./queue/index.cjs');
21
- exports.RezoQueue = _mod_zuny9f.RezoQueue;
22
- exports.HttpQueue = _mod_zuny9f.HttpQueue;
23
- exports.Priority = _mod_zuny9f.Priority;
24
- exports.HttpMethodPriority = _mod_zuny9f.HttpMethodPriority;;
1
+ const _mod_709l2k = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_709l2k.Rezo;
3
+ exports.createRezoInstance = _mod_709l2k.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_709l2k.createDefaultInstance;;
5
+ const _mod_4pfhn3 = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_4pfhn3.RezoError;
7
+ exports.RezoErrorCode = _mod_4pfhn3.RezoErrorCode;;
8
+ const _mod_c4cz93 = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_c4cz93.RezoHeaders;;
10
+ const _mod_jughps = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_jughps.RezoFormData;;
12
+ const _mod_hiuujv = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_hiuujv.RezoCookieJar;
14
+ exports.Cookie = _mod_hiuujv.Cookie;;
15
+ const _mod_0o40uv = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_0o40uv.createDefaultHooks;
17
+ exports.mergeHooks = _mod_0o40uv.mergeHooks;;
18
+ const _mod_cvs7bl = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_cvs7bl.ProxyManager;;
20
+ const _mod_9w2rwz = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_9w2rwz.RezoQueue;
22
+ exports.HttpQueue = _mod_9w2rwz.HttpQueue;
23
+ exports.Priority = _mod_9w2rwz.Priority;
24
+ exports.HttpMethodPriority = _mod_9w2rwz.HttpMethodPriority;;
25
25
  const { RezoError } = require('./errors/rezo-error.cjs');
26
26
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
27
27
  const Cancel = exports.Cancel = RezoError;
@@ -1,36 +1,36 @@
1
- const _mod_yuwab2 = require('./crawler.cjs');
2
- exports.Crawler = _mod_yuwab2.Crawler;;
3
- const _mod_ke9y75 = require('./crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_ke9y75.CrawlerOptions;;
5
- const _mod_rmkqk2 = require('../cache/file-cacher.cjs');
6
- exports.FileCacher = _mod_rmkqk2.FileCacher;;
7
- const _mod_qvrjfw = require('../cache/url-store.cjs');
8
- exports.UrlStore = _mod_qvrjfw.UrlStore;;
9
- const _mod_6wo293 = require('./addon/oxylabs/index.cjs');
10
- exports.Oxylabs = _mod_6wo293.Oxylabs;;
11
- const _mod_5jzs00 = require('./addon/oxylabs/options.cjs');
12
- exports.OXYLABS_BROWSER_TYPES = _mod_5jzs00.OXYLABS_BROWSER_TYPES;
13
- exports.OXYLABS_COMMON_LOCALES = _mod_5jzs00.OXYLABS_COMMON_LOCALES;
14
- exports.OXYLABS_COMMON_GEO_LOCATIONS = _mod_5jzs00.OXYLABS_COMMON_GEO_LOCATIONS;
15
- exports.OXYLABS_US_STATES = _mod_5jzs00.OXYLABS_US_STATES;
16
- exports.OXYLABS_EUROPEAN_COUNTRIES = _mod_5jzs00.OXYLABS_EUROPEAN_COUNTRIES;
17
- exports.OXYLABS_ASIAN_COUNTRIES = _mod_5jzs00.OXYLABS_ASIAN_COUNTRIES;
18
- exports.getRandomOxylabsBrowserType = _mod_5jzs00.getRandomBrowserType;
19
- exports.getRandomOxylabsLocale = _mod_5jzs00.getRandomLocale;
20
- exports.getRandomOxylabsGeoLocation = _mod_5jzs00.getRandomGeoLocation;;
21
- const _mod_xzulah = require('./addon/decodo/index.cjs');
22
- exports.Decodo = _mod_xzulah.Decodo;;
23
- const _mod_96s3w3 = require('./addon/decodo/options.cjs');
24
- exports.DECODO_DEVICE_TYPES = _mod_96s3w3.DECODO_DEVICE_TYPES;
25
- exports.DECODO_HEADLESS_MODES = _mod_96s3w3.DECODO_HEADLESS_MODES;
26
- exports.DECODO_COMMON_LOCALES = _mod_96s3w3.DECODO_COMMON_LOCALES;
27
- exports.DECODO_COMMON_COUNTRIES = _mod_96s3w3.DECODO_COMMON_COUNTRIES;
28
- exports.DECODO_EUROPEAN_COUNTRIES = _mod_96s3w3.DECODO_EUROPEAN_COUNTRIES;
29
- exports.DECODO_ASIAN_COUNTRIES = _mod_96s3w3.DECODO_ASIAN_COUNTRIES;
30
- exports.DECODO_US_STATES = _mod_96s3w3.DECODO_US_STATES;
31
- exports.DECODO_COMMON_CITIES = _mod_96s3w3.DECODO_COMMON_CITIES;
32
- exports.getRandomDecodoDeviceType = _mod_96s3w3.getRandomDeviceType;
33
- exports.getRandomDecodoLocale = _mod_96s3w3.getRandomLocale;
34
- exports.getRandomDecodoCountry = _mod_96s3w3.getRandomCountry;
35
- exports.getRandomDecodoCity = _mod_96s3w3.getRandomCity;
36
- exports.generateDecodoSessionId = _mod_96s3w3.generateSessionId;;
1
+ const _mod_2h7zi4 = require('./crawler.cjs');
2
+ exports.Crawler = _mod_2h7zi4.Crawler;;
3
+ const _mod_hq5ai3 = require('./crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_hq5ai3.CrawlerOptions;;
5
+ const _mod_802owd = require('../cache/file-cacher.cjs');
6
+ exports.FileCacher = _mod_802owd.FileCacher;;
7
+ const _mod_1pspqz = require('../cache/url-store.cjs');
8
+ exports.UrlStore = _mod_1pspqz.UrlStore;;
9
+ const _mod_rk4fkq = require('./addon/oxylabs/index.cjs');
10
+ exports.Oxylabs = _mod_rk4fkq.Oxylabs;;
11
+ const _mod_1mm6ev = require('./addon/oxylabs/options.cjs');
12
+ exports.OXYLABS_BROWSER_TYPES = _mod_1mm6ev.OXYLABS_BROWSER_TYPES;
13
+ exports.OXYLABS_COMMON_LOCALES = _mod_1mm6ev.OXYLABS_COMMON_LOCALES;
14
+ exports.OXYLABS_COMMON_GEO_LOCATIONS = _mod_1mm6ev.OXYLABS_COMMON_GEO_LOCATIONS;
15
+ exports.OXYLABS_US_STATES = _mod_1mm6ev.OXYLABS_US_STATES;
16
+ exports.OXYLABS_EUROPEAN_COUNTRIES = _mod_1mm6ev.OXYLABS_EUROPEAN_COUNTRIES;
17
+ exports.OXYLABS_ASIAN_COUNTRIES = _mod_1mm6ev.OXYLABS_ASIAN_COUNTRIES;
18
+ exports.getRandomOxylabsBrowserType = _mod_1mm6ev.getRandomBrowserType;
19
+ exports.getRandomOxylabsLocale = _mod_1mm6ev.getRandomLocale;
20
+ exports.getRandomOxylabsGeoLocation = _mod_1mm6ev.getRandomGeoLocation;;
21
+ const _mod_yfyj7o = require('./addon/decodo/index.cjs');
22
+ exports.Decodo = _mod_yfyj7o.Decodo;;
23
+ const _mod_ixh6o9 = require('./addon/decodo/options.cjs');
24
+ exports.DECODO_DEVICE_TYPES = _mod_ixh6o9.DECODO_DEVICE_TYPES;
25
+ exports.DECODO_HEADLESS_MODES = _mod_ixh6o9.DECODO_HEADLESS_MODES;
26
+ exports.DECODO_COMMON_LOCALES = _mod_ixh6o9.DECODO_COMMON_LOCALES;
27
+ exports.DECODO_COMMON_COUNTRIES = _mod_ixh6o9.DECODO_COMMON_COUNTRIES;
28
+ exports.DECODO_EUROPEAN_COUNTRIES = _mod_ixh6o9.DECODO_EUROPEAN_COUNTRIES;
29
+ exports.DECODO_ASIAN_COUNTRIES = _mod_ixh6o9.DECODO_ASIAN_COUNTRIES;
30
+ exports.DECODO_US_STATES = _mod_ixh6o9.DECODO_US_STATES;
31
+ exports.DECODO_COMMON_CITIES = _mod_ixh6o9.DECODO_COMMON_CITIES;
32
+ exports.getRandomDecodoDeviceType = _mod_ixh6o9.getRandomDeviceType;
33
+ exports.getRandomDecodoLocale = _mod_ixh6o9.getRandomLocale;
34
+ exports.getRandomDecodoCountry = _mod_ixh6o9.getRandomCountry;
35
+ exports.getRandomDecodoCity = _mod_ixh6o9.getRandomCity;
36
+ exports.generateDecodoSessionId = _mod_ixh6o9.generateSessionId;;
@@ -1,8 +1,8 @@
1
1
  const { SocksProxyAgent: RezoSocksProxy } = require("socks-proxy-agent");
2
2
  const { HttpsProxyAgent: RezoHttpsSocks } = require("https-proxy-agent");
3
3
  const { HttpProxyAgent: RezoHttpSocks } = require("http-proxy-agent");
4
- const _mod_1jfmwa = require('./manager.cjs');
5
- exports.ProxyManager = _mod_1jfmwa.ProxyManager;;
4
+ const _mod_za54yh = require('./manager.cjs');
5
+ exports.ProxyManager = _mod_za54yh.ProxyManager;;
6
6
  function createOptions(uri, opts) {
7
7
  if (uri instanceof URL || typeof uri === "string") {
8
8
  return {
@@ -1,8 +1,8 @@
1
- const _mod_1rrd9x = require('./queue.cjs');
2
- exports.RezoQueue = _mod_1rrd9x.RezoQueue;;
3
- const _mod_2zy0yg = require('./http-queue.cjs');
4
- exports.HttpQueue = _mod_2zy0yg.HttpQueue;
5
- exports.extractDomain = _mod_2zy0yg.extractDomain;;
6
- const _mod_5lfu3b = require('./types.cjs');
7
- exports.Priority = _mod_5lfu3b.Priority;
8
- exports.HttpMethodPriority = _mod_5lfu3b.HttpMethodPriority;;
1
+ const _mod_46s3ou = require('./queue.cjs');
2
+ exports.RezoQueue = _mod_46s3ou.RezoQueue;;
3
+ const _mod_4wb7cj = require('./http-queue.cjs');
4
+ exports.HttpQueue = _mod_4wb7cj.HttpQueue;
5
+ exports.extractDomain = _mod_4wb7cj.extractDomain;;
6
+ const _mod_6ok396 = require('./types.cjs');
7
+ exports.Priority = _mod_6ok396.Priority;
8
+ exports.HttpMethodPriority = _mod_6ok396.HttpMethodPriority;;
@@ -171,9 +171,6 @@ function setSignal() {
171
171
  if (this.timeout && typeof this.timeout === "number" && this.timeout > 100) {
172
172
  const controller = new AbortController;
173
173
  const timer = setTimeout(() => controller.abort(), this.timeout);
174
- if (typeof timer === "object" && "unref" in timer) {
175
- timer.unref();
176
- }
177
174
  this.timeoutClearInstanse = timer;
178
175
  this.signal = controller.signal;
179
176
  }
@@ -171,9 +171,6 @@ function setSignal() {
171
171
  if (this.timeout && typeof this.timeout === "number" && this.timeout > 100) {
172
172
  const controller = new AbortController;
173
173
  const timer = setTimeout(() => controller.abort(), this.timeout);
174
- if (typeof timer === "object" && "unref" in timer) {
175
- timer.unref();
176
- }
177
174
  this.timeoutClearInstanse = timer;
178
175
  this.signal = controller.signal;
179
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rezo",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Lightning-fast, enterprise-grade HTTP client for modern JavaScript. Full HTTP/2 support, intelligent cookie management, multiple adapters (HTTP, Fetch, cURL, XHR), streaming, proxy support (HTTP/HTTPS/SOCKS), and cross-environment compatibility.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",