@crawlee/playwright 4.0.0-beta.119 → 4.0.0-beta.120

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,7 +1,7 @@
1
1
  import type { BrowserHook, LoadedRequest, Request, RouterHandler, RouteSchemas, RoutesFromSchemas } from '@crawlee/browser';
2
2
  import type { BasicCrawlerOptions } from '@crawlee/basic';
3
3
  import { BasicCrawler } from '@crawlee/basic';
4
- import type { ContextPipeline, CrawlingContext, EnqueueLinksOptions, GetUserDataFromRequest, RouterRoutes, StatisticsOptions, StatisticState, StorageTransactionView } from '@crawlee/core';
4
+ import type { ContextPipeline, CrawlingContext, EnqueueLinksOptions, GetUserDataFromRequest, RouterRoutes, StatisticPersistedState, StatisticState, StorageTransactionView } from '@crawlee/core';
5
5
  import { Statistics } from '@crawlee/core';
6
6
  import type { Dictionary, Awaitable } from '@crawlee/types';
7
7
  import { type CheerioRoot } from '@crawlee/utils/internal';
@@ -16,11 +16,15 @@ interface AdaptivePlaywrightCrawlerStatisticState extends StatisticState {
16
16
  browserRequestHandlerRuns?: number;
17
17
  renderingTypeMispredictions?: number;
18
18
  }
19
+ interface AdaptivePlaywrightCrawlerPersistedStatisticState extends StatisticPersistedState {
20
+ httpOnlyRequestHandlerRuns?: number;
21
+ browserRequestHandlerRuns?: number;
22
+ renderingTypeMispredictions?: number;
23
+ }
19
24
  declare class AdaptivePlaywrightCrawlerStatistics extends Statistics {
20
- state: AdaptivePlaywrightCrawlerStatisticState;
21
- constructor(options?: StatisticsOptions);
22
- reset(): void;
23
- protected maybeLoadStatistics(): Promise<void>;
25
+ get state(): AdaptivePlaywrightCrawlerStatisticState;
26
+ protected defaultState(): AdaptivePlaywrightCrawlerStatisticState;
27
+ protected deserializeState(persistedState: AdaptivePlaywrightCrawlerPersistedStatisticState): AdaptivePlaywrightCrawlerStatisticState;
24
28
  trackHttpOnlyRequestHandlerRun(): void;
25
29
  trackBrowserRequestHandlerRun(): void;
26
30
  trackRenderingTypeMisprediction(): void;
@@ -9,26 +9,24 @@ import { addTimeoutToPromise } from '@apify/timeout';
9
9
  import { PlaywrightCrawler } from './playwright-crawler.js';
10
10
  import { RenderingTypePredictor, } from './utils/rendering-type-prediction.js';
11
11
  class AdaptivePlaywrightCrawlerStatistics extends Statistics {
12
- state = null; // this needs to be assigned for a valid override, but the initialization is done by a reset() call from the parent constructor
13
- constructor(options = {}) {
14
- super(options);
15
- this.reset();
12
+ get state() {
13
+ return super.state;
16
14
  }
17
- reset() {
18
- super.reset();
19
- this.state.httpOnlyRequestHandlerRuns = 0;
20
- this.state.browserRequestHandlerRuns = 0;
21
- this.state.renderingTypeMispredictions = 0;
15
+ defaultState() {
16
+ return {
17
+ ...super.defaultState(),
18
+ httpOnlyRequestHandlerRuns: 0,
19
+ browserRequestHandlerRuns: 0,
20
+ renderingTypeMispredictions: 0,
21
+ };
22
22
  }
23
- async maybeLoadStatistics() {
24
- await super.maybeLoadStatistics();
25
- const savedState = await this.keyValueStore?.getValue(this.persistStateKey);
26
- if (!savedState) {
27
- return;
28
- }
29
- this.state.httpOnlyRequestHandlerRuns = savedState.httpOnlyRequestHandlerRuns;
30
- this.state.browserRequestHandlerRuns = savedState.browserRequestHandlerRuns;
31
- this.state.renderingTypeMispredictions = savedState.renderingTypeMispredictions;
23
+ deserializeState(persistedState) {
24
+ return {
25
+ ...super.deserializeState(persistedState),
26
+ httpOnlyRequestHandlerRuns: persistedState.httpOnlyRequestHandlerRuns,
27
+ browserRequestHandlerRuns: persistedState.browserRequestHandlerRuns,
28
+ renderingTypeMispredictions: persistedState.renderingTypeMispredictions,
29
+ };
32
30
  }
33
31
  trackHttpOnlyRequestHandlerRun() {
34
32
  this.state.httpOnlyRequestHandlerRuns ??= 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/playwright",
3
- "version": "4.0.0-beta.119",
3
+ "version": "4.0.0-beta.120",
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"
@@ -49,13 +49,13 @@
49
49
  "dependencies": {
50
50
  "@apify/datastructures": "^2.0.3",
51
51
  "@apify/timeout": "^0.4.4",
52
- "@crawlee/basic": "4.0.0-beta.119",
53
- "@crawlee/browser": "4.0.0-beta.119",
54
- "@crawlee/browser-pool": "4.0.0-beta.119",
55
- "@crawlee/cheerio": "4.0.0-beta.119",
56
- "@crawlee/core": "4.0.0-beta.119",
57
- "@crawlee/types": "4.0.0-beta.119",
58
- "@crawlee/utils": "4.0.0-beta.119",
52
+ "@crawlee/basic": "4.0.0-beta.120",
53
+ "@crawlee/browser": "4.0.0-beta.120",
54
+ "@crawlee/browser-pool": "4.0.0-beta.120",
55
+ "@crawlee/cheerio": "4.0.0-beta.120",
56
+ "@crawlee/core": "4.0.0-beta.120",
57
+ "@crawlee/types": "4.0.0-beta.120",
58
+ "@crawlee/utils": "4.0.0-beta.120",
59
59
  "cheerio": "^1.0.0",
60
60
  "jquery": "^3.7.1",
61
61
  "ml-logistic-regression": "^2.0.0",
@@ -85,5 +85,5 @@
85
85
  }
86
86
  }
87
87
  },
88
- "gitHead": "552fe2371a3c6e9e9f3514010536ea6abdc27eb4"
88
+ "gitHead": "da5d427c4c1c9dcaea95b151e9c4c7310100885d"
89
89
  }