@letsscrapedata/controller 0.0.26 → 0.0.27
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 +22 -11
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +22 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1416,7 +1416,7 @@ var PlaywrightBrowser = class extends import_node_events3.default {
|
|
|
1416
1416
|
throw new Error(`Invalid playwright browser parameter`);
|
|
1417
1417
|
}
|
|
1418
1418
|
super();
|
|
1419
|
-
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage =
|
|
1419
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage = true, headless = false, executablePath = "" } = options;
|
|
1420
1420
|
this.#browser = browser;
|
|
1421
1421
|
this.#browserIdx = browserIdx;
|
|
1422
1422
|
this.#lsdBrowserContexts = [];
|
|
@@ -2900,7 +2900,7 @@ var PuppeteerBrowser = class extends import_node_events6.default {
|
|
|
2900
2900
|
throw new Error(`Invalid puppeteer browser parameter`);
|
|
2901
2901
|
}
|
|
2902
2902
|
super();
|
|
2903
|
-
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage =
|
|
2903
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage = true, headless = false, executablePath = "" } = options;
|
|
2904
2904
|
this.#browser = browser;
|
|
2905
2905
|
this.#browserIdx = browserIdx;
|
|
2906
2906
|
this.#lsdBrowserContexts = [];
|
|
@@ -17192,6 +17192,8 @@ var import_playwright = __toESM(require("playwright"), 1);
|
|
|
17192
17192
|
var import_utils15 = require("@letsscrapedata/utils");
|
|
17193
17193
|
var LsdBrowserController = class _LsdBrowserController {
|
|
17194
17194
|
static #forbidConstructor = false;
|
|
17195
|
+
#puppeteer;
|
|
17196
|
+
#playwrightBrowserTypes;
|
|
17195
17197
|
#nextBrowserIdx;
|
|
17196
17198
|
/**
|
|
17197
17199
|
* Possible values are 'aix', 'darwin', 'freebsd','linux', 'openbsd', 'sunos', and 'win32'.
|
|
@@ -17201,19 +17203,22 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17201
17203
|
if (_LsdBrowserController.#forbidConstructor) {
|
|
17202
17204
|
throw new Error("Only one LsdBrowserController instance can be created!");
|
|
17203
17205
|
}
|
|
17206
|
+
this.#puppeteer = import_puppeteer.default;
|
|
17207
|
+
const { chromium, firefox, webkit } = import_playwright.default;
|
|
17208
|
+
this.#playwrightBrowserTypes = { chromium, firefox, webkit };
|
|
17204
17209
|
this.#osPlatform = import_os.default.platform();
|
|
17205
17210
|
this.#nextBrowserIdx = 1;
|
|
17206
17211
|
_LsdBrowserController.#forbidConstructor = true;
|
|
17207
17212
|
}
|
|
17208
17213
|
#playwrightBrowserType(browserType, connectFlag = false) {
|
|
17209
17214
|
if (browserType === "chromium") {
|
|
17210
|
-
return
|
|
17215
|
+
return this.#playwrightBrowserTypes.chromium;
|
|
17211
17216
|
} else if (connectFlag) {
|
|
17212
17217
|
throw new Error(`playwright only can connect to chromium browser, not support ${browserType} browser`);
|
|
17213
17218
|
} else if (browserType === "firefox") {
|
|
17214
|
-
return
|
|
17219
|
+
return this.#playwrightBrowserTypes.firefox;
|
|
17215
17220
|
} else if (browserType === "webkit") {
|
|
17216
|
-
return
|
|
17221
|
+
return this.#playwrightBrowserTypes.webkit;
|
|
17217
17222
|
} else {
|
|
17218
17223
|
throw new Error(`Invalid playwright browserType ${browserType}`);
|
|
17219
17224
|
}
|
|
@@ -17225,18 +17230,24 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17225
17230
|
throw new Error(`Invalid puppeteer product ${browserType}`);
|
|
17226
17231
|
}
|
|
17227
17232
|
}
|
|
17233
|
+
setPuppeteerNode(puppeteer2) {
|
|
17234
|
+
this.#puppeteer = puppeteer2;
|
|
17235
|
+
}
|
|
17236
|
+
setPlaywrightBrowserTypes(playwrightBrowserTypes) {
|
|
17237
|
+
this.#playwrightBrowserTypes = playwrightBrowserTypes;
|
|
17238
|
+
}
|
|
17228
17239
|
async launch(browserControllerType, browserType, options) {
|
|
17229
17240
|
let {
|
|
17230
17241
|
closeFreePagesIntervalSeconds = 300,
|
|
17231
17242
|
maxBrowserContextsPerBrowser = 10,
|
|
17232
17243
|
maxPagesPerBrowserContext = 20,
|
|
17233
17244
|
maxPageFreeSeconds = 900,
|
|
17234
|
-
maxViewportOfNewPage =
|
|
17245
|
+
maxViewportOfNewPage = true,
|
|
17235
17246
|
proxy = null,
|
|
17236
17247
|
timeout = 3e4,
|
|
17237
17248
|
args = [],
|
|
17238
17249
|
executablePath = "",
|
|
17239
|
-
maxWindowSize =
|
|
17250
|
+
maxWindowSize = true,
|
|
17240
17251
|
headless = true,
|
|
17241
17252
|
minBrowserContexts = 1,
|
|
17242
17253
|
// incognito
|
|
@@ -17322,9 +17333,9 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17322
17333
|
launchOptions.args = args;
|
|
17323
17334
|
}
|
|
17324
17335
|
if (!actOptions.executablePath) {
|
|
17325
|
-
actOptions.executablePath =
|
|
17336
|
+
actOptions.executablePath = this.#puppeteer.executablePath();
|
|
17326
17337
|
}
|
|
17327
|
-
const browser = await
|
|
17338
|
+
const browser = await this.#puppeteer.launch(launchOptions);
|
|
17328
17339
|
lsdBrowser = new PuppeteerBrowser(browser, browserType, "launch", actOptions, this.#nextBrowserIdx++);
|
|
17329
17340
|
} else {
|
|
17330
17341
|
throw new Error(`Invalid browserControllerType: ${browserControllerType} in launch`);
|
|
@@ -17340,7 +17351,7 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17340
17351
|
maxBrowserContextsPerBrowser = 10,
|
|
17341
17352
|
maxPagesPerBrowserContext = 20,
|
|
17342
17353
|
maxPageFreeSeconds = 900,
|
|
17343
|
-
maxViewportOfNewPage =
|
|
17354
|
+
maxViewportOfNewPage = true,
|
|
17344
17355
|
proxy = null,
|
|
17345
17356
|
timeout = 3e4,
|
|
17346
17357
|
browserUrl,
|
|
@@ -17360,7 +17371,7 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17360
17371
|
return lsdBrowser;
|
|
17361
17372
|
} else if (browserControllerType === "puppeteer") {
|
|
17362
17373
|
this.#puppeteerProduct(browserType);
|
|
17363
|
-
const browser = await
|
|
17374
|
+
const browser = await this.#puppeteer.connect({ browserURL: browserUrl });
|
|
17364
17375
|
const lsdBrowser = new PuppeteerBrowser(browser, browserType, "connect", options, this.#nextBrowserIdx++);
|
|
17365
17376
|
;
|
|
17366
17377
|
return lsdBrowser;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, ElementHandle } from 'puppeteer';
|
|
3
|
-
import { Browser, BrowserContext, Frame, Page, Response, Locator } from 'playwright';
|
|
2
|
+
import { Browser as Browser$1, BrowserContext as BrowserContext$1, Frame as Frame$1, Page as Page$1, HTTPResponse, ElementHandle, PuppeteerNode } from 'puppeteer';
|
|
3
|
+
import { Browser, BrowserContext, Frame, Page, Response, BrowserType, Locator } from 'playwright';
|
|
4
4
|
import * as cheerio from 'cheerio';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -36,6 +36,11 @@ type Proxy = {
|
|
|
36
36
|
type BrowserControllerType = "puppeteer" | "playwright";
|
|
37
37
|
type BrowserCreationMethod = "launch" | "connect";
|
|
38
38
|
type LsdBrowserType = "chromium" | "firefox" | "webkit";
|
|
39
|
+
interface PlaywrightBrowserTypes {
|
|
40
|
+
chromium: BrowserType;
|
|
41
|
+
firefox: BrowserType;
|
|
42
|
+
webkit: BrowserType;
|
|
43
|
+
}
|
|
39
44
|
type BrowserControllerOptions = {
|
|
40
45
|
browserControllerType: BrowserControllerType;
|
|
41
46
|
};
|
|
@@ -62,7 +67,7 @@ interface BrowserOptions {
|
|
|
62
67
|
*/
|
|
63
68
|
maxPageFreeSeconds?: number;
|
|
64
69
|
/**
|
|
65
|
-
* @default
|
|
70
|
+
* @default true
|
|
66
71
|
*/
|
|
67
72
|
maxViewportOfNewPage?: boolean;
|
|
68
73
|
/**
|
|
@@ -81,7 +86,7 @@ interface LsdLaunchOptions extends BrowserOptions {
|
|
|
81
86
|
args?: string[];
|
|
82
87
|
executablePath?: string;
|
|
83
88
|
/**
|
|
84
|
-
* @default
|
|
89
|
+
* @default true
|
|
85
90
|
*/
|
|
86
91
|
maxWindowSize?: boolean;
|
|
87
92
|
/**
|
|
@@ -1258,9 +1263,11 @@ declare class CheerioElement implements LsdElement {
|
|
|
1258
1263
|
declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
1259
1264
|
#private;
|
|
1260
1265
|
constructor();
|
|
1266
|
+
setPuppeteerNode(puppeteer: PuppeteerNode): void;
|
|
1267
|
+
setPlaywrightBrowserTypes(playwrightBrowserTypes: PlaywrightBrowserTypes): void;
|
|
1261
1268
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1262
1269
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1263
1270
|
}
|
|
1264
1271
|
declare const controller: LsdBrowserController;
|
|
1265
1272
|
|
|
1266
|
-
export { type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserControllerOptions, type BrowserControllerType, type BrowserCreationMethod, type BrowserManager, CheerioElement, type CheerioNode, CheerioPage, type CookieItem, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageOpenType, type PageStatus, type PaperFormat, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightElement, PlaywrightPage, type Proxy, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ScreenshotOptions, type SelectOptions, type StateData, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, defaultProxy };
|
|
1273
|
+
export { type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserControllerOptions, type BrowserControllerType, type BrowserCreationMethod, type BrowserManager, CheerioElement, type CheerioNode, CheerioPage, type CookieItem, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageOpenType, type PageStatus, type PaperFormat, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserTypes, PlaywrightElement, PlaywrightPage, type Proxy, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ScreenshotOptions, type SelectOptions, type StateData, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, defaultProxy };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, ElementHandle } from 'puppeteer';
|
|
3
|
-
import { Browser, BrowserContext, Frame, Page, Response, Locator } from 'playwright';
|
|
2
|
+
import { Browser as Browser$1, BrowserContext as BrowserContext$1, Frame as Frame$1, Page as Page$1, HTTPResponse, ElementHandle, PuppeteerNode } from 'puppeteer';
|
|
3
|
+
import { Browser, BrowserContext, Frame, Page, Response, BrowserType, Locator } from 'playwright';
|
|
4
4
|
import * as cheerio from 'cheerio';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -36,6 +36,11 @@ type Proxy = {
|
|
|
36
36
|
type BrowserControllerType = "puppeteer" | "playwright";
|
|
37
37
|
type BrowserCreationMethod = "launch" | "connect";
|
|
38
38
|
type LsdBrowserType = "chromium" | "firefox" | "webkit";
|
|
39
|
+
interface PlaywrightBrowserTypes {
|
|
40
|
+
chromium: BrowserType;
|
|
41
|
+
firefox: BrowserType;
|
|
42
|
+
webkit: BrowserType;
|
|
43
|
+
}
|
|
39
44
|
type BrowserControllerOptions = {
|
|
40
45
|
browserControllerType: BrowserControllerType;
|
|
41
46
|
};
|
|
@@ -62,7 +67,7 @@ interface BrowserOptions {
|
|
|
62
67
|
*/
|
|
63
68
|
maxPageFreeSeconds?: number;
|
|
64
69
|
/**
|
|
65
|
-
* @default
|
|
70
|
+
* @default true
|
|
66
71
|
*/
|
|
67
72
|
maxViewportOfNewPage?: boolean;
|
|
68
73
|
/**
|
|
@@ -81,7 +86,7 @@ interface LsdLaunchOptions extends BrowserOptions {
|
|
|
81
86
|
args?: string[];
|
|
82
87
|
executablePath?: string;
|
|
83
88
|
/**
|
|
84
|
-
* @default
|
|
89
|
+
* @default true
|
|
85
90
|
*/
|
|
86
91
|
maxWindowSize?: boolean;
|
|
87
92
|
/**
|
|
@@ -1258,9 +1263,11 @@ declare class CheerioElement implements LsdElement {
|
|
|
1258
1263
|
declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
1259
1264
|
#private;
|
|
1260
1265
|
constructor();
|
|
1266
|
+
setPuppeteerNode(puppeteer: PuppeteerNode): void;
|
|
1267
|
+
setPlaywrightBrowserTypes(playwrightBrowserTypes: PlaywrightBrowserTypes): void;
|
|
1261
1268
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1262
1269
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1263
1270
|
}
|
|
1264
1271
|
declare const controller: LsdBrowserController;
|
|
1265
1272
|
|
|
1266
|
-
export { type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserControllerOptions, type BrowserControllerType, type BrowserCreationMethod, type BrowserManager, CheerioElement, type CheerioNode, CheerioPage, type CookieItem, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageOpenType, type PageStatus, type PaperFormat, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightElement, PlaywrightPage, type Proxy, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ScreenshotOptions, type SelectOptions, type StateData, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, defaultProxy };
|
|
1273
|
+
export { type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserControllerOptions, type BrowserControllerType, type BrowserCreationMethod, type BrowserManager, CheerioElement, type CheerioNode, CheerioPage, type CookieItem, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageOpenType, type PageStatus, type PaperFormat, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserTypes, PlaywrightElement, PlaywrightPage, type Proxy, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ScreenshotOptions, type SelectOptions, type StateData, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, defaultProxy };
|
package/dist/index.js
CHANGED
|
@@ -1396,7 +1396,7 @@ var PlaywrightBrowser = class extends EventEmitter3 {
|
|
|
1396
1396
|
throw new Error(`Invalid playwright browser parameter`);
|
|
1397
1397
|
}
|
|
1398
1398
|
super();
|
|
1399
|
-
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage =
|
|
1399
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage = true, headless = false, executablePath = "" } = options;
|
|
1400
1400
|
this.#browser = browser;
|
|
1401
1401
|
this.#browserIdx = browserIdx;
|
|
1402
1402
|
this.#lsdBrowserContexts = [];
|
|
@@ -2880,7 +2880,7 @@ var PuppeteerBrowser = class extends EventEmitter6 {
|
|
|
2880
2880
|
throw new Error(`Invalid puppeteer browser parameter`);
|
|
2881
2881
|
}
|
|
2882
2882
|
super();
|
|
2883
|
-
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage =
|
|
2883
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage = true, headless = false, executablePath = "" } = options;
|
|
2884
2884
|
this.#browser = browser;
|
|
2885
2885
|
this.#browserIdx = browserIdx;
|
|
2886
2886
|
this.#lsdBrowserContexts = [];
|
|
@@ -17172,6 +17172,8 @@ import playwright from "playwright";
|
|
|
17172
17172
|
import { logwarn as logwarn6 } from "@letsscrapedata/utils";
|
|
17173
17173
|
var LsdBrowserController = class _LsdBrowserController {
|
|
17174
17174
|
static #forbidConstructor = false;
|
|
17175
|
+
#puppeteer;
|
|
17176
|
+
#playwrightBrowserTypes;
|
|
17175
17177
|
#nextBrowserIdx;
|
|
17176
17178
|
/**
|
|
17177
17179
|
* Possible values are 'aix', 'darwin', 'freebsd','linux', 'openbsd', 'sunos', and 'win32'.
|
|
@@ -17181,19 +17183,22 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17181
17183
|
if (_LsdBrowserController.#forbidConstructor) {
|
|
17182
17184
|
throw new Error("Only one LsdBrowserController instance can be created!");
|
|
17183
17185
|
}
|
|
17186
|
+
this.#puppeteer = puppeteer;
|
|
17187
|
+
const { chromium, firefox, webkit } = playwright;
|
|
17188
|
+
this.#playwrightBrowserTypes = { chromium, firefox, webkit };
|
|
17184
17189
|
this.#osPlatform = os.platform();
|
|
17185
17190
|
this.#nextBrowserIdx = 1;
|
|
17186
17191
|
_LsdBrowserController.#forbidConstructor = true;
|
|
17187
17192
|
}
|
|
17188
17193
|
#playwrightBrowserType(browserType, connectFlag = false) {
|
|
17189
17194
|
if (browserType === "chromium") {
|
|
17190
|
-
return
|
|
17195
|
+
return this.#playwrightBrowserTypes.chromium;
|
|
17191
17196
|
} else if (connectFlag) {
|
|
17192
17197
|
throw new Error(`playwright only can connect to chromium browser, not support ${browserType} browser`);
|
|
17193
17198
|
} else if (browserType === "firefox") {
|
|
17194
|
-
return
|
|
17199
|
+
return this.#playwrightBrowserTypes.firefox;
|
|
17195
17200
|
} else if (browserType === "webkit") {
|
|
17196
|
-
return
|
|
17201
|
+
return this.#playwrightBrowserTypes.webkit;
|
|
17197
17202
|
} else {
|
|
17198
17203
|
throw new Error(`Invalid playwright browserType ${browserType}`);
|
|
17199
17204
|
}
|
|
@@ -17205,18 +17210,24 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17205
17210
|
throw new Error(`Invalid puppeteer product ${browserType}`);
|
|
17206
17211
|
}
|
|
17207
17212
|
}
|
|
17213
|
+
setPuppeteerNode(puppeteer2) {
|
|
17214
|
+
this.#puppeteer = puppeteer2;
|
|
17215
|
+
}
|
|
17216
|
+
setPlaywrightBrowserTypes(playwrightBrowserTypes) {
|
|
17217
|
+
this.#playwrightBrowserTypes = playwrightBrowserTypes;
|
|
17218
|
+
}
|
|
17208
17219
|
async launch(browserControllerType, browserType, options) {
|
|
17209
17220
|
let {
|
|
17210
17221
|
closeFreePagesIntervalSeconds = 300,
|
|
17211
17222
|
maxBrowserContextsPerBrowser = 10,
|
|
17212
17223
|
maxPagesPerBrowserContext = 20,
|
|
17213
17224
|
maxPageFreeSeconds = 900,
|
|
17214
|
-
maxViewportOfNewPage =
|
|
17225
|
+
maxViewportOfNewPage = true,
|
|
17215
17226
|
proxy = null,
|
|
17216
17227
|
timeout = 3e4,
|
|
17217
17228
|
args = [],
|
|
17218
17229
|
executablePath = "",
|
|
17219
|
-
maxWindowSize =
|
|
17230
|
+
maxWindowSize = true,
|
|
17220
17231
|
headless = true,
|
|
17221
17232
|
minBrowserContexts = 1,
|
|
17222
17233
|
// incognito
|
|
@@ -17302,9 +17313,9 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17302
17313
|
launchOptions.args = args;
|
|
17303
17314
|
}
|
|
17304
17315
|
if (!actOptions.executablePath) {
|
|
17305
|
-
actOptions.executablePath = puppeteer.executablePath();
|
|
17316
|
+
actOptions.executablePath = this.#puppeteer.executablePath();
|
|
17306
17317
|
}
|
|
17307
|
-
const browser = await puppeteer.launch(launchOptions);
|
|
17318
|
+
const browser = await this.#puppeteer.launch(launchOptions);
|
|
17308
17319
|
lsdBrowser = new PuppeteerBrowser(browser, browserType, "launch", actOptions, this.#nextBrowserIdx++);
|
|
17309
17320
|
} else {
|
|
17310
17321
|
throw new Error(`Invalid browserControllerType: ${browserControllerType} in launch`);
|
|
@@ -17320,7 +17331,7 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17320
17331
|
maxBrowserContextsPerBrowser = 10,
|
|
17321
17332
|
maxPagesPerBrowserContext = 20,
|
|
17322
17333
|
maxPageFreeSeconds = 900,
|
|
17323
|
-
maxViewportOfNewPage =
|
|
17334
|
+
maxViewportOfNewPage = true,
|
|
17324
17335
|
proxy = null,
|
|
17325
17336
|
timeout = 3e4,
|
|
17326
17337
|
browserUrl,
|
|
@@ -17340,7 +17351,7 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17340
17351
|
return lsdBrowser;
|
|
17341
17352
|
} else if (browserControllerType === "puppeteer") {
|
|
17342
17353
|
this.#puppeteerProduct(browserType);
|
|
17343
|
-
const browser = await puppeteer.connect({ browserURL: browserUrl });
|
|
17354
|
+
const browser = await this.#puppeteer.connect({ browserURL: browserUrl });
|
|
17344
17355
|
const lsdBrowser = new PuppeteerBrowser(browser, browserType, "connect", options, this.#nextBrowserIdx++);
|
|
17345
17356
|
;
|
|
17346
17357
|
return lsdBrowser;
|
package/package.json
CHANGED