@purepageio/fetch-engines 0.2.8 → 0.2.9

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.js CHANGED
@@ -757,6 +757,21 @@ import { chromium as playwrightChromium } from "playwright";
757
757
  import UserAgent from "user-agents";
758
758
  import { v4 as uuidv4 } from "uuid";
759
759
  import PQueue from "p-queue";
760
+ import { addExtra } from "playwright-extra";
761
+ var chromiumWithExtras;
762
+ var StealthPluginInstance;
763
+ async function loadDependencies() {
764
+ if (!chromiumWithExtras) {
765
+ chromiumWithExtras = addExtra(playwrightChromium);
766
+ const StealthPluginModule = await import("puppeteer-extra-plugin-stealth");
767
+ const stealthPluginFactory = typeof StealthPluginModule.default === "function" ? StealthPluginModule.default : StealthPluginModule;
768
+ if (typeof stealthPluginFactory !== "function") {
769
+ throw new Error("puppeteer-extra-plugin-stealth export is not a function or module structure is unexpected.");
770
+ }
771
+ StealthPluginInstance = stealthPluginFactory();
772
+ chromiumWithExtras.use(StealthPluginInstance);
773
+ }
774
+ }
760
775
  var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
761
776
  pool = /* @__PURE__ */ new Set();
762
777
  maxBrowsers;
@@ -808,6 +823,7 @@ var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
808
823
  this.proxyConfig = config.proxy;
809
824
  }
810
825
  async initialize() {
826
+ await loadDependencies();
811
827
  if (this.isCleaningUp) return;
812
828
  await this.ensureMinimumInstances();
813
829
  this.scheduleHealthCheck();
@@ -835,6 +851,7 @@ var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
835
851
  }
836
852
  }
837
853
  async createBrowserInstance() {
854
+ await loadDependencies();
838
855
  const id = uuidv4();
839
856
  const launchOptions = {
840
857
  headless: !this.useHeadedMode,
@@ -851,7 +868,7 @@ var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
851
868
  ],
852
869
  proxy: this.proxyConfig
853
870
  };
854
- const browser = await playwrightChromium.launch(launchOptions);
871
+ const browser = await chromiumWithExtras.launch(launchOptions);
855
872
  const context = await browser.newContext({
856
873
  userAgent: new UserAgent().toString(),
857
874
  viewport: {