@crawlee/stagehand 4.0.0-beta.65 → 4.0.0-beta.67
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
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<a href="https://crawlee.dev">
|
|
3
3
|
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true"
|
|
5
|
-
<img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500"
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true" />
|
|
5
|
+
<img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500" />
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
|
-
<br
|
|
8
|
+
<br />
|
|
9
9
|
<small>A web scraping and browser automation library</small>
|
|
10
10
|
</h1>
|
|
11
11
|
|
|
12
|
-
<p align=center>
|
|
13
|
-
<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift"
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift" width="250" height="55"/></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
<p align=center>
|
|
17
|
-
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg"
|
|
18
|
-
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg"
|
|
19
|
-
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord"
|
|
20
|
-
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status"
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" /></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" /></a>
|
|
19
|
+
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" /></a>
|
|
20
|
+
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status" /></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
Crawlee covers your crawling and scraping end-to-end and **helps you build reliable scrapers. Fast.**
|
package/index.mjs
CHANGED
|
@@ -32,6 +32,7 @@ export const LoggerJson = mod.LoggerJson;
|
|
|
32
32
|
export const LoggerText = mod.LoggerText;
|
|
33
33
|
export const MAX_POOL_SIZE = mod.MAX_POOL_SIZE;
|
|
34
34
|
export const MAX_QUERIES_FOR_CONSISTENCY = mod.MAX_QUERIES_FOR_CONSISTENCY;
|
|
35
|
+
export const MemoryStorageBackend = mod.MemoryStorageBackend;
|
|
35
36
|
export const MissingRouteError = mod.MissingRouteError;
|
|
36
37
|
export const MissingSessionError = mod.MissingSessionError;
|
|
37
38
|
export const NavigationSkippedError = mod.NavigationSkippedError;
|
|
@@ -48,10 +49,7 @@ export const RequestHandlerError = mod.RequestHandlerError;
|
|
|
48
49
|
export const RequestHandlerResult = mod.RequestHandlerResult;
|
|
49
50
|
export const RequestList = mod.RequestList;
|
|
50
51
|
export const RequestManagerTandem = mod.RequestManagerTandem;
|
|
51
|
-
export const RequestProvider = mod.RequestProvider;
|
|
52
52
|
export const RequestQueue = mod.RequestQueue;
|
|
53
|
-
export const RequestQueueV1 = mod.RequestQueueV1;
|
|
54
|
-
export const RequestQueueV2 = mod.RequestQueueV2;
|
|
55
53
|
export const RequestState = mod.RequestState;
|
|
56
54
|
export const RetryRequestError = mod.RetryRequestError;
|
|
57
55
|
export const Router = mod.Router;
|
|
@@ -67,6 +65,7 @@ export const Snapshotter = mod.Snapshotter;
|
|
|
67
65
|
export const StagehandCrawler = mod.StagehandCrawler;
|
|
68
66
|
export const Statistics = mod.Statistics;
|
|
69
67
|
export const StorageInstanceManager = mod.StorageInstanceManager;
|
|
68
|
+
export const StorageStatsTracker = mod.StorageStatsTracker;
|
|
70
69
|
export const SystemStatus = mod.SystemStatus;
|
|
71
70
|
export const applyRequestTransform = mod.applyRequestTransform;
|
|
72
71
|
export const assertJsonSerializable = mod.assertJsonSerializable;
|
|
@@ -96,12 +95,13 @@ export const getDefaultCookieExpirationDate = mod.getDefaultCookieExpirationDate
|
|
|
96
95
|
export const getRequestId = mod.getRequestId;
|
|
97
96
|
export const handleRequestTimeout = mod.handleRequestTimeout;
|
|
98
97
|
export const log = mod.log;
|
|
99
|
-
export const maybeStringify = mod.maybeStringify;
|
|
100
98
|
export const mergeCookies = mod.mergeCookies;
|
|
99
|
+
export const parseValue = mod.parseValue;
|
|
101
100
|
export const purgeDefaultStorages = mod.purgeDefaultStorages;
|
|
102
101
|
export const resolveBaseUrlForEnqueueLinksFiltering = mod.resolveBaseUrlForEnqueueLinksFiltering;
|
|
103
102
|
export const resolveStorageIdentifier = mod.resolveStorageIdentifier;
|
|
104
103
|
export const serializeArray = mod.serializeArray;
|
|
104
|
+
export const serializeValue = mod.serializeValue;
|
|
105
105
|
export const serviceLocator = mod.serviceLocator;
|
|
106
106
|
export const stagehandUtils = mod.stagehandUtils;
|
|
107
107
|
export const toughCookieToBrowserPoolCookie = mod.toughCookieToBrowserPoolCookie;
|
|
@@ -5,7 +5,6 @@ import type { Dictionary } from '@crawlee/types';
|
|
|
5
5
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
6
6
|
import type { LaunchOptions, Page, Response } from 'playwright';
|
|
7
7
|
import type { z } from 'zod';
|
|
8
|
-
import type { StagehandController } from './stagehand-controller';
|
|
9
8
|
import type { StagehandLaunchContext } from './stagehand-launcher';
|
|
10
9
|
import type { StagehandPlugin } from './stagehand-plugin';
|
|
11
10
|
/**
|
|
@@ -173,7 +172,7 @@ export interface StagehandPage extends Page {
|
|
|
173
172
|
* Goto options for StagehandCrawler navigation.
|
|
174
173
|
*/
|
|
175
174
|
export type StagehandGotoOptions = NonNullable<Parameters<Page['goto']>[1]>;
|
|
176
|
-
export interface StagehandCrawlingContext<UserData extends Dictionary = Dictionary> extends BrowserCrawlingContext<StagehandPage, Response,
|
|
175
|
+
export interface StagehandCrawlingContext<UserData extends Dictionary = Dictionary> extends BrowserCrawlingContext<StagehandPage, Response, UserData, StagehandGotoOptions> {
|
|
177
176
|
/**
|
|
178
177
|
* Enhanced Playwright page with Stagehand AI methods.
|
|
179
178
|
* Use page.act(), page.extract(), page.observe(), page.agent() for AI-powered operations.
|
|
@@ -198,7 +197,7 @@ export interface StagehandRequestHandler extends RequestHandler<LoadedContext<St
|
|
|
198
197
|
/**
|
|
199
198
|
* Options for StagehandCrawler.
|
|
200
199
|
*/
|
|
201
|
-
export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension> extends BrowserCrawlerOptions<StagehandPage, Response,
|
|
200
|
+
export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension> extends BrowserCrawlerOptions<StagehandPage, Response, StagehandCrawlingContext, ContextExtension, ExtendedContext, {
|
|
202
201
|
browserPlugins: [StagehandPlugin];
|
|
203
202
|
}> {
|
|
204
203
|
/**
|
|
@@ -216,7 +215,6 @@ export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, E
|
|
|
216
215
|
* The function receives the {@link StagehandCrawlingContext} as an argument, where:
|
|
217
216
|
* - `request` is an instance of the {@link Request} object with details about the URL to open, HTTP method etc.
|
|
218
217
|
* - `page` is an enhanced Playwright [`Page`](https://playwright.dev/docs/api/class-page) with AI methods
|
|
219
|
-
* - `browserController` is an instance of {@link StagehandController}
|
|
220
218
|
* - `response` is the main resource response as returned by `page.goto(request.url)`
|
|
221
219
|
* - `stagehand` is the Stagehand instance for advanced control
|
|
222
220
|
*
|
|
@@ -314,7 +312,7 @@ export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, E
|
|
|
314
312
|
* await crawler.run(['https://example.com']);
|
|
315
313
|
* ```
|
|
316
314
|
*/
|
|
317
|
-
export declare class StagehandCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension> extends BrowserCrawler<StagehandPage, Response,
|
|
315
|
+
export declare class StagehandCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension> extends BrowserCrawler<StagehandPage, Response, {
|
|
318
316
|
browserPlugins: [StagehandPlugin];
|
|
319
317
|
}, LaunchOptions, StagehandCrawlingContext, ContextExtension, ExtendedContext> {
|
|
320
318
|
protected static optionsShape: {
|
|
@@ -332,6 +330,8 @@ export declare class StagehandCrawler<ContextExtension = Dictionary<never>, Exte
|
|
|
332
330
|
launchContext: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
333
331
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
334
332
|
headless: import("ow").AnyPredicate<string | boolean>;
|
|
333
|
+
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
334
|
+
browserPool: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
335
335
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
336
336
|
saveResponseCookies: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
337
337
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
@@ -385,7 +385,7 @@ export declare class StagehandCrawler<ContextExtension = Dictionary<never>, Exte
|
|
|
385
385
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
386
386
|
configuration: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
387
387
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
388
|
-
|
|
388
|
+
storageBackend: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
389
389
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
390
390
|
eventManager: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
391
391
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
@@ -398,8 +398,6 @@ export declare class StagehandCrawler<ContextExtension = Dictionary<never>, Exte
|
|
|
398
398
|
maxRequestsPerMinute: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
399
399
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
400
400
|
keepAlive: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
401
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
402
|
-
experiments: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
403
401
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
404
402
|
statisticsOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
405
403
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
@@ -412,6 +410,16 @@ export declare class StagehandCrawler<ContextExtension = Dictionary<never>, Exte
|
|
|
412
410
|
*/
|
|
413
411
|
constructor(options?: StagehandCrawlerOptions<ContextExtension, ExtendedContext>);
|
|
414
412
|
protected buildContextPipeline(): ContextPipeline<CrawlingContext, StagehandCrawlingContext>;
|
|
413
|
+
/**
|
|
414
|
+
* Resolves the {@link StagehandController} that owns the given page, or
|
|
415
|
+
* `undefined` when the pool does not expose controllers (e.g. a custom
|
|
416
|
+
* {@link IBrowserPool} implementation).
|
|
417
|
+
*
|
|
418
|
+
* Stagehand needs direct controller access to reach the `Stagehand`
|
|
419
|
+
* instance bound to the page's browser, which is why it reaches past the
|
|
420
|
+
* {@link IBrowserPool} abstraction here.
|
|
421
|
+
*/
|
|
422
|
+
private getBrowserControllerByPage;
|
|
415
423
|
/**
|
|
416
424
|
* Enhance the page with Stagehand AI methods.
|
|
417
425
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stagehand-crawler.d.ts","sourceRoot":"","sources":["../../src/internals/stagehand-crawler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACR,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,YAAY,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAU,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM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AG,UAAU,CAAC,KAAK,CAAC,EACpC,eAAe,SAAS,wBAAwB,GAAG,wBAAwB,GAAG,gBAAgB,CAChG,SAAQ,cAAc,CACpB,aAAa,EACb,QAAQ,EACR;IAAE,cAAc,EAAE,CAAC,eAAe,CAAC,CAAA;CAAE,EACrC,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,CAClB;IACG,iBAA0B,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAIpC;IAEF;;;;OAIG;gBACS,OAAO,GAAE,uBAAuB,CAAC,gBAAgB,EAAE,eAAe,CAAM;cA0BjE,oBAAoB,IAAI,eAAe,CAAC,eAAe,EAAE,wBAAwB,CAAC;IAIrG;;;;;;;;OAQG;IACH,OAAO,CAAC,0BAA0B;IAYlC;;OAEG;YACW,cAAc;IAmB5B;;;OAGG;cACsB,kBAAkB,CACvC,eAAe,EAAE,wBAAwB,EACzC,WAAW,EAAE,oBAAoB,GAClC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAI9B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,EACnE,QAAQ,SAAS,UAAU,GAAG,sBAAsB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAC1E,MAAM,CAAC,EAAE,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,gGAEzC"}
|
|
@@ -90,11 +90,30 @@ class StagehandCrawler extends browser_1.BrowserCrawler {
|
|
|
90
90
|
buildContextPipeline() {
|
|
91
91
|
return super.buildContextPipeline().compose({ action: this.setUpStagehand.bind(this) });
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the {@link StagehandController} that owns the given page, or
|
|
95
|
+
* `undefined` when the pool does not expose controllers (e.g. a custom
|
|
96
|
+
* {@link IBrowserPool} implementation).
|
|
97
|
+
*
|
|
98
|
+
* Stagehand needs direct controller access to reach the `Stagehand`
|
|
99
|
+
* instance bound to the page's browser, which is why it reaches past the
|
|
100
|
+
* {@link IBrowserPool} abstraction here.
|
|
101
|
+
*/
|
|
102
|
+
getBrowserControllerByPage(page) {
|
|
103
|
+
if ('getBrowserControllerByPage' in this.browserPool) {
|
|
104
|
+
return this.browserPool.getBrowserControllerByPage(page);
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
93
108
|
/**
|
|
94
109
|
* Enhance the page with Stagehand AI methods.
|
|
95
110
|
*/
|
|
96
111
|
async setUpStagehand(crawlingContext) {
|
|
97
|
-
const
|
|
112
|
+
const controller = this.getBrowserControllerByPage(crawlingContext.page);
|
|
113
|
+
if (!controller) {
|
|
114
|
+
throw new Error('Could not resolve StagehandController for page — is the browser pool configured correctly?');
|
|
115
|
+
}
|
|
116
|
+
const stagehand = controller.getStagehand();
|
|
98
117
|
return {
|
|
99
118
|
stagehand,
|
|
100
119
|
page: (0, stagehand_utils_1.enhancePageWithStagehand)(crawlingContext.page, stagehand),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stagehand-crawler.js","sourceRoot":"","sources":["../../src/internals/stagehand-crawler.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"stagehand-crawler.js","sourceRoot":"","sources":["../../src/internals/stagehand-crawler.ts"],"names":[],"mappings":";;;AA2fA,sDAKC;;AAxeD,8CAA0D;AAG1D,oDAAoB;AAMpB,6DAAyD;AAEzD,6DAAmE;AAkSnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAa,gBAGX,SAAQ,wBAQT;IACa,MAAM,CAAU,YAAY,GAAG;QACrC,GAAG,wBAAc,CAAC,YAAY;QAC9B,gBAAgB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QACpC,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KACzC,CAAC;IAEF;;;;OAIG;IAC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AAC,CAAC;QAE1F,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACX,4FAA4F,CAC/F,CAAC;QACN,CAAC;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;QAE5C,OAAO;YACH,SAAS;YACT,IAAI,EAAE,IAAA,0CAAwB,EAAC,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC;SAClE,CAAC;IACN,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,kBAAkB,CACvC,eAAyC,EACzC,WAAiC;QAEjC,wCAAwC;QACxC,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC/E,CAAC;;AA1GL,4CA2GC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,qBAAqB,CAGnC,MAAwC;IACtC,OAAO,gBAAM,CAAC,MAAM,CAAU,MAAM,CAAC,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/stagehand",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.67",
|
|
4
4
|
"description": "AI-powered web crawling with Stagehand integration for Crawlee - enables natural language browser automation with act(), extract(), and observe() methods.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@apify/timeout": "^0.3.2",
|
|
60
|
-
"@crawlee/browser": "4.0.0-beta.
|
|
61
|
-
"@crawlee/browser-pool": "4.0.0-beta.
|
|
62
|
-
"@crawlee/core": "4.0.0-beta.
|
|
63
|
-
"@crawlee/types": "4.0.0-beta.
|
|
64
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
60
|
+
"@crawlee/browser": "4.0.0-beta.67",
|
|
61
|
+
"@crawlee/browser-pool": "4.0.0-beta.67",
|
|
62
|
+
"@crawlee/core": "4.0.0-beta.67",
|
|
63
|
+
"@crawlee/types": "4.0.0-beta.67",
|
|
64
|
+
"@crawlee/utils": "4.0.0-beta.67",
|
|
65
65
|
"ow": "^2.0.0",
|
|
66
66
|
"tslib": "^2.8.1"
|
|
67
67
|
},
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "20617e873491494f343cd32831645acec484abed"
|
|
97
97
|
}
|