@letsscrapedata/controller 0.0.5 → 0.0.7

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
@@ -233,9 +233,15 @@ var PlaywrightElement = class _PlaywrightElement {
233
233
  return text3 ? text3 : "";
234
234
  }
235
235
  async click(options = {}) {
236
- const { button, clickCount: count, delay, position: offset } = options;
236
+ const { button, clickCount: count, delay, position: offset, clickType = "click" } = options;
237
237
  const actOptions = { button, count, delay, offset };
238
- await this.#locator.click(actOptions);
238
+ if (clickType === "click") {
239
+ await this.#locator.click(actOptions);
240
+ } else if (clickType === "evaluate") {
241
+ await this.#locator.evaluate(async (ev) => await ev.click());
242
+ } else {
243
+ (0, import_utils.unreachable)(clickType);
244
+ }
239
245
  return true;
240
246
  }
241
247
  async focus() {
@@ -527,8 +533,8 @@ var PlaywrightPage = class extends import_node_events.default {
527
533
  this.#page = page;
528
534
  this.#status = "free";
529
535
  const currentTime = (0, import_utils2.getCurrentUnixTime)();
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: {} };
536
+ const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0, misc = {} } = pageInfo ? pageInfo : {};
537
+ this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
532
538
  this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
533
539
  this.#resquestInterceptionOptions = [];
534
540
  this.#responseInterceptionOptions = [];
@@ -1650,9 +1656,16 @@ var PuppeteerElement = class _PuppeteerElement {
1650
1656
  return text3 ? text3 : "";
1651
1657
  }
1652
1658
  async click(options = {}) {
1653
- const { button, clickCount: count, delay, position: offset } = options;
1659
+ const { button, clickCount: count, delay, position: offset, clickType = "click" } = options;
1654
1660
  const actOptions = { button, count, delay, offset };
1655
- await this.#$ele.click(actOptions);
1661
+ if (clickType === "click") {
1662
+ await this.#$ele.click(actOptions);
1663
+ } else if (clickType === "evaluate") {
1664
+ await this.#frame.evaluate(async (ev) => await ev.click(), this.#$ele);
1665
+ await this.#$ele.click(actOptions);
1666
+ } else {
1667
+ (0, import_utils5.unreachable)(clickType);
1668
+ }
1656
1669
  return true;
1657
1670
  }
1658
1671
  async focus() {
@@ -1947,8 +1960,8 @@ var PuppeteerPage = class extends import_node_events4.default {
1947
1960
  this.#page = page;
1948
1961
  this.#status = "free";
1949
1962
  const currentTime = (0, import_utils6.getCurrentUnixTime)();
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: {} };
1963
+ const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0, misc = {} } = pageInfo ? pageInfo : {};
1964
+ this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
1952
1965
  this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
1953
1966
  this.#requestInterceptionNum = 0;
1954
1967
  this.#responseInterceptionNum = 0;
