@crawlee/playwright 3.0.0-beta.9 → 3.0.0

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlaywrightCrawler = void 0;
3
+ exports.createPlaywrightRouter = exports.PlaywrightCrawler = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const ow_1 = tslib_1.__importDefault(require("ow"));
6
6
  const browser_1 = require("@crawlee/browser");
@@ -29,7 +29,7 @@ const playwright_utils_1 = require("./utils/playwright-utils");
29
29
  * The crawler finishes when there are no more {@link Request} objects to crawl.
30
30
  *
31
31
  * `PlaywrightCrawler` opens a new Chrome page (i.e. tab) for each {@link Request} object to crawl
32
- * and then calls the function provided by user as the {@link PlaywrightCrawlerOptions.handlePageFunction} option.
32
+ * and then calls the function provided by user as the {@link PlaywrightCrawlerOptions.requestHandler} option.
33
33
  *
34
34
  * New pages are only opened when there is enough free CPU and memory available,
35
35
  * using the functionality provided by the {@link AutoscaledPool} class.
@@ -44,19 +44,19 @@ const playwright_utils_1 = require("./utils/playwright-utils");
44
44
  * ```javascript
45
45
  * const crawler = new PlaywrightCrawler({
46
46
  * requestList,
47
- * handlePageFunction: async ({ page, request }) => {
47
+ * async requestHandler({ page, request }) {
48
48
  * // This function is called to extract data from a single web page
49
49
  * // 'page' is an instance of Playwright.Page with page.goto(request.url) already called
50
50
  * // 'request' is an instance of Request class with information about the page to load
51
- * await Actor.pushData({
51
+ * await Dataset.pushData({
52
52
  * title: await page.title(),
53
53
  * url: request.url,
54
54
  * succeeded: true,
55
55
  * })
56
56
  * },
57
- * handleFailedRequestFunction: async ({ request }) => {
57
+ * async failedRequestHandler({ request }) {
58
58
  * // This function is called when the crawling of a request failed too many times
59
- * await Actor.pushData({
59
+ * await Dataset.pushData({
60
60
  * url: request.url,
61
61
  * succeeded: false,
62
62
  * errors: request.errorMessages,
@@ -72,19 +72,24 @@ class PlaywrightCrawler extends browser_1.BrowserCrawler {
72
72
  /**
73
73
  * All `PlaywrightCrawler` parameters are passed via an options object.
74
74
  */
75
- constructor(options) {
75
+ constructor(options = {}, config = browser_1.Configuration.getGlobalConfig()) {
76
76
  (0, ow_1.default)(options, 'PlaywrightCrawlerOptions', ow_1.default.object.exactShape(PlaywrightCrawler.optionsShape));
77
77
  const { launchContext = {}, browserPoolOptions = {}, ...browserCrawlerOptions } = options;
78
78
  if (launchContext.proxyUrl) {
79
79
  throw new Error('PlaywrightCrawlerOptions.launchContext.proxyUrl is not allowed in PlaywrightCrawler.'
80
80
  + 'Use PlaywrightCrawlerOptions.proxyConfiguration');
81
81
  }
82
- const playwrightLauncher = new playwright_launcher_1.PlaywrightLauncher(launchContext);
82
+ const playwrightLauncher = new playwright_launcher_1.PlaywrightLauncher(launchContext, config);
83
83
  browserPoolOptions.browserPlugins = [
84
84
  playwrightLauncher.createBrowserPlugin(),
85
85
  ];
86
- super({ ...browserCrawlerOptions, browserPoolOptions });
87
- this.launchContext = launchContext;
86
+ super({ ...browserCrawlerOptions, launchContext, browserPoolOptions }, config);
87
+ Object.defineProperty(this, "config", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: config
92
+ });
88
93
  }
89
94
  async _runRequestHandler(context) {
90
95
  (0, playwright_utils_1.registerUtilsToContext)(context);
@@ -95,7 +100,7 @@ class PlaywrightCrawler extends browser_1.BrowserCrawler {
95
100
  return (0, playwright_utils_1.gotoExtended)(crawlingContext.page, crawlingContext.request, gotoOptions);
96
101
  }
97
102
  async _applyCookies({ session, request, page }, preHooksCookies, postHooksCookies) {
98
- const sessionCookie = session?.getPuppeteerCookies(request.url) ?? [];
103
+ const sessionCookie = session?.getCookies(request.url) ?? [];
99
104
  const parsedPreHooksCookies = preHooksCookies.split(/ *; */).map((c) => tough_cookie_1.Cookie.parse(c)?.toJSON());
100
105
  const parsedPostHooksCookies = postHooksCookies.split(/ *; */).map((c) => tough_cookie_1.Cookie.parse(c)?.toJSON());
101
106
  await page.context().addCookies([
@@ -116,4 +121,32 @@ Object.defineProperty(PlaywrightCrawler, "optionsShape", {
116
121
  launcher: ow_1.default.optional.object,
117
122
  }
118
123
  });
124
+ /**
125
+ * Creates new {@link Router} instance that works based on request labels.
126
+ * This instance can then serve as a `requestHandler` of your {@link PlaywrightCrawler}.
127
+ * Defaults to the {@link PlaywrightCrawlingContext}.
128
+ *
129
+ * > Serves as a shortcut for using `Router.create<PlaywrightCrawlingContext>()`.
130
+ *
131
+ * ```ts
132
+ * import { PlaywrightCrawler, createPlaywrightRouter } from 'crawlee';
133
+ *
134
+ * const router = createPlaywrightRouter();
135
+ * router.addHandler('label-a', async (ctx) => {
136
+ * ctx.log.info('...');
137
+ * });
138
+ * router.addDefaultHandler(async (ctx) => {
139
+ * ctx.log.info('...');
140
+ * });
141
+ *
142
+ * const crawler = new PlaywrightCrawler({
143
+ * requestHandler: router,
144
+ * });
145
+ * await crawler.run();
146
+ * ```
147
+ */
148
+ function createPlaywrightRouter() {
149
+ return browser_1.Router.create();
150
+ }
151
+ exports.createPlaywrightRouter = createPlaywrightRouter;
119
152
  //# sourceMappingURL=playwright-crawler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-crawler.js","sourceRoot":"","sources":["../../src/internals/playwright-crawler.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAGpB,8CAM0B;AAC1B,+CAAsC;AACtC,+DAAoF;AACpF,+DAAiI;AAqIjI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAa,iBAAkB,SAAQ,wBAAgG;IAOnI;;OAEG;IACH,YAAY,OAAiC;QACzC,IAAA,YAAE,EAAC,OAAO,EAAE,0BAA0B,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;QAE9F,MAAM,EACF,aAAa,GA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;YACI,GAAG,aAAa;YAChB,GAAG,qBAAqB;YACxB,GAAG,sBAAsB;SAC5B,CAAC,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAC1D,CAAC;IACN,CAAC;;AAtDL,8CAuDC;AAtDG;;;;WAAyC;QACrC,GAAG,wBAAc,CAAC,YAAY;QAC9B,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QACtC,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B;GAAC;AAoDN;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,sBAAsB;IAClC,OAAO,gBAAM,CAAC,MAAM,EAAW,CAAC;AACpC,CAAC;AAFD,wDAEC"}
@@ -1,7 +1,8 @@
1
1
  // @ts-ignore optional peer dependency
2
- import { Browser, BrowserType, LaunchOptions } from 'playwright';
2
+ import type { Browser, BrowserType, LaunchOptions } from 'playwright';
3
3
  import { PlaywrightPlugin } from '@crawlee/browser-pool';
4
- import { BrowserLaunchContext, BrowserLauncher } from '@crawlee/browser';
4
+ import type { BrowserLaunchContext } from '@crawlee/browser';
5
+ import { BrowserLauncher, Configuration } from '@crawlee/browser';
5
6
  /**
6
7
  * Apify extends the launch options of Playwright.
7
8
  * You can use any of the Playwright compatible
@@ -37,7 +38,7 @@ export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOpti
37
38
  * If `true` and `executablePath` is not set,
38
39
  * Playwright will launch full Google Chrome browser available on the machine
39
40
  * rather than the bundled Chromium. The path to Chrome executable
40
- * is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
41
+ * is taken from the `CRAWLEE_CHROME_EXECUTABLE_PATH` environment variable if provided,
41
42
  * or defaults to the typical Google Chrome executable location specific for the operating system.
42
43
  * By default, this option is `false`.
43
44
  * @default false
@@ -66,6 +67,7 @@ export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOpti
66
67
  * @ignore
67
68
  */
68
69
  export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin> {
70
+ readonly config: Configuration;
69
71
  protected static optionsShape: {
70
72
  launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
71
73
  proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
@@ -78,7 +80,7 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
78
80
  /**
79
81
  * All `PlaywrightLauncher` parameters are passed via this launchContext object.
80
82
  */
81
- constructor(launchContext?: PlaywrightLaunchContext);
83
+ constructor(launchContext?: PlaywrightLaunchContext, config?: Configuration);
82
84
  }
83
85
  /**
84
86
  * Launches headless browsers using Playwright pre-configured to work within the Apify platform.
@@ -87,9 +89,9 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
87
89
  *
88
90
  * The `launchPlaywright()` function alters the following Playwright options:
89
91
  *
90
- * - Passes the setting from the `APIFY_HEADLESS` environment variable to the `headless` option,
91
- * unless it was already defined by the caller or `APIFY_XVFB` environment variable is set to `1`.
92
- * Note that Apify Actor cloud platform automatically sets `APIFY_HEADLESS=1` to all running actors.
92
+ * - Passes the setting from the `CRAWLEE_HEADLESS` environment variable to the `headless` option,
93
+ * unless it was already defined by the caller or `CRAWLEE_XVFB` environment variable is set to `1`.
94
+ * Note that Apify Actor cloud platform automatically sets `CRAWLEE_HEADLESS=1` to all running actors.
93
95
  * - Takes the `proxyUrl` option, validates it and adds it to `launchOptions` in a proper format.
94
96
  * The proxy URL must define a port number and have one of the following schemes: `http://`,
