@letsscrapedata/controller 0.0.27 → 0.0.29
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 +38 -5
- package/dist/index.d.cts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +39 -6
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -17190,6 +17190,9 @@ var import_os = __toESM(require("os"), 1);
|
|
|
17190
17190
|
var import_puppeteer = __toESM(require("puppeteer"), 1);
|
|
17191
17191
|
var import_playwright = __toESM(require("playwright"), 1);
|
|
17192
17192
|
var import_utils15 = require("@letsscrapedata/utils");
|
|
17193
|
+
var import_puppeteer_extra = __toESM(require("puppeteer-extra"), 1);
|
|
17194
|
+
var playwrightExtra = __toESM(require("playwright-extra"), 1);
|
|
17195
|
+
var import_puppeteer_extra_plugin_stealth = __toESM(require("puppeteer-extra-plugin-stealth"), 1);
|
|
17193
17196
|
var LsdBrowserController = class _LsdBrowserController {
|
|
17194
17197
|
static #forbidConstructor = false;
|
|
17195
17198
|
#puppeteer;
|
|
@@ -17204,8 +17207,8 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17204
17207
|
throw new Error("Only one LsdBrowserController instance can be created!");
|
|
17205
17208
|
}
|
|
17206
17209
|
this.#puppeteer = import_puppeteer.default;
|
|
17207
|
-
const { chromium, firefox, webkit } = import_playwright.default;
|
|
17208
|
-
this.#playwrightBrowserTypes = { chromium, firefox, webkit };
|
|
17210
|
+
const { chromium: chromium2, firefox: firefox2, webkit: webkit2 } = import_playwright.default;
|
|
17211
|
+
this.#playwrightBrowserTypes = { chromium: chromium2, firefox: firefox2, webkit: webkit2 };
|
|
17209
17212
|
this.#osPlatform = import_os.default.platform();
|
|
17210
17213
|
this.#nextBrowserIdx = 1;
|
|
17211
17214
|
_LsdBrowserController.#forbidConstructor = true;
|
|
@@ -17231,10 +17234,40 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17231
17234
|
}
|
|
17232
17235
|
}
|
|
17233
17236
|
setPuppeteerNode(puppeteer2) {
|
|
17234
|
-
|
|
17237
|
+
if (puppeteer2) {
|
|
17238
|
+
this.#puppeteer = puppeteer2;
|
|
17239
|
+
} else {
|
|
17240
|
+
this.#puppeteer = import_puppeteer_extra.default.use((0, import_puppeteer_extra_plugin_stealth.default)());
|
|
17241
|
+
}
|
|
17242
|
+
return true;
|
|
17235
17243
|
}
|
|
17236
|
-
|
|
17237
|
-
|
|
17244
|
+
setPlaywrightBrowserType(browserType, playwrightBrowserType) {
|
|
17245
|
+
switch (browserType) {
|
|
17246
|
+
case "chromium":
|
|
17247
|
+
if (playwrightBrowserType) {
|
|
17248
|
+
this.#playwrightBrowserTypes.chromium = playwrightBrowserType;
|
|
17249
|
+
} else {
|
|
17250
|
+
this.#playwrightBrowserTypes.chromium = playwrightExtra.chromium.use((0, import_puppeteer_extra_plugin_stealth.default)());
|
|
17251
|
+
}
|
|
17252
|
+
break;
|
|
17253
|
+
case "firefox":
|
|
17254
|
+
if (playwrightBrowserType) {
|
|
17255
|
+
this.#playwrightBrowserTypes.firefox = playwrightBrowserType;
|
|
17256
|
+
} else {
|
|
17257
|
+
this.#playwrightBrowserTypes.firefox = playwrightExtra.firefox.use((0, import_puppeteer_extra_plugin_stealth.default)());
|
|
17258
|
+
}
|
|
17259
|
+
break;
|
|
17260
|
+
case "webkit":
|
|
17261
|
+
if (playwrightBrowserType) {
|
|
17262
|
+
this.#playwrightBrowserTypes.webkit = playwrightBrowserType;
|
|
17263
|
+
} else {
|
|
17264
|
+
this.#playwrightBrowserTypes.webkit = playwrightExtra.webkit.use((0, import_puppeteer_extra_plugin_stealth.default)());
|
|
17265
|
+
}
|
|
17266
|
+
break;
|
|
17267
|
+
default:
|
|
17268
|
+
(0, import_utils15.unreachable)(browserType);
|
|
17269
|
+
}
|
|
17270
|
+
return true;
|
|
17238
17271
|
}
|
|
17239
17272
|
async launch(browserControllerType, browserType, options) {
|
|
17240
17273
|
let {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
|
-
import { Browser as Browser$1, BrowserContext as BrowserContext$1, Frame as Frame$1, Page as Page$1, HTTPResponse,
|
|
2
|
+
import { Browser as Browser$1, BrowserContext as BrowserContext$1, Frame as Frame$1, Page as Page$1, HTTPResponse, PuppeteerNode, ElementHandle } from 'puppeteer';
|
|
3
3
|
import { Browser, BrowserContext, Frame, Page, Response, BrowserType, Locator } from 'playwright';
|
|
4
4
|
import * as cheerio from 'cheerio';
|
|
5
5
|
|
|
@@ -936,8 +936,30 @@ interface LsdBrowser extends EventEmitter {
|
|
|
936
936
|
_origBrowserContexts(): AllBrowserContext[];
|
|
937
937
|
}
|
|
938
938
|
interface LsdBrowserController$1 {
|
|
939
|
+
/**
|
|
940
|
+
* launch a new browser using related browser controller
|
|
941
|
+
* @param browserControllerType
|
|
942
|
+
* @param browserType
|
|
943
|
+
* @param options
|
|
944
|
+
*/
|
|
939
945
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options?: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
946
|
+
/**
|
|
947
|
+
* connect to the current browser using related browser controller
|
|
948
|
+
* @param browserControllerType
|
|
949
|
+
* @param browserType
|
|
950
|
+
* @param options
|
|
951
|
+
*/
|
|
940
952
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options?: LsdConnectOptions): Promise<LsdBrowser>;
|
|
953
|
+
/**
|
|
954
|
+
*
|
|
955
|
+
* @param puppeteer null means use puppeteer-extra-plugin-stealth based on puppeteer-extra
|
|
956
|
+
*/
|
|
957
|
+
setPuppeteerNode(puppeteer: PuppeteerNode | null): boolean;
|
|
958
|
+
/**
|
|
959
|
+
*
|
|
960
|
+
* @param puppeteer null means use puppeteer-extra-plugin-stealth based on playwright-extra
|
|
961
|
+
*/
|
|
962
|
+
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
941
963
|
}
|
|
942
964
|
/**
|
|
943
965
|
* globObj.cfg.XXX:
|
|
@@ -1263,8 +1285,8 @@ declare class CheerioElement implements LsdElement {
|
|
|
1263
1285
|
declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
1264
1286
|
#private;
|
|
1265
1287
|
constructor();
|
|
1266
|
-
setPuppeteerNode(puppeteer: PuppeteerNode):
|
|
1267
|
-
|
|
1288
|
+
setPuppeteerNode(puppeteer: PuppeteerNode | null): boolean;
|
|
1289
|
+
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1268
1290
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1269
1291
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1270
1292
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
|
-
import { Browser as Browser$1, BrowserContext as BrowserContext$1, Frame as Frame$1, Page as Page$1, HTTPResponse,
|
|
2
|
+
import { Browser as Browser$1, BrowserContext as BrowserContext$1, Frame as Frame$1, Page as Page$1, HTTPResponse, PuppeteerNode, ElementHandle } from 'puppeteer';
|
|
3
3
|
import { Browser, BrowserContext, Frame, Page, Response, BrowserType, Locator } from 'playwright';
|
|
4
4
|
import * as cheerio from 'cheerio';
|
|
5
5
|
|
|
@@ -936,8 +936,30 @@ interface LsdBrowser extends EventEmitter {
|
|
|
936
936
|
_origBrowserContexts(): AllBrowserContext[];
|
|
937
937
|
}
|
|
938
938
|
interface LsdBrowserController$1 {
|
|
939
|
+
/**
|
|
940
|
+
* launch a new browser using related browser controller
|
|
941
|
+
* @param browserControllerType
|
|
942
|
+
* @param browserType
|
|
943
|
+
* @param options
|
|
944
|
+
*/
|
|
939
945
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options?: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
946
|
+
/**
|
|
947
|
+
* connect to the current browser using related browser controller
|
|
948
|
+
* @param browserControllerType
|
|
949
|
+
* @param browserType
|
|
950
|
+
* @param options
|
|
951
|
+
*/
|
|
940
952
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options?: LsdConnectOptions): Promise<LsdBrowser>;
|
|
953
|
+
/**
|
|
954
|
+
*
|
|
955
|
+
* @param puppeteer null means use puppeteer-extra-plugin-stealth based on puppeteer-extra
|
|
956
|
+
*/
|
|
957
|
+
setPuppeteerNode(puppeteer: PuppeteerNode | null): boolean;
|
|
958
|
+
/**
|
|
959
|
+
*
|
|
960
|
+
* @param puppeteer null means use puppeteer-extra-plugin-stealth based on playwright-extra
|
|
961
|
+
*/
|
|
962
|
+
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
941
963
|
}
|
|
942
964
|
/**
|
|
943
965
|
* globObj.cfg.XXX:
|
|
@@ -1263,8 +1285,8 @@ declare class CheerioElement implements LsdElement {
|
|
|
1263
1285
|
declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
1264
1286
|
#private;
|
|
1265
1287
|
constructor();
|
|
1266
|
-
setPuppeteerNode(puppeteer: PuppeteerNode):
|
|
1267
|
-
|
|
1288
|
+
setPuppeteerNode(puppeteer: PuppeteerNode | null): boolean;
|
|
1289
|
+
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1268
1290
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1269
1291
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1270
1292
|
}
|
package/dist/index.js
CHANGED
|
@@ -17169,7 +17169,10 @@ var CheerioPage = class extends EventEmitter7 {
|
|
|
17169
17169
|
import os from "os";
|
|
17170
17170
|
import puppeteer from "puppeteer";
|
|
17171
17171
|
import playwright from "playwright";
|
|
17172
|
-
import { logwarn as logwarn6 } from "@letsscrapedata/utils";
|
|
17172
|
+
import { logwarn as logwarn6, unreachable as unreachable5 } from "@letsscrapedata/utils";
|
|
17173
|
+
import puppeteerExtra from "puppeteer-extra";
|
|
17174
|
+
import * as playwrightExtra from "playwright-extra";
|
|
17175
|
+
import StealthPlugin from "puppeteer-extra-plugin-stealth";
|
|
17173
17176
|
var LsdBrowserController = class _LsdBrowserController {
|
|
17174
17177
|
static #forbidConstructor = false;
|
|
17175
17178
|
#puppeteer;
|
|
@@ -17184,8 +17187,8 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17184
17187
|
throw new Error("Only one LsdBrowserController instance can be created!");
|
|
17185
17188
|
}
|
|
17186
17189
|
this.#puppeteer = puppeteer;
|
|
17187
|
-
const { chromium, firefox, webkit } = playwright;
|
|
17188
|
-
this.#playwrightBrowserTypes = { chromium, firefox, webkit };
|
|
17190
|
+
const { chromium: chromium2, firefox: firefox2, webkit: webkit2 } = playwright;
|
|
17191
|
+
this.#playwrightBrowserTypes = { chromium: chromium2, firefox: firefox2, webkit: webkit2 };
|
|
17189
17192
|
this.#osPlatform = os.platform();
|
|
17190
17193
|
this.#nextBrowserIdx = 1;
|
|
17191
17194
|
_LsdBrowserController.#forbidConstructor = true;
|
|
@@ -17211,10 +17214,40 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17211
17214
|
}
|
|
17212
17215
|
}
|
|
17213
17216
|
setPuppeteerNode(puppeteer2) {
|
|
17214
|
-
|
|
17217
|
+
if (puppeteer2) {
|
|
17218
|
+
this.#puppeteer = puppeteer2;
|
|
17219
|
+
} else {
|
|
17220
|
+
this.#puppeteer = puppeteerExtra.use(StealthPlugin());
|
|
17221
|
+
}
|
|
17222
|
+
return true;
|
|
17215
17223
|
}
|
|
17216
|
-
|
|
17217
|
-
|
|
17224
|
+
setPlaywrightBrowserType(browserType, playwrightBrowserType) {
|
|
17225
|
+
switch (browserType) {
|
|
17226
|
+
case "chromium":
|
|
17227
|
+
if (playwrightBrowserType) {
|
|
17228
|
+
this.#playwrightBrowserTypes.chromium = playwrightBrowserType;
|
|
17229
|
+
} else {
|
|
17230
|
+
this.#playwrightBrowserTypes.chromium = playwrightExtra.chromium.use(StealthPlugin());
|
|
17231
|
+
}
|
|
17232
|
+
break;
|
|
17233
|
+
case "firefox":
|
|
17234
|
+
if (playwrightBrowserType) {
|
|
17235
|
+
this.#playwrightBrowserTypes.firefox = playwrightBrowserType;
|
|
17236
|
+
} else {
|
|
17237
|
+
this.#playwrightBrowserTypes.firefox = playwrightExtra.firefox.use(StealthPlugin());
|
|
17238
|
+
}
|
|
17239
|
+
break;
|
|
17240
|
+
case "webkit":
|
|
17241
|
+
if (playwrightBrowserType) {
|
|
17242
|
+
this.#playwrightBrowserTypes.webkit = playwrightBrowserType;
|
|
17243
|
+
} else {
|
|
17244
|
+
this.#playwrightBrowserTypes.webkit = playwrightExtra.webkit.use(StealthPlugin());
|
|
17245
|
+
}
|
|
17246
|
+
break;
|
|
17247
|
+
default:
|
|
17248
|
+
unreachable5(browserType);
|
|
17249
|
+
}
|
|
17250
|
+
return true;
|
|
17218
17251
|
}
|
|
17219
17252
|
async launch(browserControllerType, browserType, options) {
|
|
17220
17253
|
let {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@letsscrapedata/controller",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "Unified browser / HTML controller interfaces that support playwright, puppeteer and cheerio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@letsscrapedata/utils": "^0.0.7",
|
|
38
38
|
"playwright": "^1.43.0",
|
|
39
|
-
"
|
|
39
|
+
"playwright-extra": "^4.3.6",
|
|
40
|
+
"puppeteer": "^22.6.3",
|
|
41
|
+
"puppeteer-extra": "^3.3.6",
|
|
42
|
+
"puppeteer-extra-plugin-stealth": "^2.11.2"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"tsup": "^8.0.2"
|