@letsscrapedata/controller 0.0.3 → 0.0.5
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 +52 -22
- package/dist/index.d.cts +40 -7
- package/dist/index.d.ts +40 -7
- package/dist/index.js +52 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -497,17 +497,22 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
497
497
|
});
|
|
498
498
|
page.on("popup", (p) => {
|
|
499
499
|
if (p) {
|
|
500
|
+
let evtData = null;
|
|
500
501
|
const pageInfo = p.pageInfo;
|
|
501
502
|
let popupPageId = "page";
|
|
502
503
|
if (pageInfo) {
|
|
503
504
|
const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
|
|
504
505
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
505
506
|
pageInfo.openType = "popup";
|
|
507
|
+
evtData = this.browserContext().page(pageIdx);
|
|
508
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
509
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
510
|
+
}
|
|
506
511
|
} else {
|
|
507
512
|
(0, import_utils2.logerr)(`##browser ${pageId} has popup without page.pageInfo`);
|
|
508
513
|
}
|
|
509
514
|
(0, import_utils2.loginfo)(`##browser ${pageId} has popup ${popupPageId}`);
|
|
510
|
-
this.emit("pagePopup",
|
|
515
|
+
this.emit("pagePopup", evtData);
|
|
511
516
|
} else {
|
|
512
517
|
(0, import_utils2.logerr)(`##browser ${pageId} has popup page with null page`);
|
|
513
518
|
}
|
|
@@ -522,8 +527,8 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
522
527
|
this.#page = page;
|
|
523
528
|
this.#status = "free";
|
|
524
529
|
const currentTime = (0, import_utils2.getCurrentUnixTime)();
|
|
525
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
526
|
-
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId };
|
|
530
|
+
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0 } = pageInfo ? pageInfo : {};
|
|
531
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc: {} };
|
|
527
532
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
528
533
|
this.#resquestInterceptionOptions = [];
|
|
529
534
|
this.#responseInterceptionOptions = [];
|
|
@@ -809,14 +814,20 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
809
814
|
throw new Error("Invalid paras in setPageInfo");
|
|
810
815
|
}
|
|
811
816
|
const actPageInfo = this.#page.pageInfo;
|
|
812
|
-
|
|
813
|
-
|
|
817
|
+
const { lastStatusUpdateTime, taskId, relatedId, misc } = pageInfo;
|
|
818
|
+
if (typeof lastStatusUpdateTime === "number") {
|
|
819
|
+
actPageInfo.lastStatusUpdateTime = lastStatusUpdateTime;
|
|
820
|
+
}
|
|
821
|
+
if (typeof taskId === "number") {
|
|
822
|
+
actPageInfo.taskId = taskId;
|
|
814
823
|
}
|
|
815
|
-
if (typeof
|
|
816
|
-
actPageInfo.
|
|
824
|
+
if (typeof relatedId === "number") {
|
|
825
|
+
actPageInfo.relatedId = relatedId;
|
|
817
826
|
}
|
|
818
|
-
if (typeof
|
|
819
|
-
|
|
827
|
+
if (misc && typeof misc === "object") {
|
|
828
|
+
for (const key of Object.keys(misc)) {
|
|
829
|
+
actPageInfo.misc[key] = misc[key];
|
|
830
|
+
}
|
|
820
831
|
}
|
|
821
832
|
return true;
|
|
822
833
|
}
|
|
@@ -1093,7 +1104,7 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
|
|
|
1093
1104
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
1094
1105
|
const lastStatusUpdateTime = (0, import_utils3.getCurrentUnixTime)();
|
|
1095
1106
|
for (const page of pages) {
|
|
1096
|
-
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0 };
|
|
1107
|
+
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0, relatedId: 0, misc: {} };
|
|
1097
1108
|
const lsdPage = new PlaywrightPage(this, page, pageInfo);
|
|
1098
1109
|
this.#lsdPages.push(lsdPage);
|
|
1099
1110
|
(0, import_utils3.loginfo)(`##browser ${lsdPage.id()} ${openType}ed`);
|
|
@@ -1127,7 +1138,7 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
|
|
|
1127
1138
|
(0, import_utils3.logwarn)(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
1128
1139
|
} else {
|
|
1129
1140
|
const currentTime = (0, import_utils3.getCurrentUnixTime)();
|
|
1130
|
-
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0 };
|
|
1141
|
+
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0, relatedId: 0, misc: {} };
|
|
1131
1142
|
const lsdPage = new PlaywrightPage(this, page, pageInfo2);
|
|
1132
1143
|
this.#lsdPages.push(lsdPage);
|
|
1133
1144
|
(0, import_utils3.loginfo)(`##browser ${lsdPage.id()} created`);
|
|
@@ -1266,6 +1277,10 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
|
|
|
1266
1277
|
isIncognito() {
|
|
1267
1278
|
return this.#incognito;
|
|
1268
1279
|
}
|
|
1280
|
+
page(pageIdx) {
|
|
1281
|
+
const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
|
|
1282
|
+
return lsdPage ? lsdPage : null;
|
|
1283
|
+
}
|
|
1269
1284
|
pages() {
|
|
1270
1285
|
return this.#lsdPages;
|
|
1271
1286
|
}
|
|
@@ -1902,17 +1917,22 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
1902
1917
|
});
|
|
1903
1918
|
page.on("popup", (p) => {
|
|
1904
1919
|
if (p) {
|
|
1920
|
+
let evtData = null;
|
|
1905
1921
|
const pageInfo = p.pageInfo;
|
|
1906
1922
|
let popupPageId = "page";
|
|
1907
1923
|
if (pageInfo) {
|
|
1908
1924
|
const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
|
|
1909
1925
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1910
1926
|
pageInfo.openType = "popup";
|
|
1927
|
+
evtData = this.browserContext().page(pageIdx);
|
|
1928
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
1929
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
1930
|
+
}
|
|
1911
1931
|
} else {
|
|
1912
1932
|
(0, import_utils6.logerr)(`##browser ${pageId} has popup without page.pageInfo`);
|
|
1913
1933
|
}
|
|
1914
1934
|
(0, import_utils6.loginfo)(`##browser ${pageId} has popup ${popupPageId}`);
|
|
1915
|
-
this.emit("pagePopup",
|
|
1935
|
+
this.emit("pagePopup", evtData);
|
|
1916
1936
|
} else {
|
|
1917
1937
|
(0, import_utils6.logerr)(`##browser ${pageId} has popup page with null page`);
|
|
1918
1938
|
}
|
|
@@ -1927,8 +1947,8 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
1927
1947
|
this.#page = page;
|
|
1928
1948
|
this.#status = "free";
|
|
1929
1949
|
const currentTime = (0, import_utils6.getCurrentUnixTime)();
|
|
1930
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
1931
|
-
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId };
|
|
1950
|
+
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0 } = pageInfo ? pageInfo : {};
|
|
1951
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc: {} };
|
|
1932
1952
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1933
1953
|
this.#requestInterceptionNum = 0;
|
|
1934
1954
|
this.#responseInterceptionNum = 0;
|
|
@@ -2217,14 +2237,20 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2217
2237
|
throw new Error("Invalid paras in setPageInfo");
|
|
2218
2238
|
}
|
|
2219
2239
|
const actPageInfo = this.#page.pageInfo;
|
|
2220
|
-
|
|
2221
|
-
|
|
2240
|
+
const { lastStatusUpdateTime, taskId, relatedId, misc } = pageInfo;
|
|
2241
|
+
if (typeof lastStatusUpdateTime === "number") {
|
|
2242
|
+
actPageInfo.lastStatusUpdateTime = lastStatusUpdateTime;
|
|
2243
|
+
}
|
|
2244
|
+
if (typeof taskId === "number") {
|
|
2245
|
+
actPageInfo.taskId = taskId;
|
|
2222
2246
|
}
|
|
2223
|
-
if (typeof
|
|
2224
|
-
actPageInfo.
|
|
2247
|
+
if (typeof relatedId === "number") {
|
|
2248
|
+
actPageInfo.relatedId = relatedId;
|
|
2225
2249
|
}
|
|
2226
|
-
if (typeof
|
|
2227
|
-
|
|
2250
|
+
if (misc && typeof misc === "object") {
|
|
2251
|
+
for (const key of Object.keys(misc)) {
|
|
2252
|
+
actPageInfo.misc[key] = misc[key];
|
|
2253
|
+
}
|
|
2228
2254
|
}
|
|
2229
2255
|
return true;
|
|
2230
2256
|
}
|
|
@@ -2490,7 +2516,7 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
|
|
|
2490
2516
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
2491
2517
|
const lastStatusUpdateTime = (0, import_utils7.getCurrentUnixTime)();
|
|
2492
2518
|
for (const page of pages) {
|
|
2493
|
-
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0 };
|
|
2519
|
+
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0, relatedId: 0, misc: {} };
|
|
2494
2520
|
const lsdPage = new PuppeteerPage(this, page, pageInfo);
|
|
2495
2521
|
if (this.#userAgent) {
|
|
2496
2522
|
await lsdPage.setUserAgent(this.#userAgent);
|
|
@@ -2533,7 +2559,7 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
|
|
|
2533
2559
|
(0, import_utils7.logwarn)(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
2534
2560
|
} else {
|
|
2535
2561
|
const currentTime = (0, import_utils7.getCurrentUnixTime)();
|
|
2536
|
-
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0 };
|
|
2562
|
+
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0, relatedId: 0, misc: {} };
|
|
2537
2563
|
const lsdPage = new PuppeteerPage(this, page, pageInfo2);
|
|
2538
2564
|
if (this.#userAgent) {
|
|
2539
2565
|
await lsdPage.setUserAgent(this.#userAgent);
|
|
@@ -2675,6 +2701,10 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
|
|
|
2675
2701
|
isIncognito() {
|
|
2676
2702
|
return this.#incognito;
|
|
2677
2703
|
}
|
|
2704
|
+
page(pageIdx) {
|
|
2705
|
+
const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
|
|
2706
|
+
return lsdPage ? lsdPage : null;
|
|
2707
|
+
}
|
|
2678
2708
|
pages() {
|
|
2679
2709
|
return this.#lsdPages;
|
|
2680
2710
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -151,7 +151,7 @@ type PageStatus = "free" | "busy" | "closed";
|
|
|
151
151
|
* * other:
|
|
152
152
|
*/
|
|
153
153
|
type PageOpenType = "newpage" | "popup" | "manual" | "launch" | "connect" | "other";
|
|
154
|
-
|
|
154
|
+
interface PageInfo {
|
|
155
155
|
/**
|
|
156
156
|
* browser index in all browsers, that starts from 1
|
|
157
157
|
* @default 0
|
|
@@ -187,7 +187,35 @@ type PageInfo = {
|
|
|
187
187
|
* @default 0
|
|
188
188
|
*/
|
|
189
189
|
taskId: number;
|
|
190
|
-
|
|
190
|
+
/**
|
|
191
|
+
* @default 0
|
|
192
|
+
*/
|
|
193
|
+
relatedId: number;
|
|
194
|
+
/**
|
|
195
|
+
* customised page information
|
|
196
|
+
*/
|
|
197
|
+
misc: Record<string, string | number>;
|
|
198
|
+
}
|
|
199
|
+
interface UpdatablePageInfo {
|
|
200
|
+
/**
|
|
201
|
+
* 上次status变化时间:如果status为free,表示空闲开始时间;如果status为busy,表示TE开始数据
|
|
202
|
+
* @default current unix time
|
|
203
|
+
*/
|
|
204
|
+
lastStatusUpdateTime?: number;
|
|
205
|
+
/**
|
|
206
|
+
* 正在执行的task的ID,参见enumSpecialTaskId
|
|
207
|
+
* @default 0
|
|
208
|
+
*/
|
|
209
|
+
taskId?: number;
|
|
210
|
+
/**
|
|
211
|
+
* @default 0
|
|
212
|
+
*/
|
|
213
|
+
relatedId?: number;
|
|
214
|
+
/**
|
|
215
|
+
* customised page information
|
|
216
|
+
*/
|
|
217
|
+
misc?: Record<string, string | number>;
|
|
218
|
+
}
|
|
191
219
|
interface PageExtInPuppeteer extends Page$1 {
|
|
192
220
|
pageInfo?: PageInfo;
|
|
193
221
|
}
|
|
@@ -685,6 +713,7 @@ interface ScreenshotOptions {
|
|
|
685
713
|
*/
|
|
686
714
|
type?: 'png' | 'jpeg';
|
|
687
715
|
}
|
|
716
|
+
type WaitElementState = "attached" | "detached" | "hidden" | "visible";
|
|
688
717
|
interface WaitElementOptions {
|
|
689
718
|
/**
|
|
690
719
|
* @default 30_000 ms
|
|
@@ -693,7 +722,7 @@ interface WaitElementOptions {
|
|
|
693
722
|
/**
|
|
694
723
|
* @default "visible"
|
|
695
724
|
*/
|
|
696
|
-
state?:
|
|
725
|
+
state?: WaitElementState;
|
|
697
726
|
}
|
|
698
727
|
interface WaitNavigationOptions {
|
|
699
728
|
/**
|
|
@@ -710,6 +739,7 @@ interface WaitNavigationOptions {
|
|
|
710
739
|
*/
|
|
711
740
|
waitUntil?: NavigationWaitUntil;
|
|
712
741
|
}
|
|
742
|
+
type PageEvent = "pageClose" | "pagePopup";
|
|
713
743
|
interface LsdPage extends EventEmitter {
|
|
714
744
|
bringToFront(): Promise<boolean>;
|
|
715
745
|
browserContext(): LsdBrowserContext;
|
|
@@ -778,7 +808,7 @@ interface LsdPage extends EventEmitter {
|
|
|
778
808
|
* @param localStorageItems
|
|
779
809
|
*/
|
|
780
810
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
781
|
-
setPageInfo(pageInfo:
|
|
811
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
782
812
|
/**
|
|
783
813
|
* Intercept requests that meet the conditions(requestMatch) to perform an action(action and fulfill).
|
|
784
814
|
* @param options
|
|
@@ -843,6 +873,7 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
843
873
|
hasNewPage(pageNum?: number): boolean;
|
|
844
874
|
id(): string;
|
|
845
875
|
isIncognito(): boolean;
|
|
876
|
+
page(pageIdx: number): LsdPage | null;
|
|
846
877
|
pages(): LsdPage[];
|
|
847
878
|
proxy(): Proxy | null;
|
|
848
879
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -923,6 +954,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
923
954
|
hasNewPage(pageNum?: number): boolean;
|
|
924
955
|
id(): string;
|
|
925
956
|
isIncognito(): boolean;
|
|
957
|
+
page(pageIdx: number): LsdPage | null;
|
|
926
958
|
pages(): LsdPage[];
|
|
927
959
|
proxy(): Proxy | null;
|
|
928
960
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -963,7 +995,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
963
995
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
964
996
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
965
997
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
966
|
-
setPageInfo(pageInfo:
|
|
998
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
967
999
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
968
1000
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
969
1001
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1029,6 +1061,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1029
1061
|
hasNewPage(pageNum?: number): boolean;
|
|
1030
1062
|
id(): string;
|
|
1031
1063
|
isIncognito(): boolean;
|
|
1064
|
+
page(pageIdx: number): LsdPage | null;
|
|
1032
1065
|
pages(): LsdPage[];
|
|
1033
1066
|
proxy(): Proxy | null;
|
|
1034
1067
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1069,7 +1102,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1069
1102
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1070
1103
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1071
1104
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
1072
|
-
setPageInfo(pageInfo:
|
|
1105
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
1073
1106
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
1074
1107
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
1075
1108
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1178,4 +1211,4 @@ declare class CheerioElement implements LsdElement {
|
|
|
1178
1211
|
scrollIntoView(): Promise<boolean>;
|
|
1179
1212
|
}
|
|
1180
1213
|
|
|
1181
|
-
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, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type NavigationWaitUntil, type PDFMargin, type PDFOptions, 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 ViewportSize, type WaitElementOptions, type WaitNavigationOptions, defaultProxy };
|
|
1214
|
+
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, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, 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, defaultProxy };
|
package/dist/index.d.ts
CHANGED
|
@@ -151,7 +151,7 @@ type PageStatus = "free" | "busy" | "closed";
|
|
|
151
151
|
* * other:
|
|
152
152
|
*/
|
|
153
153
|
type PageOpenType = "newpage" | "popup" | "manual" | "launch" | "connect" | "other";
|
|
154
|
-
|
|
154
|
+
interface PageInfo {
|
|
155
155
|
/**
|
|
156
156
|
* browser index in all browsers, that starts from 1
|
|
157
157
|
* @default 0
|
|
@@ -187,7 +187,35 @@ type PageInfo = {
|
|
|
187
187
|
* @default 0
|
|
188
188
|
*/
|
|
189
189
|
taskId: number;
|
|
190
|
-
|
|
190
|
+
/**
|
|
191
|
+
* @default 0
|
|
192
|
+
*/
|
|
193
|
+
relatedId: number;
|
|
194
|
+
/**
|
|
195
|
+
* customised page information
|
|
196
|
+
*/
|
|
197
|
+
misc: Record<string, string | number>;
|
|
198
|
+
}
|
|
199
|
+
interface UpdatablePageInfo {
|
|
200
|
+
/**
|
|
201
|
+
* 上次status变化时间:如果status为free,表示空闲开始时间;如果status为busy,表示TE开始数据
|
|
202
|
+
* @default current unix time
|
|
203
|
+
*/
|
|
204
|
+
lastStatusUpdateTime?: number;
|
|
205
|
+
/**
|
|
206
|
+
* 正在执行的task的ID,参见enumSpecialTaskId
|
|
207
|
+
* @default 0
|
|
208
|
+
*/
|
|
209
|
+
taskId?: number;
|
|
210
|
+
/**
|
|
211
|
+
* @default 0
|
|
212
|
+
*/
|
|
213
|
+
relatedId?: number;
|
|
214
|
+
/**
|
|
215
|
+
* customised page information
|
|
216
|
+
*/
|
|
217
|
+
misc?: Record<string, string | number>;
|
|
218
|
+
}
|
|
191
219
|
interface PageExtInPuppeteer extends Page$1 {
|
|
192
220
|
pageInfo?: PageInfo;
|
|
193
221
|
}
|
|
@@ -685,6 +713,7 @@ interface ScreenshotOptions {
|
|
|
685
713
|
*/
|
|
686
714
|
type?: 'png' | 'jpeg';
|
|
687
715
|
}
|
|
716
|
+
type WaitElementState = "attached" | "detached" | "hidden" | "visible";
|
|
688
717
|
interface WaitElementOptions {
|
|
689
718
|
/**
|
|
690
719
|
* @default 30_000 ms
|
|
@@ -693,7 +722,7 @@ interface WaitElementOptions {
|
|
|
693
722
|
/**
|
|
694
723
|
* @default "visible"
|
|
695
724
|
*/
|
|
696
|
-
state?:
|
|
725
|
+
state?: WaitElementState;
|
|
697
726
|
}
|
|
698
727
|
interface WaitNavigationOptions {
|
|
699
728
|
/**
|
|
@@ -710,6 +739,7 @@ interface WaitNavigationOptions {
|
|
|
710
739
|
*/
|
|
711
740
|
waitUntil?: NavigationWaitUntil;
|
|
712
741
|
}
|
|
742
|
+
type PageEvent = "pageClose" | "pagePopup";
|
|
713
743
|
interface LsdPage extends EventEmitter {
|
|
714
744
|
bringToFront(): Promise<boolean>;
|
|
715
745
|
browserContext(): LsdBrowserContext;
|
|
@@ -778,7 +808,7 @@ interface LsdPage extends EventEmitter {
|
|
|
778
808
|
* @param localStorageItems
|
|
779
809
|
*/
|
|
780
810
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
781
|
-
setPageInfo(pageInfo:
|
|
811
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
782
812
|
/**
|
|
783
813
|
* Intercept requests that meet the conditions(requestMatch) to perform an action(action and fulfill).
|
|
784
814
|
* @param options
|
|
@@ -843,6 +873,7 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
843
873
|
hasNewPage(pageNum?: number): boolean;
|
|
844
874
|
id(): string;
|
|
845
875
|
isIncognito(): boolean;
|
|
876
|
+
page(pageIdx: number): LsdPage | null;
|
|
846
877
|
pages(): LsdPage[];
|
|
847
878
|
proxy(): Proxy | null;
|
|
848
879
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -923,6 +954,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
923
954
|
hasNewPage(pageNum?: number): boolean;
|
|
924
955
|
id(): string;
|
|
925
956
|
isIncognito(): boolean;
|
|
957
|
+
page(pageIdx: number): LsdPage | null;
|
|
926
958
|
pages(): LsdPage[];
|
|
927
959
|
proxy(): Proxy | null;
|
|
928
960
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -963,7 +995,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
963
995
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
964
996
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
965
997
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
966
|
-
setPageInfo(pageInfo:
|
|
998
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
967
999
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
968
1000
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
969
1001
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1029,6 +1061,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1029
1061
|
hasNewPage(pageNum?: number): boolean;
|
|
1030
1062
|
id(): string;
|
|
1031
1063
|
isIncognito(): boolean;
|
|
1064
|
+
page(pageIdx: number): LsdPage | null;
|
|
1032
1065
|
pages(): LsdPage[];
|
|
1033
1066
|
proxy(): Proxy | null;
|
|
1034
1067
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1069,7 +1102,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1069
1102
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1070
1103
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1071
1104
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
1072
|
-
setPageInfo(pageInfo:
|
|
1105
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
1073
1106
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
1074
1107
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
1075
1108
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1178,4 +1211,4 @@ declare class CheerioElement implements LsdElement {
|
|
|
1178
1211
|
scrollIntoView(): Promise<boolean>;
|
|
1179
1212
|
}
|
|
1180
1213
|
|
|
1181
|
-
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, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type NavigationWaitUntil, type PDFMargin, type PDFOptions, 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 ViewportSize, type WaitElementOptions, type WaitNavigationOptions, defaultProxy };
|
|
1214
|
+
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, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, 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, defaultProxy };
|
package/dist/index.js
CHANGED
|
@@ -478,17 +478,22 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
478
478
|
});
|
|
479
479
|
page.on("popup", (p) => {
|
|
480
480
|
if (p) {
|
|
481
|
+
let evtData = null;
|
|
481
482
|
const pageInfo = p.pageInfo;
|
|
482
483
|
let popupPageId = "page";
|
|
483
484
|
if (pageInfo) {
|
|
484
485
|
const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
|
|
485
486
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
486
487
|
pageInfo.openType = "popup";
|
|
488
|
+
evtData = this.browserContext().page(pageIdx);
|
|
489
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
490
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
491
|
+
}
|
|
487
492
|
} else {
|
|
488
493
|
logerr(`##browser ${pageId} has popup without page.pageInfo`);
|
|
489
494
|
}
|
|
490
495
|
loginfo(`##browser ${pageId} has popup ${popupPageId}`);
|
|
491
|
-
this.emit("pagePopup",
|
|
496
|
+
this.emit("pagePopup", evtData);
|
|
492
497
|
} else {
|
|
493
498
|
logerr(`##browser ${pageId} has popup page with null page`);
|
|
494
499
|
}
|
|
@@ -503,8 +508,8 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
503
508
|
this.#page = page;
|
|
504
509
|
this.#status = "free";
|
|
505
510
|
const currentTime = getCurrentUnixTime();
|
|
506
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
507
|
-
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId };
|
|
511
|
+
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0 } = pageInfo ? pageInfo : {};
|
|
512
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc: {} };
|
|
508
513
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
509
514
|
this.#resquestInterceptionOptions = [];
|
|
510
515
|
this.#responseInterceptionOptions = [];
|
|
@@ -790,14 +795,20 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
790
795
|
throw new Error("Invalid paras in setPageInfo");
|
|
791
796
|
}
|
|
792
797
|
const actPageInfo = this.#page.pageInfo;
|
|
793
|
-
|
|
794
|
-
|
|
798
|
+
const { lastStatusUpdateTime, taskId, relatedId, misc } = pageInfo;
|
|
799
|
+
if (typeof lastStatusUpdateTime === "number") {
|
|
800
|
+
actPageInfo.lastStatusUpdateTime = lastStatusUpdateTime;
|
|
801
|
+
}
|
|
802
|
+
if (typeof taskId === "number") {
|
|
803
|
+
actPageInfo.taskId = taskId;
|
|
795
804
|
}
|
|
796
|
-
if (typeof
|
|
797
|
-
actPageInfo.
|
|
805
|
+
if (typeof relatedId === "number") {
|
|
806
|
+
actPageInfo.relatedId = relatedId;
|
|
798
807
|
}
|
|
799
|
-
if (typeof
|
|
800
|
-
|
|
808
|
+
if (misc && typeof misc === "object") {
|
|
809
|
+
for (const key of Object.keys(misc)) {
|
|
810
|
+
actPageInfo.misc[key] = misc[key];
|
|
811
|
+
}
|
|
801
812
|
}
|
|
802
813
|
return true;
|
|
803
814
|
}
|
|
@@ -1074,7 +1085,7 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
|
|
|
1074
1085
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
1075
1086
|
const lastStatusUpdateTime = getCurrentUnixTime2();
|
|
1076
1087
|
for (const page of pages) {
|
|
1077
|
-
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0 };
|
|
1088
|
+
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0, relatedId: 0, misc: {} };
|
|
1078
1089
|
const lsdPage = new PlaywrightPage(this, page, pageInfo);
|
|
1079
1090
|
this.#lsdPages.push(lsdPage);
|
|
1080
1091
|
loginfo2(`##browser ${lsdPage.id()} ${openType}ed`);
|
|
@@ -1108,7 +1119,7 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
|
|
|
1108
1119
|
logwarn2(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
1109
1120
|
} else {
|
|
1110
1121
|
const currentTime = getCurrentUnixTime2();
|
|
1111
|
-
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0 };
|
|
1122
|
+
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0, relatedId: 0, misc: {} };
|
|
1112
1123
|
const lsdPage = new PlaywrightPage(this, page, pageInfo2);
|
|
1113
1124
|
this.#lsdPages.push(lsdPage);
|
|
1114
1125
|
loginfo2(`##browser ${lsdPage.id()} created`);
|
|
@@ -1247,6 +1258,10 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
|
|
|
1247
1258
|
isIncognito() {
|
|
1248
1259
|
return this.#incognito;
|
|
1249
1260
|
}
|
|
1261
|
+
page(pageIdx) {
|
|
1262
|
+
const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
|
|
1263
|
+
return lsdPage ? lsdPage : null;
|
|
1264
|
+
}
|
|
1250
1265
|
pages() {
|
|
1251
1266
|
return this.#lsdPages;
|
|
1252
1267
|
}
|
|
@@ -1883,17 +1898,22 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
1883
1898
|
});
|
|
1884
1899
|
page.on("popup", (p) => {
|
|
1885
1900
|
if (p) {
|
|
1901
|
+
let evtData = null;
|
|
1886
1902
|
const pageInfo = p.pageInfo;
|
|
1887
1903
|
let popupPageId = "page";
|
|
1888
1904
|
if (pageInfo) {
|
|
1889
1905
|
const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
|
|
1890
1906
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1891
1907
|
pageInfo.openType = "popup";
|
|
1908
|
+
evtData = this.browserContext().page(pageIdx);
|
|
1909
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
1910
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
1911
|
+
}
|
|
1892
1912
|
} else {
|
|
1893
1913
|
logerr5(`##browser ${pageId} has popup without page.pageInfo`);
|
|
1894
1914
|
}
|
|
1895
1915
|
loginfo4(`##browser ${pageId} has popup ${popupPageId}`);
|
|
1896
|
-
this.emit("pagePopup",
|
|
1916
|
+
this.emit("pagePopup", evtData);
|
|
1897
1917
|
} else {
|
|
1898
1918
|
logerr5(`##browser ${pageId} has popup page with null page`);
|
|
1899
1919
|
}
|
|
@@ -1908,8 +1928,8 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
1908
1928
|
this.#page = page;
|
|
1909
1929
|
this.#status = "free";
|
|
1910
1930
|
const currentTime = getCurrentUnixTime3();
|
|
1911
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
1912
|
-
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId };
|
|
1931
|
+
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0 } = pageInfo ? pageInfo : {};
|
|
1932
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc: {} };
|
|
1913
1933
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1914
1934
|
this.#requestInterceptionNum = 0;
|
|
1915
1935
|
this.#responseInterceptionNum = 0;
|
|
@@ -2198,14 +2218,20 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2198
2218
|
throw new Error("Invalid paras in setPageInfo");
|
|
2199
2219
|
}
|
|
2200
2220
|
const actPageInfo = this.#page.pageInfo;
|
|
2201
|
-
|
|
2202
|
-
|
|
2221
|
+
const { lastStatusUpdateTime, taskId, relatedId, misc } = pageInfo;
|
|
2222
|
+
if (typeof lastStatusUpdateTime === "number") {
|
|
2223
|
+
actPageInfo.lastStatusUpdateTime = lastStatusUpdateTime;
|
|
2224
|
+
}
|
|
2225
|
+
if (typeof taskId === "number") {
|
|
2226
|
+
actPageInfo.taskId = taskId;
|
|
2203
2227
|
}
|
|
2204
|
-
if (typeof
|
|
2205
|
-
actPageInfo.
|
|
2228
|
+
if (typeof relatedId === "number") {
|
|
2229
|
+
actPageInfo.relatedId = relatedId;
|
|
2206
2230
|
}
|
|
2207
|
-
if (typeof
|
|
2208
|
-
|
|
2231
|
+
if (misc && typeof misc === "object") {
|
|
2232
|
+
for (const key of Object.keys(misc)) {
|
|
2233
|
+
actPageInfo.misc[key] = misc[key];
|
|
2234
|
+
}
|
|
2209
2235
|
}
|
|
2210
2236
|
return true;
|
|
2211
2237
|
}
|
|
@@ -2471,7 +2497,7 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
|
|
|
2471
2497
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
2472
2498
|
const lastStatusUpdateTime = getCurrentUnixTime4();
|
|
2473
2499
|
for (const page of pages) {
|
|
2474
|
-
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0 };
|
|
2500
|
+
const pageInfo = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType, openTime: this.#createTime, lastStatusUpdateTime, taskId: 0, relatedId: 0, misc: {} };
|
|
2475
2501
|
const lsdPage = new PuppeteerPage(this, page, pageInfo);
|
|
2476
2502
|
if (this.#userAgent) {
|
|
2477
2503
|
await lsdPage.setUserAgent(this.#userAgent);
|
|
@@ -2514,7 +2540,7 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
|
|
|
2514
2540
|
logwarn4(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
2515
2541
|
} else {
|
|
2516
2542
|
const currentTime = getCurrentUnixTime4();
|
|
2517
|
-
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0 };
|
|
2543
|
+
const pageInfo2 = { browserIdx: this.#browserIdx, browserContextIdx: this.#browserContextIdx, pageIdx: this.#nextPageIdx++, openType: "other", openTime: currentTime, lastStatusUpdateTime: currentTime, taskId: 0, relatedId: 0, misc: {} };
|
|
2518
2544
|
const lsdPage = new PuppeteerPage(this, page, pageInfo2);
|
|
2519
2545
|
if (this.#userAgent) {
|
|
2520
2546
|
await lsdPage.setUserAgent(this.#userAgent);
|
|
@@ -2656,6 +2682,10 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
|
|
|
2656
2682
|
isIncognito() {
|
|
2657
2683
|
return this.#incognito;
|
|
2658
2684
|
}
|
|
2685
|
+
page(pageIdx) {
|
|
2686
|
+
const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
|
|
2687
|
+
return lsdPage ? lsdPage : null;
|
|
2688
|
+
}
|
|
2659
2689
|
pages() {
|
|
2660
2690
|
return this.#lsdPages;
|
|
2661
2691
|
}
|
package/package.json
CHANGED