@letsscrapedata/controller 0.0.57 → 0.0.59

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
@@ -7462,7 +7462,7 @@ var CamoufoxBrowser = class _CamoufoxBrowser extends import_node_events13.defaul
7462
7462
  // constructor: called only by LsdBrowserController.launch/connect
7463
7463
  constructor(browser, browserType, browserCreateMethod, options, browserIdx = 0, pid = 0) {
7464
7464
  if (!browser || typeof browser.contexts !== "function") {
7465
- throw new Error(`Invalid playwright browser parameter`);
7465
+ throw new Error(`Invalid camoufox browser parameter`);
7466
7466
  }
7467
7467
  super();
7468
7468
  const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage = true, headless = false, executablePath = "" } = options;
@@ -7471,7 +7471,7 @@ var CamoufoxBrowser = class _CamoufoxBrowser extends import_node_events13.defaul
7471
7471
  this.#pid = pid;
7472
7472
  this.#createTime = (0, import_utils17.getCurrentUnixTime)();
7473
7473
  this.#lsdBrowserContexts = [];
7474
- this.#browserControllerType = "playwright";
7474
+ this.#browserControllerType = "camoufox";
7475
7475
  this.#browserType = browserType;
7476
7476
  if (!_CamoufoxBrowser.#supportedBrowserTypes.includes(browserType)) {
7477
7477
  throw new Error(`Browser controller ${this.#browserControllerType} doesnot support browserType ${browserType}`);
@@ -7486,7 +7486,7 @@ var CamoufoxBrowser = class _CamoufoxBrowser extends import_node_events13.defaul
7486
7486
  loginfo(`##browser ${this.id()} ${this.#browserCreationMethod}ed by ${this.#browserControllerType}`);
7487
7487
  const browserContexts = browser.contexts();
7488
7488
  if (browserContexts.length > 0) {
7489
- logwarn(`There are ${browserContexts.length} new browserContexts when playwright launches new browser`);
7489
+ logwarn(`There are ${browserContexts.length} new browserContexts when camoufox launches new browser`);
7490
7490
  }
7491
7491
  const incognito = typeof options?.incognito === "boolean" ? options.incognito : true;
7492
7492
  for (const browserContext of browserContexts) {
@@ -7900,10 +7900,23 @@ var LsdBrowserController = class _LsdBrowserController {
7900
7900
  }
7901
7901
  if (userDataDir) {
7902
7902
  launchOptions.user_data_dir = userDataDir;
7903
+ launchOptions.persistent_context = true;
7903
7904
  }
7904
7905
  if (args.length > 0) {
7905
7906
  launchOptions.args = args;
7906
7907
  }
7908
+ if (typeof options.geoip === "boolean" || typeof options.geoip === "string") {
7909
+ launchOptions.geoip = options.geoip;
7910
+ actOptions.geoip = options.geoip;
7911
+ }
7912
+ if (typeof options.mainWorldEval === "boolean") {
7913
+ launchOptions.main_world_eval = options.mainWorldEval;
7914
+ actOptions.mainWorldEval = options.mainWorldEval;
7915
+ }
7916
+ if (Array.isArray(options.addons) && options.addons.length > 0 && options.addons.every((addon) => typeof addon === "string")) {
7917
+ launchOptions.addons = options.addons;
7918
+ actOptions.addons = options.addons;
7919
+ }
7907
7920
  if (options.launchMethod === "launchServer") {
7908
7921
  const browserServer = await (0, import_camoufox_js.launchServer)(launchOptions);
7909
7922
  const process = browserServer.process();
@@ -7958,7 +7971,7 @@ var LsdBrowserController = class _LsdBrowserController {
7958
7971
  const browser = await playwrightBrowserType.connectOverCDP(browserUrl);
7959
7972
  const lsdBrowser = new PlaywrightBrowser(browser, browserType, "connect", actOptions, this.#nextBrowserIdx++, browserPid);
7960
7973
  return lsdBrowser;
7961
- } else if (browserControllerType === "patchright") {
7974
+ } else if (browserControllerType === "patchright" || browserControllerType === "camoufox") {
7962
7975
  const patchrightBrowserType = this.#patchrightBrowserType(browserType, true);
7963
7976
  const browser = await patchrightBrowserType.connectOverCDP(browserUrl);
7964
7977
  const lsdBrowser = new PatchrightBrowser(browser, browserType, "connect", actOptions, this.#nextBrowserIdx++, browserPid);
@@ -7970,7 +7983,7 @@ var LsdBrowserController = class _LsdBrowserController {
7970
7983
  ;
7971
7984
  return lsdBrowser;
7972
7985
  } else {
7973
- throw new Error(`Invalid browserControllerType: ${browserControllerType} in connect`);
7986
+ (0, import_utils18.unreachable)(browserControllerType);
7974
7987
  }
7975
7988
  }
7976
7989
  async newApiContext(options = {}) {
package/dist/index.d.cts CHANGED
@@ -177,6 +177,25 @@ interface LsdLaunchOptions extends BrowserOptions {
177
177
  * @default "launch"
178
178
  */
179
179
  launchMethod?: BrowserLaunchMethod;
180
+ /**
181
+ * Calculates longitude, latitude, timezone, country, & locale based on the IP address. Pass the target IP address(string) to use, or true to find the IP address automatically.
182
+ ** valid only in camfoufox: geoip
183
+ ** please install Camoufox with the geoip extra
184
+ * @default false
185
+ */
186
+ geoip?: boolean | string;
187
+ /**
188
+ * Whether to inject scripts into the main world when prefixed with mw.
189
+ ** valid only in camfoufox: main_world_eval
190
+ * @default false
191
+ */
192
+ mainWorldEval?: boolean;
193
+ /**
194
+ * List of Firefox addons to use. Must be paths to extracted addons.
195
+ ** valid only in camfoufox: addons
196
+ * @default []
197
+ */
198
+ addons?: string[];
180
199
  }
181
200
  interface LsdConnectOptions extends BrowserOptions {
182
201
  /**
package/dist/index.d.ts CHANGED
@@ -177,6 +177,25 @@ interface LsdLaunchOptions extends BrowserOptions {
177
177
  * @default "launch"
178
178
  */
179
179
  launchMethod?: BrowserLaunchMethod;
180
+ /**
181
+ * Calculates longitude, latitude, timezone, country, & locale based on the IP address. Pass the target IP address(string) to use, or true to find the IP address automatically.
182
+ ** valid only in camfoufox: geoip
183
+ ** please install Camoufox with the geoip extra
184
+ * @default false
185
+ */
186
+ geoip?: boolean | string;
187
+ /**
188
+ * Whether to inject scripts into the main world when prefixed with mw.
189
+ ** valid only in camfoufox: main_world_eval
190
+ * @default false
191
+ */
192
+ mainWorldEval?: boolean;
193
+ /**
194
+ * List of Firefox addons to use. Must be paths to extracted addons.
195
+ ** valid only in camfoufox: addons
196
+ * @default []
197
+ */
198
+ addons?: string[];
180
199
  }
181
200
  interface LsdConnectOptions extends BrowserOptions {
182
201
  /**
package/dist/index.js CHANGED
@@ -7415,7 +7415,7 @@ var CamoufoxBrowser = class _CamoufoxBrowser extends EventEmitter13 {
7415
7415
  // constructor: called only by LsdBrowserController.launch/connect
7416
7416
  constructor(browser, browserType, browserCreateMethod, options, browserIdx = 0, pid = 0) {
7417
7417
  if (!browser || typeof browser.contexts !== "function") {
7418
- throw new Error(`Invalid playwright browser parameter`);
7418
+ throw new Error(`Invalid camoufox browser parameter`);
7419
7419
  }
7420
7420
  super();
7421
7421
  const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, maxViewportOfNewPage = true, headless = false, executablePath = "" } = options;
@@ -7424,7 +7424,7 @@ var CamoufoxBrowser = class _CamoufoxBrowser extends EventEmitter13 {
7424
7424
  this.#pid = pid;
7425
7425
  this.#createTime = getCurrentUnixTime12();
7426
7426
  this.#lsdBrowserContexts = [];
7427
- this.#browserControllerType = "playwright";
7427
+ this.#browserControllerType = "camoufox";
7428
7428
  this.#browserType = browserType;
7429
7429
  if (!_CamoufoxBrowser.#supportedBrowserTypes.includes(browserType)) {
7430
7430
  throw new Error(`Browser controller ${this.#browserControllerType} doesnot support browserType ${browserType}`);
@@ -7439,7 +7439,7 @@ var CamoufoxBrowser = class _CamoufoxBrowser extends EventEmitter13 {
7439
7439
  loginfo(`##browser ${this.id()} ${this.#browserCreationMethod}ed by ${this.#browserControllerType}`);
7440
7440
  const browserContexts = browser.contexts();
7441
7441
  if (browserContexts.length > 0) {
7442
- logwarn(`There are ${browserContexts.length} new browserContexts when playwright launches new browser`);
7442
+ logwarn(`There are ${browserContexts.length} new browserContexts when camoufox launches new browser`);
7443
7443
  }
7444
7444
  const incognito = typeof options?.incognito === "boolean" ? options.incognito : true;
7445
7445
  for (const browserContext of browserContexts) {
@@ -7853,10 +7853,23 @@ var LsdBrowserController = class _LsdBrowserController {
7853
7853
  }
7854
7854
  if (userDataDir) {
7855
7855
  launchOptions.user_data_dir = userDataDir;
7856
+ launchOptions.persistent_context = true;
7856
7857
  }
7857
7858
  if (args.length > 0) {
7858
7859
  launchOptions.args = args;
7859
7860
  }
7861
+ if (typeof options.geoip === "boolean" || typeof options.geoip === "string") {
7862
+ launchOptions.geoip = options.geoip;
7863
+ actOptions.geoip = options.geoip;
7864
+ }
7865
+ if (typeof options.mainWorldEval === "boolean") {
7866
+ launchOptions.main_world_eval = options.mainWorldEval;
7867
+ actOptions.mainWorldEval = options.mainWorldEval;
7868
+ }
7869
+ if (Array.isArray(options.addons) && options.addons.length > 0 && options.addons.every((addon) => typeof addon === "string")) {
7870
+ launchOptions.addons = options.addons;
7871
+ actOptions.addons = options.addons;
7872
+ }
7860
7873
  if (options.launchMethod === "launchServer") {
7861
7874
  const browserServer = await launchServer(launchOptions);
7862
7875
  const process = browserServer.process();
@@ -7911,7 +7924,7 @@ var LsdBrowserController = class _LsdBrowserController {
7911
7924
  const browser = await playwrightBrowserType.connectOverCDP(browserUrl);
7912
7925
  const lsdBrowser = new PlaywrightBrowser(browser, browserType, "connect", actOptions, this.#nextBrowserIdx++, browserPid);
7913
7926
  return lsdBrowser;
7914
- } else if (browserControllerType === "patchright") {
7927
+ } else if (browserControllerType === "patchright" || browserControllerType === "camoufox") {
7915
7928
  const patchrightBrowserType = this.#patchrightBrowserType(browserType, true);
7916
7929
  const browser = await patchrightBrowserType.connectOverCDP(browserUrl);
7917
7930
  const lsdBrowser = new PatchrightBrowser(browser, browserType, "connect", actOptions, this.#nextBrowserIdx++, browserPid);
@@ -7923,7 +7936,7 @@ var LsdBrowserController = class _LsdBrowserController {
7923
7936
  ;
7924
7937
  return lsdBrowser;
7925
7938
  } else {
7926
- throw new Error(`Invalid browserControllerType: ${browserControllerType} in connect`);
7939
+ unreachable9(browserControllerType);
7927
7940
  }
7928
7941
  }
7929
7942
  async newApiContext(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsscrapedata/controller",
3
- "version": "0.0.57",
3
+ "version": "0.0.59",
4
4
  "description": "Unified browser / HTML controller interfaces that support playwright, puppeteer and cheerio",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",