@letsscrapedata/controller 0.0.4 → 0.0.6
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 +38 -20
- package/dist/index.d.cts +34 -6
- package/dist/index.d.ts +34 -6
- package/dist/index.js +38 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -505,6 +505,9 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
505
505
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
506
506
|
pageInfo.openType = "popup";
|
|
507
507
|
evtData = this.browserContext().page(pageIdx);
|
|
508
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
509
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
510
|
+
}
|
|
508
511
|
} else {
|
|
509
512
|
(0, import_utils2.logerr)(`##browser ${pageId} has popup without page.pageInfo`);
|
|
510
513
|
}
|
|
@@ -524,8 +527,8 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
524
527
|
this.#page = page;
|
|
525
528
|
this.#status = "free";
|
|
526
529
|
const currentTime = (0, import_utils2.getCurrentUnixTime)();
|
|
527
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
528
|
-
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, misc = {} } = pageInfo ? pageInfo : {};
|
|
531
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
|
|
529
532
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
530
533
|
this.#resquestInterceptionOptions = [];
|
|
531
534
|
this.#responseInterceptionOptions = [];
|
|
@@ -811,14 +814,20 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
811
814
|
throw new Error("Invalid paras in setPageInfo");
|
|
812
815
|
}
|
|
813
816
|
const actPageInfo = this.#page.pageInfo;
|
|
814
|
-
|
|
815
|
-
|
|
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;
|
|
816
823
|
}
|
|
817
|
-
if (typeof
|
|
818
|
-
actPageInfo.
|
|
824
|
+
if (typeof relatedId === "number") {
|
|
825
|
+
actPageInfo.relatedId = relatedId;
|
|
819
826
|
}
|
|
820
|
-
if (typeof
|
|
821
|
-
|
|
827
|
+
if (misc && typeof misc === "object") {
|
|
828
|
+
for (const key of Object.keys(misc)) {
|
|
829
|
+
actPageInfo.misc[key] = misc[key];
|
|
830
|
+
}
|
|
822
831
|
}
|
|
823
832
|
return true;
|
|
824
833
|
}
|
|
@@ -1095,7 +1104,7 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
|
|
|
1095
1104
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
1096
1105
|
const lastStatusUpdateTime = (0, import_utils3.getCurrentUnixTime)();
|
|
1097
1106
|
for (const page of pages) {
|
|
1098
|
-
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: {} };
|
|
1099
1108
|
const lsdPage = new PlaywrightPage(this, page, pageInfo);
|
|
1100
1109
|
this.#lsdPages.push(lsdPage);
|
|
1101
1110
|
(0, import_utils3.loginfo)(`##browser ${lsdPage.id()} ${openType}ed`);
|
|
@@ -1129,7 +1138,7 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
|
|
|
1129
1138
|
(0, import_utils3.logwarn)(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
1130
1139
|
} else {
|
|
1131
1140
|
const currentTime = (0, import_utils3.getCurrentUnixTime)();
|
|
1132
|
-
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: {} };
|
|
1133
1142
|
const lsdPage = new PlaywrightPage(this, page, pageInfo2);
|
|
1134
1143
|
this.#lsdPages.push(lsdPage);
|
|
1135
1144
|
(0, import_utils3.loginfo)(`##browser ${lsdPage.id()} created`);
|
|
@@ -1916,6 +1925,9 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
1916
1925
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1917
1926
|
pageInfo.openType = "popup";
|
|
1918
1927
|
evtData = this.browserContext().page(pageIdx);
|
|
1928
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
1929
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
1930
|
+
}
|
|
1919
1931
|
} else {
|
|
1920
1932
|
(0, import_utils6.logerr)(`##browser ${pageId} has popup without page.pageInfo`);
|
|
1921
1933
|
}
|
|
@@ -1935,8 +1947,8 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
1935
1947
|
this.#page = page;
|
|
1936
1948
|
this.#status = "free";
|
|
1937
1949
|
const currentTime = (0, import_utils6.getCurrentUnixTime)();
|
|
1938
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
1939
|
-
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, misc = {} } = pageInfo ? pageInfo : {};
|
|
1951
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
|
|
1940
1952
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1941
1953
|
this.#requestInterceptionNum = 0;
|
|
1942
1954
|
this.#responseInterceptionNum = 0;
|
|
@@ -2225,14 +2237,20 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2225
2237
|
throw new Error("Invalid paras in setPageInfo");
|
|
2226
2238
|
}
|
|
2227
2239
|
const actPageInfo = this.#page.pageInfo;
|
|
2228
|
-
|
|
2229
|
-
|
|
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;
|
|
2230
2246
|
}
|
|
2231
|
-
if (typeof
|
|
2232
|
-
actPageInfo.
|
|
2247
|
+
if (typeof relatedId === "number") {
|
|
2248
|
+
actPageInfo.relatedId = relatedId;
|
|
2233
2249
|
}
|
|
2234
|
-
if (typeof
|
|
2235
|
-
|
|
2250
|
+
if (misc && typeof misc === "object") {
|
|
2251
|
+
for (const key of Object.keys(misc)) {
|
|
2252
|
+
actPageInfo.misc[key] = misc[key];
|
|
2253
|
+
}
|
|
2236
2254
|
}
|
|
2237
2255
|
return true;
|
|
2238
2256
|
}
|
|
@@ -2498,7 +2516,7 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
|
|
|
2498
2516
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
2499
2517
|
const lastStatusUpdateTime = (0, import_utils7.getCurrentUnixTime)();
|
|
2500
2518
|
for (const page of pages) {
|
|
2501
|
-
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: {} };
|
|
2502
2520
|
const lsdPage = new PuppeteerPage(this, page, pageInfo);
|
|
2503
2521
|
if (this.#userAgent) {
|
|
2504
2522
|
await lsdPage.setUserAgent(this.#userAgent);
|
|
@@ -2541,7 +2559,7 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
|
|
|
2541
2559
|
(0, import_utils7.logwarn)(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
2542
2560
|
} else {
|
|
2543
2561
|
const currentTime = (0, import_utils7.getCurrentUnixTime)();
|
|
2544
|
-
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: {} };
|
|
2545
2563
|
const lsdPage = new PuppeteerPage(this, page, pageInfo2);
|
|
2546
2564
|
if (this.#userAgent) {
|
|
2547
2565
|
await lsdPage.setUserAgent(this.#userAgent);
|
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
|
}
|
|
@@ -780,7 +808,7 @@ interface LsdPage extends EventEmitter {
|
|
|
780
808
|
* @param localStorageItems
|
|
781
809
|
*/
|
|
782
810
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
783
|
-
setPageInfo(pageInfo:
|
|
811
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
784
812
|
/**
|
|
785
813
|
* Intercept requests that meet the conditions(requestMatch) to perform an action(action and fulfill).
|
|
786
814
|
* @param options
|
|
@@ -967,7 +995,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
967
995
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
968
996
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
969
997
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
970
|
-
setPageInfo(pageInfo:
|
|
998
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
971
999
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
972
1000
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
973
1001
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1074,7 +1102,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1074
1102
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1075
1103
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1076
1104
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
1077
|
-
setPageInfo(pageInfo:
|
|
1105
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
1078
1106
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
1079
1107
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
1080
1108
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1183,4 +1211,4 @@ declare class CheerioElement implements LsdElement {
|
|
|
1183
1211
|
scrollIntoView(): Promise<boolean>;
|
|
1184
1212
|
}
|
|
1185
1213
|
|
|
1186
|
-
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 ViewportSize, type WaitElementOptions, type WaitElementState, 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
|
}
|
|
@@ -780,7 +808,7 @@ interface LsdPage extends EventEmitter {
|
|
|
780
808
|
* @param localStorageItems
|
|
781
809
|
*/
|
|
782
810
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
783
|
-
setPageInfo(pageInfo:
|
|
811
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
784
812
|
/**
|
|
785
813
|
* Intercept requests that meet the conditions(requestMatch) to perform an action(action and fulfill).
|
|
786
814
|
* @param options
|
|
@@ -967,7 +995,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
967
995
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
968
996
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
969
997
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
970
|
-
setPageInfo(pageInfo:
|
|
998
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
971
999
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
972
1000
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
973
1001
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1074,7 +1102,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1074
1102
|
setCookies(cookies: CookieItem[]): Promise<boolean>;
|
|
1075
1103
|
setExtraHTTPHeaders(headers: Record<string, string>): Promise<boolean>;
|
|
1076
1104
|
setLocalStroage(localStorageItems: LocalStorageItem[]): Promise<boolean>;
|
|
1077
|
-
setPageInfo(pageInfo:
|
|
1105
|
+
setPageInfo(pageInfo: UpdatablePageInfo): boolean;
|
|
1078
1106
|
setRequestInterception(options: RequestInterceptionOption | RequestInterceptionOption[]): Promise<boolean>;
|
|
1079
1107
|
setResponseInterception(options: ResponseInterceptionOption | ResponseInterceptionOption[]): Promise<boolean>;
|
|
1080
1108
|
setStateData(stateData: StateData): Promise<boolean>;
|
|
@@ -1183,4 +1211,4 @@ declare class CheerioElement implements LsdElement {
|
|
|
1183
1211
|
scrollIntoView(): Promise<boolean>;
|
|
1184
1212
|
}
|
|
1185
1213
|
|
|
1186
|
-
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 ViewportSize, type WaitElementOptions, type WaitElementState, 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
|
@@ -486,6 +486,9 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
486
486
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
487
487
|
pageInfo.openType = "popup";
|
|
488
488
|
evtData = this.browserContext().page(pageIdx);
|
|
489
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
490
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
491
|
+
}
|
|
489
492
|
} else {
|
|
490
493
|
logerr(`##browser ${pageId} has popup without page.pageInfo`);
|
|
491
494
|
}
|
|
@@ -505,8 +508,8 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
505
508
|
this.#page = page;
|
|
506
509
|
this.#status = "free";
|
|
507
510
|
const currentTime = getCurrentUnixTime();
|
|
508
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
509
|
-
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, misc = {} } = pageInfo ? pageInfo : {};
|
|
512
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
|
|
510
513
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
511
514
|
this.#resquestInterceptionOptions = [];
|
|
512
515
|
this.#responseInterceptionOptions = [];
|
|
@@ -792,14 +795,20 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
792
795
|
throw new Error("Invalid paras in setPageInfo");
|
|
793
796
|
}
|
|
794
797
|
const actPageInfo = this.#page.pageInfo;
|
|
795
|
-
|
|
796
|
-
|
|
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;
|
|
797
804
|
}
|
|
798
|
-
if (typeof
|
|
799
|
-
actPageInfo.
|
|
805
|
+
if (typeof relatedId === "number") {
|
|
806
|
+
actPageInfo.relatedId = relatedId;
|
|
800
807
|
}
|
|
801
|
-
if (typeof
|
|
802
|
-
|
|
808
|
+
if (misc && typeof misc === "object") {
|
|
809
|
+
for (const key of Object.keys(misc)) {
|
|
810
|
+
actPageInfo.misc[key] = misc[key];
|
|
811
|
+
}
|
|
803
812
|
}
|
|
804
813
|
return true;
|
|
805
814
|
}
|
|
@@ -1076,7 +1085,7 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
|
|
|
1076
1085
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
1077
1086
|
const lastStatusUpdateTime = getCurrentUnixTime2();
|
|
1078
1087
|
for (const page of pages) {
|
|
1079
|
-
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: {} };
|
|
1080
1089
|
const lsdPage = new PlaywrightPage(this, page, pageInfo);
|
|
1081
1090
|
this.#lsdPages.push(lsdPage);
|
|
1082
1091
|
loginfo2(`##browser ${lsdPage.id()} ${openType}ed`);
|
|
@@ -1110,7 +1119,7 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
|
|
|
1110
1119
|
logwarn2(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
1111
1120
|
} else {
|
|
1112
1121
|
const currentTime = getCurrentUnixTime2();
|
|
1113
|
-
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: {} };
|
|
1114
1123
|
const lsdPage = new PlaywrightPage(this, page, pageInfo2);
|
|
1115
1124
|
this.#lsdPages.push(lsdPage);
|
|
1116
1125
|
loginfo2(`##browser ${lsdPage.id()} created`);
|
|
@@ -1897,6 +1906,9 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
1897
1906
|
popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1898
1907
|
pageInfo.openType = "popup";
|
|
1899
1908
|
evtData = this.browserContext().page(pageIdx);
|
|
1909
|
+
if (evtData && page.pageInfo?.taskId) {
|
|
1910
|
+
pageInfo.relatedId = page.pageInfo.taskId;
|
|
1911
|
+
}
|
|
1900
1912
|
} else {
|
|
1901
1913
|
logerr5(`##browser ${pageId} has popup without page.pageInfo`);
|
|
1902
1914
|
}
|
|
@@ -1916,8 +1928,8 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
1916
1928
|
this.#page = page;
|
|
1917
1929
|
this.#status = "free";
|
|
1918
1930
|
const currentTime = getCurrentUnixTime3();
|
|
1919
|
-
const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0 } = pageInfo ? pageInfo : {};
|
|
1920
|
-
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, misc = {} } = pageInfo ? pageInfo : {};
|
|
1932
|
+
this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
|
|
1921
1933
|
this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
|
|
1922
1934
|
this.#requestInterceptionNum = 0;
|
|
1923
1935
|
this.#responseInterceptionNum = 0;
|
|
@@ -2206,14 +2218,20 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2206
2218
|
throw new Error("Invalid paras in setPageInfo");
|
|
2207
2219
|
}
|
|
2208
2220
|
const actPageInfo = this.#page.pageInfo;
|
|
2209
|
-
|
|
2210
|
-
|
|
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;
|
|
2211
2227
|
}
|
|
2212
|
-
if (typeof
|
|
2213
|
-
actPageInfo.
|
|
2228
|
+
if (typeof relatedId === "number") {
|
|
2229
|
+
actPageInfo.relatedId = relatedId;
|
|
2214
2230
|
}
|
|
2215
|
-
if (typeof
|
|
2216
|
-
|
|
2231
|
+
if (misc && typeof misc === "object") {
|
|
2232
|
+
for (const key of Object.keys(misc)) {
|
|
2233
|
+
actPageInfo.misc[key] = misc[key];
|
|
2234
|
+
}
|
|
2217
2235
|
}
|
|
2218
2236
|
return true;
|
|
2219
2237
|
}
|
|
@@ -2479,7 +2497,7 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
|
|
|
2479
2497
|
const openType = this.#lsdBrowser.browserCreationMethod();
|
|
2480
2498
|
const lastStatusUpdateTime = getCurrentUnixTime4();
|
|
2481
2499
|
for (const page of pages) {
|
|
2482
|
-
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: {} };
|
|
2483
2501
|
const lsdPage = new PuppeteerPage(this, page, pageInfo);
|
|
2484
2502
|
if (this.#userAgent) {
|
|
2485
2503
|
await lsdPage.setUserAgent(this.#userAgent);
|
|
@@ -2522,7 +2540,7 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
|
|
|
2522
2540
|
logwarn4(`##browser page-${browserIdx2}-${browserContextIdx2}-${pageIdx} has been already created`);
|
|
2523
2541
|
} else {
|
|
2524
2542
|
const currentTime = getCurrentUnixTime4();
|
|
2525
|
-
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: {} };
|
|
2526
2544
|
const lsdPage = new PuppeteerPage(this, page, pageInfo2);
|
|
2527
2545
|
if (this.#userAgent) {
|
|
2528
2546
|
await lsdPage.setUserAgent(this.#userAgent);
|
package/package.json
CHANGED