effect-playwright 0.2.4 → 0.4.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.
- package/README.md +3 -5
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/experimental/index.d.mts +1 -2
- package/dist/experimental/index.mjs +7 -11
- package/dist/{playwright-BUFqTb7H.d.mts → index-AKFnbezx.d.mts} +774 -45
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -3
- package/dist/{playwright-BHnfmfWC.mjs → src-bbEI8uuw.mjs} +171 -42
- package/package.json +11 -8
- package/dist/chunk-DQk6qfdC.mjs +0 -18
package/README.md
CHANGED
|
@@ -37,8 +37,7 @@ const program = Effect.gen(function* () {
|
|
|
37
37
|
const page = yield* browser.newPage();
|
|
38
38
|
|
|
39
39
|
yield* page.goto("https://example.com");
|
|
40
|
-
|
|
41
|
-
console.log(`Page title: ${title}`);
|
|
40
|
+
console.log(`Page title: ${page.title()}`);
|
|
42
41
|
}).pipe(Effect.scoped, Effect.provide(Playwright.layer));
|
|
43
42
|
|
|
44
43
|
await Effect.runPromise(program);
|
|
@@ -99,7 +98,7 @@ import { Effect } from "effect";
|
|
|
99
98
|
import { chromium } from "playwright-core";
|
|
100
99
|
|
|
101
100
|
const liveLayer = PlaywrightEnvironment.layer(chromium, {
|
|
102
|
-
headless:
|
|
101
|
+
headless: false /** any other launch options */,
|
|
103
102
|
});
|
|
104
103
|
|
|
105
104
|
const program = Effect.gen(function* () {
|
|
@@ -148,8 +147,7 @@ const program = Effect.gen(function* () {
|
|
|
148
147
|
yield* page.eventStream("request").pipe(
|
|
149
148
|
Stream.runForEach((request) =>
|
|
150
149
|
Effect.gen(function* () {
|
|
151
|
-
|
|
152
|
-
yield* Effect.log(`Request: ${url}`);
|
|
150
|
+
yield* Effect.log(`Request: ${request.url()}`);
|
|
153
151
|
}),
|
|
154
152
|
),
|
|
155
153
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index.mjs";
|
|
1
|
+
import { A as PlaywrightError, D as PlaywrightFrameService, d as PlaywrightPageService, o as PlaywrightBrowser, s as PlaywrightBrowserService } from "../index-AKFnbezx.mjs";
|
|
3
2
|
import { Context, Effect, Layer, Stream } from "effect";
|
|
4
3
|
import { BrowserType, LaunchOptions } from "playwright-core";
|
|
5
4
|
import { Scope as Scope$1 } from "effect/Scope";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { t as __exportAll } from "../chunk-
|
|
2
|
-
import { n as PlaywrightBrowser, t as Playwright } from "../
|
|
3
|
-
import "../index.mjs";
|
|
1
|
+
import { t as __exportAll } from "../chunk-CfYAbeIz.mjs";
|
|
2
|
+
import { n as PlaywrightBrowser, t as Playwright } from "../src-bbEI8uuw.mjs";
|
|
4
3
|
import { Array, Context, Effect, Layer, Stream, pipe } from "effect";
|
|
5
|
-
|
|
6
4
|
//#region src/experimental/browser-utils.ts
|
|
7
5
|
var browser_utils_exports = /* @__PURE__ */ __exportAll({
|
|
8
6
|
allFrameNavigatedEventStream: () => allFrameNavigatedEventStream,
|
|
@@ -13,7 +11,7 @@ var browser_utils_exports = /* @__PURE__ */ __exportAll({
|
|
|
13
11
|
* Returns all pages in the browser from all contexts.
|
|
14
12
|
* @category util
|
|
15
13
|
*/
|
|
16
|
-
const allPages = (browser) =>
|
|
14
|
+
const allPages = (browser) => Effect.sync(() => Array.flatten(browser.contexts().map((context) => context.pages())));
|
|
17
15
|
/**
|
|
18
16
|
* Returns all frames in the browser from all pages in all contexts.
|
|
19
17
|
* @category util
|
|
@@ -25,12 +23,11 @@ const allFrames = (browser) => allPages(browser).pipe(Effect.flatMap((pages) =>
|
|
|
25
23
|
* @category util
|
|
26
24
|
*/
|
|
27
25
|
const allFrameNavigatedEventStream = (browser) => Effect.gen(function* () {
|
|
28
|
-
const contexts =
|
|
29
|
-
const currentPages = (
|
|
26
|
+
const contexts = browser.contexts();
|
|
27
|
+
const currentPages = Array.flatten(contexts.map((c) => c.pages())).map((page) => page.eventStream("framenavigated"));
|
|
30
28
|
const newPages = pipe(contexts.map((c) => c.eventStream("page")), Stream.mergeAll({ concurrency: "unbounded" }), Stream.flatMap((page) => page.eventStream("framenavigated"), { concurrency: "unbounded" }));
|
|
31
29
|
return Stream.mergeAll([newPages, ...currentPages], { concurrency: "unbounded" });
|
|
32
30
|
}).pipe(Stream.unwrap);
|
|
33
|
-
|
|
34
31
|
//#endregion
|
|
35
32
|
//#region src/experimental/environment.ts
|
|
36
33
|
var environment_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -79,7 +76,7 @@ var PlaywrightEnvironment = class extends Context.Tag("effect-playwright/experim
|
|
|
79
76
|
const layer = (browser, launchOptions) => {
|
|
80
77
|
return Layer.effect(PlaywrightEnvironment, Playwright.pipe(Effect.map((playwright) => {
|
|
81
78
|
return PlaywrightEnvironment.of({ browser: playwright.launchScoped(browser, launchOptions) });
|
|
82
|
-
})
|
|
79
|
+
}), Effect.provide(Playwright.layer)));
|
|
83
80
|
};
|
|
84
81
|
/**
|
|
85
82
|
* Provides a scoped `PlaywrightBrowser` service, allowing you to access the browser from the context (e.g. by yielding `PlaywrightBrowser`).
|
|
@@ -105,6 +102,5 @@ const layer = (browser, launchOptions) => {
|
|
|
105
102
|
* @category util
|
|
106
103
|
*/
|
|
107
104
|
const withBrowser = Effect.provide(PlaywrightEnvironment.pipe(Effect.map((e) => e.browser), Effect.flatten, Layer.scoped(PlaywrightBrowser)));
|
|
108
|
-
|
|
109
105
|
//#endregion
|
|
110
|
-
export { browser_utils_exports as BrowserUtils, environment_exports as PlaywrightEnvironment };
|
|
106
|
+
export { browser_utils_exports as BrowserUtils, environment_exports as PlaywrightEnvironment };
|