@letsscrapedata/controller 0.0.32 → 0.0.33
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 +12 -23
- package/dist/index.d.cts +29 -27
- package/dist/index.d.ts +29 -27
- package/dist/index.js +11 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -58,21 +58,10 @@ __export(src_exports, {
|
|
|
58
58
|
PuppeteerBrowserContext: () => PuppeteerBrowserContext,
|
|
59
59
|
PuppeteerElement: () => PuppeteerElement,
|
|
60
60
|
PuppeteerPage: () => PuppeteerPage,
|
|
61
|
-
controller: () => controller
|
|
62
|
-
defaultProxy: () => defaultProxy
|
|
61
|
+
controller: () => controller
|
|
63
62
|
});
|
|
64
63
|
module.exports = __toCommonJS(src_exports);
|
|
65
64
|
|
|
66
|
-
// src/types/types.ts
|
|
67
|
-
var defaultProxy = {
|
|
68
|
-
server: "default",
|
|
69
|
-
proxyIpType: "residential",
|
|
70
|
-
proxyDurationType: "static",
|
|
71
|
-
proxySharedType: "dedicated",
|
|
72
|
-
expireTime: 41024196e5
|
|
73
|
-
// "2100-01-01 01:00:00"
|
|
74
|
-
};
|
|
75
|
-
|
|
76
65
|
// src/playwright/browser.ts
|
|
77
66
|
var import_node_events3 = __toESM(require("events"), 1);
|
|
78
67
|
|
|
@@ -1234,7 +1223,7 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
|
|
|
1234
1223
|
this.#browserContext = browserContext;
|
|
1235
1224
|
this.#createTime = (0, import_utils3.getCurrentUnixTime)();
|
|
1236
1225
|
this.#incognito = incognito === false ? false : true;
|
|
1237
|
-
this.#proxy = proxy?.
|
|
1226
|
+
this.#proxy = proxy?.proxyUrl ? proxy : null;
|
|
1238
1227
|
this.#maxPagesPerBrowserContext = maxPagesPerBrowserContext;
|
|
1239
1228
|
this.#maxPageFreeSeconds = maxPageFreeSeconds;
|
|
1240
1229
|
this.#maxViewportOfNewPage = maxViewportOfNewPage;
|
|
@@ -1543,7 +1532,7 @@ var PlaywrightBrowser = class extends import_node_events3.default {
|
|
|
1543
1532
|
}
|
|
1544
1533
|
const proxy = options?.proxy ? Object.assign({}, options.proxy) : this.#proxy;
|
|
1545
1534
|
if (proxy) {
|
|
1546
|
-
const { server, username, password } = proxy;
|
|
1535
|
+
const { proxyUrl: server, username, password } = proxy;
|
|
1547
1536
|
browserContextOptions.proxy = { server, username, password };
|
|
1548
1537
|
}
|
|
1549
1538
|
if (options?.userAgent) {
|
|
@@ -2719,7 +2708,7 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
|
|
|
2719
2708
|
this.#userAgent = userAgent;
|
|
2720
2709
|
this.#createTime = (0, import_utils7.getCurrentUnixTime)();
|
|
2721
2710
|
this.#incognito = incognito === false ? false : true;
|
|
2722
|
-
this.#proxy = proxy?.
|
|
2711
|
+
this.#proxy = proxy?.proxyUrl ? proxy : null;
|
|
2723
2712
|
this.#maxPagesPerBrowserContext = maxPagesPerBrowserContext;
|
|
2724
2713
|
this.#maxPageFreeSeconds = maxPageFreeSeconds;
|
|
2725
2714
|
this.#maxViewportOfNewPage = maxViewportOfNewPage;
|
|
@@ -3032,8 +3021,8 @@ var PuppeteerBrowser = class extends import_node_events6.default {
|
|
|
3032
3021
|
}
|
|
3033
3022
|
const browserContextOptions = {};
|
|
3034
3023
|
const proxy = options?.proxy ? Object.assign({}, options.proxy) : this.#proxy;
|
|
3035
|
-
if (proxy?.
|
|
3036
|
-
browserContextOptions.proxyServer = proxy.
|
|
3024
|
+
if (proxy?.proxyUrl) {
|
|
3025
|
+
browserContextOptions.proxyServer = proxy.proxyUrl;
|
|
3037
3026
|
}
|
|
3038
3027
|
const browserContext = await this.#browser.createBrowserContext(browserContextOptions);
|
|
3039
3028
|
const userAgent = options?.userAgent ? options.userAgent : "";
|
|
@@ -17390,8 +17379,9 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17390
17379
|
if (maxWindowSize) {
|
|
17391
17380
|
args.push("--start-maximized");
|
|
17392
17381
|
}
|
|
17393
|
-
if (proxy?.
|
|
17394
|
-
|
|
17382
|
+
if (proxy?.proxyUrl && proxy.proxyUrl !== "local") {
|
|
17383
|
+
const { proxyUrl: server, username, password } = proxy;
|
|
17384
|
+
launchOptions.proxy = { server, username, password };
|
|
17395
17385
|
} else if (proxyPerBrowserContext && browserType === "chromium" && this.#osPlatform.startsWith("win")) {
|
|
17396
17386
|
launchOptions.proxy = { server: "proxyPerBrowserContext" };
|
|
17397
17387
|
}
|
|
@@ -17430,8 +17420,8 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17430
17420
|
} else if (userDataDir) {
|
|
17431
17421
|
args.push(`--user-data-dir=${userDataDir}`);
|
|
17432
17422
|
}
|
|
17433
|
-
if (proxy?.
|
|
17434
|
-
args.push(`--proxy-server=${proxy.
|
|
17423
|
+
if (proxy?.proxyUrl && proxy.proxyUrl !== "default") {
|
|
17424
|
+
args.push(`--proxy-server=${proxy.proxyUrl}`);
|
|
17435
17425
|
} else if (proxyPerBrowserContext && browserType === "chromium" && this.#osPlatform.startsWith("win")) {
|
|
17436
17426
|
args.push(`--proxy-server=proxyPerBrowserContext`);
|
|
17437
17427
|
}
|
|
@@ -17504,6 +17494,5 @@ var controller = new LsdBrowserController();
|
|
|
17504
17494
|
PuppeteerBrowserContext,
|
|
17505
17495
|
PuppeteerElement,
|
|
17506
17496
|
PuppeteerPage,
|
|
17507
|
-
controller
|
|
17508
|
-
defaultProxy
|
|
17497
|
+
controller
|
|
17509
17498
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -17,22 +17,11 @@ type AllPage = Page | Page$1;
|
|
|
17
17
|
type AllResponse = Response | HTTPResponse;
|
|
18
18
|
type AllApiRequestContext = APIRequestContext;
|
|
19
19
|
type CheerioNode = cheerio.Cheerio<cheerio.Element>;
|
|
20
|
-
type
|
|
21
|
-
|
|
20
|
+
type ProxyInController = {
|
|
21
|
+
proxyUrl: string;
|
|
22
22
|
username?: string;
|
|
23
23
|
password?: string;
|
|
24
24
|
proxyId?: string;
|
|
25
|
-
host?: string;
|
|
26
|
-
port?: number;
|
|
27
|
-
expireTime?: number;
|
|
28
|
-
proxyIpType?: string;
|
|
29
|
-
proxyDurationType?: string;
|
|
30
|
-
proxySharedType?: string;
|
|
31
|
-
latitude?: number;
|
|
32
|
-
longitude?: number;
|
|
33
|
-
freeable?: boolean;
|
|
34
|
-
interfaceName?: string;
|
|
35
|
-
packageName?: string;
|
|
36
25
|
};
|
|
37
26
|
type BrowserControllerType = "puppeteer" | "playwright";
|
|
38
27
|
type BrowserCreationMethod = "launch" | "connect";
|
|
@@ -45,7 +34,6 @@ interface PlaywrightBrowserTypes {
|
|
|
45
34
|
type BrowserControllerOptions = {
|
|
46
35
|
browserControllerType: BrowserControllerType;
|
|
47
36
|
};
|
|
48
|
-
declare const defaultProxy: Proxy;
|
|
49
37
|
interface BrowserOptions {
|
|
50
38
|
/**
|
|
51
39
|
* Interval between closing free pages (seconds) if greater than 0
|
|
@@ -76,7 +64,7 @@ interface BrowserOptions {
|
|
|
76
64
|
* * this will used as default proxy when creating new browserContexts later
|
|
77
65
|
* @default null
|
|
78
66
|
*/
|
|
79
|
-
proxy?:
|
|
67
|
+
proxy?: ProxyInController | null;
|
|
80
68
|
/**
|
|
81
69
|
* Maximum time in milliseconds to wait for the browser instance to start. Pass 0 to disable timeout.
|
|
82
70
|
* * default 30_000 (30 seconds)
|
|
@@ -143,7 +131,7 @@ interface LsdConnectOptions extends BrowserOptions {
|
|
|
143
131
|
userAgent?: string;
|
|
144
132
|
}
|
|
145
133
|
type LsdBrowserContextOptions = {
|
|
146
|
-
proxy:
|
|
134
|
+
proxy: ProxyInController | null;
|
|
147
135
|
/**
|
|
148
136
|
* @default browser.options.maxViewportOfNewPage
|
|
149
137
|
*/
|
|
@@ -154,7 +142,6 @@ type LsdBrowserContextOptions = {
|
|
|
154
142
|
* * puppeteer: set when creating the new page in the browserContext
|
|
155
143
|
*/
|
|
156
144
|
userAgent?: string;
|
|
157
|
-
fingerPrint: Object;
|
|
158
145
|
};
|
|
159
146
|
type PageStatus = "free" | "busy" | "closed";
|
|
160
147
|
/**
|
|
@@ -875,6 +862,10 @@ interface LsdPage extends EventEmitter {
|
|
|
875
862
|
* @param stateData
|
|
876
863
|
*/
|
|
877
864
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
865
|
+
/**
|
|
866
|
+
* valid only in puppeteer
|
|
867
|
+
* @param userAgent
|
|
868
|
+
*/
|
|
878
869
|
setUserAgent(userAgent: string): Promise<boolean>;
|
|
879
870
|
setViewportSize(viewPortSize: ViewportSize): Promise<boolean>;
|
|
880
871
|
stateData(): Promise<StateData>;
|
|
@@ -913,30 +904,41 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
913
904
|
*/
|
|
914
905
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
915
906
|
/**
|
|
916
|
-
*
|
|
917
|
-
* * TBD:需要预留pageQuota给需要capName的TE使用
|
|
907
|
+
* get a free page from current pages or by creating a new page
|
|
918
908
|
*/
|
|
919
909
|
getPage(always?: boolean): Promise<LsdPage | null>;
|
|
920
910
|
/**
|
|
921
|
-
*
|
|
922
|
-
*
|
|
911
|
+
* whether can get a number of free page(s)
|
|
912
|
+
* * refer to getPage()
|
|
913
|
+
* @param pageNum default 1, the number of free pages
|
|
923
914
|
*/
|
|
924
915
|
hasNewPage(pageNum?: number): boolean;
|
|
925
916
|
id(): string;
|
|
926
917
|
isIncognito(): boolean;
|
|
927
918
|
page(pageIdx: number): LsdPage | null;
|
|
928
919
|
pages(): LsdPage[];
|
|
929
|
-
proxy():
|
|
920
|
+
proxy(): ProxyInController | null;
|
|
930
921
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
931
922
|
_origBrowserContext(): AllBrowserContext;
|
|
932
923
|
}
|
|
933
924
|
interface LsdBrowser extends EventEmitter {
|
|
934
925
|
newBrowserContext(options?: LsdBrowserContextOptions): Promise<LsdBrowserContext | null>;
|
|
926
|
+
/**
|
|
927
|
+
* 1. launched: close all browserContexts and this browser
|
|
928
|
+
* 2. connected:
|
|
929
|
+
* * in puppeteer: close all browserContexts and this browser???
|
|
930
|
+
* * in playwright: only browserContexts created by newContext will be closed, browser is disconnected and browser will not be closed
|
|
931
|
+
*/
|
|
935
932
|
close(): Promise<boolean>;
|
|
936
933
|
browserContexts(): LsdBrowserContext[];
|
|
937
934
|
browserControllerType(): BrowserControllerType;
|
|
938
935
|
browserCreationMethod(): BrowserCreationMethod;
|
|
939
936
|
browserType(): LsdBrowserType;
|
|
937
|
+
/**
|
|
938
|
+
* @returns
|
|
939
|
+
* 1. launched: actual executable path
|
|
940
|
+
* 2. connected: exectuablePath in LsdConnectOptions, default ""(unkown)
|
|
941
|
+
*/
|
|
940
942
|
executablePath(): string;
|
|
941
943
|
id(): string;
|
|
942
944
|
isConnected(): boolean;
|
|
@@ -1023,7 +1025,7 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1023
1025
|
|
|
1024
1026
|
declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1025
1027
|
#private;
|
|
1026
|
-
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, incognito?: boolean, proxy?:
|
|
1028
|
+
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, maxViewportOfNewPage?: boolean);
|
|
1027
1029
|
browser(): LsdBrowser;
|
|
1028
1030
|
close(): Promise<boolean>;
|
|
1029
1031
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
@@ -1033,7 +1035,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
1033
1035
|
isIncognito(): boolean;
|
|
1034
1036
|
page(pageIdx: number): LsdPage | null;
|
|
1035
1037
|
pages(): LsdPage[];
|
|
1036
|
-
proxy():
|
|
1038
|
+
proxy(): ProxyInController | null;
|
|
1037
1039
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
1038
1040
|
_origBrowserContext(): AllBrowserContext;
|
|
1039
1041
|
}
|
|
@@ -1132,7 +1134,7 @@ declare class PuppeteerBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1132
1134
|
|
|
1133
1135
|
declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1134
1136
|
#private;
|
|
1135
|
-
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext$1, incognito?: boolean, proxy?:
|
|
1137
|
+
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext$1, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, userAgent?: string, maxViewportOfNewPage?: boolean);
|
|
1136
1138
|
browser(): LsdBrowser;
|
|
1137
1139
|
close(): Promise<boolean>;
|
|
1138
1140
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
@@ -1142,7 +1144,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1142
1144
|
isIncognito(): boolean;
|
|
1143
1145
|
page(pageIdx: number): LsdPage | null;
|
|
1144
1146
|
pages(): LsdPage[];
|
|
1145
|
-
proxy():
|
|
1147
|
+
proxy(): ProxyInController | null;
|
|
1146
1148
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
1147
1149
|
_origBrowserContext(): AllBrowserContext;
|
|
1148
1150
|
}
|
|
@@ -1310,4 +1312,4 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
|
1310
1312
|
}
|
|
1311
1313
|
declare const controller: LsdBrowserController;
|
|
1312
1314
|
|
|
1313
|
-
export { type AllApiRequestContext, 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
|
|
1315
|
+
export { type AllApiRequestContext, 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 ProxyInController, 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 ResponsePageData, type ScreenshotOptions, type SelectOptions, type StateData, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,22 +17,11 @@ type AllPage = Page | Page$1;
|
|
|
17
17
|
type AllResponse = Response | HTTPResponse;
|
|
18
18
|
type AllApiRequestContext = APIRequestContext;
|
|
19
19
|
type CheerioNode = cheerio.Cheerio<cheerio.Element>;
|
|
20
|
-
type
|
|
21
|
-
|
|
20
|
+
type ProxyInController = {
|
|
21
|
+
proxyUrl: string;
|
|
22
22
|
username?: string;
|
|
23
23
|
password?: string;
|
|
24
24
|
proxyId?: string;
|
|
25
|
-
host?: string;
|
|
26
|
-
port?: number;
|
|
27
|
-
expireTime?: number;
|
|
28
|
-
proxyIpType?: string;
|
|
29
|
-
proxyDurationType?: string;
|
|
30
|
-
proxySharedType?: string;
|
|
31
|
-
latitude?: number;
|
|
32
|
-
longitude?: number;
|
|
33
|
-
freeable?: boolean;
|
|
34
|
-
interfaceName?: string;
|
|
35
|
-
packageName?: string;
|
|
36
25
|
};
|
|
37
26
|
type BrowserControllerType = "puppeteer" | "playwright";
|
|
38
27
|
type BrowserCreationMethod = "launch" | "connect";
|
|
@@ -45,7 +34,6 @@ interface PlaywrightBrowserTypes {
|
|
|
45
34
|
type BrowserControllerOptions = {
|
|
46
35
|
browserControllerType: BrowserControllerType;
|
|
47
36
|
};
|
|
48
|
-
declare const defaultProxy: Proxy;
|
|
49
37
|
interface BrowserOptions {
|
|
50
38
|
/**
|
|
51
39
|
* Interval between closing free pages (seconds) if greater than 0
|
|
@@ -76,7 +64,7 @@ interface BrowserOptions {
|
|
|
76
64
|
* * this will used as default proxy when creating new browserContexts later
|
|
77
65
|
* @default null
|
|
78
66
|
*/
|
|
79
|
-
proxy?:
|
|
67
|
+
proxy?: ProxyInController | null;
|
|
80
68
|
/**
|
|
81
69
|
* Maximum time in milliseconds to wait for the browser instance to start. Pass 0 to disable timeout.
|
|
82
70
|
* * default 30_000 (30 seconds)
|
|
@@ -143,7 +131,7 @@ interface LsdConnectOptions extends BrowserOptions {
|
|
|
143
131
|
userAgent?: string;
|
|
144
132
|
}
|
|
145
133
|
type LsdBrowserContextOptions = {
|
|
146
|
-
proxy:
|
|
134
|
+
proxy: ProxyInController | null;
|
|
147
135
|
/**
|
|
148
136
|
* @default browser.options.maxViewportOfNewPage
|
|
149
137
|
*/
|
|
@@ -154,7 +142,6 @@ type LsdBrowserContextOptions = {
|
|
|
154
142
|
* * puppeteer: set when creating the new page in the browserContext
|
|
155
143
|
*/
|
|
156
144
|
userAgent?: string;
|
|
157
|
-
fingerPrint: Object;
|
|
158
145
|
};
|
|
159
146
|
type PageStatus = "free" | "busy" | "closed";
|
|
160
147
|
/**
|
|
@@ -875,6 +862,10 @@ interface LsdPage extends EventEmitter {
|
|
|
875
862
|
* @param stateData
|
|
876
863
|
*/
|
|
877
864
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
865
|
+
/**
|
|
866
|
+
* valid only in puppeteer
|
|
867
|
+
* @param userAgent
|
|
868
|
+
*/
|
|
878
869
|
setUserAgent(userAgent: string): Promise<boolean>;
|
|
879
870
|
setViewportSize(viewPortSize: ViewportSize): Promise<boolean>;
|
|
880
871
|
stateData(): Promise<StateData>;
|
|
@@ -913,30 +904,41 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
913
904
|
*/
|
|
914
905
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
915
906
|
/**
|
|
916
|
-
*
|
|
917
|
-
* * TBD:需要预留pageQuota给需要capName的TE使用
|
|
907
|
+
* get a free page from current pages or by creating a new page
|
|
918
908
|
*/
|
|
919
909
|
getPage(always?: boolean): Promise<LsdPage | null>;
|
|
920
910
|
/**
|
|
921
|
-
*
|
|
922
|
-
*
|
|
911
|
+
* whether can get a number of free page(s)
|
|
912
|
+
* * refer to getPage()
|
|
913
|
+
* @param pageNum default 1, the number of free pages
|
|
923
914
|
*/
|
|
924
915
|
hasNewPage(pageNum?: number): boolean;
|
|
925
916
|
id(): string;
|
|
926
917
|
isIncognito(): boolean;
|
|
927
918
|
page(pageIdx: number): LsdPage | null;
|
|
928
919
|
pages(): LsdPage[];
|
|
929
|
-
proxy():
|
|
920
|
+
proxy(): ProxyInController | null;
|
|
930
921
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
931
922
|
_origBrowserContext(): AllBrowserContext;
|
|
932
923
|
}
|
|
933
924
|
interface LsdBrowser extends EventEmitter {
|
|
934
925
|
newBrowserContext(options?: LsdBrowserContextOptions): Promise<LsdBrowserContext | null>;
|
|
926
|
+
/**
|
|
927
|
+
* 1. launched: close all browserContexts and this browser
|
|
928
|
+
* 2. connected:
|
|
929
|
+
* * in puppeteer: close all browserContexts and this browser???
|
|
930
|
+
* * in playwright: only browserContexts created by newContext will be closed, browser is disconnected and browser will not be closed
|
|
931
|
+
*/
|
|
935
932
|
close(): Promise<boolean>;
|
|
936
933
|
browserContexts(): LsdBrowserContext[];
|
|
937
934
|
browserControllerType(): BrowserControllerType;
|
|
938
935
|
browserCreationMethod(): BrowserCreationMethod;
|
|
939
936
|
browserType(): LsdBrowserType;
|
|
937
|
+
/**
|
|
938
|
+
* @returns
|
|
939
|
+
* 1. launched: actual executable path
|
|
940
|
+
* 2. connected: exectuablePath in LsdConnectOptions, default ""(unkown)
|
|
941
|
+
*/
|
|
940
942
|
executablePath(): string;
|
|
941
943
|
id(): string;
|
|
942
944
|
isConnected(): boolean;
|
|
@@ -1023,7 +1025,7 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1023
1025
|
|
|
1024
1026
|
declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1025
1027
|
#private;
|
|
1026
|
-
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, incognito?: boolean, proxy?:
|
|
1028
|
+
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, maxViewportOfNewPage?: boolean);
|
|
1027
1029
|
browser(): LsdBrowser;
|
|
1028
1030
|
close(): Promise<boolean>;
|
|
1029
1031
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
@@ -1033,7 +1035,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
1033
1035
|
isIncognito(): boolean;
|
|
1034
1036
|
page(pageIdx: number): LsdPage | null;
|
|
1035
1037
|
pages(): LsdPage[];
|
|
1036
|
-
proxy():
|
|
1038
|
+
proxy(): ProxyInController | null;
|
|
1037
1039
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
1038
1040
|
_origBrowserContext(): AllBrowserContext;
|
|
1039
1041
|
}
|
|
@@ -1132,7 +1134,7 @@ declare class PuppeteerBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1132
1134
|
|
|
1133
1135
|
declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1134
1136
|
#private;
|
|
1135
|
-
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext$1, incognito?: boolean, proxy?:
|
|
1137
|
+
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext$1, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, userAgent?: string, maxViewportOfNewPage?: boolean);
|
|
1136
1138
|
browser(): LsdBrowser;
|
|
1137
1139
|
close(): Promise<boolean>;
|
|
1138
1140
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
@@ -1142,7 +1144,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1142
1144
|
isIncognito(): boolean;
|
|
1143
1145
|
page(pageIdx: number): LsdPage | null;
|
|
1144
1146
|
pages(): LsdPage[];
|
|
1145
|
-
proxy():
|
|
1147
|
+
proxy(): ProxyInController | null;
|
|
1146
1148
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
1147
1149
|
_origBrowserContext(): AllBrowserContext;
|
|
1148
1150
|
}
|
|
@@ -1310,4 +1312,4 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
|
1310
1312
|
}
|
|
1311
1313
|
declare const controller: LsdBrowserController;
|
|
1312
1314
|
|
|
1313
|
-
export { type AllApiRequestContext, 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
|
|
1315
|
+
export { type AllApiRequestContext, 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 ProxyInController, 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 ResponsePageData, type ScreenshotOptions, type SelectOptions, type StateData, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller };
|
package/dist/index.js
CHANGED
|
@@ -43,16 +43,6 @@ var require_boolbase = __commonJS({
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
// src/types/types.ts
|
|
47
|
-
var defaultProxy = {
|
|
48
|
-
server: "default",
|
|
49
|
-
proxyIpType: "residential",
|
|
50
|
-
proxyDurationType: "static",
|
|
51
|
-
proxySharedType: "dedicated",
|
|
52
|
-
expireTime: 41024196e5
|
|
53
|
-
// "2100-01-01 01:00:00"
|
|
54
|
-
};
|
|
55
|
-
|
|
56
46
|
// src/playwright/browser.ts
|
|
57
47
|
import EventEmitter3 from "events";
|
|
58
48
|
|
|
@@ -1214,7 +1204,7 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
|
|
|
1214
1204
|
this.#browserContext = browserContext;
|
|
1215
1205
|
this.#createTime = getCurrentUnixTime2();
|
|
1216
1206
|
this.#incognito = incognito === false ? false : true;
|
|
1217
|
-
this.#proxy = proxy?.
|
|
1207
|
+
this.#proxy = proxy?.proxyUrl ? proxy : null;
|
|
1218
1208
|
this.#maxPagesPerBrowserContext = maxPagesPerBrowserContext;
|
|
1219
1209
|
this.#maxPageFreeSeconds = maxPageFreeSeconds;
|
|
1220
1210
|
this.#maxViewportOfNewPage = maxViewportOfNewPage;
|
|
@@ -1523,7 +1513,7 @@ var PlaywrightBrowser = class extends EventEmitter3 {
|
|
|
1523
1513
|
}
|
|
1524
1514
|
const proxy = options?.proxy ? Object.assign({}, options.proxy) : this.#proxy;
|
|
1525
1515
|
if (proxy) {
|
|
1526
|
-
const { server, username, password } = proxy;
|
|
1516
|
+
const { proxyUrl: server, username, password } = proxy;
|
|
1527
1517
|
browserContextOptions.proxy = { server, username, password };
|
|
1528
1518
|
}
|
|
1529
1519
|
if (options?.userAgent) {
|
|
@@ -2699,7 +2689,7 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
|
|
|
2699
2689
|
this.#userAgent = userAgent;
|
|
2700
2690
|
this.#createTime = getCurrentUnixTime4();
|
|
2701
2691
|
this.#incognito = incognito === false ? false : true;
|
|
2702
|
-
this.#proxy = proxy?.
|
|
2692
|
+
this.#proxy = proxy?.proxyUrl ? proxy : null;
|
|
2703
2693
|
this.#maxPagesPerBrowserContext = maxPagesPerBrowserContext;
|
|
2704
2694
|
this.#maxPageFreeSeconds = maxPageFreeSeconds;
|
|
2705
2695
|
this.#maxViewportOfNewPage = maxViewportOfNewPage;
|
|
@@ -3012,8 +3002,8 @@ var PuppeteerBrowser = class extends EventEmitter6 {
|
|
|
3012
3002
|
}
|
|
3013
3003
|
const browserContextOptions = {};
|
|
3014
3004
|
const proxy = options?.proxy ? Object.assign({}, options.proxy) : this.#proxy;
|
|
3015
|
-
if (proxy?.
|
|
3016
|
-
browserContextOptions.proxyServer = proxy.
|
|
3005
|
+
if (proxy?.proxyUrl) {
|
|
3006
|
+
browserContextOptions.proxyServer = proxy.proxyUrl;
|
|
3017
3007
|
}
|
|
3018
3008
|
const browserContext = await this.#browser.createBrowserContext(browserContextOptions);
|
|
3019
3009
|
const userAgent = options?.userAgent ? options.userAgent : "";
|
|
@@ -17370,8 +17360,9 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17370
17360
|
if (maxWindowSize) {
|
|
17371
17361
|
args.push("--start-maximized");
|
|
17372
17362
|
}
|
|
17373
|
-
if (proxy?.
|
|
17374
|
-
|
|
17363
|
+
if (proxy?.proxyUrl && proxy.proxyUrl !== "local") {
|
|
17364
|
+
const { proxyUrl: server, username, password } = proxy;
|
|
17365
|
+
launchOptions.proxy = { server, username, password };
|
|
17375
17366
|
} else if (proxyPerBrowserContext && browserType === "chromium" && this.#osPlatform.startsWith("win")) {
|
|
17376
17367
|
launchOptions.proxy = { server: "proxyPerBrowserContext" };
|
|
17377
17368
|
}
|
|
@@ -17410,8 +17401,8 @@ var LsdBrowserController = class _LsdBrowserController {
|
|
|
17410
17401
|
} else if (userDataDir) {
|
|
17411
17402
|
args.push(`--user-data-dir=${userDataDir}`);
|
|
17412
17403
|
}
|
|
17413
|
-
if (proxy?.
|
|
17414
|
-
args.push(`--proxy-server=${proxy.
|
|
17404
|
+
if (proxy?.proxyUrl && proxy.proxyUrl !== "default") {
|
|
17405
|
+
args.push(`--proxy-server=${proxy.proxyUrl}`);
|
|
17415
17406
|
} else if (proxyPerBrowserContext && browserType === "chromium" && this.#osPlatform.startsWith("win")) {
|
|
17416
17407
|
args.push(`--proxy-server=proxyPerBrowserContext`);
|
|
17417
17408
|
}
|
|
@@ -17483,6 +17474,5 @@ export {
|
|
|
17483
17474
|
PuppeteerBrowserContext,
|
|
17484
17475
|
PuppeteerElement,
|
|
17485
17476
|
PuppeteerPage,
|
|
17486
|
-
controller
|
|
17487
|
-
defaultProxy
|
|
17477
|
+
controller
|
|
17488
17478
|
};
|
package/package.json
CHANGED