{-# LANGUAGE PatternSynonyms #-}
-- For HasCallStack compatibility
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.MediaStreamEvent
       (newMediaStreamEvent, getStream, getStreamUnsafe,
        getStreamUnchecked, MediaStreamEvent(..), gTypeMediaStreamEvent)
       where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamEvent Mozilla MediaStreamEvent documentation> 
newMediaStreamEvent ::
                    (MonadDOM m, ToJSString type') =>
                      type' -> Maybe MediaStreamEventInit -> m MediaStreamEvent
newMediaStreamEvent :: forall (m :: * -> *) type'.
(MonadDOM m, ToJSString type') =>
type' -> Maybe MediaStreamEventInit -> m MediaStreamEvent
newMediaStreamEvent type'
type' Maybe MediaStreamEventInit
eventInitDict
  = DOM MediaStreamEvent -> m MediaStreamEvent
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (JSVal -> MediaStreamEvent
MediaStreamEvent (JSVal -> MediaStreamEvent) -> JSM JSVal -> DOM MediaStreamEvent
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
         JSM JSVal -> [JSM JSVal] -> JSM JSVal
forall constructor args.
(MakeObject constructor, MakeArgs args) =>
constructor -> args -> JSM JSVal
new (String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"MediaStreamEvent")
           [type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal type'
type', Maybe MediaStreamEventInit -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe MediaStreamEventInit
eventInitDict])

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamEvent.stream Mozilla MediaStreamEvent.stream documentation> 
getStream ::
          (MonadDOM m) => MediaStreamEvent -> m (Maybe MediaStream)
getStream :: forall (m :: * -> *).
MonadDOM m =>
MediaStreamEvent -> m (Maybe MediaStream)
getStream MediaStreamEvent
self = DOM (Maybe MediaStream) -> m (Maybe MediaStream)
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaStreamEvent
self MediaStreamEvent
-> Getting (JSM JSVal) MediaStreamEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaStreamEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"stream") JSM JSVal
-> (JSVal -> DOM (Maybe MediaStream)) -> DOM (Maybe MediaStream)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe MediaStream)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamEvent.stream Mozilla MediaStreamEvent.stream documentation> 
getStreamUnsafe ::
                (MonadDOM m, HasCallStack) => MediaStreamEvent -> m MediaStream
getStreamUnsafe :: forall (m :: * -> *).
(MonadDOM m, HasCallStack) =>
MediaStreamEvent -> m MediaStream
getStreamUnsafe MediaStreamEvent
self
  = DOM MediaStream -> m MediaStream
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (((MediaStreamEvent
self MediaStreamEvent
-> Getting (JSM JSVal) MediaStreamEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaStreamEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"stream") JSM JSVal
-> (JSVal -> DOM (Maybe MediaStream)) -> DOM (Maybe MediaStream)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe MediaStream)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal) DOM (Maybe MediaStream)
-> (Maybe MediaStream -> DOM MediaStream) -> DOM MediaStream
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
         DOM MediaStream
-> (MediaStream -> DOM MediaStream)
-> Maybe MediaStream
-> DOM MediaStream
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> DOM MediaStream
forall a. HasCallStack => String -> a
Prelude.error String
"Nothing to return") MediaStream -> DOM MediaStream
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamEvent.stream Mozilla MediaStreamEvent.stream documentation> 
getStreamUnchecked ::
                   (MonadDOM m) => MediaStreamEvent -> m MediaStream
getStreamUnchecked :: forall (m :: * -> *).
MonadDOM m =>
MediaStreamEvent -> m MediaStream
getStreamUnchecked MediaStreamEvent
self
  = DOM MediaStream -> m MediaStream
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaStreamEvent
self MediaStreamEvent
-> Getting (JSM JSVal) MediaStreamEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaStreamEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"stream") JSM JSVal -> (JSVal -> DOM MediaStream) -> DOM MediaStream
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM MediaStream
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)