95
97
  * `https://`, `socks4://` or `socks5://`.
@@ -109,8 +111,9 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
109
111
  * Optional settings passed to `browserType.launch()`. In addition to
110
112
  * [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
111
113
  * the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
114
+ * @param [config]
112
115
  * @returns
113
116
  * Promise that resolves to Playwright's `Browser` instance.
114
117
  */
115
- export declare function launchPlaywright(launchContext?: PlaywrightLaunchContext): Promise<Browser>;
118
+ export declare function launchPlaywright(launchContext?: PlaywrightLaunchContext, config?: Configuration): Promise<Browser>;
116
119
  //# sourceMappingURL=playwright-launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-launcher.d.ts","sourceRoot":"","sources":["../../src/internals/playwright-launcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB,CAAC,aAAa,EAAE,WAAW,CAAC;IAC7F,4GAA4G;IAC5G,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;MAIE;IACF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,eAAe,CAAC,gBAAgB,CAAC;IACrE,iBAA0B,YAAY;;;;;;;;MAGpC;IAEF;;OAEG;gBACS,aAAa,GAAE,uBAA4B;CAoB1D;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAIhG"}
1
+ {"version":3,"file":"playwright-launcher.d.ts","sourceRoot":"","sources":["../../src/internals/playwright-launcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB,CAAC,aAAa,EAAE,WAAW,CAAC;IAC7F,4GAA4G;IAC5G,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;MAIE;IACF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,eAAe,CAAC,gBAAgB,CAAC;aAW/C,MAAM;IAV5B,iBAA0B,YAAY;;;;;;;;MAGpC;IAEF;;OAEG;gBAEC,aAAa,GAAE,uBAA4B,EACzB,MAAM,gBAAkC;CAqBjE;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,CAAC,EAAE,uBAAuB,EAAE,MAAM,gBAAkC,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1I"}
@@ -13,7 +13,7 @@ class PlaywrightLauncher extends browser_1.BrowserLauncher {
13
13
  /**
14
14
  * All `PlaywrightLauncher` parameters are passed via this launchContext object.
15
15
  */
16
- constructor(launchContext = {}) {
16
+ constructor(launchContext = {}, config = browser_1.Configuration.getGlobalConfig()) {
17
17
  (0, ow_1.default)(launchContext, 'PlaywrightLauncherOptions', ow_1.default.object.exactShape(PlaywrightLauncher.optionsShape));
18
18
  const { launcher = browser_1.BrowserLauncher.requireLauncherOrThrow('playwright', 'apify/actor-node-playwright-*').chromium, } = launchContext;
19
19
  const { launchOptions = {}, ...rest } = launchContext;
@@ -21,9 +21,15 @@ class PlaywrightLauncher extends browser_1.BrowserLauncher {
21
21
  ...rest,
22
22
  launchOptions: {
23
23
  ...launchOptions,
24
- executablePath: getDefaultExecutablePath(launchContext),
24
+ executablePath: getDefaultExecutablePath(launchContext, config),
25
25
  },
26
26
  launcher,
27
+ }, config);
28
+ Object.defineProperty(this, "config", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: config
27
33
  });
28
34
  this.Plugin = browser_pool_1.PlaywrightPlugin;
29
35
  }
@@ -39,12 +45,12 @@ Object.defineProperty(PlaywrightLauncher, "optionsShape", {
39
45
  }
40
46
  });
41
47
  /**
42
- * @returns {string | undefined} default path to browser.
43
- * If actor-node-playwright-* image is used the APIFY_DEFAULT_BROWSER_PATH is considered as default.
48
+ * If actor-node-playwright-* image is used the CRAWLEE_DEFAULT_BROWSER_PATH is considered as default.
49
+ * @returns default path to browser.
44
50
  * @ignore
45
51
  */
46
- function getDefaultExecutablePath(launchContext) {
47
- const pathFromPlaywrightImage = process.env.APIFY_DEFAULT_BROWSER_PATH;
52
+ function getDefaultExecutablePath(launchContext, config) {
53
+ const pathFromPlaywrightImage = config.get('defaultBrowserPath');
48
54
  const { launchOptions = {} } = launchContext;
49
55
  if (launchOptions.executablePath) {
50
56
  return launchOptions.executablePath;
@@ -64,9 +70,9 @@ function getDefaultExecutablePath(launchContext) {
64
70
  *
65
71
  * The `launchPlaywright()` function alters the following Playwright options:
66
72
  *
67
- * - Passes the setting from the `APIFY_HEADLESS` environment variable to the `headless` option,
68
- * unless it was already defined by the caller or `APIFY_XVFB` environment variable is set to `1`.
69
- * Note that Apify Actor cloud platform automatically sets `APIFY_HEADLESS=1` to all running actors.
73
+ * - Passes the setting from the `CRAWLEE_HEADLESS` environment variable to the `headless` option,
74
+ * unless it was already defined by the caller or `CRAWLEE_XVFB` environment variable is set to `1`.
75
+ * Note that Apify Actor cloud platform automatically sets `CRAWLEE_HEADLESS=1` to all running actors.
70
76
  * - Takes the `proxyUrl` option, validates it and adds it to `launchOptions` in a proper format.
71
77
  * The proxy URL must define a port number and have one of the following schemes: `http://`,
72
78
  * `https://`, `socks4://` or `socks5://`.
@@ -86,11 +92,12 @@ function getDefaultExecutablePath(launchContext) {
86
92
  * Optional settings passed to `browserType.launch()`. In addition to
87
93
  * [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
88
94
  * the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
95
+ * @param [config]
89
96
  * @returns
90
97
  * Promise that resolves to Playwright's `Browser` instance.
91
98
  */
92
- async function launchPlaywright(launchContext) {
93
- const playwrightLauncher = new PlaywrightLauncher(launchContext);
99
+ async function launchPlaywright(launchContext, config = browser_1.Configuration.getGlobalConfig()) {
100
+ const playwrightLauncher = new PlaywrightLauncher(launchContext, config);
94
101
  return playwrightLauncher.launch();
95
102
  }
96
103
  exports.launchPlaywright = launchPlaywright;
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-launcher.js","sourceRoot":"","sources":["../../src/internals/playwright-launcher.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAEpB,wDAAyD;AACzD,8CAAyE;AAmEzE;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,yBAAiC;IAMrE;;OAEG;IACH,YAAY,gBAAyC,EAAE;QACnD,IAAA,YAAE,EAAC,aAAa,EAAE,2BAA2B,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;QAEtG,MAAM,EACF,QAAQ,GAA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AAI,uBAAuB,EAAE;QACzB,OAAO,uBAAuB,CAAC;KAClC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,KAAK,UAAU,gBAAgB,CAAC,aAAuC,EAAE,MAAM,GAAG,uBAAa,CAAC,eAAe,EAAE;IACpH,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAEzE,OAAO,kBAAkB,CAAC,MAAM,EAAE,CAAC;AACvC,CAAC;AAJD,4CAIC"}
@@ -5,13 +5,12 @@
5
5
  * **Example usage:**
6
6
  *
7
7
  * ```javascript
8
- * const Apify = require('apify');
9
- * const { playwright } = Actor.utils;
8
+ * import { launchPlaywright, playwrightUtils } from 'crawlee';
10
9
  *
11
10
  * // Navigate to https://www.example.com in Playwright with a POST request
12
- * const browser = await Actor.launchPlaywright();
11
+ * const browser = await launchPlaywright();
13
12
  * const page = await browser.newPage();
14
- * await playwright.gotoExtended(page, {
13
+ * await playwrightUtils.gotoExtended(page, {
15
14
  * url: 'https://example.com,
16
15
  * method: 'POST',
17
16
  * });
@@ -19,9 +18,9 @@
19
18
  * @module playwrightUtils
20
19
  */
21
20
  // @ts-ignore optional peer dependency
22
- import { Page, Response } from 'playwright';
23
- import { Request } from '@crawlee/core';
24
- import { PlaywrightCrawlingContext } from '../playwright-crawler';
21
+ import type { Page, Response } from 'playwright';
22
+ import type { Request } from '@crawlee/core';
23
+ import type { PlaywrightCrawlingContext } from '../playwright-crawler';
25
24
  export interface InjectFileOptions {
26
25
  /**
27
26
  * Enables the injected script to survive page navigations and reloads without need to be re-injected manually.
@@ -102,6 +101,14 @@ export interface DirectNavigationOptions {
102
101
  */
103
102
  export declare function gotoExtended(page: Page, request: Request, gotoOptions?: DirectNavigationOptions): Promise<Response | null>;
104
103
  export interface PlaywrightContextUtils {
104
+ injectFile(filePath: string, options?: InjectFileOptions): Promise<unknown>;
105
+ injectJQuery(): Promise<unknown>;
105
106
  }
106
- export declare function registerUtilsToContext(_context: PlaywrightCrawlingContext): void;
107
+ export declare function registerUtilsToContext(context: PlaywrightCrawlingContext): void;
108
+ /** @internal */
109
+ export declare const playwrightUtils: {
110
+ injectFile: typeof injectFile;
111
+ injectJQuery: typeof injectJQuery;
112
+ gotoExtended: typeof gotoExtended;
113
+ };
107
114
  //# sourceMappingURL=playwright-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-utils.d.ts","sourceRoot":"","sources":["../../../src/internals/utils/playwright-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAS,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAc,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAQlE,MAAM,WAAW,iBAAiB;IAC9B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC;AAOD;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBhH;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAGzD;AAED,MAAM,WAAW,uBAAuB;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,kBAAkB,GAAG,MAAM,GAAG,aAAa,CAAC;IAExD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OA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AAED,MAAM,WAAW,sBAAsB;IACnC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5E,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CACpC;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI,CAG/E;AAED,gBAAgB;AAChB,eAAO,MAAM,eAAe;;;;CAI3B,CAAC"}
@@ -6,13 +6,12 @@
6
6
  * **Example usage:**
7
7
  *
8
8
  * ```javascript
9
- * const Apify = require('apify');
10
- * const { playwright } = Actor.utils;
9
+ * import { launchPlaywright, playwrightUtils } from 'crawlee';
11
10
  *
12
11
  * // Navigate to https://www.example.com in Playwright with a POST request
13
- * const browser = await Actor.launchPlaywright();
12
+ * const browser = await launchPlaywright();
14
13
  * const page = await browser.newPage();
15
- * await playwright.gotoExtended(page, {
14
+ * await playwrightUtils.gotoExtended(page, {
16
15
  * url: 'https://example.com,
17
16
  * method: 'POST',
18
17
  * });
@@ -20,7 +19,7 @@
20
19
  * @module playwrightUtils
21
20
  */
22
21
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.registerUtilsToContext = exports.gotoExtended = exports.injectJQuery = exports.injectFile = void 0;
22
+ exports.playwrightUtils = exports.registerUtilsToContext = exports.gotoExtended = exports.injectJQuery = exports.injectFile = void 0;
24
23
  const tslib_1 = require("tslib");
25
24
  const promises_1 = require("node:fs/promises");
26
25
  const ow_1 = tslib_1.__importDefault(require("ow"));
@@ -148,8 +147,15 @@ async function gotoExtended(page, request, gotoOptions = {}) {
148
147
  return page.goto(url, gotoOptions);
149
148
  }
150
149
  exports.gotoExtended = gotoExtended;
151
- function registerUtilsToContext(_context) {
152
- // TODO register utils to context when we have some (to be backported from apify-js)
150
+ function registerUtilsToContext(context) {
151
+ context.injectFile = (filePath, options) => injectFile(context.page, filePath, options);
152
+ context.injectJQuery = () => injectJQuery(context.page);
153
153
  }
154
154
  exports.registerUtilsToContext = registerUtilsToContext;
155
+ /** @internal */
156
+ exports.playwrightUtils = {
157
+ injectFile,
158
+ injectJQuery,
159
+ gotoExtended,
160
+ };
155
161
  //# sourceMappingURL=playwright-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-utils.js","sourceRoot":"","sources":["../../../src/internals/utils/playwright-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;AAEH,+CAA4C;AAC5C,oDAAoB;AAEpB,0DAAiD;AACjD,6DAA8B;AAC9B,wCAAoD;AAIpD,MAAM,GAAG,GAAG,aAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAEvD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE7C,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAWtC;;GAEG;AACH,MAAM,kBAAkB,GAAG,IAAI,yBAAQ,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,CAAC;AAEnF;;;;;;;;;;GAUG;AACI,KAAK,UAAU,UAAU,CAAC,IAAU,EAAE,QAAgB,EAAE,UAA6B,EAAE;IAC1F,IAAA,YAAE,EAAC,IAAI,EAAE,YAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IACrD,IAAA,YAAE,EAAC,QAAQ,EAAE,YAAE,CAAC,MAAM,CAAC,CAAC;IACxB,IAAA,YAAE,EAAC,OAAO,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC;QAC7B,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,OAAO;KAC1C,CAAC,CAAC,CAAC;IAEJ,IAAI,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,EAAE;QACX,QAAQ,GAAG,MAAM,IAAA,m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AAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;aACnC;YAAC,OAAO,KAAK,EAAE;gBACZ,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;aAC5D;QACL,CAAC,CAAC;QAEF,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;KACrD;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AACvC,CAAC;AA1CD,oCA0CC;AAOD,SAAgB,sBAAsB,CAAC,OAAkC;IACrE,OAAO,CAAC,UAAU,GAAG,CAAC,QAAgB,EAAE,OAA2B,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpH,OAAO,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC;AAHD,wDAGC;AAED,gBAAgB;AACH,QAAA,eAAe,GAAG;IAC3B,UAAU;IACV,YAAY;IACZ,YAAY;CACf,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "@crawlee/playwright",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0",
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": ">=16.0.0"
7
7
  },
8
- "types": "index.d.ts",
8
+ "main": "./index.js",
9
+ "module": "./index.mjs",
10
+ "types": "./index.d.ts",
9
11
  "exports": {
10
12
  ".": {
11
13
  "import": "./index.mjs",
12
- "require": "./index.js"
13
- }
14
+ "require": "./index.js",
15
+ "types": "./index.d.ts"
16
+ },
17
+ "./package.json": "./package.json"
14
18
  },
15
19
  "keywords": [
16
20
  "apify",
@@ -33,12 +37,12 @@
33
37
  "license": "Apache-2.0",
34
38
  "repository": {
35
39
  "type": "git",
36
- "url": "git+https://github.com/apify/apify-js"
40
+ "url": "git+https://github.com/apify/crawlee"
37
41
  },
38
42
  "bugs": {
39
- "url": "https://github.com/apify/apify-js/issues"
43
+ "url": "https://github.com/apify/crawlee/issues"
40
44
  },
41
- "homepage": "https://sdk.apify.com/",
45
+ "homepage": "https://crawlee.dev",
42
46
  "scripts": {
43
47
  "build": "npm run clean && npm run compile && npm run copy",
44
48
  "clean": "rimraf ./dist",
@@ -49,12 +53,12 @@
49
53
  "access": "public"
50
54
  },
51
55
  "dependencies": {
52
- "@apify/log": "^1.2.3",
53
- "@apify/datastructures": "^1.0.1",
54
- "@crawlee/browser": "^3.0.0-beta.9",
55
- "@crawlee/browser-pool": "^3.0.0-beta.9",
56
- "@crawlee/core": "^3.0.0-beta.9",
57
- "@crawlee/utils": "^3.0.0-beta.9",
56
+ "@apify/log": "^2.0.0",
57
+ "@apify/datastructures": "^2.0.0",
58
+ "@crawlee/browser": "^3.0.0",
59
+ "@crawlee/browser-pool": "^3.0.0",
60
+ "@crawlee/core": "^3.0.0",
61
+ "@crawlee/utils": "^3.0.0",
58
62
  "jquery": "^3.6.0",
59
63
  "ow": "^0.28.1",
60
64
  "tough-cookie": "^4.0.0"