@letsscrapedata/controller 0.0.13 → 0.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/index.cjs +6 -6
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -952,7 +952,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
952
952
|
return;
|
|
953
953
|
}
|
|
954
954
|
for (const option of this.#responseInterceptionOptions) {
|
|
955
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
955
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
956
956
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
957
957
|
if (matchedFlag && responseMatch) {
|
|
958
958
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -981,7 +981,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
981
981
|
(0, import_utils2.loginfo)(`##browser cache matched response: ${requestUrl}`);
|
|
982
982
|
}
|
|
983
983
|
if (typeof handler === "function") {
|
|
984
|
-
await handler(response, handlerOptions);
|
|
984
|
+
await handler(response, handlerOptions, pageUrl);
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
987
|
return;
|
|
@@ -2408,18 +2408,18 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2408
2408
|
return false;
|
|
2409
2409
|
}
|
|
2410
2410
|
this.#responseInterceptionNum++;
|
|
2411
|
-
const pageUrl = this.#page.url();
|
|
2412
2411
|
this.#page.on("response", async (response) => {
|
|
2413
2412
|
try {
|
|
2414
|
-
if (!response.ok()) {
|
|
2413
|
+
if (!response.ok() || !this.#page) {
|
|
2415
2414
|
return false;
|
|
2416
2415
|
}
|
|
2416
|
+
const pageUrl = this.#page.url();
|
|
2417
2417
|
const request = response.request();
|
|
2418
2418
|
if (!request) {
|
|
2419
2419
|
return false;
|
|
2420
2420
|
}
|
|
2421
2421
|
for (const option of actOptions) {
|
|
2422
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
2422
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
2423
2423
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
2424
2424
|
if (matchedFlag && responseMatch) {
|
|
2425
2425
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -2447,7 +2447,7 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2447
2447
|
});
|
|
2448
2448
|
}
|
|
2449
2449
|
if (typeof handler === "function") {
|
|
2450
|
-
await handler(response, handlerOptions);
|
|
2450
|
+
await handler(response, handlerOptions, pageUrl);
|
|
2451
2451
|
}
|
|
2452
2452
|
}
|
|
2453
2453
|
return true;
|
package/dist/index.d.cts
CHANGED
|
@@ -456,7 +456,7 @@ interface ResponseMatch {
|
|
|
456
456
|
maxLength?: number;
|
|
457
457
|
}
|
|
458
458
|
type ResponseHandlerOptions = Record<string, any>;
|
|
459
|
-
type ResponseHandler = (response: AllResponse, options
|
|
459
|
+
type ResponseHandler = (response: AllResponse, options: ResponseHandlerOptions, pageUrl: string) => Promise<void> | void;
|
|
460
460
|
interface ResponseInterceptionItem {
|
|
461
461
|
/**
|
|
462
462
|
* page.url()
|
|
@@ -490,6 +490,10 @@ interface ResponseInterceptionOption {
|
|
|
490
490
|
* handler will be called if handler is a function
|
|
491
491
|
*/
|
|
492
492
|
handler?: ResponseHandler;
|
|
493
|
+
/**
|
|
494
|
+
* valid only if handler is a function
|
|
495
|
+
* @default {}
|
|
496
|
+
*/
|
|
493
497
|
handlerOptions?: ResponseHandlerOptions;
|
|
494
498
|
}
|
|
495
499
|
interface PDFMargin {
|
package/dist/index.d.ts
CHANGED
|
@@ -456,7 +456,7 @@ interface ResponseMatch {
|
|
|
456
456
|
maxLength?: number;
|
|
457
457
|
}
|
|
458
458
|
type ResponseHandlerOptions = Record<string, any>;
|
|
459
|
-
type ResponseHandler = (response: AllResponse, options
|
|
459
|
+
type ResponseHandler = (response: AllResponse, options: ResponseHandlerOptions, pageUrl: string) => Promise<void> | void;
|
|
460
460
|
interface ResponseInterceptionItem {
|
|
461
461
|
/**
|
|
462
462
|
* page.url()
|
|
@@ -490,6 +490,10 @@ interface ResponseInterceptionOption {
|
|
|
490
490
|
* handler will be called if handler is a function
|
|
491
491
|
*/
|
|
492
492
|
handler?: ResponseHandler;
|
|
493
|
+
/**
|
|
494
|
+
* valid only if handler is a function
|
|
495
|
+
* @default {}
|
|
496
|
+
*/
|
|
493
497
|
handlerOptions?: ResponseHandlerOptions;
|
|
494
498
|
}
|
|
495
499
|
interface PDFMargin {
|
package/dist/index.js
CHANGED
|
@@ -932,7 +932,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
932
932
|
return;
|
|
933
933
|
}
|
|
934
934
|
for (const option of this.#responseInterceptionOptions) {
|
|
935
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
935
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
936
936
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
937
937
|
if (matchedFlag && responseMatch) {
|
|
938
938
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -961,7 +961,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
961
961
|
loginfo(`##browser cache matched response: ${requestUrl}`);
|
|
962
962
|
}
|
|
963
963
|
if (typeof handler === "function") {
|
|
964
|
-
await handler(response, handlerOptions);
|
|
964
|
+
await handler(response, handlerOptions, pageUrl);
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
967
|
return;
|
|
@@ -2388,18 +2388,18 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2388
2388
|
return false;
|
|
2389
2389
|
}
|
|
2390
2390
|
this.#responseInterceptionNum++;
|
|
2391
|
-
const pageUrl = this.#page.url();
|
|
2392
2391
|
this.#page.on("response", async (response) => {
|
|
2393
2392
|
try {
|
|
2394
|
-
if (!response.ok()) {
|
|
2393
|
+
if (!response.ok() || !this.#page) {
|
|
2395
2394
|
return false;
|
|
2396
2395
|
}
|
|
2396
|
+
const pageUrl = this.#page.url();
|
|
2397
2397
|
const request = response.request();
|
|
2398
2398
|
if (!request) {
|
|
2399
2399
|
return false;
|
|
2400
2400
|
}
|
|
2401
2401
|
for (const option of actOptions) {
|
|
2402
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
2402
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
2403
2403
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
2404
2404
|
if (matchedFlag && responseMatch) {
|
|
2405
2405
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -2427,7 +2427,7 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2427
2427
|
});
|
|
2428
2428
|
}
|
|
2429
2429
|
if (typeof handler === "function") {
|
|
2430
|
-
await handler(response, handlerOptions);
|
|
2430
|
+
await handler(response, handlerOptions, pageUrl);
|
|
2431
2431
|
}
|
|
2432
2432
|
}
|
|
2433
2433
|
return true;
|
package/package.json
CHANGED