effect-playwright 0.2.3 → 0.3.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 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
- const title = yield* page.title;
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: true /** any other launch options */,
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
- const url = yield* request.url;
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,4 +1,4 @@
1
- import { S as PlaywrightError, d as PlaywrightPageService, o as PlaywrightBrowser, s as PlaywrightBrowserService, y as PlaywrightFrameService } from "../index-xKVXY-Ra.mjs";
1
+ import { A as PlaywrightError, D as PlaywrightFrameService, d as PlaywrightPageService, o as PlaywrightBrowser, s as PlaywrightBrowserService } from "../index-CA1jsZ4o.mjs";
2
2
  import { Context, Effect, Layer, Stream } from "effect";
3
3
  import { BrowserType, LaunchOptions } from "playwright-core";
4
4
  import { Scope as Scope$1 } from "effect/Scope";
@@ -1,7 +1,6 @@
1
- import { t as __exportAll } from "../chunk-Bo1DHCg-.mjs";
2
- import { n as PlaywrightBrowser, t as Playwright } from "../src-bN0oCmot.mjs";
1
+ import { t as __exportAll } from "../chunk-CfYAbeIz.mjs";
2
+ import { n as PlaywrightBrowser, t as Playwright } from "../src-DxTog178.mjs";
3
3
  import { Array, Context, Effect, Layer, Stream, pipe } from "effect";
4
-
5
4
  //#region src/experimental/browser-utils.ts
6
5
  var browser_utils_exports = /* @__PURE__ */ __exportAll({
7
6
  allFrameNavigatedEventStream: () => allFrameNavigatedEventStream,
@@ -12,7 +11,7 @@ var browser_utils_exports = /* @__PURE__ */ __exportAll({
12
11
  * Returns all pages in the browser from all contexts.
13
12
  * @category util
14
13
  */
15
- const allPages = (browser) => browser.contexts.pipe(Effect.flatMap((contexts) => Effect.all(contexts.map((context) => context.pages))), Effect.map(Array.flatten));
14
+ const allPages = (browser) => Effect.all(browser.contexts().map((context) => context.pages)).pipe(Effect.map(Array.flatten));
16
15
  /**
17
16
  * Returns all frames in the browser from all pages in all contexts.
18
17
  * @category util
@@ -24,12 +23,11 @@ const allFrames = (browser) => allPages(browser).pipe(Effect.flatMap((pages) =>
24
23
  * @category util
25
24
  */
26
25
  const allFrameNavigatedEventStream = (browser) => Effect.gen(function* () {
27
- const contexts = yield* browser.contexts;
28
- const currentPages = (yield* pipe(contexts.map((c) => c.pages), Effect.all, Effect.map(Array.flatten))).map((page) => page.eventStream("framenavigated"));
26
+ const contexts = browser.contexts();
27
+ const currentPages = (yield* Effect.all(contexts.map((c) => c.pages)).pipe(Effect.map(Array.flatten))).map((page) => page.eventStream("framenavigated"));
29
28
  const newPages = pipe(contexts.map((c) => c.eventStream("page")), Stream.mergeAll({ concurrency: "unbounded" }), Stream.flatMap((page) => page.eventStream("framenavigated"), { concurrency: "unbounded" }));
30
29
  return Stream.mergeAll([newPages, ...currentPages], { concurrency: "unbounded" });
31
30
  }).pipe(Stream.unwrap);
32
-
33
31
  //#endregion
34
32
  //#region src/experimental/environment.ts
35
33
  var environment_exports = /* @__PURE__ */ __exportAll({
@@ -78,7 +76,7 @@ var PlaywrightEnvironment = class extends Context.Tag("effect-playwright/experim
78
76
  const layer = (browser, launchOptions) => {
79
77
  return Layer.effect(PlaywrightEnvironment, Playwright.pipe(Effect.map((playwright) => {
80
78
  return PlaywrightEnvironment.of({ browser: playwright.launchScoped(browser, launchOptions) });
81
- })).pipe(Effect.provide(Playwright.layer)));
79
+ }), Effect.provide(Playwright.layer)));
82
80
  };
83
81
  /**
84
82
  * Provides a scoped `PlaywrightBrowser` service, allowing you to access the browser from the context (e.g. by yielding `PlaywrightBrowser`).
@@ -104,6 +102,5 @@ const layer = (browser, launchOptions) => {
104
102
  * @category util
105
103
  */
106
104
  const withBrowser = Effect.provide(PlaywrightEnvironment.pipe(Effect.map((e) => e.browser), Effect.flatten, Layer.scoped(PlaywrightBrowser)));
107
-
108
105
  //#endregion
109
- export { browser_utils_exports as BrowserUtils, environment_exports as PlaywrightEnvironment };
106
+ export { browser_utils_exports as BrowserUtils, environment_exports as PlaywrightEnvironment };