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 +3 -5
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/experimental/index.d.mts +1 -1
- package/dist/experimental/index.mjs +7 -10
- package/dist/{index-xKVXY-Ra.d.mts → index-CA1jsZ4o.d.mts} +867 -50
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -3
- package/dist/{src-bN0oCmot.mjs → src-DxTog178.mjs} +171 -39
- package/package.json +14 -11
- package/dist/chunk-Bo1DHCg-.mjs +0 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
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 { A as PlaywrightError, C as PlaywrightWorker, D as PlaywrightFrameService, E as PlaywrightFrame, O as PlaywrightLocator, S as PlaywrightResponse, T as PlaywrightClockService, _ as PlaywrightKeyboardService, a as NewPageOptions, b as PlaywrightFileChooser, c as PlaywrightBrowserContext, d as PlaywrightPageService, f as PlaywrightTouchscreen, g as PlaywrightKeyboard, h as PlaywrightMouseService, i as NewContextOptions, j as PlaywrightErrorReason, k as PlaywrightLocatorService, l as PlaywrightBrowserContextService, m as PlaywrightMouse, n as PlaywrightService, o as PlaywrightBrowser, p as PlaywrightTouchscreenService, r as LaunchOptions, s as PlaywrightBrowserService, t as Playwright, u as PlaywrightPage, v as PlaywrightDialog, w as PlaywrightClock, x as PlaywrightRequest, y as PlaywrightDownload } from "./index-CA1jsZ4o.mjs";
|
|
2
|
+
export { LaunchOptions, NewContextOptions, NewPageOptions, Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightBrowserContextService, PlaywrightBrowserService, PlaywrightClock, PlaywrightClockService, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightErrorReason, PlaywrightFileChooser, PlaywrightFrame, PlaywrightFrameService, PlaywrightKeyboard, PlaywrightKeyboardService, PlaywrightLocator, PlaywrightLocatorService, PlaywrightMouse, PlaywrightMouseService, PlaywrightPage, PlaywrightPageService, PlaywrightRequest, PlaywrightResponse, PlaywrightService, PlaywrightTouchscreen, PlaywrightTouchscreenService, PlaywrightWorker };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { a as PlaywrightDownload, c as PlaywrightResponse, d as
|
|
2
|
-
|
|
3
|
-
export { Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightFileChooser, PlaywrightFrame, PlaywrightLocator, PlaywrightPage, PlaywrightRequest, PlaywrightResponse, PlaywrightWorker };
|
|
1
|
+
import { _ as PlaywrightError, a as PlaywrightDownload, c as PlaywrightResponse, d as PlaywrightTouchscreen, f as PlaywrightMouse, g as PlaywrightClock, h as PlaywrightLocator, i as PlaywrightDialog, l as PlaywrightWorker, m as PlaywrightFrame, n as PlaywrightBrowser, o as PlaywrightFileChooser, p as PlaywrightKeyboard, r as PlaywrightBrowserContext, s as PlaywrightRequest, t as Playwright, u as PlaywrightPage } from "./src-DxTog178.mjs";
|
|
2
|
+
export { Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightClock, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightFileChooser, PlaywrightFrame, PlaywrightKeyboard, PlaywrightLocator, PlaywrightMouse, PlaywrightPage, PlaywrightRequest, PlaywrightResponse, PlaywrightTouchscreen, PlaywrightWorker };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Context, Data, Effect, Layer, Option, Stream, identity } from "effect";
|
|
2
|
-
import { Readable } from "node:stream";
|
|
1
|
+
import { Context, Data, Effect, Layer, Option, Runtime, Stream, identity } from "effect";
|
|
3
2
|
import { chromium, errors } from "playwright-core";
|
|
4
|
-
|
|
3
|
+
import { Readable } from "node:stream";
|
|
5
4
|
//#region src/errors.ts
|
|
6
5
|
/**
|
|
7
6
|
* Error type that is returned when a Playwright error occurs.
|
|
@@ -24,12 +23,40 @@ function wrapError(error) {
|
|
|
24
23
|
cause: error
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
27
|
//#region src/utils.ts
|
|
30
28
|
/** @internal */
|
|
31
29
|
const useHelper = (api) => (userFunction) => Effect.tryPromise(() => userFunction(api)).pipe(Effect.mapError(wrapError));
|
|
32
|
-
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/clock.ts
|
|
32
|
+
/**
|
|
33
|
+
* A service that provides a `PlaywrightClock` instance.
|
|
34
|
+
*
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
* @category tag
|
|
37
|
+
*/
|
|
38
|
+
var PlaywrightClock = class PlaywrightClock extends Context.Tag("effect-playwright/PlaywrightClock")() {
|
|
39
|
+
/**
|
|
40
|
+
* Creates a `PlaywrightClock` from a Playwright `Clock` instance.
|
|
41
|
+
*
|
|
42
|
+
* @param clock - The Playwright `Clock` instance to wrap.
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
* @category constructor
|
|
45
|
+
*/
|
|
46
|
+
static make(clock) {
|
|
47
|
+
const use = useHelper(clock);
|
|
48
|
+
return PlaywrightClock.of({
|
|
49
|
+
fastForward: (ticks) => use((c) => c.fastForward(ticks)),
|
|
50
|
+
install: (options) => use((c) => c.install(options)),
|
|
51
|
+
pauseAt: (time) => use((c) => c.pauseAt(time)),
|
|
52
|
+
resume: use((c) => c.resume()),
|
|
53
|
+
runFor: (ticks) => use((c) => c.runFor(ticks)),
|
|
54
|
+
setFixedTime: (time) => use((c) => c.setFixedTime(time)),
|
|
55
|
+
setSystemTime: (time) => use((c) => c.setSystemTime(time)),
|
|
56
|
+
use
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
33
60
|
//#endregion
|
|
34
61
|
//#region src/locator.ts
|
|
35
62
|
/**
|
|
@@ -72,7 +99,6 @@ var PlaywrightLocator = class PlaywrightLocator extends Context.Tag("effect-play
|
|
|
72
99
|
});
|
|
73
100
|
}
|
|
74
101
|
};
|
|
75
|
-
|
|
76
102
|
//#endregion
|
|
77
103
|
//#region src/frame.ts
|
|
78
104
|
/**
|
|
@@ -100,14 +126,78 @@ var PlaywrightFrame = class PlaywrightFrame extends Context.Tag("effect-playwrig
|
|
|
100
126
|
getByText: (text, options) => PlaywrightLocator.make(frame.getByText(text, options)),
|
|
101
127
|
getByLabel: (label, options) => PlaywrightLocator.make(frame.getByLabel(label, options)),
|
|
102
128
|
getByTestId: (testId) => PlaywrightLocator.make(frame.getByTestId(testId)),
|
|
103
|
-
url:
|
|
129
|
+
url: () => frame.url(),
|
|
104
130
|
content: use((f) => f.content()),
|
|
105
|
-
name:
|
|
131
|
+
name: () => frame.name(),
|
|
106
132
|
click: (selector, options) => use((f) => f.click(selector, options))
|
|
107
133
|
});
|
|
108
134
|
}
|
|
109
135
|
};
|
|
110
|
-
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/keyboard.ts
|
|
138
|
+
/**
|
|
139
|
+
* @category tag
|
|
140
|
+
*/
|
|
141
|
+
var PlaywrightKeyboard = class PlaywrightKeyboard extends Context.Tag("effect-playwright/PlaywrightKeyboard")() {
|
|
142
|
+
/**
|
|
143
|
+
* Creates a `PlaywrightKeyboard` from a Playwright `Keyboard` instance.
|
|
144
|
+
*
|
|
145
|
+
* @param keyboard - The Playwright `Keyboard` instance to wrap.
|
|
146
|
+
* @since 0.1.0
|
|
147
|
+
*/
|
|
148
|
+
static make(keyboard) {
|
|
149
|
+
const use = useHelper(keyboard);
|
|
150
|
+
return PlaywrightKeyboard.of({
|
|
151
|
+
down: (key) => use((k) => k.down(key)),
|
|
152
|
+
insertText: (text) => use((k) => k.insertText(text)),
|
|
153
|
+
press: (key, options) => use((k) => k.press(key, options)),
|
|
154
|
+
type: (text, options) => use((k) => k.type(text, options)),
|
|
155
|
+
up: (key) => use((k) => k.up(key))
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/mouse.ts
|
|
161
|
+
/**
|
|
162
|
+
* @category tag
|
|
163
|
+
*/
|
|
164
|
+
var PlaywrightMouse = class PlaywrightMouse extends Context.Tag("effect-playwright/PlaywrightMouse")() {
|
|
165
|
+
/**
|
|
166
|
+
* Creates a `PlaywrightMouse` from a Playwright `Mouse` instance.
|
|
167
|
+
*
|
|
168
|
+
* @param mouse - The Playwright `Mouse` instance to wrap.
|
|
169
|
+
* @since 0.3.0
|
|
170
|
+
*/
|
|
171
|
+
static make(mouse) {
|
|
172
|
+
const use = useHelper(mouse);
|
|
173
|
+
return PlaywrightMouse.of({
|
|
174
|
+
click: (x, y, options) => use((m) => m.click(x, y, options)),
|
|
175
|
+
dblclick: (x, y, options) => use((m) => m.dblclick(x, y, options)),
|
|
176
|
+
down: (options) => use((m) => m.down(options)),
|
|
177
|
+
move: (x, y, options) => use((m) => m.move(x, y, options)),
|
|
178
|
+
up: (options) => use((m) => m.up(options)),
|
|
179
|
+
wheel: (deltaX, deltaY) => use((m) => m.wheel(deltaX, deltaY))
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/touchscreen.ts
|
|
185
|
+
/**
|
|
186
|
+
* @category tag
|
|
187
|
+
* @since 0.3.0
|
|
188
|
+
*/
|
|
189
|
+
var PlaywrightTouchscreen = class PlaywrightTouchscreen extends Context.Tag("effect-playwright/PlaywrightTouchscreen")() {
|
|
190
|
+
/**
|
|
191
|
+
* Creates a `PlaywrightTouchscreen` from a Playwright `Touchscreen` instance.
|
|
192
|
+
*
|
|
193
|
+
* @param touchscreen - The Playwright `Touchscreen` instance to wrap.
|
|
194
|
+
* @since 0.3.0
|
|
195
|
+
*/
|
|
196
|
+
static make(touchscreen) {
|
|
197
|
+
const use = useHelper(touchscreen);
|
|
198
|
+
return PlaywrightTouchscreen.of({ tap: (x, y) => use((t) => t.tap(x, y)) });
|
|
199
|
+
}
|
|
200
|
+
};
|
|
111
201
|
//#endregion
|
|
112
202
|
//#region src/page.ts
|
|
113
203
|
const eventMappings$2 = {
|
|
@@ -144,21 +234,57 @@ var PlaywrightPage = class PlaywrightPage extends Context.Tag("effect-playwright
|
|
|
144
234
|
static make(page) {
|
|
145
235
|
const use = useHelper(page);
|
|
146
236
|
return PlaywrightPage.of({
|
|
237
|
+
clock: PlaywrightClock.make(page.clock),
|
|
238
|
+
keyboard: PlaywrightKeyboard.make(page.keyboard),
|
|
239
|
+
mouse: PlaywrightMouse.make(page.mouse),
|
|
240
|
+
touchscreen: PlaywrightTouchscreen.make(page.touchscreen),
|
|
147
241
|
goto: (url, options) => use((p) => p.goto(url, options)),
|
|
242
|
+
setContent: (html, options) => use((p) => p.setContent(html, options)),
|
|
243
|
+
setDefaultNavigationTimeout: (timeout) => Effect.sync(() => page.setDefaultNavigationTimeout(timeout)),
|
|
244
|
+
setDefaultTimeout: (timeout) => Effect.sync(() => page.setDefaultTimeout(timeout)),
|
|
245
|
+
setExtraHTTPHeaders: (headers) => use((p) => p.setExtraHTTPHeaders(headers)),
|
|
246
|
+
setViewportSize: (viewportSize) => use((p) => p.setViewportSize(viewportSize)),
|
|
247
|
+
viewportSize: () => Option.fromNullable(page.viewportSize()),
|
|
148
248
|
waitForURL: (url, options) => use((p) => p.waitForURL(url, options)),
|
|
149
249
|
waitForLoadState: (state, options) => use((p) => p.waitForLoadState(state, options)),
|
|
150
250
|
title: use((p) => p.title()),
|
|
251
|
+
content: use((p) => p.content()),
|
|
151
252
|
evaluate: (f, arg) => use((p) => p.evaluate(f, arg)),
|
|
253
|
+
addInitScript: (script, arg) => use((p) => p.addInitScript(script, arg)),
|
|
254
|
+
addScriptTag: (options) => use((p) => p.addScriptTag(options)),
|
|
255
|
+
addStyleTag: (options) => use((p) => p.addStyleTag(options)),
|
|
256
|
+
exposeFunction: (name, effectFn) => Effect.runtime().pipe(Effect.map((r) => Runtime.runPromise(r)), Effect.flatMap((runPromise) => use((p) => p.exposeFunction(name, (...args) => runPromise(effectFn(...args)))))),
|
|
257
|
+
exposeEffect: (name, effectFn) => Effect.runtime().pipe(Effect.map((r) => Runtime.runPromise(r)), Effect.flatMap((runPromise) => use((p) => p.exposeFunction(name, () => runPromise(effectFn))))),
|
|
152
258
|
locator: (selector, options) => PlaywrightLocator.make(page.locator(selector, options)),
|
|
153
259
|
getByRole: (role, options) => PlaywrightLocator.make(page.getByRole(role, options)),
|
|
154
260
|
getByText: (text, options) => PlaywrightLocator.make(page.getByText(text, options)),
|
|
155
261
|
getByLabel: (label, options) => PlaywrightLocator.make(page.getByLabel(label, options)),
|
|
156
262
|
getByTestId: (testId) => PlaywrightLocator.make(page.getByTestId(testId)),
|
|
157
|
-
|
|
263
|
+
getByAltText: (text, options) => PlaywrightLocator.make(page.getByAltText(text, options)),
|
|
264
|
+
getByPlaceholder: (text, options) => PlaywrightLocator.make(page.getByPlaceholder(text, options)),
|
|
265
|
+
getByTitle: (text, options) => PlaywrightLocator.make(page.getByTitle(text, options)),
|
|
266
|
+
url: () => page.url(),
|
|
267
|
+
context: () => PlaywrightBrowserContext.make(page.context()),
|
|
268
|
+
opener: use((p) => p.opener()).pipe(Effect.map(Option.fromNullable), Effect.map(Option.map(PlaywrightPage.make))),
|
|
269
|
+
consoleMessages: use((p) => p.consoleMessages()),
|
|
270
|
+
pageErrors: use((p) => p.pageErrors()),
|
|
271
|
+
workers: () => page.workers().map(PlaywrightWorker.make),
|
|
272
|
+
frame: (frameSelector) => Option.fromNullable(page.frame(frameSelector)).pipe(Option.map(PlaywrightFrame.make)),
|
|
158
273
|
frames: use((p) => Promise.resolve(p.frames().map(PlaywrightFrame.make))),
|
|
274
|
+
mainFrame: () => PlaywrightFrame.make(page.mainFrame()),
|
|
159
275
|
reload: use((p) => p.reload()),
|
|
276
|
+
goBack: (options) => use((p) => p.goBack(options)).pipe(Effect.map(Option.fromNullable), Effect.map(Option.map(PlaywrightResponse.make))),
|
|
277
|
+
goForward: (options) => use((p) => p.goForward(options)).pipe(Effect.map(Option.fromNullable), Effect.map(Option.map(PlaywrightResponse.make))),
|
|
278
|
+
requestGC: use((p) => p.requestGC()),
|
|
279
|
+
bringToFront: use((p) => p.bringToFront()),
|
|
280
|
+
pause: use((p) => p.pause()),
|
|
160
281
|
close: use((p) => p.close()),
|
|
282
|
+
isClosed: () => page.isClosed(),
|
|
283
|
+
screenshot: (options) => use((p) => p.screenshot(options)),
|
|
284
|
+
pdf: (options) => use((p) => p.pdf(options)),
|
|
285
|
+
dragAndDrop: (source, target, options) => use((p) => p.dragAndDrop(source, target, options)),
|
|
161
286
|
click: (selector, options) => use((p) => p.click(selector, options)),
|
|
287
|
+
emulateMedia: (options) => use((p) => p.emulateMedia(options)),
|
|
162
288
|
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
163
289
|
page.on(event, emit.single);
|
|
164
290
|
page.once("close", emit.end);
|
|
@@ -173,7 +299,6 @@ var PlaywrightPage = class PlaywrightPage extends Context.Tag("effect-playwright
|
|
|
173
299
|
});
|
|
174
300
|
}
|
|
175
301
|
};
|
|
176
|
-
|
|
177
302
|
//#endregion
|
|
178
303
|
//#region src/common.ts
|
|
179
304
|
/**
|
|
@@ -188,21 +313,21 @@ var PlaywrightRequest = class PlaywrightRequest extends Data.TaggedClass("Playwr
|
|
|
188
313
|
failure: Option.liftNullable(request.failure),
|
|
189
314
|
frame: Effect.sync(() => PlaywrightFrame.make(request.frame())),
|
|
190
315
|
headerValue: (name) => use(() => request.headerValue(name)).pipe(Effect.map(Option.fromNullable)),
|
|
191
|
-
headers:
|
|
316
|
+
headers: () => request.headers(),
|
|
192
317
|
headersArray: use(() => request.headersArray()),
|
|
193
|
-
isNavigationRequest:
|
|
194
|
-
method:
|
|
318
|
+
isNavigationRequest: () => request.isNavigationRequest(),
|
|
319
|
+
method: () => request.method(),
|
|
195
320
|
postData: Option.liftNullable(request.postData),
|
|
196
321
|
postDataBuffer: Option.liftNullable(request.postDataBuffer),
|
|
197
322
|
postDataJSON: use(() => request.postDataJSON()).pipe(Effect.map(Option.fromNullable)),
|
|
198
323
|
redirectedFrom: () => Option.fromNullable(request.redirectedFrom()).pipe(Option.map(PlaywrightRequest.make)),
|
|
199
324
|
redirectedTo: () => Option.fromNullable(request.redirectedTo()).pipe(Option.map(PlaywrightRequest.make)),
|
|
200
|
-
resourceType:
|
|
325
|
+
resourceType: () => request.resourceType(),
|
|
201
326
|
response: use(() => request.response()).pipe(Effect.map(Option.fromNullable), Effect.map(Option.map(PlaywrightResponse.make))),
|
|
202
327
|
serviceWorker: () => Option.fromNullable(request.serviceWorker()).pipe(Option.map(PlaywrightWorker.make)),
|
|
203
328
|
sizes: use(() => request.sizes()),
|
|
204
|
-
timing:
|
|
205
|
-
url:
|
|
329
|
+
timing: () => request.timing(),
|
|
330
|
+
url: () => request.url()
|
|
206
331
|
});
|
|
207
332
|
}
|
|
208
333
|
};
|
|
@@ -218,20 +343,20 @@ var PlaywrightResponse = class PlaywrightResponse extends Data.TaggedClass("Play
|
|
|
218
343
|
body: use(() => response.body()),
|
|
219
344
|
finished: use(() => response.finished()),
|
|
220
345
|
frame: Effect.sync(() => PlaywrightFrame.make(response.frame())),
|
|
221
|
-
fromServiceWorker:
|
|
222
|
-
headers:
|
|
346
|
+
fromServiceWorker: () => response.fromServiceWorker(),
|
|
347
|
+
headers: () => response.headers(),
|
|
223
348
|
headersArray: use(() => response.headersArray()),
|
|
224
349
|
headerValue: (name) => use(() => response.headerValue(name)).pipe(Effect.map(Option.fromNullable)),
|
|
225
350
|
headerValues: (name) => use(() => response.headerValues(name)),
|
|
226
351
|
json: use(() => response.json()),
|
|
227
|
-
ok:
|
|
352
|
+
ok: () => response.ok(),
|
|
228
353
|
request: () => PlaywrightRequest.make(response.request()),
|
|
229
354
|
securityDetails: use(() => response.securityDetails()).pipe(Effect.map(Option.fromNullable)),
|
|
230
355
|
serverAddr: use(() => response.serverAddr()).pipe(Effect.map(Option.fromNullable)),
|
|
231
|
-
status:
|
|
232
|
-
statusText:
|
|
356
|
+
status: () => response.status(),
|
|
357
|
+
statusText: () => response.statusText(),
|
|
233
358
|
text: use(() => response.text()),
|
|
234
|
-
url:
|
|
359
|
+
url: () => response.url()
|
|
235
360
|
});
|
|
236
361
|
}
|
|
237
362
|
};
|
|
@@ -244,7 +369,7 @@ var PlaywrightWorker = class PlaywrightWorker extends Data.TaggedClass("Playwrig
|
|
|
244
369
|
const use = useHelper(worker);
|
|
245
370
|
return new PlaywrightWorker({
|
|
246
371
|
evaluate: (f, arg) => use((w) => w.evaluate(f, arg)),
|
|
247
|
-
url:
|
|
372
|
+
url: () => worker.url()
|
|
248
373
|
});
|
|
249
374
|
}
|
|
250
375
|
};
|
|
@@ -257,11 +382,11 @@ var PlaywrightDialog = class PlaywrightDialog extends Data.TaggedClass("Playwrig
|
|
|
257
382
|
const use = useHelper(dialog);
|
|
258
383
|
return new PlaywrightDialog({
|
|
259
384
|
accept: (promptText) => use(() => dialog.accept(promptText)),
|
|
260
|
-
defaultValue:
|
|
385
|
+
defaultValue: () => dialog.defaultValue(),
|
|
261
386
|
dismiss: use(() => dialog.dismiss()),
|
|
262
|
-
message:
|
|
387
|
+
message: () => dialog.message(),
|
|
263
388
|
page: () => Option.fromNullable(dialog.page()).pipe(Option.map(PlaywrightPage.make)),
|
|
264
|
-
type:
|
|
389
|
+
type: () => dialog.type()
|
|
265
390
|
});
|
|
266
391
|
}
|
|
267
392
|
};
|
|
@@ -274,7 +399,7 @@ var PlaywrightFileChooser = class PlaywrightFileChooser extends Data.TaggedClass
|
|
|
274
399
|
const use = useHelper(fileChooser);
|
|
275
400
|
return new PlaywrightFileChooser({
|
|
276
401
|
element: () => fileChooser.element(),
|
|
277
|
-
isMultiple:
|
|
402
|
+
isMultiple: () => fileChooser.isMultiple(),
|
|
278
403
|
page: () => PlaywrightPage.make(fileChooser.page()),
|
|
279
404
|
setFiles: (files, options) => use(() => fileChooser.setFiles(files, options))
|
|
280
405
|
});
|
|
@@ -295,13 +420,12 @@ var PlaywrightDownload = class PlaywrightDownload extends Data.TaggedClass("Play
|
|
|
295
420
|
page: () => PlaywrightPage.make(download.page()),
|
|
296
421
|
path: use(() => download.path()).pipe(Effect.map(Option.fromNullable)),
|
|
297
422
|
saveAs: (path) => use(() => download.saveAs(path)),
|
|
298
|
-
suggestedFilename:
|
|
299
|
-
url:
|
|
423
|
+
suggestedFilename: () => download.suggestedFilename(),
|
|
424
|
+
url: () => download.url(),
|
|
300
425
|
use
|
|
301
426
|
});
|
|
302
427
|
}
|
|
303
428
|
};
|
|
304
|
-
|
|
305
429
|
//#endregion
|
|
306
430
|
//#region src/browser-context.ts
|
|
307
431
|
const eventMappings$1 = {
|
|
@@ -330,9 +454,11 @@ var PlaywrightBrowserContext = class PlaywrightBrowserContext extends Context.Ta
|
|
|
330
454
|
static make(context) {
|
|
331
455
|
const use = useHelper(context);
|
|
332
456
|
return PlaywrightBrowserContext.of({
|
|
457
|
+
clock: PlaywrightClock.make(context.clock),
|
|
333
458
|
pages: Effect.sync(() => context.pages().map(PlaywrightPage.make)),
|
|
334
459
|
newPage: use((c) => c.newPage().then(PlaywrightPage.make)),
|
|
335
460
|
close: use((c) => c.close()),
|
|
461
|
+
addInitScript: (script, arg) => use((c) => c.addInitScript(script, arg)),
|
|
336
462
|
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
337
463
|
context.on(event, emit.single);
|
|
338
464
|
context.once("close", emit.end);
|
|
@@ -346,7 +472,6 @@ var PlaywrightBrowserContext = class PlaywrightBrowserContext extends Context.Ta
|
|
|
346
472
|
});
|
|
347
473
|
}
|
|
348
474
|
};
|
|
349
|
-
|
|
350
475
|
//#endregion
|
|
351
476
|
//#region src/browser.ts
|
|
352
477
|
const eventMappings = { disconnected: (browser) => PlaywrightBrowser.make(browser) };
|
|
@@ -362,11 +487,11 @@ var PlaywrightBrowser = class PlaywrightBrowser extends Context.Tag("effect-play
|
|
|
362
487
|
return PlaywrightBrowser.of({
|
|
363
488
|
newPage: (options) => use((browser) => browser.newPage(options).then(PlaywrightPage.make)),
|
|
364
489
|
close: use((browser) => browser.close()),
|
|
365
|
-
contexts:
|
|
490
|
+
contexts: () => browser.contexts().map(PlaywrightBrowserContext.make),
|
|
366
491
|
newContext: (options) => Effect.acquireRelease(use((browser) => browser.newContext(options).then(PlaywrightBrowserContext.make)), (context) => context.close.pipe(Effect.ignoreLogged)),
|
|
367
|
-
browserType:
|
|
368
|
-
version:
|
|
369
|
-
isConnected:
|
|
492
|
+
browserType: () => browser.browserType(),
|
|
493
|
+
version: () => browser.version(),
|
|
494
|
+
isConnected: () => browser.isConnected(),
|
|
370
495
|
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
371
496
|
browser.on(event, emit.single);
|
|
372
497
|
browser.once("disconnected", emit.end);
|
|
@@ -381,7 +506,6 @@ var PlaywrightBrowser = class PlaywrightBrowser extends Context.Tag("effect-play
|
|
|
381
506
|
});
|
|
382
507
|
}
|
|
383
508
|
};
|
|
384
|
-
|
|
385
509
|
//#endregion
|
|
386
510
|
//#region src/playwright.ts
|
|
387
511
|
const launch = Effect.fn(function* (browserType, options) {
|
|
@@ -398,6 +522,13 @@ const connectCDP = Effect.fn(function* (cdpUrl, options) {
|
|
|
398
522
|
});
|
|
399
523
|
return PlaywrightBrowser.make(browser);
|
|
400
524
|
});
|
|
525
|
+
const launchPersistentContext = Effect.fn(function* (browserType, userDataDir, options) {
|
|
526
|
+
const rawContext = yield* Effect.tryPromise({
|
|
527
|
+
try: () => browserType.launchPersistentContext(userDataDir, options),
|
|
528
|
+
catch: wrapError
|
|
529
|
+
});
|
|
530
|
+
return PlaywrightBrowserContext.make(rawContext);
|
|
531
|
+
});
|
|
401
532
|
/**
|
|
402
533
|
* @category tag
|
|
403
534
|
* @since 0.1.0
|
|
@@ -409,10 +540,11 @@ var Playwright = class Playwright extends Context.Tag("effect-playwright/index/P
|
|
|
409
540
|
static layer = Layer.succeed(Playwright, {
|
|
410
541
|
launch,
|
|
411
542
|
launchScoped: (browserType, options) => Effect.acquireRelease(launch(browserType, options), (browser) => browser.close.pipe(Effect.ignore)),
|
|
543
|
+
launchPersistentContext,
|
|
544
|
+
launchPersistentContextScoped: (browserType, userDataDir, options) => Effect.acquireRelease(launchPersistentContext(browserType, userDataDir, options), (context) => context.close.pipe(Effect.ignore)),
|
|
412
545
|
connectCDP,
|
|
413
546
|
connectCDPScoped: (cdpUrl, options) => Effect.acquireRelease(connectCDP(cdpUrl, options), (browser) => browser.close.pipe(Effect.ignore))
|
|
414
547
|
});
|
|
415
548
|
};
|
|
416
|
-
|
|
417
549
|
//#endregion
|
|
418
|
-
export { PlaywrightDownload as a, PlaywrightResponse as c,
|
|
550
|
+
export { PlaywrightError as _, PlaywrightDownload as a, PlaywrightResponse as c, PlaywrightTouchscreen as d, PlaywrightMouse as f, PlaywrightClock as g, PlaywrightLocator as h, PlaywrightDialog as i, PlaywrightWorker as l, PlaywrightFrame as m, PlaywrightBrowser as n, PlaywrightFileChooser as o, PlaywrightKeyboard as p, PlaywrightBrowserContext as r, PlaywrightRequest as s, Playwright as t, PlaywrightPage as u };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-playwright",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "An Effect-based Playwright library.",
|
|
6
6
|
"author": "Jobflow GmbH",
|
|
7
7
|
"license": "ISC",
|
|
@@ -29,24 +29,26 @@
|
|
|
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.
|
|
40
|
-
"@effect/
|
|
41
|
-
"@effect/
|
|
39
|
+
"@biomejs/biome": "2.4.6",
|
|
40
|
+
"@effect/cli": "^0.73.2",
|
|
41
|
+
"@effect/language-service": "0.77.0",
|
|
42
|
+
"@effect/platform": "^0.94.5",
|
|
42
43
|
"@effect/platform-node": "^0.104.1",
|
|
43
44
|
"@effect/vitest": "^0.27.0",
|
|
44
|
-
"@types/node": "^25.
|
|
45
|
-
"effect": "^3.19.
|
|
46
|
-
"playwright": "^1.58.
|
|
47
|
-
"
|
|
45
|
+
"@types/node": "^25.3.3",
|
|
46
|
+
"effect": "^3.19.19",
|
|
47
|
+
"playwright": "^1.58.2",
|
|
48
|
+
"ts-morph": "^27.0.2",
|
|
49
|
+
"tsdown": "0.21.0",
|
|
48
50
|
"tsx": "^4.21.0",
|
|
49
|
-
"typedoc": "^0.28.
|
|
51
|
+
"typedoc": "^0.28.17",
|
|
50
52
|
"typescript": "^5.9.3",
|
|
51
53
|
"vitest": "^4.0.18"
|
|
52
54
|
},
|
|
@@ -55,7 +57,8 @@
|
|
|
55
57
|
"build": "tsdown",
|
|
56
58
|
"test": "vitest run",
|
|
57
59
|
"type-check": "tsc --noEmit",
|
|
60
|
+
"coverage": "tsx scripts/coverage.ts",
|
|
58
61
|
"generate-docs": "typedoc",
|
|
59
|
-
"format
|
|
62
|
+
"format": "biome format --fix"
|
|
60
63
|
}
|
|
61
64
|
}
|
package/dist/chunk-Bo1DHCg-.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) {
|
|
6
|
-
__defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (symbols) {
|
|
12
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { __exportAll as t };
|