@skrillex1224/playwright-toolkit 2.1.161 → 2.1.162
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/README.md +9 -7
- package/dist/index.cjs +44 -10
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +44 -10
- package/dist/index.js.map +2 -2
- package/index.d.ts +33 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1592,6 +1592,12 @@ var createTrafficMeter = ({
|
|
|
1592
1592
|
|
|
1593
1593
|
// src/launch.js
|
|
1594
1594
|
var logger7 = createInternalLogger("Launch");
|
|
1595
|
+
var DEFAULT_CRAWLER_BASE_OPTIONS = Object.freeze({
|
|
1596
|
+
maxConcurrency: 1,
|
|
1597
|
+
maxRequestRetries: 0,
|
|
1598
|
+
requestHandlerTimeoutSecs: 240,
|
|
1599
|
+
navigationTimeoutSecs: 120
|
|
1600
|
+
});
|
|
1595
1601
|
var resolveProxyLaunchOptions = (proxyConfiguration = {}) => {
|
|
1596
1602
|
const config = proxyConfiguration && typeof proxyConfiguration === "object" && !Array.isArray(proxyConfiguration) ? proxyConfiguration : {};
|
|
1597
1603
|
const proxyUrl = String(config.proxy_url || "").trim();
|
|
@@ -1617,12 +1623,17 @@ var resolveProxyLaunchOptions = (proxyConfiguration = {}) => {
|
|
|
1617
1623
|
return { launchProxy, byPassDomains, enableProxy, proxyUrl };
|
|
1618
1624
|
};
|
|
1619
1625
|
var Launch = {
|
|
1620
|
-
|
|
1626
|
+
getPlaywrightCrawlerOptions(options = {}) {
|
|
1621
1627
|
const normalizedOptions = Array.isArray(options) ? { customArgs: options } : options || {};
|
|
1622
1628
|
const {
|
|
1623
1629
|
customArgs = [],
|
|
1624
1630
|
proxyConfiguration = {},
|
|
1625
|
-
log: logOptions = null
|
|
1631
|
+
log: logOptions = null,
|
|
1632
|
+
runInHeadfulMode = false,
|
|
1633
|
+
isRunningOnApify = false,
|
|
1634
|
+
launcher = null,
|
|
1635
|
+
preNavigationHooks = [],
|
|
1636
|
+
postNavigationHooks = []
|
|
1626
1637
|
} = normalizedOptions;
|
|
1627
1638
|
const { launchProxy, byPassDomains, enableProxy, proxyUrl } = resolveProxyLaunchOptions(proxyConfiguration);
|
|
1628
1639
|
const byPassRules = buildByPassDomainRules(byPassDomains);
|
|
@@ -1674,14 +1685,37 @@ var Launch = {
|
|
|
1674
1685
|
page.on("request", requestHandler);
|
|
1675
1686
|
return recommendedGotoOptions;
|
|
1676
1687
|
};
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1688
|
+
const launchContext = {
|
|
1689
|
+
useIncognitoPages: true,
|
|
1690
|
+
launchOptions
|
|
1691
|
+
};
|
|
1692
|
+
if (launcher) {
|
|
1693
|
+
launchContext.launcher = launcher;
|
|
1694
|
+
}
|
|
1695
|
+
const crawlerBaseOptions = {
|
|
1696
|
+
...DEFAULT_CRAWLER_BASE_OPTIONS,
|
|
1697
|
+
headless: !runInHeadfulMode || isRunningOnApify,
|
|
1698
|
+
browserPoolOptions: {
|
|
1699
|
+
useFingerprints: true,
|
|
1700
|
+
fingerprintOptions: {
|
|
1701
|
+
fingerprintGeneratorOptions: AntiCheat.getFingerprintGeneratorOptions()
|
|
1702
|
+
}
|
|
1703
|
+
},
|
|
1704
|
+
launchContext
|
|
1705
|
+
};
|
|
1706
|
+
const normalizedPreNavigationHooks = Array.isArray(preNavigationHooks) ? preNavigationHooks : [];
|
|
1707
|
+
const normalizedPostNavigationHooks = Array.isArray(postNavigationHooks) ? postNavigationHooks : [];
|
|
1708
|
+
const internalPreNavigationHook = async ({ page }, gotoOptions = {}) => {
|
|
1709
|
+
const recommendedGotoOptions = onPageCreated(page);
|
|
1710
|
+
if (recommendedGotoOptions && typeof recommendedGotoOptions === "object") {
|
|
1711
|
+
Object.assign(gotoOptions, recommendedGotoOptions);
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
return {
|
|
1715
|
+
...crawlerBaseOptions,
|
|
1716
|
+
preNavigationHooks: [internalPreNavigationHook, ...normalizedPreNavigationHooks],
|
|
1717
|
+
...normalizedPostNavigationHooks.length > 0 ? { postNavigationHooks: normalizedPostNavigationHooks } : {}
|
|
1718
|
+
};
|
|
1685
1719
|
}
|
|
1686
1720
|
};
|
|
1687
1721
|
|