@letsscrapedata/controller 0.0.3 → 0.0.4

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 CHANGED
@@ -497,17 +497,19 @@ 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);
506
508
  } else {
507
509
  (0, import_utils2.logerr)(`##browser ${pageId} has popup without page.pageInfo`);
508
510
  }
509
511
  (0, import_utils2.loginfo)(`##browser ${pageId} has popup ${popupPageId}`);
510
- this.emit("pagePopup", pageInfo);
512
+ this.emit("pagePopup", evtData);
511
513
  } else {
512
514
  (0, import_utils2.logerr)(`##browser ${pageId} has popup page with null page`);
513
515
  }
@@ -1266,6 +1268,10 @@ var PlaywrightBrowserContext = class extends import_node_events2.default {
1266
1268
  isIncognito() {
1267
1269
  return this.#incognito;
1268
1270
  }
1271
+ page(pageIdx) {
1272
+ const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
1273
+ return lsdPage ? lsdPage : null;
1274
+ }
1269
1275
  pages() {
1270
1276
  return this.#lsdPages;
1271
1277
  }
@@ -1902,17 +1908,19 @@ var PuppeteerPage = class extends import_node_events4.default {
1902
1908
  });
1903
1909
  page.on("popup", (p) => {
1904
1910
  if (p) {
1911
+ let evtData = null;
1905
1912
  const pageInfo = p.pageInfo;
1906
1913
  let popupPageId = "page";
1907
1914
  if (pageInfo) {
1908
1915
  const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
1909
1916
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
1910
1917
  pageInfo.openType = "popup";
1918
+ evtData = this.browserContext().page(pageIdx);
1911
1919
  } else {
1912
1920
  (0, import_utils6.logerr)(`##browser ${pageId} has popup without page.pageInfo`);
1913
1921
  }
1914
1922
  (0, import_utils6.loginfo)(`##browser ${pageId} has popup ${popupPageId}`);
1915
- this.emit("pagePopup", pageInfo);
1923
+ this.emit("pagePopup", evtData);
1916
1924
  } else {
1917
1925
  (0, import_utils6.logerr)(`##browser ${pageId} has popup page with null page`);
1918
1926
  }
@@ -2675,6 +2683,10 @@ var PuppeteerBrowserContext = class extends import_node_events5.default {
2675
2683
  isIncognito() {
2676
2684
  return this.#incognito;
2677
2685
  }
2686
+ page(pageIdx) {
2687
+ const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
2688
+ return lsdPage ? lsdPage : null;
2689
+ }
2678
2690
  pages() {
2679
2691
  return this.#lsdPages;
2680
2692
  }
package/dist/index.d.cts CHANGED
@@ -685,6 +685,7 @@ interface ScreenshotOptions {
685
685
  */
686
686
  type?: 'png' | 'jpeg';
687
687
  }
688
+ type WaitElementState = "attached" | "detached" | "hidden" | "visible";
688
689
  interface WaitElementOptions {
689
690
  /**
690
691
  * @default 30_000 ms
@@ -693,7 +694,7 @@ interface WaitElementOptions {
693
694
  /**
694
695
  * @default "visible"
695
696
  */
696
- state?: "attached" | "detached" | "hidden" | "visible";
697
+ state?: WaitElementState;
697
698
  }
698
699
  interface WaitNavigationOptions {
699
700
  /**
@@ -710,6 +711,7 @@ interface WaitNavigationOptions {
710
711
  */
711
712
  waitUntil?: NavigationWaitUntil;
712
713
  }
714
+ type PageEvent = "pageClose" | "pagePopup";
713
715
  interface LsdPage extends EventEmitter {
714
716
  bringToFront(): Promise<boolean>;
715
717
  browserContext(): LsdBrowserContext;
@@ -843,6 +845,7 @@ interface LsdBrowserContext extends EventEmitter {
843
845
  hasNewPage(pageNum?: number): boolean;
844
846
  id(): string;
845
847
  isIncognito(): boolean;
848
+ page(pageIdx: number): LsdPage | null;
846
849
  pages(): LsdPage[];
847
850
  proxy(): Proxy | null;
848
851
  setStateData(stateData: StateData): Promise<boolean>;
@@ -923,6 +926,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
923
926
  hasNewPage(pageNum?: number): boolean;
924
927
  id(): string;
925
928
  isIncognito(): boolean;
929
+ page(pageIdx: number): LsdPage | null;
926
930
  pages(): LsdPage[];
927
931
  proxy(): Proxy | null;
928
932
  setStateData(stateData: StateData): Promise<boolean>;
@@ -1029,6 +1033,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
1029
1033
  hasNewPage(pageNum?: number): boolean;
1030
1034
  id(): string;
1031
1035
  isIncognito(): boolean;
1036
+ page(pageIdx: number): LsdPage | null;
1032
1037
  pages(): LsdPage[];
1033
1038
  proxy(): Proxy | null;
1034
1039
  setStateData(stateData: StateData): Promise<boolean>;
@@ -1178,4 +1183,4 @@ declare class CheerioElement implements LsdElement {
1178
1183
  scrollIntoView(): Promise<boolean>;
1179
1184
  }
1180
1185
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -685,6 +685,7 @@ interface ScreenshotOptions {
685
685
  */
686
686
  type?: 'png' | 'jpeg';
687
687
  }
688
+ type WaitElementState = "attached" | "detached" | "hidden" | "visible";
688
689
  interface WaitElementOptions {
689
690
  /**
690
691
  * @default 30_000 ms
@@ -693,7 +694,7 @@ interface WaitElementOptions {
693
694
  /**
694
695
  * @default "visible"
695
696
  */
696
- state?: "attached" | "detached" | "hidden" | "visible";
697
+ state?: WaitElementState;
697
698
  }
698
699
  interface WaitNavigationOptions {
699
700
  /**
@@ -710,6 +711,7 @@ interface WaitNavigationOptions {
710
711
  */
711
712
  waitUntil?: NavigationWaitUntil;
712
713
  }
714
+ type PageEvent = "pageClose" | "pagePopup";
713
715
  interface LsdPage extends EventEmitter {
714
716
  bringToFront(): Promise<boolean>;
715
717
  browserContext(): LsdBrowserContext;
@@ -843,6 +845,7 @@ interface LsdBrowserContext extends EventEmitter {
843
845
  hasNewPage(pageNum?: number): boolean;
844
846
  id(): string;
845
847
  isIncognito(): boolean;
848
+ page(pageIdx: number): LsdPage | null;
846
849
  pages(): LsdPage[];
847
850
  proxy(): Proxy | null;
848
851
  setStateData(stateData: StateData): Promise<boolean>;
@@ -923,6 +926,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
923
926
  hasNewPage(pageNum?: number): boolean;
924
927
  id(): string;
925
928
  isIncognito(): boolean;
929
+ page(pageIdx: number): LsdPage | null;
926
930
  pages(): LsdPage[];
927
931
  proxy(): Proxy | null;
928
932
  setStateData(stateData: StateData): Promise<boolean>;
@@ -1029,6 +1033,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
1029
1033
  hasNewPage(pageNum?: number): boolean;
1030
1034
  id(): string;
1031
1035
  isIncognito(): boolean;
1036
+ page(pageIdx: number): LsdPage | null;
1032
1037
  pages(): LsdPage[];
1033
1038
  proxy(): Proxy | null;
1034
1039
  setStateData(stateData: StateData): Promise<boolean>;
@@ -1178,4 +1183,4 @@ declare class CheerioElement implements LsdElement {
1178
1183
  scrollIntoView(): Promise<boolean>;
1179
1184
  }
1180
1185
 
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 };
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 };
package/dist/index.js CHANGED
@@ -478,17 +478,19 @@ 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);
487
489
  } else {
488
490
  logerr(`##browser ${pageId} has popup without page.pageInfo`);
489
491
  }
490
492
  loginfo(`##browser ${pageId} has popup ${popupPageId}`);
491
- this.emit("pagePopup", pageInfo);
493
+ this.emit("pagePopup", evtData);
492
494
  } else {
493
495
  logerr(`##browser ${pageId} has popup page with null page`);
494
496
  }
@@ -1247,6 +1249,10 @@ var PlaywrightBrowserContext = class extends EventEmitter2 {
1247
1249
  isIncognito() {
1248
1250
  return this.#incognito;
1249
1251
  }
1252
+ page(pageIdx) {
1253
+ const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
1254
+ return lsdPage ? lsdPage : null;
1255
+ }
1250
1256
  pages() {
1251
1257
  return this.#lsdPages;
1252
1258
  }
@@ -1883,17 +1889,19 @@ var PuppeteerPage = class extends EventEmitter4 {
1883
1889
  });
1884
1890
  page.on("popup", (p) => {
1885
1891
  if (p) {
1892
+ let evtData = null;
1886
1893
  const pageInfo = p.pageInfo;
1887
1894
  let popupPageId = "page";
1888
1895
  if (pageInfo) {
1889
1896
  const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
1890
1897
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
1891
1898
  pageInfo.openType = "popup";
1899
+ evtData = this.browserContext().page(pageIdx);
1892
1900
  } else {
1893
1901
  logerr5(`##browser ${pageId} has popup without page.pageInfo`);
1894
1902
  }
1895
1903
  loginfo4(`##browser ${pageId} has popup ${popupPageId}`);
1896
- this.emit("pagePopup", pageInfo);
1904
+ this.emit("pagePopup", evtData);
1897
1905
  } else {
1898
1906
  logerr5(`##browser ${pageId} has popup page with null page`);
1899
1907
  }
@@ -2656,6 +2664,10 @@ var PuppeteerBrowserContext = class extends EventEmitter5 {
2656
2664
  isIncognito() {
2657
2665
  return this.#incognito;
2658
2666
  }
2667
+ page(pageIdx) {
2668
+ const lsdPage = this.#lsdPages.find((p) => p.pageInfo().pageIdx === pageIdx);
2669
+ return lsdPage ? lsdPage : null;
2670
+ }
2659
2671
  pages() {
2660
2672
  return this.#lsdPages;
2661
2673
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsscrapedata/controller",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Unified browser / HTML controller interfaces that support playwright, puppeteer and cheerio",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",