@crawlee/browser 4.0.0-beta.85 → 4.0.0-beta.87

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.
@@ -1,4 +1,4 @@
1
- import type { Awaitable, BasicCrawlerOptions, BasicCrawlingContext, CrawlingContext, Dictionary, EnqueueLinksOptions, ErrorHandler, IRequestManager, LoadedRequest, Request, RequestHandler, SkippedRequestCallback } from '@crawlee/basic';
1
+ import type { Awaitable, BasicCrawlerOptions, BasicCrawlingContext, CrawlingContext, Dictionary, EnqueueLinksOptions, ErrorHandler, GetUserDataFromRequest, IRequestManager, LoadedRequest, Request, RequestHandler, RouterHandler, SkippedRequestCallback } from '@crawlee/basic';
2
2
  import { BasicCrawler, ContextPipeline } from '@crawlee/basic';
3
3
  import type { BrowserController, BrowserPlugin, BrowserPoolHooks, BrowserPoolOptions, CommonPage, CrawlerRemoteBrowserOptions, InferBrowserPluginArray, LaunchContext } from '@crawlee/browser-pool';
4
4
  import type { BatchAddRequestsResult, IBrowserPool } from '@crawlee/types';
@@ -32,7 +32,7 @@ export interface BrowserCrawlingContext<Page extends CommonPage = CommonPage, Re
32
32
  enqueueLinks: (options?: EnqueueLinksOptions) => Promise<BatchAddRequestsResult>;
33
33
  }
34
34
  export type BrowserHook<Context = BrowserCrawlingContext, ContextExtension = {}> = (crawlingContext: Context & ContextExtension) => Awaitable<void | Partial<Context>>;
