effect-playwright 0.2.3 → 0.2.4
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/dist/{chunk-Bo1DHCg-.mjs → chunk-DQk6qfdC.mjs} +3 -3
- package/dist/experimental/index.d.mts +2 -1
- package/dist/experimental/index.mjs +3 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-bN0oCmot.mjs → playwright-BHnfmfWC.mjs} +9 -0
- package/dist/{index-xKVXY-Ra.d.mts → playwright-BUFqTb7H.d.mts} +96 -8
- package/package.json +10 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all,
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
4
|
let target = {};
|
|
5
5
|
for (var name in all) {
|
|
6
6
|
__defProp(target, name, {
|
|
@@ -8,7 +8,7 @@ var __exportAll = (all, symbols) => {
|
|
|
8
8
|
enumerable: true
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
if (
|
|
11
|
+
if (!no_symbols) {
|
|
12
12
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
13
|
}
|
|
14
14
|
return target;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { S as PlaywrightError, d as PlaywrightPageService, o as PlaywrightBrowser, s as PlaywrightBrowserService, y as PlaywrightFrameService } from "../
|
|
1
|
+
import { S as PlaywrightError, d as PlaywrightPageService, o as PlaywrightBrowser, s as PlaywrightBrowserService, y as PlaywrightFrameService } from "../playwright-BUFqTb7H.mjs";
|
|
2
|
+
import "../index.mjs";
|
|
2
3
|
import { Context, Effect, Layer, Stream } from "effect";
|
|
3
4
|
import { BrowserType, LaunchOptions } from "playwright-core";
|
|
4
5
|
import { Scope as Scope$1 } from "effect/Scope";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { t as __exportAll } from "../chunk-
|
|
2
|
-
import { n as PlaywrightBrowser, t as Playwright } from "../
|
|
1
|
+
import { t as __exportAll } from "../chunk-DQk6qfdC.mjs";
|
|
2
|
+
import { n as PlaywrightBrowser, t as Playwright } from "../playwright-BHnfmfWC.mjs";
|
|
3
|
+
import "../index.mjs";
|
|
3
4
|
import { Array, Context, Effect, Layer, Stream, pipe } from "effect";
|
|
4
5
|
|
|
5
6
|
//#region src/experimental/browser-utils.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as PlaywrightErrorReason, S as PlaywrightError, _ as PlaywrightWorker, a as NewPageOptions, b as PlaywrightLocator, c as PlaywrightBrowserContext, d as PlaywrightPageService, f as PlaywrightDialog, g as PlaywrightResponse, h as PlaywrightRequest, i as NewContextOptions, l as PlaywrightBrowserContextService, m as PlaywrightFileChooser, n as PlaywrightService, o as PlaywrightBrowser, p as PlaywrightDownload, r as LaunchOptions, s as PlaywrightBrowserService, t as Playwright, u as PlaywrightPage, v as PlaywrightFrame, x as PlaywrightLocatorService, y as PlaywrightFrameService } from "./
|
|
2
|
-
export { LaunchOptions, NewContextOptions, NewPageOptions, Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightBrowserContextService, PlaywrightBrowserService, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightErrorReason, PlaywrightFileChooser, PlaywrightFrame, PlaywrightFrameService, PlaywrightLocator, PlaywrightLocatorService, PlaywrightPage, PlaywrightPageService, PlaywrightRequest, PlaywrightResponse, PlaywrightService, PlaywrightWorker };
|
|
1
|
+
import { C as PlaywrightErrorReason, S as PlaywrightError, _ as PlaywrightWorker, a as NewPageOptions, b as PlaywrightLocator, c as PlaywrightBrowserContext, d as PlaywrightPageService, f as PlaywrightDialog, g as PlaywrightResponse, h as PlaywrightRequest, i as NewContextOptions, l as PlaywrightBrowserContextService, m as PlaywrightFileChooser, n as PlaywrightService, o as PlaywrightBrowser, p as PlaywrightDownload, r as LaunchOptions, s as PlaywrightBrowserService, t as Playwright, u as PlaywrightPage, v as PlaywrightFrame, x as PlaywrightLocatorService, y as PlaywrightFrameService } from "./playwright-BUFqTb7H.mjs";
|
|
2
|
+
export { LaunchOptions, NewContextOptions, NewPageOptions, Playwright, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserContextService, PlaywrightBrowserService, PlaywrightDialog, PlaywrightDownload, PlaywrightError, type PlaywrightErrorReason, PlaywrightFileChooser, PlaywrightFrame, PlaywrightFrameService, PlaywrightLocator, PlaywrightLocatorService, PlaywrightPage, PlaywrightPageService, PlaywrightRequest, PlaywrightResponse, PlaywrightService, PlaywrightWorker };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as PlaywrightDownload, c as PlaywrightResponse, d as PlaywrightFrame, f as PlaywrightLocator, i as PlaywrightDialog, l as PlaywrightWorker, n as PlaywrightBrowser, o as PlaywrightFileChooser, p as PlaywrightError, r as PlaywrightBrowserContext, s as PlaywrightRequest, t as Playwright, u as PlaywrightPage } from "./
|
|
1
|
+
import { a as PlaywrightDownload, c as PlaywrightResponse, d as PlaywrightFrame, f as PlaywrightLocator, i as PlaywrightDialog, l as PlaywrightWorker, n as PlaywrightBrowser, o as PlaywrightFileChooser, p as PlaywrightError, r as PlaywrightBrowserContext, s as PlaywrightRequest, t as Playwright, u as PlaywrightPage } from "./playwright-BHnfmfWC.mjs";
|
|
2
2
|
|
|
3
3
|
export { Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightFileChooser, PlaywrightFrame, PlaywrightLocator, PlaywrightPage, PlaywrightRequest, PlaywrightResponse, PlaywrightWorker };
|
|
@@ -398,6 +398,13 @@ const connectCDP = Effect.fn(function* (cdpUrl, options) {
|
|
|
398
398
|
});
|
|
399
399
|
return PlaywrightBrowser.make(browser);
|
|
400
400
|
});
|
|
401
|
+
const launchPersistentContext = Effect.fn(function* (browserType, userDataDir, options) {
|
|
402
|
+
const rawContext = yield* Effect.tryPromise({
|
|
403
|
+
try: () => browserType.launchPersistentContext(userDataDir, options),
|
|
404
|
+
catch: wrapError
|
|
405
|
+
});
|
|
406
|
+
return PlaywrightBrowserContext.make(rawContext);
|
|
407
|
+
});
|
|
401
408
|
/**
|
|
402
409
|
* @category tag
|
|
403
410
|
* @since 0.1.0
|
|
@@ -409,6 +416,8 @@ var Playwright = class Playwright extends Context.Tag("effect-playwright/index/P
|
|
|
409
416
|
static layer = Layer.succeed(Playwright, {
|
|
410
417
|
launch,
|
|
411
418
|
launchScoped: (browserType, options) => Effect.acquireRelease(launch(browserType, options), (browser) => browser.close.pipe(Effect.ignore)),
|
|
419
|
+
launchPersistentContext,
|
|
420
|
+
launchPersistentContextScoped: (browserType, userDataDir, options) => Effect.acquireRelease(launchPersistentContext(browserType, userDataDir, options), (context) => context.close.pipe(Effect.ignore)),
|
|
412
421
|
connectCDP,
|
|
413
422
|
connectCDPScoped: (cdpUrl, options) => Effect.acquireRelease(connectCDP(cdpUrl, options), (browser) => browser.close.pipe(Effect.ignore))
|
|
414
423
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Option, Scope, Stream } from "effect";
|
|
2
2
|
import { Browser, BrowserContext, BrowserType, ConnectOverCDPOptions, ConsoleMessage, Dialog, Download, ElementHandle, FileChooser, Frame, JSHandle, Locator, Page, Request, Response, WebError, WebSocket, Worker, chromium } from "playwright-core";
|
|
3
3
|
import { Scope as Scope$1 } from "effect/Scope";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_Types0 from "effect/Types";
|
|
5
5
|
import * as effect_Cause0 from "effect/Cause";
|
|
6
6
|
|
|
7
7
|
//#region src/errors.d.ts
|
|
@@ -13,7 +13,7 @@ import * as effect_Cause0 from "effect/Cause";
|
|
|
13
13
|
* @since 0.1.0
|
|
14
14
|
*/
|
|
15
15
|
type PlaywrightErrorReason = "Timeout" | "Unknown";
|
|
16
|
-
declare const PlaywrightError_base: new <A extends Record<string, any> = {}>(args:
|
|
16
|
+
declare const PlaywrightError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause0.YieldableError & {
|
|
17
17
|
readonly _tag: "PlaywrightError";
|
|
18
18
|
} & Readonly<A>;
|
|
19
19
|
/**
|
|
@@ -332,7 +332,7 @@ declare class PlaywrightFrame extends PlaywrightFrame_base {
|
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
334
334
|
//#region src/common.d.ts
|
|
335
|
-
declare const PlaywrightRequest_base: new <A extends Record<string, any> = {}>(args:
|
|
335
|
+
declare const PlaywrightRequest_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
336
336
|
readonly _tag: "PlaywrightRequest";
|
|
337
337
|
};
|
|
338
338
|
/**
|
|
@@ -362,7 +362,7 @@ declare class PlaywrightRequest extends PlaywrightRequest_base<{
|
|
|
362
362
|
}> {
|
|
363
363
|
static make(request: Request): PlaywrightRequest;
|
|
364
364
|
}
|
|
365
|
-
declare const PlaywrightResponse_base: new <A extends Record<string, any> = {}>(args:
|
|
365
|
+
declare const PlaywrightResponse_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
366
366
|
readonly _tag: "PlaywrightResponse";
|
|
367
367
|
};
|
|
368
368
|
/**
|
|
@@ -391,7 +391,7 @@ declare class PlaywrightResponse extends PlaywrightResponse_base<{
|
|
|
391
391
|
}> {
|
|
392
392
|
static make(response: Response): PlaywrightResponse;
|
|
393
393
|
}
|
|
394
|
-
declare const PlaywrightWorker_base: new <A extends Record<string, any> = {}>(args:
|
|
394
|
+
declare const PlaywrightWorker_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
395
395
|
readonly _tag: "PlaywrightWorker";
|
|
396
396
|
};
|
|
397
397
|
/**
|
|
@@ -404,7 +404,7 @@ declare class PlaywrightWorker extends PlaywrightWorker_base<{
|
|
|
404
404
|
}> {
|
|
405
405
|
static make(worker: Worker): PlaywrightWorker;
|
|
406
406
|
}
|
|
407
|
-
declare const PlaywrightDialog_base: new <A extends Record<string, any> = {}>(args:
|
|
407
|
+
declare const PlaywrightDialog_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
408
408
|
readonly _tag: "PlaywrightDialog";
|
|
409
409
|
};
|
|
410
410
|
/**
|
|
@@ -421,7 +421,7 @@ declare class PlaywrightDialog extends PlaywrightDialog_base<{
|
|
|
421
421
|
}> {
|
|
422
422
|
static make(dialog: Dialog): PlaywrightDialog;
|
|
423
423
|
}
|
|
424
|
-
declare const PlaywrightFileChooser_base: new <A extends Record<string, any> = {}>(args:
|
|
424
|
+
declare const PlaywrightFileChooser_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
425
425
|
readonly _tag: "PlaywrightFileChooser";
|
|
426
426
|
};
|
|
427
427
|
/**
|
|
@@ -436,7 +436,7 @@ declare class PlaywrightFileChooser extends PlaywrightFileChooser_base<{
|
|
|
436
436
|
}> {
|
|
437
437
|
static make(fileChooser: FileChooser): PlaywrightFileChooser;
|
|
438
438
|
}
|
|
439
|
-
declare const PlaywrightDownload_base: new <A extends Record<string, any> = {}>(args:
|
|
439
|
+
declare const PlaywrightDownload_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
440
440
|
readonly _tag: "PlaywrightDownload";
|
|
441
441
|
};
|
|
442
442
|
/**
|
|
@@ -881,6 +881,7 @@ declare class PlaywrightBrowser extends PlaywrightBrowser_base {
|
|
|
881
881
|
}
|
|
882
882
|
//#endregion
|
|
883
883
|
//#region src/playwright.d.ts
|
|
884
|
+
type LaunchPersistentContextOptions = Parameters<BrowserType["launchPersistentContext"]>[1];
|
|
884
885
|
/**
|
|
885
886
|
* @category model
|
|
886
887
|
* @since 0.1.0
|
|
@@ -935,6 +936,93 @@ interface PlaywrightService {
|
|
|
935
936
|
* @since 0.1.0
|
|
936
937
|
*/
|
|
937
938
|
launchScoped: (browserType: BrowserType, options?: LaunchOptions$1) => Effect.Effect<typeof PlaywrightBrowser.Service, PlaywrightError, Scope.Scope>;
|
|
939
|
+
/**
|
|
940
|
+
* Launches a persistent browser context.
|
|
941
|
+
*
|
|
942
|
+
* Unlike {@link launchPersistentContextScoped}, this method does **not** close the
|
|
943
|
+
* context automatically when scope is closed. You are responsible for closing it.
|
|
944
|
+
*
|
|
945
|
+
* This launches a browser with a persistent profile under `userDataDir` and returns
|
|
946
|
+
* the single persistent context for that browser.
|
|
947
|
+
*
|
|
948
|
+
* Closing this context also closes the underlying browser process.
|
|
949
|
+
*
|
|
950
|
+
* ```ts
|
|
951
|
+
* import { Effect } from "effect";
|
|
952
|
+
* import { Playwright } from "effect-playwright";
|
|
953
|
+
* import { chromium } from "playwright-core";
|
|
954
|
+
*
|
|
955
|
+
* const program = Effect.gen(function* () {
|
|
956
|
+
* const playwright = yield* Playwright;
|
|
957
|
+
* const context = yield* playwright.launchPersistentContext(
|
|
958
|
+
* chromium,
|
|
959
|
+
* "./.playwright-profile",
|
|
960
|
+
* );
|
|
961
|
+
*
|
|
962
|
+
* const page = yield* context.newPage;
|
|
963
|
+
* yield* page.goto("https://example.com");
|
|
964
|
+
*
|
|
965
|
+
* // Closes the persistent context and browser process.
|
|
966
|
+
* yield* context.close;
|
|
967
|
+
* });
|
|
968
|
+
*
|
|
969
|
+
* await Effect.runPromise(program);
|
|
970
|
+
* ```
|
|
971
|
+
*
|
|
972
|
+
* If you call this non-scoped variant inside a scope, add a finalizer for cleanup:
|
|
973
|
+
*
|
|
974
|
+
* ```ts
|
|
975
|
+
* const program = Effect.gen(function* () {
|
|
976
|
+
* const playwright = yield* Playwright;
|
|
977
|
+
* const context = yield* playwright.launchPersistentContext(
|
|
978
|
+
* chromium,
|
|
979
|
+
* "./.playwright-profile",
|
|
980
|
+
* );
|
|
981
|
+
*
|
|
982
|
+
* yield* Effect.addFinalizer(() => context.close.pipe(Effect.ignore));
|
|
983
|
+
* });
|
|
984
|
+
*
|
|
985
|
+
* await Effect.runPromise(program.pipe(Effect.scoped));
|
|
986
|
+
* ```
|
|
987
|
+
*
|
|
988
|
+
* @param browserType - The browser type to launch (e.g. chromium, firefox, webkit).
|
|
989
|
+
* @param userDataDir - Directory used for persistent browser profile data. Pass `""` for a temporary profile directory.
|
|
990
|
+
* @param options - Optional persistent context launch options.
|
|
991
|
+
* @since 0.2.4
|
|
992
|
+
*/
|
|
993
|
+
launchPersistentContext: (browserType: BrowserType, userDataDir: string, options?: LaunchPersistentContextOptions) => Effect.Effect<typeof PlaywrightBrowserContext.Service, PlaywrightError>;
|
|
994
|
+
/**
|
|
995
|
+
* Launches a persistent browser context managed by a Scope.
|
|
996
|
+
*
|
|
997
|
+
* This automatically closes the persistent context (and therefore the browser process)
|
|
998
|
+
* when the scope is closed.
|
|
999
|
+
*
|
|
1000
|
+
* ```ts
|
|
1001
|
+
* import { Effect } from "effect";
|
|
1002
|
+
* import { Playwright } from "effect-playwright";
|
|
1003
|
+
* import { chromium } from "playwright-core";
|
|
1004
|
+
*
|
|
1005
|
+
* const program = Effect.gen(function* () {
|
|
1006
|
+
* const playwright = yield* Playwright;
|
|
1007
|
+
* const context = yield* playwright.launchPersistentContextScoped(
|
|
1008
|
+
* chromium,
|
|
1009
|
+
* "./.playwright-profile",
|
|
1010
|
+
* );
|
|
1011
|
+
*
|
|
1012
|
+
* const page = yield* context.newPage;
|
|
1013
|
+
* yield* page.goto("https://example.com");
|
|
1014
|
+
* // Context/browser cleanup is automatic when scope closes.
|
|
1015
|
+
* }).pipe(Effect.scoped);
|
|
1016
|
+
*
|
|
1017
|
+
* await Effect.runPromise(program);
|
|
1018
|
+
* ```
|
|
1019
|
+
*
|
|
1020
|
+
* @param browserType - The browser type to launch (e.g. chromium, firefox, webkit).
|
|
1021
|
+
* @param userDataDir - Directory used for persistent browser profile data. Pass `""` for a temporary profile directory.
|
|
1022
|
+
* @param options - Optional persistent context launch options.
|
|
1023
|
+
* @since 0.2.4
|
|
1024
|
+
*/
|
|
1025
|
+
launchPersistentContextScoped: (browserType: BrowserType, userDataDir: string, options?: LaunchPersistentContextOptions) => Effect.Effect<typeof PlaywrightBrowserContext.Service, PlaywrightError, Scope.Scope>;
|
|
938
1026
|
/**
|
|
939
1027
|
* Connects to a browser instance via Chrome DevTools Protocol (CDP).
|
|
940
1028
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-playwright",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"description": "An Effect-based Playwright library.",
|
|
6
6
|
"author": "Jobflow GmbH",
|
|
7
7
|
"license": "ISC",
|
|
@@ -29,24 +29,24 @@
|
|
|
29
29
|
"automation"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"playwright-core": "^1.58.
|
|
32
|
+
"playwright-core": "^1.58.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@effect/platform": "^0.93.3",
|
|
36
36
|
"effect": "^3.19.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@biomejs/biome": "2.3.
|
|
40
|
-
"@effect/language-service": "0.
|
|
41
|
-
"@effect/platform": "^0.94.
|
|
39
|
+
"@biomejs/biome": "2.3.15",
|
|
40
|
+
"@effect/language-service": "0.73.1",
|
|
41
|
+
"@effect/platform": "^0.94.4",
|
|
42
42
|
"@effect/platform-node": "^0.104.1",
|
|
43
43
|
"@effect/vitest": "^0.27.0",
|
|
44
|
-
"@types/node": "^25.
|
|
45
|
-
"effect": "^3.19.
|
|
46
|
-
"playwright": "^1.58.
|
|
47
|
-
"tsdown": "0.20.
|
|
44
|
+
"@types/node": "^25.2.3",
|
|
45
|
+
"effect": "^3.19.16",
|
|
46
|
+
"playwright": "^1.58.2",
|
|
47
|
+
"tsdown": "0.20.3",
|
|
48
48
|
"tsx": "^4.21.0",
|
|
49
|
-
"typedoc": "^0.28.
|
|
49
|
+
"typedoc": "^0.28.17",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
51
|
"vitest": "^4.0.18"
|
|
52
52
|
},
|