@letsscrapedata/controller 0.0.37 → 0.0.39
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 +325 -14120
- package/dist/index.d.cts +102 -19
- package/dist/index.d.ts +102 -19
- package/dist/index.js +317 -14139
- package/package.json +50 -47
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
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, APIRequestContext, BrowserType, Locator, FrameLocator } from 'playwright';
|
|
4
|
-
import * as cheerio from 'cheerio';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* 命名规则:为了与playwright/puppeteer中的同名区别
|
|
8
|
-
* 1.
|
|
9
|
-
* 2.
|
|
10
|
-
* 3. 接口的实现类class的名称: LsdXxxYyy,如LsdBrowserContext
|
|
7
|
+
* 1. name of type:AllXxxYyy,如AllBrowserContext
|
|
8
|
+
* 2. 接口的实现类class的名称: LsdXxxYyy,如LsdBrowserContext
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
type AllBrowser = Browser | Browser$1;
|
|
@@ -16,16 +14,80 @@ type AllFrame = Frame | Frame$1;
|
|
|
16
14
|
type AllPage = Page | Page$1;
|
|
17
15
|
type AllResponse = Response | HTTPResponse;
|
|
18
16
|
type AllApiRequestContext = APIRequestContext;
|
|
19
|
-
type CheerioNode = cheerio.Cheerio
|
|
20
|
-
type
|
|
17
|
+
type CheerioNode = cheerio.Cheerio;
|
|
18
|
+
type BrowserControllerType = "puppeteer" | "playwright";
|
|
19
|
+
type BrowserCreationMethod = "launch" | "connect";
|
|
20
|
+
type LsdBrowserType = "chromium" | "firefox" | "webkit";
|
|
21
|
+
interface BrowserContextRequirements {
|
|
22
|
+
browserControllerTypes: BrowserControllerType[];
|
|
23
|
+
browserTypes: LsdBrowserType[];
|
|
24
|
+
headlesses: boolean[];
|
|
25
|
+
incognitos: boolean[];
|
|
26
|
+
}
|
|
27
|
+
interface ProxyInController {
|
|
21
28
|
proxyUrl: string;
|
|
22
29
|
username?: string;
|
|
23
30
|
password?: string;
|
|
24
31
|
proxyId?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
}
|
|
33
|
+
interface ClientCertificate {
|
|
34
|
+
origin: string;
|
|
35
|
+
cert?: Buffer;
|
|
36
|
+
certPath?: string;
|
|
37
|
+
key?: Buffer;
|
|
38
|
+
keyPath?: string;
|
|
39
|
+
pfx?: Buffer;
|
|
40
|
+
pfxPath?: string;
|
|
41
|
+
passphrase?: string;
|
|
42
|
+
}
|
|
43
|
+
interface LsdApiContextOptions {
|
|
44
|
+
proxy?: ProxyInController;
|
|
45
|
+
/**
|
|
46
|
+
* storageState
|
|
47
|
+
*/
|
|
48
|
+
stateData?: BrowserStateData;
|
|
49
|
+
userAgent?: string;
|
|
50
|
+
timeout?: number;
|
|
51
|
+
ignoreHTTPSErrors?: boolean;
|
|
52
|
+
extraHTTPHeaders?: Record<string, string>;
|
|
53
|
+
httpCredentials?: {
|
|
54
|
+
username: string;
|
|
55
|
+
password: string;
|
|
56
|
+
origin?: string;
|
|
57
|
+
send?: 'always' | 'unauthorized';
|
|
58
|
+
};
|
|
59
|
+
clientCertificates?: ClientCertificate[];
|
|
60
|
+
}
|
|
61
|
+
interface LsdFetchOptions {
|
|
62
|
+
/**
|
|
63
|
+
* @default "get"
|
|
64
|
+
*/
|
|
65
|
+
method?: "delete" | "get" | "post" | "put";
|
|
66
|
+
params?: Record<string, string | number | boolean>;
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
data?: any;
|
|
69
|
+
form?: Record<string, string | number | boolean>;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
failOnStatusCode?: boolean;
|
|
72
|
+
ignoreHTTPSErrors?: boolean;
|
|
73
|
+
maxRedirects?: number;
|
|
74
|
+
maxRetries?: number;
|
|
75
|
+
}
|
|
76
|
+
interface LsdApiResponse {
|
|
77
|
+
headers: Record<string, string>;
|
|
78
|
+
status: number;
|
|
79
|
+
statusText: string;
|
|
80
|
+
text: string;
|
|
81
|
+
url: string;
|
|
82
|
+
}
|
|
83
|
+
interface LsdApiContext {
|
|
84
|
+
fetch(url: string, options?: LsdFetchOptions): Promise<LsdApiResponse>;
|
|
85
|
+
stateData(): Promise<BrowserStateData>;
|
|
86
|
+
/**
|
|
87
|
+
* destroyed LsdApiContext cannot be used again, or throw an exeception
|
|
88
|
+
*/
|
|
89
|
+
destroy(): Promise<boolean>;
|
|
90
|
+
}
|
|
29
91
|
interface PlaywrightBrowserTypes {
|
|
30
92
|
chromium: BrowserType;
|
|
31
93
|
firefox: BrowserType;
|
|
@@ -771,10 +833,10 @@ interface WaitNavigationOptions {
|
|
|
771
833
|
type PageEvent = "pageClose" | "pagePopup";
|
|
772
834
|
interface LsdPage extends EventEmitter {
|
|
773
835
|
/**
|
|
774
|
-
* Get the
|
|
836
|
+
* Get the LsdApiContext associated with this page's LsdBrowserContext
|
|
775
837
|
* * only vaild in playwright
|
|
776
838
|
*/
|
|
777
|
-
|
|
839
|
+
apiContext(): LsdApiContext;
|
|
778
840
|
bringToFront(): Promise<boolean>;
|
|
779
841
|
browserContext(): LsdBrowserContext;
|
|
780
842
|
/**
|
|
@@ -916,6 +978,11 @@ interface LsdPage extends EventEmitter {
|
|
|
916
978
|
_origPage(): AllPage;
|
|
917
979
|
}
|
|
918
980
|
interface LsdBrowserContext extends EventEmitter {
|
|
981
|
+
/**
|
|
982
|
+
* Get the LsdApiContext associated with this LsdBrowserContext
|
|
983
|
+
* * only vaild in playwright
|
|
984
|
+
*/
|
|
985
|
+
apiContext(): LsdApiContext;
|
|
919
986
|
browser(): LsdBrowser;
|
|
920
987
|
close(): Promise<boolean>;
|
|
921
988
|
/**
|
|
@@ -924,6 +991,11 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
924
991
|
* @default 0 the default maxPageFreeSeconds of the browserContext will be used
|
|
925
992
|
*/
|
|
926
993
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
994
|
+
/**
|
|
995
|
+
* doest this browser meet browserContextRequirements (incognitos ignored in browser)?
|
|
996
|
+
* @param browserContextRequirements
|
|
997
|
+
*/
|
|
998
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
927
999
|
/**
|
|
928
1000
|
* get a free page from current pages or by creating a new page
|
|
929
1001
|
*/
|
|
@@ -955,6 +1027,11 @@ interface LsdBrowser extends EventEmitter {
|
|
|
955
1027
|
browserControllerType(): BrowserControllerType;
|
|
956
1028
|
browserCreationMethod(): BrowserCreationMethod;
|
|
957
1029
|
browserType(): LsdBrowserType;
|
|
1030
|
+
/**
|
|
1031
|
+
* doest this browser meet browserContextRequirements (incognitos ignored in browser)?
|
|
1032
|
+
* @param browserContextRequirements
|
|
1033
|
+
*/
|
|
1034
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
958
1035
|
/**
|
|
959
1036
|
* @returns
|
|
960
1037
|
* 1. launched: actual executable path
|
|
@@ -1009,9 +1086,9 @@ interface LsdBrowserController$1 {
|
|
|
1009
1086
|
*/
|
|
1010
1087
|
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1011
1088
|
/**
|
|
1012
|
-
* Create a new
|
|
1089
|
+
* Create a new LsdApiContext, valid in playwright;
|
|
1013
1090
|
*/
|
|
1014
|
-
|
|
1091
|
+
newApiContext(options?: LsdApiContextOptions): Promise<LsdApiContext>;
|
|
1015
1092
|
}
|
|
1016
1093
|
/**
|
|
1017
1094
|
* globObj.cfg.XXX:
|
|
@@ -1050,6 +1127,7 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1050
1127
|
browserControllerType(): BrowserControllerType;
|
|
1051
1128
|
browserCreationMethod(): BrowserCreationMethod;
|
|
1052
1129
|
browserType(): LsdBrowserType;
|
|
1130
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1053
1131
|
executablePath(): string;
|
|
1054
1132
|
id(): string;
|
|
1055
1133
|
isConnected(): boolean;
|
|
@@ -1067,9 +1145,11 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1067
1145
|
declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1068
1146
|
#private;
|
|
1069
1147
|
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, maxViewportOfNewPage?: boolean);
|
|
1148
|
+
apiContext(): LsdApiContext;
|
|
1070
1149
|
browser(): LsdBrowser;
|
|
1071
1150
|
close(): Promise<boolean>;
|
|
1072
1151
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
1152
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1073
1153
|
getPage(always?: boolean): Promise<LsdPage | null>;
|
|
1074
1154
|
hasFreePage(pageNum?: number): boolean;
|
|
1075
1155
|
id(): string;
|
|
@@ -1084,7 +1164,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
1084
1164
|
declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
1085
1165
|
#private;
|
|
1086
1166
|
constructor(browserContext: LsdBrowserContext, page: Page, pageInfo?: PageInfo);
|
|
1087
|
-
|
|
1167
|
+
apiContext(): LsdApiContext;
|
|
1088
1168
|
bringToFront(): Promise<boolean>;
|
|
1089
1169
|
browserContext(): LsdBrowserContext;
|
|
1090
1170
|
clearCookies(): Promise<boolean>;
|
|
@@ -1166,6 +1246,7 @@ declare class PuppeteerBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1166
1246
|
browserControllerType(): BrowserControllerType;
|
|
1167
1247
|
browserCreationMethod(): BrowserCreationMethod;
|
|
1168
1248
|
browserType(): LsdBrowserType;
|
|
1249
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1169
1250
|
executablePath(): string;
|
|
1170
1251
|
id(): string;
|
|
1171
1252
|
isConnected(): boolean;
|
|
@@ -1183,9 +1264,11 @@ declare class PuppeteerBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1183
1264
|
declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1184
1265
|
#private;
|
|
1185
1266
|
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext$1, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, userAgent?: string, maxViewportOfNewPage?: boolean);
|
|
1267
|
+
apiContext(): LsdApiContext;
|
|
1186
1268
|
browser(): LsdBrowser;
|
|
1187
1269
|
close(): Promise<boolean>;
|
|
1188
1270
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
1271
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1189
1272
|
getPage(always?: boolean): Promise<LsdPage | null>;
|
|
1190
1273
|
hasFreePage(pageNum?: number): boolean;
|
|
1191
1274
|
id(): string;
|
|
@@ -1200,7 +1283,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1200
1283
|
declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
1201
1284
|
#private;
|
|
1202
1285
|
constructor(browserContext: LsdBrowserContext, page: Page$1, pageInfo?: PageInfo);
|
|
1203
|
-
|
|
1286
|
+
apiContext(): LsdApiContext;
|
|
1204
1287
|
bringToFront(): Promise<boolean>;
|
|
1205
1288
|
browserContext(): LsdBrowserContext;
|
|
1206
1289
|
clearCookies(): Promise<boolean>;
|
|
@@ -1282,7 +1365,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1282
1365
|
*/
|
|
1283
1366
|
constructor(html?: string, isHtml?: boolean);
|
|
1284
1367
|
_origPage(): AllPage;
|
|
1285
|
-
|
|
1368
|
+
apiContext(): LsdApiContext;
|
|
1286
1369
|
bringToFront(): Promise<boolean>;
|
|
1287
1370
|
browserContext(): LsdBrowserContext;
|
|
1288
1371
|
clearCookies(): Promise<boolean>;
|
|
@@ -1360,8 +1443,8 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
|
1360
1443
|
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1361
1444
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1362
1445
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1363
|
-
|
|
1446
|
+
newApiContext(options?: LsdApiContextOptions): Promise<LsdApiContext>;
|
|
1364
1447
|
}
|
|
1365
1448
|
declare const controller: LsdBrowserController;
|
|
1366
1449
|
|
|
1367
|
-
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserManager, type BrowserStateData, 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 UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller };
|
|
1450
|
+
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserContextRequirements, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserManager, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, type CookieItem, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdApiContext, type LsdApiContextOptions, type LsdApiResponse, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, 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 UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
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, APIRequestContext, BrowserType, Locator, FrameLocator } from 'playwright';
|
|
4
|
-
import * as cheerio from 'cheerio';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* 命名规则:为了与playwright/puppeteer中的同名区别
|
|
8
|
-
* 1.
|
|
9
|
-
* 2.
|
|
10
|
-
* 3. 接口的实现类class的名称: LsdXxxYyy,如LsdBrowserContext
|
|
7
|
+
* 1. name of type:AllXxxYyy,如AllBrowserContext
|
|
8
|
+
* 2. 接口的实现类class的名称: LsdXxxYyy,如LsdBrowserContext
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
type AllBrowser = Browser | Browser$1;
|
|
@@ -16,16 +14,80 @@ type AllFrame = Frame | Frame$1;
|
|
|
16
14
|
type AllPage = Page | Page$1;
|
|
17
15
|
type AllResponse = Response | HTTPResponse;
|
|
18
16
|
type AllApiRequestContext = APIRequestContext;
|
|
19
|
-
type CheerioNode = cheerio.Cheerio
|
|
20
|
-
type
|
|
17
|
+
type CheerioNode = cheerio.Cheerio;
|
|
18
|
+
type BrowserControllerType = "puppeteer" | "playwright";
|
|
19
|
+
type BrowserCreationMethod = "launch" | "connect";
|
|
20
|
+
type LsdBrowserType = "chromium" | "firefox" | "webkit";
|
|
21
|
+
interface BrowserContextRequirements {
|
|
22
|
+
browserControllerTypes: BrowserControllerType[];
|
|
23
|
+
browserTypes: LsdBrowserType[];
|
|
24
|
+
headlesses: boolean[];
|
|
25
|
+
incognitos: boolean[];
|
|
26
|
+
}
|
|
27
|
+
interface ProxyInController {
|
|
21
28
|
proxyUrl: string;
|
|
22
29
|
username?: string;
|
|
23
30
|
password?: string;
|
|
24
31
|
proxyId?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
}
|
|
33
|
+
interface ClientCertificate {
|
|
34
|
+
origin: string;
|
|
35
|
+
cert?: Buffer;
|
|
36
|
+
certPath?: string;
|
|
37
|
+
key?: Buffer;
|
|
38
|
+
keyPath?: string;
|
|
39
|
+
pfx?: Buffer;
|
|
40
|
+
pfxPath?: string;
|
|
41
|
+
passphrase?: string;
|
|
42
|
+
}
|
|
43
|
+
interface LsdApiContextOptions {
|
|
44
|
+
proxy?: ProxyInController;
|
|
45
|
+
/**
|
|
46
|
+
* storageState
|
|
47
|
+
*/
|
|
48
|
+
stateData?: BrowserStateData;
|
|
49
|
+
userAgent?: string;
|
|
50
|
+
timeout?: number;
|
|
51
|
+
ignoreHTTPSErrors?: boolean;
|
|
52
|
+
extraHTTPHeaders?: Record<string, string>;
|
|
53
|
+
httpCredentials?: {
|
|
54
|
+
username: string;
|
|
55
|
+
password: string;
|
|
56
|
+
origin?: string;
|
|
57
|
+
send?: 'always' | 'unauthorized';
|
|
58
|
+
};
|
|
59
|
+
clientCertificates?: ClientCertificate[];
|
|
60
|
+
}
|
|
61
|
+
interface LsdFetchOptions {
|
|
62
|
+
/**
|
|
63
|
+
* @default "get"
|
|
64
|
+
*/
|
|
65
|
+
method?: "delete" | "get" | "post" | "put";
|
|
66
|
+
params?: Record<string, string | number | boolean>;
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
data?: any;
|
|
69
|
+
form?: Record<string, string | number | boolean>;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
failOnStatusCode?: boolean;
|
|
72
|
+
ignoreHTTPSErrors?: boolean;
|
|
73
|
+
maxRedirects?: number;
|
|
74
|
+
maxRetries?: number;
|
|
75
|
+
}
|
|
76
|
+
interface LsdApiResponse {
|
|
77
|
+
headers: Record<string, string>;
|
|
78
|
+
status: number;
|
|
79
|
+
statusText: string;
|
|
80
|
+
text: string;
|
|
81
|
+
url: string;
|
|
82
|
+
}
|
|
83
|
+
interface LsdApiContext {
|
|
84
|
+
fetch(url: string, options?: LsdFetchOptions): Promise<LsdApiResponse>;
|
|
85
|
+
stateData(): Promise<BrowserStateData>;
|
|
86
|
+
/**
|
|
87
|
+
* destroyed LsdApiContext cannot be used again, or throw an exeception
|
|
88
|
+
*/
|
|
89
|
+
destroy(): Promise<boolean>;
|
|
90
|
+
}
|
|
29
91
|
interface PlaywrightBrowserTypes {
|
|
30
92
|
chromium: BrowserType;
|
|
31
93
|
firefox: BrowserType;
|
|
@@ -771,10 +833,10 @@ interface WaitNavigationOptions {
|
|
|
771
833
|
type PageEvent = "pageClose" | "pagePopup";
|
|
772
834
|
interface LsdPage extends EventEmitter {
|
|
773
835
|
/**
|
|
774
|
-
* Get the
|
|
836
|
+
* Get the LsdApiContext associated with this page's LsdBrowserContext
|
|
775
837
|
* * only vaild in playwright
|
|
776
838
|
*/
|
|
777
|
-
|
|
839
|
+
apiContext(): LsdApiContext;
|
|
778
840
|
bringToFront(): Promise<boolean>;
|
|
779
841
|
browserContext(): LsdBrowserContext;
|
|
780
842
|
/**
|
|
@@ -916,6 +978,11 @@ interface LsdPage extends EventEmitter {
|
|
|
916
978
|
_origPage(): AllPage;
|
|
917
979
|
}
|
|
918
980
|
interface LsdBrowserContext extends EventEmitter {
|
|
981
|
+
/**
|
|
982
|
+
* Get the LsdApiContext associated with this LsdBrowserContext
|
|
983
|
+
* * only vaild in playwright
|
|
984
|
+
*/
|
|
985
|
+
apiContext(): LsdApiContext;
|
|
919
986
|
browser(): LsdBrowser;
|
|
920
987
|
close(): Promise<boolean>;
|
|
921
988
|
/**
|
|
@@ -924,6 +991,11 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
924
991
|
* @default 0 the default maxPageFreeSeconds of the browserContext will be used
|
|
925
992
|
*/
|
|
926
993
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
994
|
+
/**
|
|
995
|
+
* doest this browser meet browserContextRequirements (incognitos ignored in browser)?
|
|
996
|
+
* @param browserContextRequirements
|
|
997
|
+
*/
|
|
998
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
927
999
|
/**
|
|
928
1000
|
* get a free page from current pages or by creating a new page
|
|
929
1001
|
*/
|
|
@@ -955,6 +1027,11 @@ interface LsdBrowser extends EventEmitter {
|
|
|
955
1027
|
browserControllerType(): BrowserControllerType;
|
|
956
1028
|
browserCreationMethod(): BrowserCreationMethod;
|
|
957
1029
|
browserType(): LsdBrowserType;
|
|
1030
|
+
/**
|
|
1031
|
+
* doest this browser meet browserContextRequirements (incognitos ignored in browser)?
|
|
1032
|
+
* @param browserContextRequirements
|
|
1033
|
+
*/
|
|
1034
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
958
1035
|
/**
|
|
959
1036
|
* @returns
|
|
960
1037
|
* 1. launched: actual executable path
|
|
@@ -1009,9 +1086,9 @@ interface LsdBrowserController$1 {
|
|
|
1009
1086
|
*/
|
|
1010
1087
|
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1011
1088
|
/**
|
|
1012
|
-
* Create a new
|
|
1089
|
+
* Create a new LsdApiContext, valid in playwright;
|
|
1013
1090
|
*/
|
|
1014
|
-
|
|
1091
|
+
newApiContext(options?: LsdApiContextOptions): Promise<LsdApiContext>;
|
|
1015
1092
|
}
|
|
1016
1093
|
/**
|
|
1017
1094
|
* globObj.cfg.XXX:
|
|
@@ -1050,6 +1127,7 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1050
1127
|
browserControllerType(): BrowserControllerType;
|
|
1051
1128
|
browserCreationMethod(): BrowserCreationMethod;
|
|
1052
1129
|
browserType(): LsdBrowserType;
|
|
1130
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1053
1131
|
executablePath(): string;
|
|
1054
1132
|
id(): string;
|
|
1055
1133
|
isConnected(): boolean;
|
|
@@ -1067,9 +1145,11 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1067
1145
|
declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1068
1146
|
#private;
|
|
1069
1147
|
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, maxViewportOfNewPage?: boolean);
|
|
1148
|
+
apiContext(): LsdApiContext;
|
|
1070
1149
|
browser(): LsdBrowser;
|
|
1071
1150
|
close(): Promise<boolean>;
|
|
1072
1151
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
1152
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1073
1153
|
getPage(always?: boolean): Promise<LsdPage | null>;
|
|
1074
1154
|
hasFreePage(pageNum?: number): boolean;
|
|
1075
1155
|
id(): string;
|
|
@@ -1084,7 +1164,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
1084
1164
|
declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
1085
1165
|
#private;
|
|
1086
1166
|
constructor(browserContext: LsdBrowserContext, page: Page, pageInfo?: PageInfo);
|
|
1087
|
-
|
|
1167
|
+
apiContext(): LsdApiContext;
|
|
1088
1168
|
bringToFront(): Promise<boolean>;
|
|
1089
1169
|
browserContext(): LsdBrowserContext;
|
|
1090
1170
|
clearCookies(): Promise<boolean>;
|
|
@@ -1166,6 +1246,7 @@ declare class PuppeteerBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1166
1246
|
browserControllerType(): BrowserControllerType;
|
|
1167
1247
|
browserCreationMethod(): BrowserCreationMethod;
|
|
1168
1248
|
browserType(): LsdBrowserType;
|
|
1249
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1169
1250
|
executablePath(): string;
|
|
1170
1251
|
id(): string;
|
|
1171
1252
|
isConnected(): boolean;
|
|
@@ -1183,9 +1264,11 @@ declare class PuppeteerBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1183
1264
|
declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1184
1265
|
#private;
|
|
1185
1266
|
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext$1, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, userAgent?: string, maxViewportOfNewPage?: boolean);
|
|
1267
|
+
apiContext(): LsdApiContext;
|
|
1186
1268
|
browser(): LsdBrowser;
|
|
1187
1269
|
close(): Promise<boolean>;
|
|
1188
1270
|
closeFreePages(maxPageFreeSeconds?: number): Promise<boolean>;
|
|
1271
|
+
doesMeetBrowserContextRequirements(browserContextRequirements: BrowserContextRequirements): boolean;
|
|
1189
1272
|
getPage(always?: boolean): Promise<LsdPage | null>;
|
|
1190
1273
|
hasFreePage(pageNum?: number): boolean;
|
|
1191
1274
|
id(): string;
|
|
@@ -1200,7 +1283,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1200
1283
|
declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
1201
1284
|
#private;
|
|
1202
1285
|
constructor(browserContext: LsdBrowserContext, page: Page$1, pageInfo?: PageInfo);
|
|
1203
|
-
|
|
1286
|
+
apiContext(): LsdApiContext;
|
|
1204
1287
|
bringToFront(): Promise<boolean>;
|
|
1205
1288
|
browserContext(): LsdBrowserContext;
|
|
1206
1289
|
clearCookies(): Promise<boolean>;
|
|
@@ -1282,7 +1365,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1282
1365
|
*/
|
|
1283
1366
|
constructor(html?: string, isHtml?: boolean);
|
|
1284
1367
|
_origPage(): AllPage;
|
|
1285
|
-
|
|
1368
|
+
apiContext(): LsdApiContext;
|
|
1286
1369
|
bringToFront(): Promise<boolean>;
|
|
1287
1370
|
browserContext(): LsdBrowserContext;
|
|
1288
1371
|
clearCookies(): Promise<boolean>;
|
|
@@ -1360,8 +1443,8 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
|
1360
1443
|
setPlaywrightBrowserType(browserType: LsdBrowserType, playwrightBrowserType: BrowserType | null): boolean;
|
|
1361
1444
|
launch(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdLaunchOptions): Promise<LsdBrowser>;
|
|
1362
1445
|
connect(browserControllerType: BrowserControllerType, browserType: LsdBrowserType, options: LsdConnectOptions): Promise<LsdBrowser>;
|
|
1363
|
-
|
|
1446
|
+
newApiContext(options?: LsdApiContextOptions): Promise<LsdApiContext>;
|
|
1364
1447
|
}
|
|
1365
1448
|
declare const controller: LsdBrowserController;
|
|
1366
1449
|
|
|
1367
|
-
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserManager, type BrowserStateData, 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 UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller };
|
|
1450
|
+
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllFrame, type AllPage, type AllResponse, type BrowserContextRequirements, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserManager, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, type CookieItem, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdApiContext, type LsdApiContextOptions, type LsdApiResponse, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, 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 UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller };
|