35
- export interface BrowserCrawlerOptions<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, Context extends BrowserCrawlingContext<Page, Response, Dictionary> = BrowserCrawlingContext<Page, Response, Dictionary>, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, __BrowserPlugins extends BrowserPlugin[] = InferBrowserPluginArray<InternalBrowserPoolOptions['browserPlugins']>, __BrowserControllerReturn extends BrowserController = ReturnType<__BrowserPlugins[number]['createController']>, __LaunchContextReturn extends LaunchContext = ReturnType<__BrowserPlugins[number]['createLaunchContext']>> extends Omit<BasicCrawlerOptions<Context, ContextExtension, ExtendedContext>, 'requestHandler' | 'failedRequestHandler' | 'errorHandler'> {
35
+ export interface BrowserCrawlerOptions<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, Context extends BrowserCrawlingContext<Page, Response, Dictionary> = BrowserCrawlingContext<Page, Response, Dictionary>, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>, __BrowserPlugins extends BrowserPlugin[] = InferBrowserPluginArray<InternalBrowserPoolOptions['browserPlugins']>, __BrowserControllerReturn extends BrowserController = ReturnType<__BrowserPlugins[number]['createController']>, __LaunchContextReturn extends LaunchContext = ReturnType<__BrowserPlugins[number]['createLaunchContext']>> extends Omit<BasicCrawlerOptions<Context, ContextExtension, ExtendedContext>, 'requestHandler' | 'failedRequestHandler' | 'errorHandler'> {
36
36
  launchContext?: BrowserLaunchContext<any, any>;
37
37
  /**
38
38
  * An existing browser pool instance to use. When provided, the crawler will use this pool directly instead of
@@ -78,7 +78,7 @@ export interface BrowserCrawlerOptions<Page extends CommonPage = CommonPage, Res
78
78
  * The exceptions are logged to the request using the
79
79
  * {@link Request.pushErrorMessage|`Request.pushErrorMessage()`} function.
80
80
  */
81
- requestHandler?: RequestHandler<ExtendedContext>;
81
+ requestHandler?: RouterHandler<ExtendedContext, Routes> | RequestHandler<ExtendedContext>;
82
82
  /**
83
83
  * User-provided function that allows modifying the request object before it gets retried by the crawler.
84
84
  * It's executed before each retry for the requests that failed less than {@link BrowserCrawlerOptions.maxRequestRetries|`maxRequestRetries`} times.
@@ -223,7 +223,7 @@ export interface BrowserCrawlerOptions<Page extends CommonPage = CommonPage, Res
223
223
  *
224
224
  * @category Crawlers
225
225
  */
226
- export declare abstract class BrowserCrawler<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, LaunchOptions extends Dictionary | undefined = Dictionary, Context extends BrowserCrawlingContext<Page, Response, Dictionary> = BrowserCrawlingContext<Page, Response, Dictionary>, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, GoToOptions extends Dictionary = Dictionary> extends BasicCrawler<Context, ContextExtension, ExtendedContext> {
226
+ export declare abstract class BrowserCrawler<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, LaunchOptions extends Dictionary | undefined = Dictionary, Context extends BrowserCrawlingContext<Page, Response, Dictionary> = BrowserCrawlingContext<Page, Response, Dictionary>, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>, GoToOptions extends Dictionary = Dictionary> extends BasicCrawler<Context, ContextExtension, ExtendedContext, Routes> {
227
227
  /** Backs the {@link BrowserCrawler.browserPool|`browserPool`} getter. */
228
228
  private browserPoolDep;
229
229
  /**
@@ -69,7 +69,7 @@ export interface BrowserLaunchContext<TOptions, Launcher> extends BrowserPluginO
69
69
  * @ignore
70
70
  */
71
71
  export declare abstract class BrowserLauncher<Plugin extends BrowserPlugin, Launcher = Plugin['library'], T extends Constructor<Plugin> = Constructor<Plugin>, LaunchOptions extends Dictionary<any> | undefined = Partial<Parameters<Plugin['launch']>[0]>, LaunchResult extends ReturnType<Plugin['launch']> = ReturnType<Plugin['launch']>> {
72
- readonly config: Configuration;
72
+ readonly configuration: Configuration;
73
73
  launcher: Launcher;
74
74
  proxyUrl?: string;
75
75
  useChrome?: boolean;
@@ -99,7 +99,7 @@ export declare abstract class BrowserLauncher<Plugin extends BrowserPlugin, Laun
99
99
  /**
100
100
  * All `BrowserLauncher` parameters are passed via an launchContext object.
101
101
  */
102
- constructor(launchContext: BrowserLaunchContext<LaunchOptions, Launcher>, config?: Configuration);
102
+ constructor(launchContext: BrowserLaunchContext<LaunchOptions, Launcher>, configuration?: Configuration);
103
103
  /**
104
104
  * @ignore
105
105
  */
@@ -13,7 +13,7 @@ const require = createRequire(import.meta.url);
13
13
  * @ignore
14
14
  */
15
15
  export class BrowserLauncher {
16
- config;
16
+ configuration;
17
17
  launcher;
18
18
  proxyUrl;
19
19
  useChrome;
@@ -51,8 +51,8 @@ export class BrowserLauncher {
51
51
  /**
52
52
  * All `BrowserLauncher` parameters are passed via an launchContext object.
53
53
  */
54
- constructor(launchContext, config = Configuration.getGlobalConfig()) {
55
- this.config = config;
54
+ constructor(launchContext, configuration = Configuration.getGlobalConfiguration()) {
55
+ this.configuration = configuration;
56
56
  const { launcher, proxyUrl, useChrome, userAgent, launchOptions = {}, ...otherLaunchContextProps } = launchContext;
57
57
  this.validateProxyUrlProtocol(proxyUrl);
58
58
  // those need to be reassigned otherwise they are {} in types
@@ -88,7 +88,7 @@ export class BrowserLauncher {
88
88
  defaultViewport: DEFAULT_VIEWPORT,
89
89
  ...this.launchOptions,
90
90
  };
91
- if (this.config.disableBrowserSandbox) {
91
+ if (this.configuration.disableBrowserSandbox) {
92
92
  launchOptions.args.push('--no-sandbox');
93
93
  }
94
94
  if (this.userAgent) {
@@ -103,10 +103,10 @@ export class BrowserLauncher {
103
103
  return launchOptions;
104
104
  }
105
105
  getDefaultHeadlessOption() {
106
- return this.config.headless && !this.config.xvfb;
106
+ return this.configuration.headless && !this.configuration.xvfb;
107
107
  }
108
108
  getChromeExecutablePath() {
109
- return this.config.chromeExecutablePath ?? this.getTypicalChromeExecutablePath();
109
+ return this.configuration.chromeExecutablePath ?? this.getTypicalChromeExecutablePath();
110
110
  }
111
111
  /**
112
112
  * Gets a typical path to Chrome executable, depending on the current operating system.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/browser",
3
- "version": "4.0.0-beta.85",
3
+ "version": "4.0.0-beta.87",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -48,10 +48,10 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@apify/timeout": "^0.3.2",
51
- "@crawlee/basic": "4.0.0-beta.85",
52
- "@crawlee/browser-pool": "4.0.0-beta.85",
53
- "@crawlee/types": "4.0.0-beta.85",
54
- "@crawlee/utils": "4.0.0-beta.85",
51
+ "@crawlee/basic": "4.0.0-beta.87",
52
+ "@crawlee/browser-pool": "4.0.0-beta.87",
53
+ "@crawlee/types": "4.0.0-beta.87",
54
+ "@crawlee/utils": "4.0.0-beta.87",
55
55
  "ow": "^2.0.0",
56
56
  "tslib": "^2.8.1",
57
57
  "type-fest": "^4.41.0"
@@ -75,5 +75,5 @@
75
75
  }
76
76
  }
77
77
  },
78
- "gitHead": "8d6d3cd9da3dc9cb0b7822b28eb317019b6806bc"
78
+ "gitHead": "1b7604cd77b694460aac4448b4555444fa1b2bdb"
79
79
  }