packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SpeechSynthesisUtterance.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from speech-api (webref). Do not edit.
module JSDOM.Generated.SpeechSynthesisUtterance
       (newSpeechSynthesisUtterance, setText, getText, setLang, getLang, setVoice, getVoice, getVoiceUnsafe, getVoiceUnchecked, setVolume, getVolume, setRate, getRate, setPitch, getPitch, start, end, error, pause, resume, mark, boundary, SpeechSynthesisUtterance(..), gTypeSpeechSynthesisUtterance)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/SpeechSynthesisUtterance MDN SpeechSynthesisUtterance. documentation>
newSpeechSynthesisUtterance :: (MonadDOM m, ToJSString text) => Maybe text -> m SpeechSynthesisUtterance
newSpeechSynthesisUtterance text = liftDOM (((new (jsg "SpeechSynthesisUtterance") [P.maybe (P.return jsUndefined) toJSVal text]) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/text MDN SpeechSynthesisUtterance.text documentation>
setText :: (MonadDOM m, ToJSString val) => SpeechSynthesisUtterance -> val -> m ()
setText self val = liftDOM (void (self ^. jss "text" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/text MDN SpeechSynthesisUtterance.text documentation>
getText :: (MonadDOM m, FromJSString result) => SpeechSynthesisUtterance -> m result
getText self = liftDOM (((self ^. js "text") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/lang MDN SpeechSynthesisUtterance.lang documentation>
setLang :: (MonadDOM m, ToJSString val) => SpeechSynthesisUtterance -> val -> m ()
setLang self val = liftDOM (void (self ^. jss "lang" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/lang MDN SpeechSynthesisUtterance.lang documentation>
getLang :: (MonadDOM m, FromJSString result) => SpeechSynthesisUtterance -> m result
getLang self = liftDOM (((self ^. js "lang") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/voice MDN SpeechSynthesisUtterance.voice documentation>
setVoice :: (MonadDOM m) => SpeechSynthesisUtterance -> Maybe SpeechSynthesisVoice -> m ()
setVoice self val = liftDOM (void (self ^. jss "voice" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/voice MDN SpeechSynthesisUtterance.voice documentation>
getVoice :: (MonadDOM m) => SpeechSynthesisUtterance -> m (Maybe SpeechSynthesisVoice)
getVoice self = liftDOM (((self ^. js "voice") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/voice MDN SpeechSynthesisUtterance.voice documentation>
getVoiceUnsafe :: (MonadDOM m, HasCallStack) => SpeechSynthesisUtterance -> m SpeechSynthesisVoice
getVoiceUnsafe self = liftDOM ((((self ^. js "voice") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/voice MDN SpeechSynthesisUtterance.voice documentation>
getVoiceUnchecked :: (MonadDOM m) => SpeechSynthesisUtterance -> m SpeechSynthesisVoice
getVoiceUnchecked self = liftDOM (((self ^. js "voice") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/volume MDN SpeechSynthesisUtterance.volume documentation>
setVolume :: (MonadDOM m) => SpeechSynthesisUtterance -> Float -> m ()
setVolume self val = liftDOM (void (self ^. jss "volume" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/volume MDN SpeechSynthesisUtterance.volume documentation>
getVolume :: (MonadDOM m) => SpeechSynthesisUtterance -> m Float
getVolume self = liftDOM ((P.realToFrac <$> ((self ^. js "volume") >>= valToNumber)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/rate MDN SpeechSynthesisUtterance.rate documentation>
setRate :: (MonadDOM m) => SpeechSynthesisUtterance -> Float -> m ()
setRate self val = liftDOM (void (self ^. jss "rate" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/rate MDN SpeechSynthesisUtterance.rate documentation>
getRate :: (MonadDOM m) => SpeechSynthesisUtterance -> m Float
getRate self = liftDOM ((P.realToFrac <$> ((self ^. js "rate") >>= valToNumber)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/pitch MDN SpeechSynthesisUtterance.pitch documentation>
setPitch :: (MonadDOM m) => SpeechSynthesisUtterance -> Float -> m ()
setPitch self val = liftDOM (void (self ^. jss "pitch" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechSynthesisUtterance/pitch MDN SpeechSynthesisUtterance.pitch documentation>
getPitch :: (MonadDOM m) => SpeechSynthesisUtterance -> m Float
getPitch self = liftDOM ((P.realToFrac <$> ((self ^. js "pitch") >>= valToNumber)))

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onstart start event>
start :: EventName SpeechSynthesisUtterance SpeechSynthesisEvent
start = unsafeEventName (toJSString "start")

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onend end event>
end :: EventName SpeechSynthesisUtterance SpeechSynthesisEvent
end = unsafeEventName (toJSString "end")

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onerror error event>
error :: EventName SpeechSynthesisUtterance SpeechSynthesisErrorEvent
error = unsafeEventNameAsync (toJSString "error")

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onpause pause event>
pause :: EventName SpeechSynthesisUtterance SpeechSynthesisEvent
pause = unsafeEventName (toJSString "pause")

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onresume resume event>
resume :: EventName SpeechSynthesisUtterance SpeechSynthesisEvent
resume = unsafeEventName (toJSString "resume")

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onmark mark event>
mark :: EventName SpeechSynthesisUtterance SpeechSynthesisEvent
mark = unsafeEventName (toJSString "mark")

-- | <https://webaudio.github.io/web-speech-api/#dom-speechsynthesisutterance-onboundary boundary event>
boundary :: EventName SpeechSynthesisUtterance SpeechSynthesisEvent
boundary = unsafeEventName (toJSString "boundary")