/** * Low-level Effect wrappers for Window and its usage via Context. * @since 8.19.0 */ import * as Context from "@typed/context" import * as Effect from "effect/Effect" import type * as Scope from "effect/Scope" import * as EventTarget from "./EventTarget.js" /** * Context for the Window object * @since 8.19.0 * @category models */ export interface Window extends globalThis.Window {} /** * Context for the Window object * @since 8.19.0 * @category context */ export const Window: Context.Tagged = Context.Tagged("@typed/dom/Window") /** * Get the innerWidth from the Window * @since 8.19.0 * @category getters */ export const getInnerWidth: Effect.Effect = Window.with((w) => w.innerWidth) /** * Get the innerHeight from the Window * @since 8.19.0 * @category getters */ export const getInnerHeight: Effect.Effect = Window.with( (w) => w.innerHeight ) /** * Get the computed style of an Element * @since 8.19.0 * @category getters */ export const getComputedStyle: (el: Element) => Effect.Effect = ( el: Element ): Effect.Effect => Window.withEffect((w) => Effect.sync(() => w.getComputedStyle(el))) /** * Add an event listener to the Window * @since 8.19.0 * @category events */ export const addWindowListener: ( options: EventTarget.AddEventListenerOptions ) => Effect.Effect = ( options: EventTarget.AddEventListenerOptions ): Effect.Effect => Window.withEffect((d) => EventTarget.addEventListener(d, options))