effect-playwright 0.2.2 → 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.
@@ -1,6 +1,6 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __exportAll = (all, symbols) => {
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 (symbols) {
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 "../index-BdIazBpL.mjs";
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-BiucMVzj.mjs";
2
- import { n as PlaywrightBrowser, t as Playwright } from "../src-BBJfAuBn.mjs";
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 "./index-BdIazBpL.mjs";
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 "./src-BBJfAuBn.mjs";
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 };
@@ -92,7 +92,7 @@ var PlaywrightFrame = class PlaywrightFrame extends Context.Tag("effect-playwrig
92
92
  goto: (url, options) => use((f) => f.goto(url, options)),
93
93
  waitForURL: (url, options) => use((f) => f.waitForURL(url, options)),
94
94
  waitForLoadState: (state, options) => use((f) => f.waitForLoadState(state, options)),
95
- evaluate: (f, arg) => use((frame$1) => frame$1.evaluate(f, arg)),
95
+ evaluate: (f, arg) => use((frame) => frame.evaluate(f, arg)),
96
96
  title: use((f) => f.title()),
97
97
  use,
98
98
  locator: (selector, options) => PlaywrightLocator.make(frame.locator(selector, options)),
@@ -360,10 +360,10 @@ var PlaywrightBrowser = class PlaywrightBrowser extends Context.Tag("effect-play
360
360
  static make(browser) {
361
361
  const use = useHelper(browser);
362
362
  return PlaywrightBrowser.of({
363
- newPage: (options) => use((browser$1) => browser$1.newPage(options).then(PlaywrightPage.make)),
364
- close: use((browser$1) => browser$1.close()),
363
+ newPage: (options) => use((browser) => browser.newPage(options).then(PlaywrightPage.make)),
364
+ close: use((browser) => browser.close()),
365
365
  contexts: Effect.sync(() => browser.contexts().map(PlaywrightBrowserContext.make)),
366
- newContext: (options) => Effect.acquireRelease(use((browser$1) => browser$1.newContext(options).then(PlaywrightBrowserContext.make)), (context) => context.close.pipe(Effect.ignoreLogged)),
366
+ newContext: (options) => Effect.acquireRelease(use((browser) => browser.newContext(options).then(PlaywrightBrowserContext.make)), (context) => context.close.pipe(Effect.ignoreLogged)),
367
367
  browserType: Effect.sync(() => browser.browserType()),
368
368
  version: Effect.sync(() => browser.version()),
369
369
  isConnected: Effect.sync(() => browser.isConnected()),
@@ -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
  });