effect-playwright 0.1.1 → 0.2.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 +36 -0
- package/dist/experimental/index.d.mts +26 -6
- package/dist/experimental/index.mjs +35 -5
- package/dist/index-K6LNMeXC.d.mts +1004 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{src-BGGNNney.mjs → src-Bf0XqK7M.mjs} +222 -114
- package/package.json +8 -5
- package/dist/index-DnbVDccF.d.mts +0 -754
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as NewPageOptions, c as PlaywrightPageService, i as NewContextOptions, l as
|
|
2
|
-
export { LaunchOptions, NewContextOptions, NewPageOptions, Playwright, PlaywrightBrowser, PlaywrightLocator, PlaywrightLocatorService, PlaywrightPage, PlaywrightPageService, PlaywrightService };
|
|
1
|
+
import { S as PlaywrightErrorReason, _ as PlaywrightWorker, a as NewPageOptions, b as PlaywrightLocatorService, 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, x as PlaywrightError, y as PlaywrightLocator } from "./index-K6LNMeXC.mjs";
|
|
2
|
+
export { LaunchOptions, NewContextOptions, NewPageOptions, Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightBrowserContextService, PlaywrightBrowserService, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightErrorReason, PlaywrightFileChooser, PlaywrightLocator, PlaywrightLocatorService, PlaywrightPage, PlaywrightPageService, PlaywrightRequest, PlaywrightResponse, PlaywrightService, PlaywrightWorker };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as PlaywrightDownload, c as PlaywrightResponse, d as PlaywrightLocator, f as PlaywrightError, i as PlaywrightDialog, l as PlaywrightWorker, n as PlaywrightBrowser, o as PlaywrightFileChooser, r as PlaywrightBrowserContext, s as PlaywrightRequest, t as Playwright, u as PlaywrightPage } from "./src-Bf0XqK7M.mjs";
|
|
2
2
|
|
|
3
|
-
export { Playwright, PlaywrightBrowser, PlaywrightLocator, PlaywrightPage };
|
|
3
|
+
export { Playwright, PlaywrightBrowser, PlaywrightBrowserContext, PlaywrightDialog, PlaywrightDownload, PlaywrightError, PlaywrightFileChooser, PlaywrightLocator, PlaywrightPage, PlaywrightRequest, PlaywrightResponse, PlaywrightWorker };
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { Context, Data, Effect, Layer, Option, Stream, identity } from "effect";
|
|
2
|
+
import { Readable } from "node:stream";
|
|
2
3
|
import { chromium, errors } from "playwright-core";
|
|
3
4
|
|
|
4
5
|
//#region src/errors.ts
|
|
6
|
+
/**
|
|
7
|
+
* Error type that is returned when a Playwright error occurs.
|
|
8
|
+
* Reason can either be "Timeout" or "Unknown".
|
|
9
|
+
*
|
|
10
|
+
* Timeout errors occur when a timeout is reached. All other errors are
|
|
11
|
+
* grouped under "Unknown".
|
|
12
|
+
*
|
|
13
|
+
* @category error
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
*/
|
|
5
16
|
var PlaywrightError = class extends Data.TaggedError("PlaywrightError") {};
|
|
6
17
|
function wrapError(error) {
|
|
7
18
|
if (error instanceof errors.TimeoutError) return new PlaywrightError({
|
|
@@ -20,12 +31,155 @@ function wrapError(error) {
|
|
|
20
31
|
const useHelper = (api) => (userFunction) => Effect.tryPromise(() => userFunction(api)).pipe(Effect.mapError(wrapError));
|
|
21
32
|
|
|
22
33
|
//#endregion
|
|
23
|
-
//#region src/
|
|
24
|
-
|
|
34
|
+
//#region src/locator.ts
|
|
35
|
+
/**
|
|
36
|
+
* A service that provides a `PlaywrightLocator` instance.
|
|
37
|
+
*
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
* @category tag
|
|
40
|
+
*/
|
|
41
|
+
var PlaywrightLocator = class PlaywrightLocator extends Context.Tag("effect-playwright/PlaywrightLocator")() {
|
|
42
|
+
/**
|
|
43
|
+
* Creates a `PlaywrightLocator` from a Playwright `Locator` instance. This is mostly for internal use.
|
|
44
|
+
* But you could use this if you have used `use` or similar to wrap the locator.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const playwrightNativeLocator = yield* page.use((p) => p.locator("button"));
|
|
49
|
+
* const locator = PlaywrightLocator.make(playwrightNativeLocator);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param locator - The Playwright `Locator` instance to wrap.
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
* @category constructor
|
|
55
|
+
*/
|
|
56
|
+
static make(locator) {
|
|
57
|
+
const use = useHelper(locator);
|
|
58
|
+
return PlaywrightLocator.of({
|
|
59
|
+
click: (options) => use((l) => l.click(options)),
|
|
60
|
+
fill: (value, options) => use((l) => l.fill(value, options)),
|
|
61
|
+
getAttribute: (name, options) => use((l) => l.getAttribute(name, options)),
|
|
62
|
+
innerText: (options) => use((l) => l.innerText(options)),
|
|
63
|
+
innerHTML: (options) => use((l) => l.innerHTML(options)),
|
|
64
|
+
inputValue: (options) => use((l) => l.inputValue(options)),
|
|
65
|
+
textContent: (options) => use((l) => l.textContent(options)),
|
|
66
|
+
count: use((l) => l.count()),
|
|
67
|
+
first: () => PlaywrightLocator.make(locator.first()),
|
|
68
|
+
last: () => PlaywrightLocator.make(locator.last()),
|
|
69
|
+
nth: (index) => PlaywrightLocator.make(locator.nth(index)),
|
|
70
|
+
evaluate: (pageFunction, arg, options) => use((l) => l.evaluate(pageFunction, arg, options)),
|
|
71
|
+
use
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/frame.ts
|
|
78
|
+
/**
|
|
79
|
+
* @category tag
|
|
80
|
+
* @since 0.1.2
|
|
81
|
+
*/
|
|
82
|
+
var PlaywrightFrame = class PlaywrightFrame extends Context.Tag("effect-playwright/PlaywrightFrame")() {
|
|
83
|
+
/**
|
|
84
|
+
* Creates a `PlaywrightFrame` from a Playwright `Frame` instance.
|
|
85
|
+
*
|
|
86
|
+
* @param frame - The Playwright `Frame` instance to wrap.
|
|
87
|
+
* @since 0.1.2
|
|
88
|
+
*/
|
|
25
89
|
static make(frame) {
|
|
26
|
-
|
|
90
|
+
const use = useHelper(frame);
|
|
91
|
+
return PlaywrightFrame.of({
|
|
92
|
+
goto: (url, options) => use((f) => f.goto(url, options)),
|
|
93
|
+
waitForURL: (url, options) => use((f) => f.waitForURL(url, options)),
|
|
94
|
+
waitForLoadState: (state, options) => use((f) => f.waitForLoadState(state, options)),
|
|
95
|
+
evaluate: (f, arg) => use((frame$1) => frame$1.evaluate(f, arg)),
|
|
96
|
+
title: use((f) => f.title()),
|
|
97
|
+
use,
|
|
98
|
+
locator: (selector, options) => PlaywrightLocator.make(frame.locator(selector, options)),
|
|
99
|
+
getByRole: (role, options) => PlaywrightLocator.make(frame.getByRole(role, options)),
|
|
100
|
+
getByText: (text, options) => PlaywrightLocator.make(frame.getByText(text, options)),
|
|
101
|
+
getByLabel: (label, options) => PlaywrightLocator.make(frame.getByLabel(label, options)),
|
|
102
|
+
getByTestId: (testId) => PlaywrightLocator.make(frame.getByTestId(testId)),
|
|
103
|
+
url: Effect.sync(() => frame.url()),
|
|
104
|
+
content: use((f) => f.content()),
|
|
105
|
+
name: Effect.sync(() => frame.name()),
|
|
106
|
+
click: (selector, options) => use((f) => f.click(selector, options))
|
|
107
|
+
});
|
|
27
108
|
}
|
|
28
109
|
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/page.ts
|
|
113
|
+
const eventMappings$2 = {
|
|
114
|
+
close: (page) => PlaywrightPage.make(page),
|
|
115
|
+
console: identity,
|
|
116
|
+
crash: (page) => PlaywrightPage.make(page),
|
|
117
|
+
dialog: (dialog) => PlaywrightDialog.make(dialog),
|
|
118
|
+
domcontentloaded: (page) => PlaywrightPage.make(page),
|
|
119
|
+
download: (download) => PlaywrightDownload.make(download),
|
|
120
|
+
filechooser: (fileChooser) => PlaywrightFileChooser.make(fileChooser),
|
|
121
|
+
frameattached: (frame) => PlaywrightFrame.make(frame),
|
|
122
|
+
framedetached: (frame) => PlaywrightFrame.make(frame),
|
|
123
|
+
framenavigated: (frame) => PlaywrightFrame.make(frame),
|
|
124
|
+
load: (page) => PlaywrightPage.make(page),
|
|
125
|
+
pageerror: identity,
|
|
126
|
+
popup: (page) => PlaywrightPage.make(page),
|
|
127
|
+
request: (request) => PlaywrightRequest.make(request),
|
|
128
|
+
requestfailed: (request) => PlaywrightRequest.make(request),
|
|
129
|
+
requestfinished: (request) => PlaywrightRequest.make(request),
|
|
130
|
+
response: (response) => PlaywrightResponse.make(response),
|
|
131
|
+
websocket: identity,
|
|
132
|
+
worker: (worker) => PlaywrightWorker.make(worker)
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* @category tag
|
|
136
|
+
*/
|
|
137
|
+
var PlaywrightPage = class PlaywrightPage extends Context.Tag("effect-playwright/PlaywrightPage")() {
|
|
138
|
+
/**
|
|
139
|
+
* Creates a `PlaywrightPage` from a Playwright `Page` instance.
|
|
140
|
+
*
|
|
141
|
+
* @param page - The Playwright `Page` instance to wrap.
|
|
142
|
+
* @since 0.1.0
|
|
143
|
+
*/
|
|
144
|
+
static make(page) {
|
|
145
|
+
const use = useHelper(page);
|
|
146
|
+
return PlaywrightPage.of({
|
|
147
|
+
goto: (url, options) => use((p) => p.goto(url, options)),
|
|
148
|
+
waitForURL: (url, options) => use((p) => p.waitForURL(url, options)),
|
|
149
|
+
waitForLoadState: (state, options) => use((p) => p.waitForLoadState(state, options)),
|
|
150
|
+
title: use((p) => p.title()),
|
|
151
|
+
evaluate: (f, arg) => use((p) => p.evaluate(f, arg)),
|
|
152
|
+
locator: (selector, options) => PlaywrightLocator.make(page.locator(selector, options)),
|
|
153
|
+
getByRole: (role, options) => PlaywrightLocator.make(page.getByRole(role, options)),
|
|
154
|
+
getByText: (text, options) => PlaywrightLocator.make(page.getByText(text, options)),
|
|
155
|
+
getByLabel: (label, options) => PlaywrightLocator.make(page.getByLabel(label, options)),
|
|
156
|
+
getByTestId: (testId) => PlaywrightLocator.make(page.getByTestId(testId)),
|
|
157
|
+
url: Effect.sync(() => page.url()),
|
|
158
|
+
frames: use((p) => Promise.resolve(p.frames().map(PlaywrightFrame.make))),
|
|
159
|
+
reload: use((p) => p.reload()),
|
|
160
|
+
close: use((p) => p.close()),
|
|
161
|
+
click: (selector, options) => use((p) => p.click(selector, options)),
|
|
162
|
+
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
163
|
+
page.on(event, emit.single);
|
|
164
|
+
page.once("close", emit.end);
|
|
165
|
+
}), () => Effect.sync(() => {
|
|
166
|
+
page.off(event, emit.single);
|
|
167
|
+
page.off("close", emit.end);
|
|
168
|
+
}))).pipe(Stream.map((e) => {
|
|
169
|
+
const mapping = eventMappings$2[event];
|
|
170
|
+
return mapping(e);
|
|
171
|
+
})),
|
|
172
|
+
use
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/common.ts
|
|
179
|
+
/**
|
|
180
|
+
* @category model
|
|
181
|
+
* @since 0.1.2
|
|
182
|
+
*/
|
|
29
183
|
var PlaywrightRequest = class PlaywrightRequest extends Data.TaggedClass("PlaywrightRequest") {
|
|
30
184
|
static make(request) {
|
|
31
185
|
const use = useHelper(request);
|
|
@@ -52,6 +206,10 @@ var PlaywrightRequest = class PlaywrightRequest extends Data.TaggedClass("Playwr
|
|
|
52
206
|
});
|
|
53
207
|
}
|
|
54
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* @category model
|
|
211
|
+
* @since 0.1.2
|
|
212
|
+
*/
|
|
55
213
|
var PlaywrightResponse = class PlaywrightResponse extends Data.TaggedClass("PlaywrightResponse") {
|
|
56
214
|
static make(response) {
|
|
57
215
|
const use = useHelper(response);
|
|
@@ -77,6 +235,10 @@ var PlaywrightResponse = class PlaywrightResponse extends Data.TaggedClass("Play
|
|
|
77
235
|
});
|
|
78
236
|
}
|
|
79
237
|
};
|
|
238
|
+
/**
|
|
239
|
+
* @category model
|
|
240
|
+
* @since 0.1.2
|
|
241
|
+
*/
|
|
80
242
|
var PlaywrightWorker = class PlaywrightWorker extends Data.TaggedClass("PlaywrightWorker") {
|
|
81
243
|
static make(worker) {
|
|
82
244
|
const use = useHelper(worker);
|
|
@@ -86,6 +248,10 @@ var PlaywrightWorker = class PlaywrightWorker extends Data.TaggedClass("Playwrig
|
|
|
86
248
|
});
|
|
87
249
|
}
|
|
88
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* @category model
|
|
253
|
+
* @since 0.1.2
|
|
254
|
+
*/
|
|
89
255
|
var PlaywrightDialog = class PlaywrightDialog extends Data.TaggedClass("PlaywrightDialog") {
|
|
90
256
|
static make(dialog) {
|
|
91
257
|
const use = useHelper(dialog);
|
|
@@ -99,6 +265,10 @@ var PlaywrightDialog = class PlaywrightDialog extends Data.TaggedClass("Playwrig
|
|
|
99
265
|
});
|
|
100
266
|
}
|
|
101
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* @category model
|
|
270
|
+
* @since 0.1.2
|
|
271
|
+
*/
|
|
102
272
|
var PlaywrightFileChooser = class PlaywrightFileChooser extends Data.TaggedClass("PlaywrightFileChooser") {
|
|
103
273
|
static make(fileChooser) {
|
|
104
274
|
const use = useHelper(fileChooser);
|
|
@@ -110,12 +280,16 @@ var PlaywrightFileChooser = class PlaywrightFileChooser extends Data.TaggedClass
|
|
|
110
280
|
});
|
|
111
281
|
}
|
|
112
282
|
};
|
|
283
|
+
/**
|
|
284
|
+
* @category model
|
|
285
|
+
* @since 0.1.2
|
|
286
|
+
*/
|
|
113
287
|
var PlaywrightDownload = class PlaywrightDownload extends Data.TaggedClass("PlaywrightDownload") {
|
|
114
288
|
static make(download) {
|
|
115
289
|
const use = useHelper(download);
|
|
116
290
|
return new PlaywrightDownload({
|
|
117
291
|
cancel: use(() => download.cancel()),
|
|
118
|
-
|
|
292
|
+
stream: use(() => download.createReadStream().then((s) => Readable.toWeb(s))).pipe(Effect.map((s) => Stream.fromReadableStream(() => s, wrapError)), Stream.unwrap),
|
|
119
293
|
delete: use(() => download.delete()),
|
|
120
294
|
failure: use(() => download.failure()).pipe(Effect.map(Option.fromNullable)),
|
|
121
295
|
page: () => PlaywrightPage.make(download.page()),
|
|
@@ -129,137 +303,57 @@ var PlaywrightDownload = class PlaywrightDownload extends Data.TaggedClass("Play
|
|
|
129
303
|
};
|
|
130
304
|
|
|
131
305
|
//#endregion
|
|
132
|
-
//#region src/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* ```ts
|
|
146
|
-
* const playwrightNativeLocator = yield* page.use((p) => p.locator("button"));
|
|
147
|
-
* const locator = PlaywrightLocator.make(playwrightNativeLocator);
|
|
148
|
-
* ```
|
|
149
|
-
*
|
|
150
|
-
* @param locator - The Playwright `Locator` instance to wrap.
|
|
151
|
-
* @since 0.1.0
|
|
152
|
-
* @category constructor
|
|
153
|
-
*/
|
|
154
|
-
static make(locator) {
|
|
155
|
-
const use = useHelper(locator);
|
|
156
|
-
return PlaywrightLocator.of({
|
|
157
|
-
click: (options) => use((l) => l.click(options)),
|
|
158
|
-
fill: (value, options) => use((l) => l.fill(value, options)),
|
|
159
|
-
getAttribute: (name, options) => use((l) => l.getAttribute(name, options)),
|
|
160
|
-
innerText: (options) => use((l) => l.innerText(options)),
|
|
161
|
-
innerHTML: (options) => use((l) => l.innerHTML(options)),
|
|
162
|
-
inputValue: (options) => use((l) => l.inputValue(options)),
|
|
163
|
-
textContent: (options) => use((l) => l.textContent(options)),
|
|
164
|
-
count: use((l) => l.count()),
|
|
165
|
-
first: () => PlaywrightLocator.make(locator.first()),
|
|
166
|
-
last: () => PlaywrightLocator.make(locator.last()),
|
|
167
|
-
nth: (index) => PlaywrightLocator.make(locator.nth(index)),
|
|
168
|
-
evaluate: (pageFunction, arg, options) => use((l) => l.evaluate(pageFunction, arg, options)),
|
|
169
|
-
use
|
|
170
|
-
});
|
|
171
|
-
}
|
|
306
|
+
//#region src/browser-context.ts
|
|
307
|
+
const eventMappings$1 = {
|
|
308
|
+
backgroundpage: (page) => PlaywrightPage.make(page),
|
|
309
|
+
close: (context) => PlaywrightBrowserContext.make(context),
|
|
310
|
+
console: identity,
|
|
311
|
+
dialog: (dialog) => PlaywrightDialog.make(dialog),
|
|
312
|
+
page: (page) => PlaywrightPage.make(page),
|
|
313
|
+
request: (request) => PlaywrightRequest.make(request),
|
|
314
|
+
requestfailed: (request) => PlaywrightRequest.make(request),
|
|
315
|
+
requestfinished: (request) => PlaywrightRequest.make(request),
|
|
316
|
+
response: (response) => PlaywrightResponse.make(response),
|
|
317
|
+
serviceworker: (worker) => PlaywrightWorker.make(worker),
|
|
318
|
+
weberror: identity
|
|
172
319
|
};
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/page.ts
|
|
176
320
|
/**
|
|
177
321
|
* @category tag
|
|
178
322
|
*/
|
|
179
|
-
var
|
|
323
|
+
var PlaywrightBrowserContext = class PlaywrightBrowserContext extends Context.Tag("effect-playwright/PlaywrightBrowserContext")() {
|
|
180
324
|
/**
|
|
181
|
-
* Creates a `
|
|
325
|
+
* Creates a `PlaywrightBrowserContext` from a Playwright `BrowserContext` instance.
|
|
182
326
|
*
|
|
183
|
-
* @param
|
|
327
|
+
* @param context - The Playwright `BrowserContext` instance to wrap.
|
|
184
328
|
* @since 0.1.0
|
|
185
329
|
*/
|
|
186
|
-
static make(page) {
|
|
187
|
-
const use = useHelper(page);
|
|
188
|
-
return PlaywrightPage.of({
|
|
189
|
-
goto: (url, options) => use((p) => p.goto(url, options)),
|
|
190
|
-
waitForURL: (url, options) => use((p) => p.waitForURL(url, options)),
|
|
191
|
-
title: use((p) => p.title()),
|
|
192
|
-
evaluate: (f, arg) => use((p) => p.evaluate(f, arg)),
|
|
193
|
-
locator: (selector, options) => PlaywrightLocator.make(page.locator(selector, options)),
|
|
194
|
-
getByRole: (role, options) => PlaywrightLocator.make(page.getByRole(role, options)),
|
|
195
|
-
getByText: (text, options) => PlaywrightLocator.make(page.getByText(text, options)),
|
|
196
|
-
getByLabel: (label, options) => PlaywrightLocator.make(page.getByLabel(label, options)),
|
|
197
|
-
getByTestId: (testId) => PlaywrightLocator.make(page.getByTestId(testId)),
|
|
198
|
-
url: Effect.sync(() => page.url()),
|
|
199
|
-
reload: use((p) => p.reload()),
|
|
200
|
-
close: use((p) => p.close()),
|
|
201
|
-
click: (selector, options) => use((p) => p.click(selector, options)),
|
|
202
|
-
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
203
|
-
const callback = emit.single;
|
|
204
|
-
const closeCallback = emit.end;
|
|
205
|
-
page.on(event, callback);
|
|
206
|
-
page.once("close", closeCallback);
|
|
207
|
-
return {
|
|
208
|
-
callback,
|
|
209
|
-
closeCallback
|
|
210
|
-
};
|
|
211
|
-
}), ({ callback, closeCallback }) => Effect.sync(() => {
|
|
212
|
-
page.off(event, callback);
|
|
213
|
-
page.off("close", closeCallback);
|
|
214
|
-
}))).pipe(Stream.map((e) => {
|
|
215
|
-
const mapper = eventMappings[event];
|
|
216
|
-
return mapper(e);
|
|
217
|
-
})),
|
|
218
|
-
use
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
const eventMappings = {
|
|
223
|
-
close: PlaywrightPage.make,
|
|
224
|
-
console: identity,
|
|
225
|
-
crash: PlaywrightPage.make,
|
|
226
|
-
dialog: PlaywrightDialog.make,
|
|
227
|
-
domcontentloaded: PlaywrightPage.make,
|
|
228
|
-
download: PlaywrightDownload.make,
|
|
229
|
-
filechooser: PlaywrightFileChooser.make,
|
|
230
|
-
frameattached: PlaywrightFrame.make,
|
|
231
|
-
framedetached: PlaywrightFrame.make,
|
|
232
|
-
framenavigated: PlaywrightFrame.make,
|
|
233
|
-
load: PlaywrightPage.make,
|
|
234
|
-
pageerror: identity,
|
|
235
|
-
popup: PlaywrightPage.make,
|
|
236
|
-
request: PlaywrightRequest.make,
|
|
237
|
-
requestfailed: PlaywrightRequest.make,
|
|
238
|
-
requestfinished: PlaywrightRequest.make,
|
|
239
|
-
response: PlaywrightResponse.make,
|
|
240
|
-
websocket: identity,
|
|
241
|
-
worker: PlaywrightWorker.make
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region src/browser-context.ts
|
|
246
|
-
var PlaywrightBrowserContext = class PlaywrightBrowserContext extends Context.Tag("cehs/backend/lib/playwright/PlaywrightBrowserContext")() {
|
|
247
330
|
static make(context) {
|
|
248
331
|
const use = useHelper(context);
|
|
249
332
|
return PlaywrightBrowserContext.of({
|
|
250
333
|
pages: Effect.sync(() => context.pages().map(PlaywrightPage.make)),
|
|
251
334
|
newPage: use((c) => c.newPage().then(PlaywrightPage.make)),
|
|
252
|
-
close: use((c) => c.close())
|
|
335
|
+
close: use((c) => c.close()),
|
|
336
|
+
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
337
|
+
context.on(event, emit.single);
|
|
338
|
+
context.once("close", emit.end);
|
|
339
|
+
}), () => Effect.sync(() => {
|
|
340
|
+
context.off(event, emit.single);
|
|
341
|
+
context.off("close", emit.end);
|
|
342
|
+
}))).pipe(Stream.map((e) => {
|
|
343
|
+
const mapping = eventMappings$1[event];
|
|
344
|
+
return mapping(e);
|
|
345
|
+
}))
|
|
253
346
|
});
|
|
254
347
|
}
|
|
255
348
|
};
|
|
256
349
|
|
|
257
350
|
//#endregion
|
|
258
351
|
//#region src/browser.ts
|
|
352
|
+
const eventMappings = { disconnected: (browser) => PlaywrightBrowser.make(browser) };
|
|
259
353
|
/**
|
|
260
354
|
* @category tag
|
|
261
355
|
*/
|
|
262
|
-
var PlaywrightBrowser = class PlaywrightBrowser extends Context.Tag("
|
|
356
|
+
var PlaywrightBrowser = class PlaywrightBrowser extends Context.Tag("effect-playwright/PlaywrightBrowser")() {
|
|
263
357
|
/**
|
|
264
358
|
* @category constructor
|
|
265
359
|
*/
|
|
@@ -273,6 +367,16 @@ var PlaywrightBrowser = class PlaywrightBrowser extends Context.Tag("cehs/backen
|
|
|
273
367
|
browserType: Effect.sync(() => browser.browserType()),
|
|
274
368
|
version: Effect.sync(() => browser.version()),
|
|
275
369
|
isConnected: Effect.sync(() => browser.isConnected()),
|
|
370
|
+
eventStream: (event) => Stream.asyncPush((emit) => Effect.acquireRelease(Effect.sync(() => {
|
|
371
|
+
browser.on(event, emit.single);
|
|
372
|
+
browser.once("disconnected", emit.end);
|
|
373
|
+
}), () => Effect.sync(() => {
|
|
374
|
+
browser.off(event, emit.single);
|
|
375
|
+
browser.off("disconnected", emit.end);
|
|
376
|
+
}))).pipe(Stream.map((e) => {
|
|
377
|
+
const mapping = eventMappings[event];
|
|
378
|
+
return mapping(e);
|
|
379
|
+
})),
|
|
276
380
|
use
|
|
277
381
|
});
|
|
278
382
|
}
|
|
@@ -294,6 +398,10 @@ const connectCDP = Effect.fn(function* (cdpUrl, options) {
|
|
|
294
398
|
});
|
|
295
399
|
return PlaywrightBrowser.make(browser);
|
|
296
400
|
});
|
|
401
|
+
/**
|
|
402
|
+
* @category tag
|
|
403
|
+
* @since 0.1.0
|
|
404
|
+
*/
|
|
297
405
|
var Playwright = class Playwright extends Context.Tag("effect-playwright/index/Playwright")() {
|
|
298
406
|
/**
|
|
299
407
|
* @category layer
|
|
@@ -307,4 +415,4 @@ var Playwright = class Playwright extends Context.Tag("effect-playwright/index/P
|
|
|
307
415
|
};
|
|
308
416
|
|
|
309
417
|
//#endregion
|
|
310
|
-
export { PlaywrightLocator as i, PlaywrightBrowser as n,
|
|
418
|
+
export { PlaywrightDownload as a, PlaywrightResponse as c, PlaywrightLocator as d, PlaywrightError as f, PlaywrightDialog as i, PlaywrightWorker as l, PlaywrightBrowser as n, PlaywrightFileChooser as o, 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.2.0",
|
|
5
5
|
"description": "An Effect-based Playwright library.",
|
|
6
6
|
"author": "Jobflow GmbH",
|
|
7
7
|
"license": "ISC",
|
|
@@ -37,15 +37,16 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@biomejs/biome": "2.3.11",
|
|
40
|
-
"@effect/language-service": "
|
|
40
|
+
"@effect/language-service": "0.71.1",
|
|
41
41
|
"@effect/platform": "^0.94.1",
|
|
42
42
|
"@effect/platform-node": "^0.104.0",
|
|
43
43
|
"@effect/vitest": "^0.27.0",
|
|
44
|
-
"@types/node": "^25.0.
|
|
44
|
+
"@types/node": "^25.0.9",
|
|
45
45
|
"effect": "^3.19.14",
|
|
46
46
|
"playwright": "^1.57.0",
|
|
47
|
-
"tsdown": "0.20.0-beta.
|
|
47
|
+
"tsdown": "0.20.0-beta.3",
|
|
48
48
|
"tsx": "^4.21.0",
|
|
49
|
+
"typedoc": "^0.28.16",
|
|
49
50
|
"typescript": "^5.9.3",
|
|
50
51
|
"vitest": "^4.0.17"
|
|
51
52
|
},
|
|
@@ -53,6 +54,8 @@
|
|
|
53
54
|
"scripts": {
|
|
54
55
|
"build": "tsdown",
|
|
55
56
|
"test": "vitest run",
|
|
56
|
-
"type-check": "tsc --noEmit"
|
|
57
|
+
"type-check": "tsc --noEmit",
|
|
58
|
+
"generate-docs": "typedoc",
|
|
59
|
+
"format-fix": "biome format --fix"
|
|
57
60
|
}
|
|
58
61
|
}
|