@crawlee/puppeteer 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.
@@ -14,9 +14,9 @@ export interface PuppeteerCrawlingContext<UserData extends Dictionary = Dictiona
14
14
  // @ts-ignore optional peer dependency or compatibility with es2022
15
15
  export interface PuppeteerHook extends BrowserHook<PuppeteerCrawlingContext> {
16
16
  }
17
- export interface PuppeteerCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends PuppeteerCrawlingContext = PuppeteerCrawlingContext & ContextExtension> extends BrowserCrawlerOptions<Page, HTTPResponse, PuppeteerCrawlingContext, ContextExtension, ExtendedContext, {
17
+ export interface PuppeteerCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends PuppeteerCrawlingContext = PuppeteerCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<PuppeteerCrawlingContext['request']>>> extends BrowserCrawlerOptions<Page, HTTPResponse, PuppeteerCrawlingContext, ContextExtension, ExtendedContext, {
18
18
  browserPlugins: [PuppeteerPlugin];
19
- }> {
19
+ }, Routes> {
20
20
  /**
21
21
  * Options used by {@link launchPuppeteer} to start new Puppeteer instances.
22
22
  */
@@ -121,9 +121,9 @@ export interface PuppeteerCrawlerOptions<ContextExtension = Dictionary<never>, E
121
121
  * ```
122
122
  * @category Crawlers
123
123
  */
124
- export declare class PuppeteerCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends PuppeteerCrawlingContext = PuppeteerCrawlingContext & ContextExtension> extends BrowserCrawler<Page, HTTPResponse, {
124
+ export declare class PuppeteerCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends PuppeteerCrawlingContext = PuppeteerCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<PuppeteerCrawlingContext['request']>>> extends BrowserCrawler<Page, HTTPResponse, {
125
125
  browserPlugins: [PuppeteerPlugin];
126
- }, LaunchOptions, PuppeteerCrawlingContext, ContextExtension, ExtendedContext> {
126
+ }, LaunchOptions, PuppeteerCrawlingContext, ContextExtension, ExtendedContext, Routes> {
127
127
  protected static optionsShape: {
128
128
  // @ts-ignore optional peer dependency or compatibility with es2022
129
129
  browserPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
@@ -215,7 +215,7 @@ export declare class PuppeteerCrawler<ContextExtension = Dictionary<never>, Exte
215
215
  /**
216
216
  * All `PuppeteerCrawler` parameters are passed via an options object.
217
217
  */
218
- constructor(options?: PuppeteerCrawlerOptions<ContextExtension, ExtendedContext>);
218
+ constructor(options?: PuppeteerCrawlerOptions<ContextExtension, ExtendedContext, Routes>);
219
219
  // @ts-ignore optional peer dependency or compatibility with es2022
220
220
  protected buildContextPipeline(): import("@crawlee/browser").ContextPipeline<import("@crawlee/browser").CrawlingContext<Dictionary>, BrowserCrawlingContext<Page, HTTPResponse, Dictionary, Dictionary> & {
221
221
  injectFile: (filePath: string, options?: InjectFileOptions) => Promise<unknown>;
@@ -139,7 +139,10 @@ export class PuppeteerCrawler extends BrowserCrawler {
139
139
  addInterceptRequestHandler: async (handler) => puppeteerUtils.addInterceptRequestHandler(context.page, handler),
140
140
  removeInterceptRequestHandler: async (handler) => puppeteerUtils.removeInterceptRequestHandler(context.page, handler),
141
141
  infiniteScroll: async (options) => puppeteerUtils.infiniteScroll(context.page, options),
142
- saveSnapshot: async (options) => puppeteerUtils.saveSnapshot(context.page, { ...options, config: serviceLocator.getConfiguration() }),
142
+ saveSnapshot: async (options) => puppeteerUtils.saveSnapshot(context.page, {
143
+ ...options,
144
+ configuration: serviceLocator.getConfiguration(),
145
+ }),
143
146
  closeCookieModals: async () => puppeteerUtils.closeCookieModals(context.page),
144
147
  };
145
148
  }
@@ -66,7 +66,7 @@ export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPl
66
66
  * @ignore
67
67
  */
68
68
  export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin, unknown> {
69
- readonly config: Configuration;
69
+ readonly configuration: Configuration;
70
70
  protected static optionsShape: {
71
71
  // @ts-ignore optional peer dependency or compatibility with es2022
72
72
  launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
@@ -90,7 +90,7 @@ export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin,
90
90
  /**
91
91
  * All `PuppeteerLauncher` parameters are passed via an launchContext object.
92
92
  */
93
- constructor(launchContext?: PuppeteerLaunchContext, config?: Configuration);
93
+ constructor(launchContext?: PuppeteerLaunchContext, configuration?: Configuration);
94
94
  protected getDefaultHeadlessOption(): boolean;
95
95
  }
96
96
  /**
@@ -121,8 +121,8 @@ export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin,
121
121
  * @param [launchContext]
122
122
  * All `PuppeteerLauncher` parameters are passed via an launchContext object.
123
123
  * If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
124
- * @param [config]
124
+ * @param [configuration]
125
125
  * @returns
126
126
  * Promise that resolves to Puppeteer's `Browser` instance.
127
127
  */
128
- export declare function launchPuppeteer(launchContext?: PuppeteerLaunchContext, config?: Configuration): Promise<Browser>;
128
+ export declare function launchPuppeteer(launchContext?: PuppeteerLaunchContext, configuration?: Configuration): Promise<Browser>;
@@ -6,7 +6,7 @@ import ow from 'ow';
6
6
  * @ignore
7
7
  */
8
8
  export class PuppeteerLauncher extends BrowserLauncher {
9
- config;
9
+ configuration;
10
10
  static optionsShape = {
11
11
  ...BrowserLauncher.optionsShape,
12
12
  launcher: ow.optional.object,
@@ -14,14 +14,14 @@ export class PuppeteerLauncher extends BrowserLauncher {
14
14
  /**
15
15
  * All `PuppeteerLauncher` parameters are passed via an launchContext object.
16
16
  */
17
- constructor(launchContext = {}, config = Configuration.getGlobalConfig()) {
17
+ constructor(launchContext = {}, configuration = Configuration.getGlobalConfiguration()) {
18
18
  ow(launchContext, 'PuppeteerLauncher', ow.object.exactShape(PuppeteerLauncher.optionsShape));
19
19
  const { launcher = BrowserLauncher.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'), ...browserLauncherOptions } = launchContext;
20
20
  super({
21
21
  ...browserLauncherOptions,
22
22
  launcher,
23
- }, config);
24
- this.config = config;
23
+ }, configuration);
24
+ this.configuration = configuration;
25
25
  this.Plugin = PuppeteerPlugin;
26
26
  }
27
27
  getDefaultHeadlessOption() {
@@ -57,11 +57,11 @@ export class PuppeteerLauncher extends BrowserLauncher {
57
57
  * @param [launchContext]
58
58
  * All `PuppeteerLauncher` parameters are passed via an launchContext object.
59
59
  * If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
60
- * @param [config]
60
+ * @param [configuration]
61
61
  * @returns
62
62
  * Promise that resolves to Puppeteer's `Browser` instance.
63
63
  */
64
- export async function launchPuppeteer(launchContext, config = Configuration.getGlobalConfig()) {
65
- const puppeteerLauncher = new PuppeteerLauncher(launchContext, config);
64
+ export async function launchPuppeteer(launchContext, configuration = Configuration.getGlobalConfiguration()) {
65
+ const puppeteerLauncher = new PuppeteerLauncher(launchContext, configuration);
66
66
  return puppeteerLauncher.launch();
67
67
  }
@@ -305,9 +305,9 @@ export interface SaveSnapshotOptions {
305
305
  keyValueStoreName?: string | null;
306
306
  /**
307
307
  * Configuration of the crawler that will be used to save the snapshot.
308
- * @default Configuration.getGlobalConfig()
308
+ * @default Configuration.getGlobalConfiguration()
309
309
  */
310
- config?: Configuration;
310
+ configuration?: Configuration;
311
311
  }
312
312
  /**
313
313
  * Saves a full screenshot and HTML of the current page into a Key-Value store.
@@ -515,12 +515,12 @@ export async function saveSnapshot(page, options = {}) {
515
515
  saveScreenshot: ow.optional.boolean,
516
516
  saveHtml: ow.optional.boolean,
517
517
  keyValueStoreName: ow.optional.string,
518
- config: ow.optional.object,
518
+ configuration: ow.optional.object,
519
519
  }));
520
- const { key = 'SNAPSHOT', screenshotQuality = 50, saveScreenshot = true, saveHtml = true, keyValueStoreName, config, } = options;
520
+ const { key = 'SNAPSHOT', screenshotQuality = 50, saveScreenshot = true, saveHtml = true, keyValueStoreName, configuration, } = options;
521
521
  try {
522
522
  const store = await KeyValueStore.open(keyValueStoreName ? { name: keyValueStoreName } : null, {
523
- config: config ?? Configuration.getGlobalConfig(),
523
+ configuration: configuration ?? Configuration.getGlobalConfiguration(),
524
524
  });
525
525
  if (saveScreenshot) {
526
526
  const screenshotName = `${key}.jpg`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/puppeteer",
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,11 +48,11 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@apify/datastructures": "^2.0.3",
51
- "@crawlee/browser": "4.0.0-beta.85",
52
- "@crawlee/browser-pool": "4.0.0-beta.85",
53
- "@crawlee/core": "4.0.0-beta.85",
54
- "@crawlee/types": "4.0.0-beta.85",
55
- "@crawlee/utils": "4.0.0-beta.85",
51
+ "@crawlee/browser": "4.0.0-beta.87",
52
+ "@crawlee/browser-pool": "4.0.0-beta.87",
53
+ "@crawlee/core": "4.0.0-beta.87",
54
+ "@crawlee/types": "4.0.0-beta.87",
55
+ "@crawlee/utils": "4.0.0-beta.87",
56
56
  "cheerio": "^1.0.0",
57
57
  "devtools-protocol": "*",
58
58
  "idcac-playwright": "^0.2.0",
@@ -79,5 +79,5 @@
79
79
  }
80
80
  }
81
81
  },
82
- "gitHead": "8d6d3cd9da3dc9cb0b7822b28eb317019b6806bc"
82
+ "gitHead": "1b7604cd77b694460aac4448b4555444fa1b2bdb"
83
83
  }