import type { HowlOptions } from "howler"; declare global { interface HTMLElement { /** * Plays the sound * only works if the sound is created using the `svelte-sound` action */ play: () => void; /** * Stops the sound * only works if the sound is created using the `svelte-sound` action */ stop: () => void; } } /** * The events that is used to play the sound */ type PlayEvent = keyof HTMLElementEventMap; /** * The events that is used to stop the sound */ type StopEvent = keyof HTMLElementEventMap; type SoundSource = HowlOptions["src"]; type SoundEvents = [PlayEvent, StopEvent?]; type SoundOptions = Omit; /** * Options for creating a SyntheticSound instance. */ type Options = { events: SoundEvents; } & HowlOptions; /** * A class representing a synthetic sound. */ export declare class Sound { private src; private options?; private howl; /** * Creates a new SyntheticSound instance. * @param options The options for the sound. */ constructor(src: SoundSource, options?: SoundOptions); /** * Creates the Howl instance for the sound. */ private create; /** * Updates the options for the sound. * @param options The new options for the sound. */ update(options?: Options): void; /** * Destroys the sound instance. */ destroy(): void; /** * Plays the sound. */ play(): void; /** * Stops the sound. */ stop(): void; /** * Unloads the sound. */ private unload; } /** * A class representing a sound player that can be attached to an HTML element. * @extends Sound */ declare class SvelteSound extends Sound { node: HTMLElement; events: SoundEvents; /** * Creates a new Sound instance. * @param node The HTML element to attach the sound player to. * @param options The options to configure the sound player. */ constructor(node: HTMLElement, { src, events, ...options }: Options); /** * Adds event listeners to the HTML element to play and stop the sound. */ attachControls(): void; /** * Removes event listeners from the HTML element to play and stop the sound. */ removeEventListeners(): void; /** * Updates the sound player with new options. * @param options The new options to configure the sound player. */ update(options: Parameters[0]): void; /** * Destroys the sound player and removes all event listeners. */ destroy(): void; } /** * Creates a new Sound instance. * @param node The HTML element to attach the sound player to. * @param options The options to configure the sound player. * @returns A new Sound instance. */ export declare function sound(node: HTMLElement, options: Options): SvelteSound; /** * Creates a new Sound instance with the given options. * @param src The source URL(s) of the sound. * @param events The events to listen to for playing and stopping the sound. * @param options The options to configure the sound player. * @returns A function that creates a new Sound instance with the given options. */ export declare function useSound(src: SoundSource, events: SoundEvents, options?: SoundOptions): (node: HTMLElement, overrideOptions?: Partial) => SvelteSound; export {};