The best way to control Claude Code, Codex and more from any computer or phone

main
ts 59 lines 1.74 KB
Raw
1 /**
2 * Browser DOM event streams.
3 *
4 * This module provides typed constructors that turn `window.addEventListener`
5 * and `document.addEventListener` events into Effect `Stream` values. Both
6 * helpers accept the usual listener options and an optional stream buffer size.
7 *
8 * @stability unstable
9 * @since 4.0.0
10 */
11
12 import * as Stream from "effect/Stream"
13
14 /**
15 * Creates a `Stream` from `window.addEventListener`.
16 *
17 * **Details**
18 *
19 * By default, the underlying buffer is unbounded in size. You can customize the
20 * buffer size by passing an object as the second argument with the `bufferSize`
21 * field.
22 *
23 * @stability unstable
24 * @category constructors
25 * @since 4.0.0
26 */
27 export const fromEventListenerWindow = <K extends keyof WindowEventMap>(
28 type: K,
29 options?: boolean | {
30 readonly capture?: boolean
31 readonly passive?: boolean
32 readonly once?: boolean
33 readonly bufferSize?: number | undefined
34 } | undefined
35 ): Stream.Stream<WindowEventMap[K], never, never> => Stream.fromEventListener<WindowEventMap[K]>(window, type, options)
36
37 /**
38 * Creates a `Stream` from `document.addEventListener`.
39 *
40 * **Details**
41 *
42 * By default, the underlying buffer is unbounded in size. You can customize the
43 * buffer size by passing an object as the second argument with the `bufferSize`
44 * field.
45 *
46 * @stability unstable
47 * @category constructors
48 * @since 4.0.0
49 */
50 export const fromEventListenerDocument = <K extends keyof DocumentEventMap>(
51 type: K,
52 options?: boolean | {
53 readonly capture?: boolean
54 readonly passive?: boolean
55 readonly once?: boolean
56 readonly bufferSize?: number | undefined
57 } | undefined
58 ): Stream.Stream<DocumentEventMap[K], never, never> =>
59 Stream.fromEventListener<DocumentEventMap[K]>(document, type, options)