package/dist/index.d.cts CHANGED
@@ -222,6 +222,7 @@ interface PageExtInPuppeteer extends Page$1 {
222
222
  interface PageExtInPlaywright extends Page {
223
223
  pageInfo?: PageInfo;
224
224
  }
225
+ type MouseClickType = "click" | "evaluate";
225
226
  interface MouseClickOptions {
226
227
  /**
227
228
  * Which button will be pressed.
@@ -252,6 +253,10 @@ interface MouseClickOptions {
252
253
  * * puppeteer: not supported, ignored
253
254
  */
254
255
  modifiers?: Array<"Alt" | "Control" | "Meta" | "Shift">;
256
+ /**
257
+ * @default click
258
+ */
259
+ clickType?: MouseClickType;
255
260
  }
256
261
  interface SelectOptions {
257
262
  /**
@@ -1211,4 +1216,4 @@ declare class CheerioElement implements LsdElement {
1211
1216
  scrollIntoView(): Promise<boolean>;
1212
1217
  }
1213
1218
 
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 };
1219
+ 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 MouseClickType, 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
@@ -222,6 +222,7 @@ interface PageExtInPuppeteer extends Page$1 {
222
222
  interface PageExtInPlaywright extends Page {
223
223
  pageInfo?: PageInfo;
224
224
  }
225
+ type MouseClickType = "click" | "evaluate";
225
226
  interface MouseClickOptions {
226
227
  /**
227
228
  * Which button will be pressed.
@@ -252,6 +253,10 @@ interface MouseClickOptions {
252
253
  * * puppeteer: not supported, ignored
253
254
  */
254
255
  modifiers?: Array<"Alt" | "Control" | "Meta" | "Shift">;
256
+ /**
257
+ * @default click
258
+ */
259
+ clickType?: MouseClickType;
255
260
  }
256
261
  interface SelectOptions {
257
262
  /**
@@ -1211,4 +1216,4 @@ declare class CheerioElement implements LsdElement {
1211
1216
  scrollIntoView(): Promise<boolean>;
1212
1217
  }
1213
1218
 
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 };
1219
+ 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 MouseClickType, 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
@@ -214,9 +214,15 @@ var PlaywrightElement = class _PlaywrightElement {
214
214
  return text3 ? text3 : "";
215
215
  }
216
216
  async click(options = {}) {
217
- const { button, clickCount: count, delay, position: offset } = options;
217
+ const { button, clickCount: count, delay, position: offset, clickType = "click" } = options;
218
218
  const actOptions = { button, count, delay, offset };
219
- await this.#locator.click(actOptions);
219
+ if (clickType === "click") {
220
+ await this.#locator.click(actOptions);
221
+ } else if (clickType === "evaluate") {
222
+ await this.#locator.evaluate(async (ev) => await ev.click());
223
+ } else {
224
+ unreachable(clickType);
225
+ }
220
226
  return true;
221
227
  }
222
228
  async focus() {
@@ -508,8 +514,8 @@ var PlaywrightPage = class extends EventEmitter {
508
514
  this.#page = page;
509
515
  this.#status = "free";
510
516
  const currentTime = getCurrentUnixTime();
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: {} };
517
+ const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0, misc = {} } = pageInfo ? pageInfo : {};
518
+ this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
513
519
  this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
514
520
  this.#resquestInterceptionOptions = [];
515
521
  this.#responseInterceptionOptions = [];
@@ -1631,9 +1637,16 @@ var PuppeteerElement = class _PuppeteerElement {
1631
1637
  return text3 ? text3 : "";
1632
1638
  }
1633
1639
  async click(options = {}) {
1634
- const { button, clickCount: count, delay, position: offset } = options;
1640
+ const { button, clickCount: count, delay, position: offset, clickType = "click" } = options;
1635
1641
  const actOptions = { button, count, delay, offset };
1636
- await this.#$ele.click(actOptions);
1642
+ if (clickType === "click") {
1643
+ await this.#$ele.click(actOptions);
1644
+ } else if (clickType === "evaluate") {
1645
+ await this.#frame.evaluate(async (ev) => await ev.click(), this.#$ele);
1646
+ await this.#$ele.click(actOptions);
1647
+ } else {
1648
+ unreachable3(clickType);
1649
+ }
1637
1650
  return true;
1638
1651
  }
1639
1652
  async focus() {
@@ -1928,8 +1941,8 @@ var PuppeteerPage = class extends EventEmitter4 {
1928
1941
  this.#page = page;
1929
1942
  this.#status = "free";
1930
1943
  const currentTime = getCurrentUnixTime3();
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: {} };
1944
+ const { browserIdx = 0, browserContextIdx = 0, pageIdx = 0, openType = "other", openTime = currentTime, lastStatusUpdateTime = currentTime, taskId = 0, relatedId = 0, misc = {} } = pageInfo ? pageInfo : {};
1945
+ this.#page.pageInfo = { browserIdx, browserContextIdx, pageIdx, openType, openTime, lastStatusUpdateTime, taskId, relatedId, misc };
1933
1946
  this.#pageId = `page${browserIdx}-${browserContextIdx}-${pageIdx}`;
1934
1947
  this.#requestInterceptionNum = 0;
1935
1948
  this.#responseInterceptionNum = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsscrapedata/controller",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Unified browser / HTML controller interfaces that support playwright, puppeteer and cheerio",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",