rezo 1.0.12 → 1.0.14
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/adapters/curl.cjs +89 -22
- package/dist/adapters/curl.js +89 -22
- package/dist/adapters/entries/curl.d.ts +8 -0
- package/dist/adapters/entries/fetch.d.ts +8 -0
- package/dist/adapters/entries/http.d.ts +8 -0
- package/dist/adapters/entries/http2.d.ts +8 -0
- package/dist/adapters/entries/react-native.d.ts +8 -0
- package/dist/adapters/entries/xhr.d.ts +8 -0
- package/dist/adapters/fetch.cjs +128 -58
- package/dist/adapters/fetch.js +128 -58
- package/dist/adapters/http.cjs +43 -13
- package/dist/adapters/http.js +43 -13
- package/dist/adapters/http2.cjs +136 -58
- package/dist/adapters/http2.js +136 -58
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/core/rezo.cjs +27 -6
- package/dist/core/rezo.js +27 -6
- package/dist/crawler.d.ts +8 -0
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +8 -0
- package/dist/platform/browser.d.ts +8 -0
- package/dist/platform/bun.d.ts +8 -0
- package/dist/platform/deno.d.ts +8 -0
- package/dist/platform/node.d.ts +8 -0
- package/dist/platform/react-native.d.ts +8 -0
- package/dist/platform/worker.d.ts +8 -0
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/queue/index.cjs +8 -8
- package/dist/responses/buildError.cjs +5 -1
- package/dist/responses/buildError.js +5 -1
- package/dist/responses/buildResponse.cjs +2 -0
- package/dist/responses/buildResponse.js +2 -0
- package/dist/utils/compression.cjs +6 -6
- package/dist/utils/compression.js +6 -6
- package/dist/utils/form-data.cjs +64 -7
- package/dist/utils/form-data.js +64 -7
- package/dist/utils/headers.cjs +17 -0
- package/dist/utils/headers.js +17 -1
- package/dist/utils/http-config.cjs +39 -4
- package/dist/utils/http-config.js +39 -4
- package/package.json +1 -1
package/dist/adapters/http2.js
CHANGED
|
@@ -4,14 +4,15 @@ import { URL } from "node:url";
|
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
import { RezoError } from '../errors/rezo-error.js';
|
|
6
6
|
import { buildSmartError, buildDecompressionError, builErrorFromResponse, buildDownloadError } from '../responses/buildError.js';
|
|
7
|
-
import {
|
|
7
|
+
import { RezoCookieJar } from '../utils/cookies.js';
|
|
8
8
|
import RezoFormData from '../utils/form-data.js';
|
|
9
9
|
import { getDefaultConfig, prepareHTTPOptions } from '../utils/http-config.js';
|
|
10
|
-
import { RezoHeaders } from '../utils/headers.js';
|
|
10
|
+
import { RezoHeaders, sanitizeHttp2Headers } from '../utils/headers.js';
|
|
11
11
|
import { RezoURLSearchParams } from '../utils/data-operations.js';
|
|
12
12
|
import { StreamResponse } from '../responses/stream.js';
|
|
13
13
|
import { DownloadResponse } from '../responses/download.js';
|
|
14
14
|
import { UploadResponse } from '../responses/upload.js';
|
|
15
|
+
import { CompressionUtil } from '../utils/compression.js';
|
|
15
16
|
import { isSameDomain, RezoPerformance } from '../utils/tools.js';
|
|
16
17
|
import { ResponseCache } from '../cache/response-cache.js';
|
|
17
18
|
let zstdDecompressSync = null;
|
|
@@ -142,15 +143,14 @@ class Http2SessionPool {
|
|
|
142
143
|
reject(new Error(`HTTP/2 connection timeout after ${timeout}ms`));
|
|
143
144
|
}
|
|
144
145
|
}, timeout) : null;
|
|
146
|
+
if (timeoutId && typeof timeoutId === "object" && "unref" in timeoutId) {
|
|
147
|
+
timeoutId.unref();
|
|
148
|
+
}
|
|
145
149
|
session.on("connect", () => {
|
|
146
150
|
if (!settled) {
|
|
147
151
|
settled = true;
|
|
148
152
|
if (timeoutId)
|
|
149
153
|
clearTimeout(timeoutId);
|
|
150
|
-
const socket = session.socket;
|
|
151
|
-
if (socket && typeof socket.unref === "function") {
|
|
152
|
-
socket.unref();
|
|
153
|
-
}
|
|
154
154
|
resolve(session);
|
|
155
155
|
}
|
|
156
156
|
});
|
|
@@ -170,6 +170,12 @@ class Http2SessionPool {
|
|
|
170
170
|
if (entry) {
|
|
171
171
|
entry.refCount = Math.max(0, entry.refCount - 1);
|
|
172
172
|
entry.lastUsed = Date.now();
|
|
173
|
+
if (entry.refCount === 0) {
|
|
174
|
+
const socket = entry.session.socket;
|
|
175
|
+
if (socket && typeof socket.unref === "function") {
|
|
176
|
+
socket.unref();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
closeSession(url) {
|
|
@@ -275,38 +281,66 @@ function updateCookies(config, headers, url) {
|
|
|
275
281
|
if (!setCookieHeaders)
|
|
276
282
|
return;
|
|
277
283
|
const cookieHeaderArray = Array.isArray(setCookieHeaders) ? setCookieHeaders : [setCookieHeaders];
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
setCookiesString: []
|
|
285
|
-
};
|
|
284
|
+
if (cookieHeaderArray.length === 0)
|
|
285
|
+
return;
|
|
286
|
+
const jar = new RezoCookieJar;
|
|
287
|
+
jar.setCookiesSync(cookieHeaderArray, url);
|
|
288
|
+
if (config.enableCookieJar && config.cookieJar) {
|
|
289
|
+
config.cookieJar.setCookiesSync(cookieHeaderArray, url);
|
|
286
290
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
291
|
+
const cookies = jar.cookies();
|
|
292
|
+
cookies.setCookiesString = cookieHeaderArray;
|
|
293
|
+
if (config.useCookies) {
|
|
294
|
+
const existingArray = config.responseCookies?.array || [];
|
|
295
|
+
for (const cookie of cookies.array) {
|
|
296
|
+
const existingIndex = existingArray.findIndex((c) => c.key === cookie.key && c.domain === cookie.domain);
|
|
297
|
+
if (existingIndex >= 0) {
|
|
298
|
+
existingArray[existingIndex] = cookie;
|
|
299
|
+
} else {
|
|
300
|
+
existingArray.push(cookie);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const mergedJar = new RezoCookieJar(existingArray, url);
|
|
304
|
+
config.responseCookies = mergedJar.cookies();
|
|
305
|
+
config.responseCookies.setCookiesString = cookieHeaderArray;
|
|
306
|
+
} else {
|
|
307
|
+
config.responseCookies = cookies;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function mergeRequestAndResponseCookies(config, responseCookies, url) {
|
|
311
|
+
const mergedCookiesArray = [];
|
|
312
|
+
const cookieKeyDomainMap = new Map;
|
|
313
|
+
if (config.requestCookies && config.requestCookies.length > 0) {
|
|
314
|
+
for (const cookie of config.requestCookies) {
|
|
315
|
+
const key = `${cookie.key}|${cookie.domain || ""}`;
|
|
316
|
+
mergedCookiesArray.push(cookie);
|
|
317
|
+
cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
|
|
304
318
|
}
|
|
305
319
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
320
|
+
for (const cookie of responseCookies.array) {
|
|
321
|
+
const key = `${cookie.key}|${cookie.domain || ""}`;
|
|
322
|
+
const existingIndex = cookieKeyDomainMap.get(key);
|
|
323
|
+
if (existingIndex !== undefined) {
|
|
324
|
+
mergedCookiesArray[existingIndex] = cookie;
|
|
325
|
+
} else {
|
|
326
|
+
mergedCookiesArray.push(cookie);
|
|
327
|
+
cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (mergedCookiesArray.length > 0) {
|
|
331
|
+
const mergedJar = new RezoCookieJar(mergedCookiesArray, url);
|
|
332
|
+
return mergedJar.cookies();
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
array: [],
|
|
336
|
+
serialized: [],
|
|
337
|
+
netscape: `# Netscape HTTP Cookie File
|
|
338
|
+
# This file was generated by Rezo HTTP client
|
|
339
|
+
# Based on uniqhtt cookie implementation
|
|
340
|
+
`,
|
|
341
|
+
string: "",
|
|
342
|
+
setCookiesString: []
|
|
343
|
+
};
|
|
310
344
|
}
|
|
311
345
|
export async function executeRequest(options, defaultOptions, jar) {
|
|
312
346
|
if (!options.responseType) {
|
|
@@ -484,6 +518,8 @@ async function executeHttp2Request(fetchOptions, config, options, perform, fs, s
|
|
|
484
518
|
if (fileName && fs && fs.existsSync(fileName)) {
|
|
485
519
|
fs.unlinkSync(fileName);
|
|
486
520
|
}
|
|
521
|
+
if (!config.errors)
|
|
522
|
+
config.errors = [];
|
|
487
523
|
config.errors.push({
|
|
488
524
|
attempt: config.retryAttempts + 1,
|
|
489
525
|
error: response,
|
|
@@ -524,6 +560,29 @@ async function executeHttp2Request(fetchOptions, config, options, perform, fs, s
|
|
|
524
560
|
if (statusOnNext === "success") {
|
|
525
561
|
return response;
|
|
526
562
|
}
|
|
563
|
+
if (statusOnNext === "error") {
|
|
564
|
+
const httpError = builErrorFromResponse(`Request failed with status code ${response.status}`, response, config, fetchOptions);
|
|
565
|
+
if (config.retry && statusCodes?.includes(response.status)) {
|
|
566
|
+
if (maxRetries > retries) {
|
|
567
|
+
retries++;
|
|
568
|
+
config.retryAttempts++;
|
|
569
|
+
config.errors.push({
|
|
570
|
+
attempt: config.retryAttempts,
|
|
571
|
+
error: httpError,
|
|
572
|
+
duration: perform.now()
|
|
573
|
+
});
|
|
574
|
+
perform.reset();
|
|
575
|
+
if (config.debug) {
|
|
576
|
+
console.log(`Request failed with status code ${response.status}, retrying...${retryDelay > 0 ? " in " + (incrementDelay ? retryDelay * retries : retryDelay) + "ms" : ""}`);
|
|
577
|
+
}
|
|
578
|
+
if (retryDelay > 0) {
|
|
579
|
+
await new Promise((resolve) => setTimeout(resolve, incrementDelay ? retryDelay * retries : retryDelay));
|
|
580
|
+
}
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
throw httpError;
|
|
585
|
+
}
|
|
527
586
|
if (statusOnNext === "redirect") {
|
|
528
587
|
const location = _stats.redirectUrl;
|
|
529
588
|
if (!location) {
|
|
@@ -620,6 +679,13 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
620
679
|
if (!headers["accept-encoding"]) {
|
|
621
680
|
headers["accept-encoding"] = "gzip, deflate, br";
|
|
622
681
|
}
|
|
682
|
+
if (body instanceof RezoFormData) {
|
|
683
|
+
headers["content-type"] = `multipart/form-data; boundary=${body.getBoundary()}`;
|
|
684
|
+
} else if (body instanceof FormData) {
|
|
685
|
+
const tempForm = await RezoFormData.fromNativeFormData(body);
|
|
686
|
+
headers["content-type"] = `multipart/form-data; boundary=${tempForm.getBoundary()}`;
|
|
687
|
+
fetchOptions._convertedFormData = tempForm;
|
|
688
|
+
}
|
|
623
689
|
const eventEmitter = streamResult || downloadResult || uploadResult;
|
|
624
690
|
if (eventEmitter && requestCount === 0) {
|
|
625
691
|
const startEvent = {
|
|
@@ -735,6 +801,25 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
735
801
|
config.timing.endTimestamp = Date.now();
|
|
736
802
|
config.timing.durationMs = performance.now() - timing.startTime;
|
|
737
803
|
config.timing.transferMs = timing.firstByteTime ? performance.now() - timing.firstByteTime : config.timing.durationMs;
|
|
804
|
+
if (!config.transfer) {
|
|
805
|
+
config.transfer = { requestSize: 0, responseSize: 0, headerSize: 0, bodySize: 0 };
|
|
806
|
+
}
|
|
807
|
+
if (config.transfer.requestSize === undefined) {
|
|
808
|
+
config.transfer.requestSize = 0;
|
|
809
|
+
}
|
|
810
|
+
if (config.transfer.requestSize === 0 && body) {
|
|
811
|
+
if (typeof body === "string") {
|
|
812
|
+
config.transfer.requestSize = Buffer.byteLength(body, "utf8");
|
|
813
|
+
} else if (body instanceof Buffer || body instanceof Uint8Array) {
|
|
814
|
+
config.transfer.requestSize = body.length;
|
|
815
|
+
} else if (body instanceof URLSearchParams || body instanceof RezoURLSearchParams) {
|
|
816
|
+
config.transfer.requestSize = Buffer.byteLength(body.toString(), "utf8");
|
|
817
|
+
} else if (body instanceof RezoFormData) {
|
|
818
|
+
config.transfer.requestSize = body.getLengthSync();
|
|
819
|
+
} else if (typeof body === "object") {
|
|
820
|
+
config.transfer.requestSize = Buffer.byteLength(JSON.stringify(body), "utf8");
|
|
821
|
+
}
|
|
822
|
+
}
|
|
738
823
|
config.transfer.bodySize = contentLengthCounter;
|
|
739
824
|
config.transfer.responseSize = contentLengthCounter;
|
|
740
825
|
(sessionPool || Http2SessionPool.getInstance()).releaseSession(url);
|
|
@@ -743,7 +828,7 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
743
828
|
data: "",
|
|
744
829
|
status,
|
|
745
830
|
statusText,
|
|
746
|
-
headers: new RezoHeaders(responseHeaders),
|
|
831
|
+
headers: new RezoHeaders(sanitizeHttp2Headers(responseHeaders)),
|
|
747
832
|
cookies: config.responseCookies || { array: [], serialized: [], netscape: "", string: "", setCookiesString: [] },
|
|
748
833
|
config,
|
|
749
834
|
contentType: responseHeaders["content-type"],
|
|
@@ -756,14 +841,14 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
756
841
|
}
|
|
757
842
|
let responseBody = Buffer.concat(chunks);
|
|
758
843
|
const contentEncoding = responseHeaders["content-encoding"];
|
|
759
|
-
if (contentEncoding && contentLengthCounter > 0) {
|
|
844
|
+
if (contentEncoding && contentLengthCounter > 0 && CompressionUtil.shouldDecompress(contentEncoding, config)) {
|
|
760
845
|
try {
|
|
761
846
|
const decompressed = await decompressBuffer(responseBody, contentEncoding);
|
|
762
847
|
responseBody = decompressed;
|
|
763
848
|
} catch (err) {
|
|
764
849
|
const error = buildDecompressionError({
|
|
765
850
|
statusCode: status,
|
|
766
|
-
headers: responseHeaders,
|
|
851
|
+
headers: sanitizeHttp2Headers(responseHeaders),
|
|
767
852
|
contentType: responseHeaders["content-type"],
|
|
768
853
|
contentLength: String(contentLengthCounter),
|
|
769
854
|
cookies: config.responseCookies?.setCookiesString || [],
|
|
@@ -803,24 +888,17 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
803
888
|
data = responseBody.toString("utf-8");
|
|
804
889
|
}
|
|
805
890
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
data
|
|
812
|
-
}, config, fetchOptions);
|
|
813
|
-
_stats.statusOnNext = "error";
|
|
814
|
-
resolve(error);
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
_stats.statusOnNext = "success";
|
|
891
|
+
config.status = status;
|
|
892
|
+
config.statusText = statusText;
|
|
893
|
+
_stats.statusOnNext = status >= 400 ? "error" : "success";
|
|
894
|
+
const responseCookies = config.responseCookies || { array: [], serialized: [], netscape: "", string: "", setCookiesString: [] };
|
|
895
|
+
const mergedCookies = mergeRequestAndResponseCookies(config, responseCookies, url.href);
|
|
818
896
|
const finalResponse = {
|
|
819
897
|
data,
|
|
820
898
|
status,
|
|
821
899
|
statusText,
|
|
822
|
-
headers: new RezoHeaders(responseHeaders),
|
|
823
|
-
cookies:
|
|
900
|
+
headers: new RezoHeaders(sanitizeHttp2Headers(responseHeaders)),
|
|
901
|
+
cookies: mergedCookies,
|
|
824
902
|
config,
|
|
825
903
|
contentType,
|
|
826
904
|
contentLength: contentLengthCounter,
|
|
@@ -833,11 +911,11 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
833
911
|
const downloadFinishEvent = {
|
|
834
912
|
status,
|
|
835
913
|
statusText,
|
|
836
|
-
headers: new RezoHeaders(responseHeaders),
|
|
914
|
+
headers: new RezoHeaders(sanitizeHttp2Headers(responseHeaders)),
|
|
837
915
|
contentType,
|
|
838
916
|
contentLength: responseBody.length,
|
|
839
917
|
finalUrl: url.href,
|
|
840
|
-
cookies:
|
|
918
|
+
cookies: mergedCookies,
|
|
841
919
|
urls: buildUrlTree(config, url.href),
|
|
842
920
|
fileName: config.fileName,
|
|
843
921
|
fileSize: responseBody.length,
|
|
@@ -858,7 +936,7 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
858
936
|
} catch (err) {
|
|
859
937
|
const error = buildDownloadError({
|
|
860
938
|
statusCode: status,
|
|
861
|
-
headers: responseHeaders,
|
|
939
|
+
headers: sanitizeHttp2Headers(responseHeaders),
|
|
862
940
|
contentType,
|
|
863
941
|
contentLength: String(contentLengthCounter),
|
|
864
942
|
cookies: config.responseCookies?.setCookiesString || [],
|
|
@@ -878,7 +956,7 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
878
956
|
const streamFinishEvent = {
|
|
879
957
|
status,
|
|
880
958
|
statusText,
|
|
881
|
-
headers: new RezoHeaders(responseHeaders),
|
|
959
|
+
headers: new RezoHeaders(sanitizeHttp2Headers(responseHeaders)),
|
|
882
960
|
contentType,
|
|
883
961
|
contentLength: contentLengthCounter,
|
|
884
962
|
finalUrl: url.href,
|
|
@@ -904,7 +982,7 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
904
982
|
response: {
|
|
905
983
|
status,
|
|
906
984
|
statusText,
|
|
907
|
-
headers: new RezoHeaders(responseHeaders),
|
|
985
|
+
headers: new RezoHeaders(sanitizeHttp2Headers(responseHeaders)),
|
|
908
986
|
data,
|
|
909
987
|
contentType,
|
|
910
988
|
contentLength: contentLengthCounter
|
|
@@ -949,7 +1027,7 @@ async function executeHttp2Stream(config, fetchOptions, requestCount, timing, _s
|
|
|
949
1027
|
body.pipe(req);
|
|
950
1028
|
return;
|
|
951
1029
|
} else {
|
|
952
|
-
const form = await RezoFormData.fromNativeFormData(body);
|
|
1030
|
+
const form = fetchOptions._convertedFormData || await RezoFormData.fromNativeFormData(body);
|
|
953
1031
|
form.pipe(req);
|
|
954
1032
|
return;
|
|
955
1033
|
}
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.detectRuntime =
|
|
3
|
-
exports.getAdapterCapabilities =
|
|
4
|
-
exports.buildAdapterContext =
|
|
5
|
-
exports.getAvailableAdapters =
|
|
6
|
-
exports.selectAdapter =
|
|
1
|
+
const _mod_wby0uw = require('./picker.cjs');
|
|
2
|
+
exports.detectRuntime = _mod_wby0uw.detectRuntime;
|
|
3
|
+
exports.getAdapterCapabilities = _mod_wby0uw.getAdapterCapabilities;
|
|
4
|
+
exports.buildAdapterContext = _mod_wby0uw.buildAdapterContext;
|
|
5
|
+
exports.getAvailableAdapters = _mod_wby0uw.getAvailableAdapters;
|
|
6
|
+
exports.selectAdapter = _mod_wby0uw.selectAdapter;;
|
package/dist/cache/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.LRUCache =
|
|
3
|
-
const
|
|
4
|
-
exports.DNSCache =
|
|
5
|
-
exports.getGlobalDNSCache =
|
|
6
|
-
exports.resetGlobalDNSCache =
|
|
7
|
-
const
|
|
8
|
-
exports.ResponseCache =
|
|
9
|
-
exports.normalizeResponseCacheConfig =
|
|
10
|
-
const
|
|
11
|
-
exports.FileCacher =
|
|
12
|
-
const
|
|
13
|
-
exports.UrlStore =
|
|
1
|
+
const _mod_hi5yx4 = require('./lru-cache.cjs');
|
|
2
|
+
exports.LRUCache = _mod_hi5yx4.LRUCache;;
|
|
3
|
+
const _mod_xvsb8i = require('./dns-cache.cjs');
|
|
4
|
+
exports.DNSCache = _mod_xvsb8i.DNSCache;
|
|
5
|
+
exports.getGlobalDNSCache = _mod_xvsb8i.getGlobalDNSCache;
|
|
6
|
+
exports.resetGlobalDNSCache = _mod_xvsb8i.resetGlobalDNSCache;;
|
|
7
|
+
const _mod_gble7l = require('./response-cache.cjs');
|
|
8
|
+
exports.ResponseCache = _mod_gble7l.ResponseCache;
|
|
9
|
+
exports.normalizeResponseCacheConfig = _mod_gble7l.normalizeResponseCacheConfig;;
|
|
10
|
+
const _mod_oq9kzw = require('./file-cacher.cjs');
|
|
11
|
+
exports.FileCacher = _mod_oq9kzw.FileCacher;;
|
|
12
|
+
const _mod_mhhavh = require('./url-store.cjs');
|
|
13
|
+
exports.UrlStore = _mod_mhhavh.UrlStore;;
|
package/dist/core/rezo.cjs
CHANGED
|
@@ -176,11 +176,18 @@ class Rezo {
|
|
|
176
176
|
}, this.defaults, this.jar);
|
|
177
177
|
};
|
|
178
178
|
postMultipart = async (url, data, options = {}) => {
|
|
179
|
-
|
|
179
|
+
let formData;
|
|
180
|
+
if (data instanceof RezoFormData) {
|
|
181
|
+
formData = data;
|
|
182
|
+
} else if (data instanceof FormData) {
|
|
183
|
+
formData = await RezoFormData.fromNativeFormData(data);
|
|
184
|
+
} else {
|
|
185
|
+
formData = RezoFormData.fromObject(data);
|
|
186
|
+
}
|
|
180
187
|
return this.executeRequest({
|
|
181
188
|
...options,
|
|
182
189
|
url,
|
|
183
|
-
formData
|
|
190
|
+
formData,
|
|
184
191
|
method: "POST"
|
|
185
192
|
}, this.defaults, this.jar);
|
|
186
193
|
};
|
|
@@ -217,11 +224,18 @@ class Rezo {
|
|
|
217
224
|
}, this.defaults, this.jar);
|
|
218
225
|
};
|
|
219
226
|
putMultipart = async (url, data, options = {}) => {
|
|
220
|
-
|
|
227
|
+
let formData;
|
|
228
|
+
if (data instanceof RezoFormData) {
|
|
229
|
+
formData = data;
|
|
230
|
+
} else if (data instanceof FormData) {
|
|
231
|
+
formData = await RezoFormData.fromNativeFormData(data);
|
|
232
|
+
} else {
|
|
233
|
+
formData = RezoFormData.fromObject(data);
|
|
234
|
+
}
|
|
221
235
|
return this.executeRequest({
|
|
222
236
|
...options,
|
|
223
237
|
url,
|
|
224
|
-
formData
|
|
238
|
+
formData,
|
|
225
239
|
method: "PUT"
|
|
226
240
|
}, this.defaults, this.jar);
|
|
227
241
|
};
|
|
@@ -258,11 +272,18 @@ class Rezo {
|
|
|
258
272
|
}, this.defaults, this.jar);
|
|
259
273
|
};
|
|
260
274
|
patchMultipart = async (url, data, options = {}) => {
|
|
261
|
-
|
|
275
|
+
let formData;
|
|
276
|
+
if (data instanceof RezoFormData) {
|
|
277
|
+
formData = data;
|
|
278
|
+
} else if (data instanceof FormData) {
|
|
279
|
+
formData = await RezoFormData.fromNativeFormData(data);
|
|
280
|
+
} else {
|
|
281
|
+
formData = RezoFormData.fromObject(data);
|
|
282
|
+
}
|
|
262
283
|
return this.executeRequest({
|
|
263
284
|
...options,
|
|
264
285
|
url,
|
|
265
|
-
formData
|
|
286
|
+
formData,
|
|
266
287
|
method: "PATCH"
|
|
267
288
|
}, this.defaults, this.jar);
|
|
268
289
|
};
|
package/dist/core/rezo.js
CHANGED
|
@@ -176,11 +176,18 @@ export class Rezo {
|
|
|
176
176
|
}, this.defaults, this.jar);
|
|
177
177
|
};
|
|
178
178
|
postMultipart = async (url, data, options = {}) => {
|
|
179
|
-
|
|
179
|
+
let formData;
|
|
180
|
+
if (data instanceof RezoFormData) {
|
|
181
|
+
formData = data;
|
|
182
|
+
} else if (data instanceof FormData) {
|
|
183
|
+
formData = await RezoFormData.fromNativeFormData(data);
|
|
184
|
+
} else {
|
|
185
|
+
formData = RezoFormData.fromObject(data);
|
|
186
|
+
}
|
|
180
187
|
return this.executeRequest({
|
|
181
188
|
...options,
|
|
182
189
|
url,
|
|
183
|
-
formData
|
|
190
|
+
formData,
|
|
184
191
|
method: "POST"
|
|
185
192
|
}, this.defaults, this.jar);
|
|
186
193
|
};
|
|
@@ -217,11 +224,18 @@ export class Rezo {
|
|
|
217
224
|
}, this.defaults, this.jar);
|
|
218
225
|
};
|
|
219
226
|
putMultipart = async (url, data, options = {}) => {
|
|
220
|
-
|
|
227
|
+
let formData;
|
|
228
|
+
if (data instanceof RezoFormData) {
|
|
229
|
+
formData = data;
|
|
230
|
+
} else if (data instanceof FormData) {
|
|
231
|
+
formData = await RezoFormData.fromNativeFormData(data);
|
|
232
|
+
} else {
|
|
233
|
+
formData = RezoFormData.fromObject(data);
|
|
234
|
+
}
|
|
221
235
|
return this.executeRequest({
|
|
222
236
|
...options,
|
|
223
237
|
url,
|
|
224
|
-
formData
|
|
238
|
+
formData,
|
|
225
239
|
method: "PUT"
|
|
226
240
|
}, this.defaults, this.jar);
|
|
227
241
|
};
|
|
@@ -258,11 +272,18 @@ export class Rezo {
|
|
|
258
272
|
}, this.defaults, this.jar);
|
|
259
273
|
};
|
|
260
274
|
patchMultipart = async (url, data, options = {}) => {
|
|
261
|
-
|
|
275
|
+
let formData;
|
|
276
|
+
if (data instanceof RezoFormData) {
|
|
277
|
+
formData = data;
|
|
278
|
+
} else if (data instanceof FormData) {
|
|
279
|
+
formData = await RezoFormData.fromNativeFormData(data);
|
|
280
|
+
} else {
|
|
281
|
+
formData = RezoFormData.fromObject(data);
|
|
282
|
+
}
|
|
262
283
|
return this.executeRequest({
|
|
263
284
|
...options,
|
|
264
285
|
url,
|
|
265
|
-
formData
|
|
286
|
+
formData,
|
|
266
287
|
method: "PATCH"
|
|
267
288
|
}, this.defaults, this.jar);
|
|
268
289
|
};
|
package/dist/crawler.d.ts
CHANGED
|
@@ -537,11 +537,19 @@ declare class RezoFormData extends NodeFormData {
|
|
|
537
537
|
toBuffer(): Buffer;
|
|
538
538
|
/**
|
|
539
539
|
* Create RezoFormData from object
|
|
540
|
+
* Properly handles nested objects by JSON.stringify-ing them
|
|
540
541
|
* @param {Record<string, any>} obj - Object to convert
|
|
541
542
|
* @param {Options} options - Optional RezoFormData options
|
|
542
543
|
* @returns {RezoFormData}
|
|
543
544
|
*/
|
|
544
545
|
static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
|
|
546
|
+
/**
|
|
547
|
+
* Helper to append a value to FormData with proper type handling
|
|
548
|
+
* @param {RezoFormData} formData - The form data to append to
|
|
549
|
+
* @param {string} key - The field name
|
|
550
|
+
* @param {any} value - The value to append
|
|
551
|
+
*/
|
|
552
|
+
private static appendValue;
|
|
545
553
|
/**
|
|
546
554
|
* Convert to URL query string
|
|
547
555
|
* Warning: File, Blob, and binary data will be omitted
|
package/dist/entries/crawler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Crawler =
|
|
3
|
-
const
|
|
4
|
-
exports.CrawlerOptions =
|
|
5
|
-
exports.Domain =
|
|
1
|
+
const _mod_6aofz8 = require('../plugin/crawler.cjs');
|
|
2
|
+
exports.Crawler = _mod_6aofz8.Crawler;;
|
|
3
|
+
const _mod_t23px8 = require('../plugin/crawler-options.cjs');
|
|
4
|
+
exports.CrawlerOptions = _mod_t23px8.CrawlerOptions;
|
|
5
|
+
exports.Domain = _mod_t23px8.Domain;;
|
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Rezo =
|
|
3
|
-
exports.createRezoInstance =
|
|
4
|
-
exports.createDefaultInstance =
|
|
5
|
-
const
|
|
6
|
-
exports.RezoError =
|
|
7
|
-
exports.RezoErrorCode =
|
|
8
|
-
const
|
|
9
|
-
exports.RezoHeaders =
|
|
10
|
-
const
|
|
11
|
-
exports.RezoFormData =
|
|
12
|
-
const
|
|
13
|
-
exports.RezoCookieJar =
|
|
14
|
-
exports.Cookie =
|
|
15
|
-
const
|
|
16
|
-
exports.createDefaultHooks =
|
|
17
|
-
exports.mergeHooks =
|
|
18
|
-
const
|
|
19
|
-
exports.ProxyManager =
|
|
20
|
-
const
|
|
21
|
-
exports.RezoQueue =
|
|
22
|
-
exports.HttpQueue =
|
|
23
|
-
exports.Priority =
|
|
24
|
-
exports.HttpMethodPriority =
|
|
1
|
+
const _mod_wsc945 = require('./core/rezo.cjs');
|
|
2
|
+
exports.Rezo = _mod_wsc945.Rezo;
|
|
3
|
+
exports.createRezoInstance = _mod_wsc945.createRezoInstance;
|
|
4
|
+
exports.createDefaultInstance = _mod_wsc945.createDefaultInstance;;
|
|
5
|
+
const _mod_pc2qgs = require('./errors/rezo-error.cjs');
|
|
6
|
+
exports.RezoError = _mod_pc2qgs.RezoError;
|
|
7
|
+
exports.RezoErrorCode = _mod_pc2qgs.RezoErrorCode;;
|
|
8
|
+
const _mod_wei4ay = require('./utils/headers.cjs');
|
|
9
|
+
exports.RezoHeaders = _mod_wei4ay.RezoHeaders;;
|
|
10
|
+
const _mod_honebj = require('./utils/form-data.cjs');
|
|
11
|
+
exports.RezoFormData = _mod_honebj.RezoFormData;;
|
|
12
|
+
const _mod_6yx1gr = require('./utils/cookies.cjs');
|
|
13
|
+
exports.RezoCookieJar = _mod_6yx1gr.RezoCookieJar;
|
|
14
|
+
exports.Cookie = _mod_6yx1gr.Cookie;;
|
|
15
|
+
const _mod_dyuwd6 = require('./core/hooks.cjs');
|
|
16
|
+
exports.createDefaultHooks = _mod_dyuwd6.createDefaultHooks;
|
|
17
|
+
exports.mergeHooks = _mod_dyuwd6.mergeHooks;;
|
|
18
|
+
const _mod_h49ine = require('./proxy/manager.cjs');
|
|
19
|
+
exports.ProxyManager = _mod_h49ine.ProxyManager;;
|
|
20
|
+
const _mod_psyc82 = require('./queue/index.cjs');
|
|
21
|
+
exports.RezoQueue = _mod_psyc82.RezoQueue;
|
|
22
|
+
exports.HttpQueue = _mod_psyc82.HttpQueue;
|
|
23
|
+
exports.Priority = _mod_psyc82.Priority;
|
|
24
|
+
exports.HttpMethodPriority = _mod_psyc82.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;
|
package/dist/index.d.ts
CHANGED
|
@@ -314,11 +314,19 @@ export declare class RezoFormData extends NodeFormData {
|
|
|
314
314
|
toBuffer(): Buffer;
|
|
315
315
|
/**
|
|
316
316
|
* Create RezoFormData from object
|
|
317
|
+
* Properly handles nested objects by JSON.stringify-ing them
|
|
317
318
|
* @param {Record<string, any>} obj - Object to convert
|
|
318
319
|
* @param {Options} options - Optional RezoFormData options
|
|
319
320
|
* @returns {RezoFormData}
|
|
320
321
|
*/
|
|
321
322
|
static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
|
|
323
|
+
/**
|
|
324
|
+
* Helper to append a value to FormData with proper type handling
|
|
325
|
+
* @param {RezoFormData} formData - The form data to append to
|
|
326
|
+
* @param {string} key - The field name
|
|
327
|
+
* @param {any} value - The value to append
|
|
328
|
+
*/
|
|
329
|
+
private static appendValue;
|
|
322
330
|
/**
|
|
323
331
|
* Convert to URL query string
|
|
324
332
|
* Warning: File, Blob, and binary data will be omitted
|
|
@@ -314,11 +314,19 @@ export declare class RezoFormData extends NodeFormData {
|
|
|
314
314
|
toBuffer(): Buffer;
|
|
315
315
|
/**
|
|
316
316
|
* Create RezoFormData from object
|
|
317
|
+
* Properly handles nested objects by JSON.stringify-ing them
|
|
317
318
|
* @param {Record<string, any>} obj - Object to convert
|
|
318
319
|
* @param {Options} options - Optional RezoFormData options
|
|
319
320
|
* @returns {RezoFormData}
|
|
320
321
|
*/
|
|
321
322
|
static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
|
|
323
|
+
/**
|
|
324
|
+
* Helper to append a value to FormData with proper type handling
|
|
325
|
+
* @param {RezoFormData} formData - The form data to append to
|
|
326
|
+
* @param {string} key - The field name
|
|
327
|
+
* @param {any} value - The value to append
|
|
328
|
+
*/
|
|
329
|
+
private static appendValue;
|
|
322
330
|
/**
|
|
323
331
|
* Convert to URL query string
|
|
324
332
|
* Warning: File, Blob, and binary data will be omitted
|
package/dist/platform/bun.d.ts
CHANGED
|
@@ -314,11 +314,19 @@ export declare class RezoFormData extends NodeFormData {
|
|
|
314
314
|
toBuffer(): Buffer;
|
|
315
315
|
/**
|
|
316
316
|
* Create RezoFormData from object
|
|
317
|
+
* Properly handles nested objects by JSON.stringify-ing them
|
|
317
318
|
* @param {Record<string, any>} obj - Object to convert
|
|
318
319
|
* @param {Options} options - Optional RezoFormData options
|
|
319
320
|
* @returns {RezoFormData}
|
|
320
321
|
*/
|
|
321
322
|
static fromObject(obj: Record<string, any>, options?: Options): RezoFormData;
|
|
323
|
+
/**
|
|
324
|
+
* Helper to append a value to FormData with proper type handling
|
|
325
|
+
* @param {RezoFormData} formData - The form data to append to
|
|
326
|
+
* @param {string} key - The field name
|
|
327
|
+
* @param {any} value - The value to append
|
|
328
|
+
*/
|
|
329
|
+
private static appendValue;
|
|
322
330
|
/**
|
|
323
331
|
* Convert to URL query string
|
|
324
332
|
* Warning: File, Blob, and binary data will be omitted
|