@letsscrapedata/controller 0.5.0 → 0.6.0

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
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  LsdBrowserContextEvent: () => LsdBrowserContextEvent,
37
37
  LsdBrowserEvent: () => LsdBrowserEvent,
38
38
  LsdPageEvent: () => LsdPageEvent,
39
+ POPUP_TASK_ID: () => POPUP_TASK_ID,
39
40
  PlaywrightBrowser: () => PlaywrightBrowser,
40
41
  PlaywrightBrowserContext: () => PlaywrightBrowserContext,
41
42
  PlaywrightElement: () => PlaywrightElement,
@@ -74,6 +75,7 @@ var LsdBrowserEvent = /* @__PURE__ */ ((LsdBrowserEvent2) => {
74
75
  LsdBrowserEvent2["BROWSER_CONTEXT_CLOSE"] = "browserContextClose";
75
76
  return LsdBrowserEvent2;
76
77
  })(LsdBrowserEvent || {});
78
+ var POPUP_TASK_ID = 7;
77
79
 
78
80
  // src/utils/log.ts
79
81
  var import_utils = require("@letsscrapedata/utils");
@@ -673,12 +675,12 @@ var PlaywrightPage = class extends import_node_events.default {
673
675
  const pageInfo = p.pageInfo;
674
676
  let popupPageId = "page";
675
677
  if (pageInfo) {
676
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
678
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
677
679
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
678
680
  pageInfo.openType = "popup";
679
681
  evtData = this.browserContext().page(pageIdx);
680
- if (evtData && page.pageInfo?.taskId) {
681
- pageInfo.relatedId = page.pageInfo.taskId;
682
+ if (evtData) {
683
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
682
684
  }
683
685
  } else {
684
686
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -2537,12 +2539,12 @@ var PuppeteerPage = class extends import_node_events4.default {
2537
2539
  const pageInfo = p.pageInfo;
2538
2540
  let popupPageId = "page";
2539
2541
  if (pageInfo) {
2540
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
2542
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
2541
2543
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
2542
2544
  pageInfo.openType = "popup";
2543
2545
  evtData = this.browserContext().page(pageIdx);
2544
- if (evtData && page.pageInfo?.taskId) {
2545
- pageInfo.relatedId = page.pageInfo.taskId;
2546
+ if (evtData) {
2547
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
2546
2548
  }
2547
2549
  } else {
2548
2550
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -4792,12 +4794,12 @@ var PatchrightPage = class extends import_node_events8.default {
4792
4794
  const pageInfo = p.pageInfo;
4793
4795
  let popupPageId = "page";
4794
4796
  if (pageInfo) {
4795
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
4797
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
4796
4798
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
4797
4799
  pageInfo.openType = "popup";
4798
4800
  evtData = this.browserContext().page(pageIdx);
4799
- if (evtData && page.pageInfo?.taskId) {
4800
- pageInfo.relatedId = page.pageInfo.taskId;
4801
+ if (evtData) {
4802
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
4801
4803
  }
4802
4804
  } else {
4803
4805
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -6698,12 +6700,12 @@ var CamoufoxPage = class extends import_node_events11.default {
6698
6700
  const pageInfo = p.pageInfo;
6699
6701
  let popupPageId = "page";
6700
6702
  if (pageInfo) {
6701
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
6703
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
6702
6704
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
6703
6705
  pageInfo.openType = "popup";
6704
6706
  evtData = this.browserContext().page(pageIdx);
6705
- if (evtData && page.pageInfo?.taskId) {
6706
- pageInfo.relatedId = page.pageInfo.taskId;
6707
+ if (evtData) {
6708
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
6707
6709
  }
6708
6710
  } else {
6709
6711
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -8423,6 +8425,7 @@ var controller = new LsdBrowserController();
8423
8425
  LsdBrowserContextEvent,
8424
8426
  LsdBrowserEvent,
8425
8427
  LsdPageEvent,
8428
+ POPUP_TASK_ID,
8426
8429
  PlaywrightBrowser,
8427
8430
  PlaywrightBrowserContext,
8428
8431
  PlaywrightElement,
package/dist/index.d.cts CHANGED
@@ -348,6 +348,8 @@ interface PageInfo {
348
348
  */
349
349
  taskId: number;
350
350
  /**
351
+ ** popup page: parentTaskId
352
+ ** normal page@scraper: templateId
351
353
  * @default 0
352
354
  */
353
355
  relatedId: number;
@@ -990,6 +992,7 @@ interface WaitNavigationOptions {
990
992
  */
991
993
  waitUntil?: NavigationWaitUntil;
992
994
  }
995
+ declare const POPUP_TASK_ID = 7;
993
996
  interface LsdPage extends EventEmitter {
994
997
  /**
995
998
  * Adds a script which would be evaluated in one of the following scenarios:
@@ -1759,4 +1762,4 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
1759
1762
  }
1760
1763
  declare const controller: LsdBrowserController;
1761
1764
 
1762
- export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, ControllerEvent, type CookieItem, type FrameAddScriptTagOptions, 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, LsdBrowserContextEvent, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, LsdBrowserEvent, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, LsdPageEvent, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageMouseClickOptions, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserControllerType, 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, setControllerLogFun };
1765
+ export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, ControllerEvent, type CookieItem, type FrameAddScriptTagOptions, 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, LsdBrowserContextEvent, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, LsdBrowserEvent, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, LsdPageEvent, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, POPUP_TASK_ID, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageMouseClickOptions, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserControllerType, 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, setControllerLogFun };
package/dist/index.d.ts CHANGED
@@ -348,6 +348,8 @@ interface PageInfo {
348
348
  */
349
349
  taskId: number;
350
350
  /**
351
+ ** popup page: parentTaskId
352
+ ** normal page@scraper: templateId
351
353
  * @default 0
352
354
  */
353
355
  relatedId: number;
@@ -990,6 +992,7 @@ interface WaitNavigationOptions {
990
992
  */
991
993
  waitUntil?: NavigationWaitUntil;
992
994
  }
995
+ declare const POPUP_TASK_ID = 7;
993
996
  interface LsdPage extends EventEmitter {
994
997
  /**
995
998
  * Adds a script which would be evaluated in one of the following scenarios:
@@ -1759,4 +1762,4 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
1759
1762
  }
1760
1763
  declare const controller: LsdBrowserController;
1761
1764
 
1762
- export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, ControllerEvent, type CookieItem, type FrameAddScriptTagOptions, 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, LsdBrowserContextEvent, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, LsdBrowserEvent, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, LsdPageEvent, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageMouseClickOptions, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserControllerType, 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, setControllerLogFun };
1765
+ export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, ControllerEvent, type CookieItem, type FrameAddScriptTagOptions, 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, LsdBrowserContextEvent, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, LsdBrowserEvent, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, LsdPageEvent, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, POPUP_TASK_ID, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageMouseClickOptions, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserControllerType, 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, setControllerLogFun };
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ var LsdBrowserEvent = /* @__PURE__ */ ((LsdBrowserEvent2) => {
23
23
  LsdBrowserEvent2["BROWSER_CONTEXT_CLOSE"] = "browserContextClose";
24
24
  return LsdBrowserEvent2;
25
25
  })(LsdBrowserEvent || {});
26
+ var POPUP_TASK_ID = 7;
26
27
 
27
28
  // src/utils/log.ts
28
29
  import { log, LogLevel } from "@letsscrapedata/utils";
@@ -622,12 +623,12 @@ var PlaywrightPage = class extends EventEmitter {
622
623
  const pageInfo = p.pageInfo;
623
624
  let popupPageId = "page";
624
625
  if (pageInfo) {
625
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
626
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
626
627
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
627
628
  pageInfo.openType = "popup";
628
629
  evtData = this.browserContext().page(pageIdx);
629
- if (evtData && page.pageInfo?.taskId) {
630
- pageInfo.relatedId = page.pageInfo.taskId;
630
+ if (evtData) {
631
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
631
632
  }
632
633
  } else {
633
634
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -2486,12 +2487,12 @@ var PuppeteerPage = class extends EventEmitter4 {
2486
2487
  const pageInfo = p.pageInfo;
2487
2488
  let popupPageId = "page";
2488
2489
  if (pageInfo) {
2489
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
2490
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
2490
2491
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
2491
2492
  pageInfo.openType = "popup";
2492
2493
  evtData = this.browserContext().page(pageIdx);
2493
- if (evtData && page.pageInfo?.taskId) {
2494
- pageInfo.relatedId = page.pageInfo.taskId;
2494
+ if (evtData) {
2495
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
2495
2496
  }
2496
2497
  } else {
2497
2498
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -4741,12 +4742,12 @@ var PatchrightPage = class extends EventEmitter8 {
4741
4742
  const pageInfo = p.pageInfo;
4742
4743
  let popupPageId = "page";
4743
4744
  if (pageInfo) {
4744
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
4745
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
4745
4746
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
4746
4747
  pageInfo.openType = "popup";
4747
4748
  evtData = this.browserContext().page(pageIdx);
4748
- if (evtData && page.pageInfo?.taskId) {
4749
- pageInfo.relatedId = page.pageInfo.taskId;
4749
+ if (evtData) {
4750
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
4750
4751
  }
4751
4752
  } else {
4752
4753
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -6647,12 +6648,12 @@ var CamoufoxPage = class extends EventEmitter11 {
6647
6648
  const pageInfo = p.pageInfo;
6648
6649
  let popupPageId = "page";
6649
6650
  if (pageInfo) {
6650
- const { browserIdx, browserContextIdx, pageIdx } = pageInfo;
6651
+ const { taskId, browserIdx, browserContextIdx, pageIdx } = pageInfo;
6651
6652
  popupPageId = `page-${browserIdx}-${browserContextIdx}-${pageIdx}`;
6652
6653
  pageInfo.openType = "popup";
6653
6654
  evtData = this.browserContext().page(pageIdx);
6654
- if (evtData && page.pageInfo?.taskId) {
6655
- pageInfo.relatedId = page.pageInfo.taskId;
6655
+ if (evtData) {
6656
+ evtData.setPageInfo({ taskId: POPUP_TASK_ID, relatedId: taskId });
6656
6657
  }
6657
6658
  } else {
6658
6659
  logerr(`##browser page ${pageId} has popup without page.pageInfo @LsdPage`);
@@ -8371,6 +8372,7 @@ export {
8371
8372
  LsdBrowserContextEvent,
8372
8373
  LsdBrowserEvent,
8373
8374
  LsdPageEvent,
8375
+ POPUP_TASK_ID,
8374
8376
  PlaywrightBrowser,
8375
8377
  PlaywrightBrowserContext,
8376
8378
  PlaywrightElement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsscrapedata/controller",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Unified browser / HTML controller interfaces that support patchright, camoufox, playwright, puppeteer and cheerio",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",