@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.cjs +18 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -795,6 +795,21 @@ var import_playwright = require("playwright");
|
|
|
795
795
|
var import_user_agents = __toESM(require("user-agents"), 1);
|
|
796
796
|
var import_uuid = require("uuid");
|
|
797
797
|
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
798
|
+
var import_playwright_extra = require("playwright-extra");
|
|
799
|
+
var chromiumWithExtras;
|
|
800
|
+
var StealthPluginInstance;
|
|
801
|
+
async function loadDependencies() {
|
|
802
|
+
if (!chromiumWithExtras) {
|
|
803
|
+
chromiumWithExtras = (0, import_playwright_extra.addExtra)(import_playwright.chromium);
|
|
804
|
+
const StealthPluginModule = await import("puppeteer-extra-plugin-stealth");
|
|
805
|
+
const stealthPluginFactory = typeof StealthPluginModule.default === "function" ? StealthPluginModule.default : StealthPluginModule;
|
|
806
|
+
if (typeof stealthPluginFactory !== "function") {
|
|
807
|
+
throw new Error("puppeteer-extra-plugin-stealth export is not a function or module structure is unexpected.");
|
|
808
|
+
}
|
|
809
|
+
StealthPluginInstance = stealthPluginFactory();
|
|
810
|
+
chromiumWithExtras.use(StealthPluginInstance);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
798
813
|
var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
|
|
799
814
|
pool = /* @__PURE__ */ new Set();
|
|
800
815
|
maxBrowsers;
|
|
@@ -846,6 +861,7 @@ var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
|
|
|
846
861
|
this.proxyConfig = config.proxy;
|
|
847
862
|
}
|
|
848
863
|
async initialize() {
|
|
864
|
+
await loadDependencies();
|
|
849
865
|
if (this.isCleaningUp) return;
|
|
850
866
|
await this.ensureMinimumInstances();
|
|
851
867
|
this.scheduleHealthCheck();
|
|
@@ -873,6 +889,7 @@ var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
|
|
|
873
889
|
}
|
|
874
890
|
}
|
|
875
891
|
async createBrowserInstance() {
|
|
892
|
+
await loadDependencies();
|
|
876
893
|
const id = (0, import_uuid.v4)();
|
|
877
894
|
const launchOptions = {
|
|
878
895
|
headless: !this.useHeadedMode,
|
|
@@ -889,7 +906,7 @@ var PlaywrightBrowserPool = class _PlaywrightBrowserPool {
|
|
|
889
906
|
],
|
|
890
907
|
proxy: this.proxyConfig
|
|
891
908
|
};
|
|
892
|
-
const browser = await
|
|
909
|
+
const browser = await chromiumWithExtras.launch(launchOptions);
|
|
893
910
|
const context = await browser.newContext({
|
|
894
911
|
userAgent: new import_user_agents.default().toString(),
|
|
895
912
|
viewport: {
|