@letsscrapedata/controller 0.0.28 → 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 +25 -6
- package/dist/index.d.cts +24 -4
- package/dist/index.d.ts +24 -4
- package/dist/index.js +25 -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,19 +17234,35 @@ 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
|
+
}
|
|
17235
17242
|
return true;
|
|
17236
17243
|
}
|
|
17237
17244
|
setPlaywrightBrowserType(browserType, playwrightBrowserType) {
|
|
17238
17245
|
switch (browserType) {
|
|
17239
17246
|
case "chromium":
|
|
17240
|
-
|
|
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
|
+
}
|
|
17241
17252
|
break;
|
|
17242
17253
|
case "firefox":
|
|
17243
|
-
|
|
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
|
+
}
|
|
17244
17259
|
break;
|
|
17245
17260
|
case "webkit":
|
|
17246
|
-
|
|
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
|
+
}
|
|
17247
17266
|
break;
|
|
17248
17267
|
default:
|
|
17249
17268
|
(0, import_utils15.unreachable)(browserType);
|
package/dist/index.d.cts
CHANGED
|
@@ -936,10 +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>;
|
|
941
|
-
|
|
942
|
-
|
|
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;
|
|
943
963
|
}
|
|
944
964
|
/**
|
|
945
965
|
* globObj.cfg.XXX:
|
|
@@ -1265,8 +1285,8 @@ declare class CheerioElement implements LsdElement {
|
|
|
1265
1285
|
declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
1266
1286
|
#private;
|
|
1267
1287
|
constructor();
|
|
1268
|
-
setPuppeteerNode(puppeteer: PuppeteerNode): boolean;
|
|
1269
|
-
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType): boolean;
|
|
1288
|
+
setPuppeteerNode(puppeteer: PuppeteerNode | null): boolean;
|
|
1289
|
+
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1270
1290
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1271
1291
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1272
1292
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -936,10 +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>;
|
|
941
|
-
|
|
942
|
-
|
|
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;
|
|
943
963
|
}
|
|
944
964
|
/**
|
|
945
965
|
* globObj.cfg.XXX:
|
|
@@ -1265,8 +1285,8 @@ declare class CheerioElement implements LsdElement {
|
|
|
1265
1285
|
declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
1266
1286
|
#private;
|
|
1267
1287
|
constructor();
|
|
1268
|
-
setPuppeteerNode(puppeteer: PuppeteerNode): boolean;
|
|
1269
|
-
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType): boolean;
|
|
1288
|
+
setPuppeteerNode(puppeteer: PuppeteerNode | null): boolean;
|
|
1289
|
+
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1270
1290
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1271
1291
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1272
1292
|
}
|
package/dist/index.js
CHANGED
|
@@ -17170,6 +17170,9 @@ import os from "os";
|
|
|
17170
17170
|
import puppeteer from "puppeteer";
|
|
17171
17171
|
import playwright from "playwright";
|
|
17172
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,19 +17214,35 @@ 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
|
+
}
|
|
17215
17222
|
return true;
|
|
17216
17223
|
}
|
|
17217
17224
|
setPlaywrightBrowserType(browserType, playwrightBrowserType) {
|
|
17218
17225
|
switch (browserType) {
|
|
17219
17226
|
case "chromium":
|
|
17220
|
-
|
|
17227
|
+
if (playwrightBrowserType) {
|
|
17228
|
+
this.#playwrightBrowserTypes.chromium = playwrightBrowserType;
|
|
17229
|
+
} else {
|
|
17230
|
+
this.#playwrightBrowserTypes.chromium = playwrightExtra.chromium.use(StealthPlugin());
|
|
17231
|
+
}
|
|
17221
17232
|
break;
|
|
17222
17233
|
case "firefox":
|
|
17223
|
-
|
|
17234
|
+
if (playwrightBrowserType) {
|
|
17235
|
+
this.#playwrightBrowserTypes.firefox = playwrightBrowserType;
|
|
17236
|
+
} else {
|
|
17237
|
+
this.#playwrightBrowserTypes.firefox = playwrightExtra.firefox.use(StealthPlugin());
|
|
17238
|
+
}
|
|
17224
17239
|
break;
|
|
17225
17240
|
case "webkit":
|
|
17226
|
-
|
|
17241
|
+
if (playwrightBrowserType) {
|
|
17242
|
+
this.#playwrightBrowserTypes.webkit = playwrightBrowserType;
|
|
17243
|
+
} else {
|
|
17244
|
+
this.#playwrightBrowserTypes.webkit = playwrightExtra.webkit.use(StealthPlugin());
|
|
17245
|
+
}
|
|
17227
17246
|
break;
|
|
17228
17247
|
default:
|
|
17229
17248
|
unreachable5(browserType);
|
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"
|