@letsscrapedata/controller 0.0.7 → 0.0.8
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 +42 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +42 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -327,6 +327,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
327
327
|
#pageId;
|
|
328
328
|
#resquestInterceptionOptions;
|
|
329
329
|
#responseInterceptionOptions;
|
|
330
|
+
#client;
|
|
330
331
|
#hasValidUrl(page) {
|
|
331
332
|
const url = page.url();
|
|
332
333
|
return url.toLowerCase().startsWith("http");
|
|
@@ -538,6 +539,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
538
539
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
539
540
|
this.#resquestInterceptionOptions = [];
|
|
540
541
|
this.#responseInterceptionOptions = [];
|
|
542
|
+
this.#client = null;
|
|
541
543
|
this.#addPageOn();
|
|
542
544
|
}
|
|
543
545
|
async bringToFront() {
|
|
@@ -793,6 +795,24 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
793
795
|
);
|
|
794
796
|
return true;
|
|
795
797
|
}
|
|
798
|
+
async sendCDPMessage(method, params = null, detach = true) {
|
|
799
|
+
if (!this.#client) {
|
|
800
|
+
const origContext = this.browserContext()._origBrowserContext();
|
|
801
|
+
if (!origContext) {
|
|
802
|
+
throw new Error(`Invalid playwright browserContext`);
|
|
803
|
+
}
|
|
804
|
+
this.#client = origContext.newCDPSession(this.#page);
|
|
805
|
+
}
|
|
806
|
+
if (!this.#client) {
|
|
807
|
+
throw new Error("No valid CDP session to send message");
|
|
808
|
+
}
|
|
809
|
+
const response = params ? await this.#client.send(method, params) : await this.#client.send(method);
|
|
810
|
+
if (detach) {
|
|
811
|
+
await this.#client.detach();
|
|
812
|
+
this.#client = null;
|
|
813
|
+
}
|
|
814
|
+
return response;
|
|
815
|
+
}
|
|
796
816
|
async setCookies(cookies) {
|
|
797
817
|
if (!this.#page) {
|
|
798
818
|
throw new Error("No valid page");
|
|
@@ -1769,6 +1789,7 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
1769
1789
|
#pageId;
|
|
1770
1790
|
#requestInterceptionNum;
|
|
1771
1791
|
#responseInterceptionNum;
|
|
1792
|
+
#client;
|
|
1772
1793
|
#hasValidUrl(page) {
|
|
1773
1794
|
const url = page.url();
|
|
1774
1795
|
return url.toLowerCase().startsWith("http");
|
|
@@ -1965,6 +1986,7 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
1965
1986
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1966
1987
|
this.#requestInterceptionNum = 0;
|
|
1967
1988
|
this.#responseInterceptionNum = 0;
|
|
1989
|
+
this.#client = null;
|
|
1968
1990
|
this.#addPageOn();
|
|
1969
1991
|
}
|
|
1970
1992
|
async bringToFront() {
|
|
@@ -2223,6 +2245,23 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2223
2245
|
);
|
|
2224
2246
|
return true;
|
|
2225
2247
|
}
|
|
2248
|
+
async sendCDPMessage(method, params = null, detach = true) {
|
|
2249
|
+
if (!this.#page) {
|
|
2250
|
+
throw new Error("No valid page");
|
|
2251
|
+
}
|
|
2252
|
+
if (!this.#client) {
|
|
2253
|
+
this.#client = await this.#page.createCDPSession();
|
|
2254
|
+
}
|
|
2255
|
+
if (!this.#client) {
|
|
2256
|
+
throw new Error("No valid CDP session to send message");
|
|
2257
|
+
}
|
|
2258
|
+
const response = params ? await this.#client.send(method, params) : await this.#client.send(method);
|
|
2259
|
+
if (detach) {
|
|
2260
|
+
await this.#client.detach();
|
|
2261
|
+
this.#client = null;
|
|
2262
|
+
}
|
|
2263
|
+
return response;
|
|
2264
|
+
}
|
|
2226
2265
|
async setCookies(cookies) {
|
|
2227
2266
|
if (!this.#page) {
|
|
2228
2267
|
throw new Error("No valid page");
|
|
@@ -17012,6 +17051,9 @@ var CheerioPage = class extends import_node_events7.default {
|
|
|
17012
17051
|
async scrollTo() {
|
|
17013
17052
|
throw new Error("Not supported in CheerioElement.");
|
|
17014
17053
|
}
|
|
17054
|
+
async sendCDPMessage() {
|
|
17055
|
+
throw new Error("Method not implemented.");
|
|
17056
|
+
}
|
|
17015
17057
|
async setCookies() {
|
|
17016
17058
|
throw new Error("Not supported in CheerioPage.");
|
|
17017
17059
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -806,6 +806,14 @@ interface LsdPage extends EventEmitter {
|
|
|
806
806
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
807
807
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
808
808
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
809
|
+
/**
|
|
810
|
+
*
|
|
811
|
+
* Send a CDP message over the current(not detached) or new CDP session
|
|
812
|
+
* @param method protocol method name
|
|
813
|
+
* @param params default null(ignored), method parameters
|
|
814
|
+
* @param detach default true, whether to detach the CDPSession from target
|
|
815
|
+
*/
|
|
816
|
+
sendCDPMessage(method: string, params?: object | null, detach?: boolean): Promise<object>;
|
|
809
817
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
810
818
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
811
819
|
/**
|
|
@@ -997,6 +1005,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
997
1005
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
998
1006
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
999
1007
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
1008
|
+
sendCDPMessage(method: string, params?: object | null, detach?: boolean): Promise<object>;
|
|
1000
1009
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1001
1010
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1002
1011
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
@@ -1104,6 +1113,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1104
1113
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1105
1114
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1106
1115
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
1116
|
+
sendCDPMessage(method: string, params?: object | null, detach?: boolean): Promise<object>;
|
|
1107
1117
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1108
1118
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1109
1119
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
@@ -1175,6 +1185,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1175
1185
|
screenshot(): Promise<Buffer>;
|
|
1176
1186
|
scrollBy(): Promise<boolean>;
|
|
1177
1187
|
scrollTo(): Promise<boolean>;
|
|
1188
|
+
sendCDPMessage(): Promise<object>;
|
|
1178
1189
|
setCookies(): Promise<boolean>;
|
|
1179
1190
|
setExtraHTTPHeaders(): Promise<boolean>;
|
|
1180
1191
|
setLocalStroage(): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -806,6 +806,14 @@ interface LsdPage extends EventEmitter {
|
|
|
806
806
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
807
807
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
808
808
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
809
|
+
/**
|
|
810
|
+
*
|
|
811
|
+
* Send a CDP message over the current(not detached) or new CDP session
|
|
812
|
+
* @param method protocol method name
|
|
813
|
+
* @param params default null(ignored), method parameters
|
|
814
|
+
* @param detach default true, whether to detach the CDPSession from target
|
|
815
|
+
*/
|
|
816
|
+
sendCDPMessage(method: string, params?: object | null, detach?: boolean): Promise<object>;
|
|
809
817
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
810
818
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
811
819
|
/**
|
|
@@ -997,6 +1005,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
997
1005
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
998
1006
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
999
1007
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
1008
|
+
sendCDPMessage(method: string, params?: object | null, detach?: boolean): Promise<object>;
|
|
1000
1009
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1001
1010
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1002
1011
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
@@ -1104,6 +1113,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1104
1113
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1105
1114
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1106
1115
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
1116
|
+
sendCDPMessage(method: string, params?: object | null, detach?: boolean): Promise<object>;
|
|
1107
1117
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1108
1118
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1109
1119
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
@@ -1175,6 +1185,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1175
1185
|
screenshot(): Promise<Buffer>;
|
|
1176
1186
|
scrollBy(): Promise<boolean>;
|
|
1177
1187
|
scrollTo(): Promise<boolean>;
|
|
1188
|
+
sendCDPMessage(): Promise<object>;
|
|
1178
1189
|
setCookies(): Promise<boolean>;
|
|
1179
1190
|
setExtraHTTPHeaders(): Promise<boolean>;
|
|
1180
1191
|
setLocalStroage(): Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -308,6 +308,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
308
308
|
#pageId;
|
|
309
309
|
#resquestInterceptionOptions;
|
|
310
310
|
#responseInterceptionOptions;
|
|
311
|
+
#client;
|
|
311
312
|
#hasValidUrl(page) {
|
|
312
313
|
const url = page.url();
|
|
313
314
|
return url.toLowerCase().startsWith("http");
|
|
@@ -519,6 +520,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
519
520
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
520
521
|
this.#resquestInterceptionOptions = [];
|
|
521
522
|
this.#responseInterceptionOptions = [];
|
|
523
|
+
this.#client = null;
|
|
522
524
|
this.#addPageOn();
|
|
523
525
|
}
|
|
524
526
|
async bringToFront() {
|
|
@@ -774,6 +776,24 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
774
776
|
);
|
|
775
777
|
return true;
|
|
776
778
|
}
|
|
779
|
+
async sendCDPMessage(method, params = null, detach = true) {
|
|
780
|
+
if (!this.#client) {
|
|
781
|
+
const origContext = this.browserContext()._origBrowserContext();
|
|
782
|
+
if (!origContext) {
|
|
783
|
+
throw new Error(`Invalid playwright browserContext`);
|
|
784
|
+
}
|
|
785
|
+
this.#client = origContext.newCDPSession(this.#page);
|
|
786
|
+
}
|
|
787
|
+
if (!this.#client) {
|
|
788
|
+
throw new Error("No valid CDP session to send message");
|
|
789
|
+
}
|
|
790
|
+
const response = params ? await this.#client.send(method, params) : await this.#client.send(method);
|
|
791
|
+
if (detach) {
|
|
792
|
+
await this.#client.detach();
|
|
793
|
+
this.#client = null;
|
|
794
|
+
}
|
|
795
|
+
return response;
|
|
796
|
+
}
|
|
777
797
|
async setCookies(cookies) {
|
|
778
798
|
if (!this.#page) {
|
|
779
799
|
throw new Error("No valid page");
|
|
@@ -1750,6 +1770,7 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
1750
1770
|
#pageId;
|
|
1751
1771
|
#requestInterceptionNum;
|
|
1752
1772
|
#responseInterceptionNum;
|
|
1773
|
+
#client;
|
|
1753
1774
|
#hasValidUrl(page) {
|
|
1754
1775
|
const url = page.url();
|
|
1755
1776
|
return url.toLowerCase().startsWith("http");
|
|
@@ -1946,6 +1967,7 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
1946
1967
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1947
1968
|
this.#requestInterceptionNum = 0;
|
|
1948
1969
|
this.#responseInterceptionNum = 0;
|
|
1970
|
+
this.#client = null;
|
|
1949
1971
|
this.#addPageOn();
|
|
1950
1972
|
}
|
|
1951
1973
|
async bringToFront() {
|
|
@@ -2204,6 +2226,23 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2204
2226
|
);
|
|
2205
2227
|
return true;
|
|
2206
2228
|
}
|
|
2229
|
+
async sendCDPMessage(method, params = null, detach = true) {
|
|
2230
|
+
if (!this.#page) {
|
|
2231
|
+
throw new Error("No valid page");
|
|
2232
|
+
}
|
|
2233
|
+
if (!this.#client) {
|
|
2234
|
+
this.#client = await this.#page.createCDPSession();
|
|
2235
|
+
}
|
|
2236
|
+
if (!this.#client) {
|
|
2237
|
+
throw new Error("No valid CDP session to send message");
|
|
2238
|
+
}
|
|
2239
|
+
const response = params ? await this.#client.send(method, params) : await this.#client.send(method);
|
|
2240
|
+
if (detach) {
|
|
2241
|
+
await this.#client.detach();
|
|
2242
|
+
this.#client = null;
|
|
2243
|
+
}
|
|
2244
|
+
return response;
|
|
2245
|
+
}
|
|
2207
2246
|
async setCookies(cookies) {
|
|
2208
2247
|
if (!this.#page) {
|
|
2209
2248
|
throw new Error("No valid page");
|
|
@@ -16993,6 +17032,9 @@ var CheerioPage = class extends EventEmitter7 {
|
|
|
16993
17032
|
async scrollTo() {
|
|
16994
17033
|
throw new Error("Not supported in CheerioElement.");
|
|
16995
17034
|
}
|
|
17035
|
+
async sendCDPMessage() {
|
|
17036
|
+
throw new Error("Method not implemented.");
|
|
17037
|
+
}
|
|
16996
17038
|
async setCookies() {
|
|
16997
17039
|
throw new Error("Not supported in CheerioPage.");
|
|
16998
17040
|
}
|
package/package.json
CHANGED