{-# LANGUAGE PatternSynonyms #-}
-- For HasCallStack compatibility
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.MediaKeySession
       (generateRequest, load, load_, update, close, remove, getSessionId,
        getExpiration, getClosed, getKeyStatuses, keystatuseschange,
        message, MediaKeySession(..), gTypeMediaKeySession)
       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/WebKitMediaKeySession.generateRequest Mozilla WebKitMediaKeySession.generateRequest documentation> 
generateRequest ::
                (MonadDOM m, ToJSString initDataType, IsBufferSource initData) =>
                  MediaKeySession -> initDataType -> initData -> m ()
generateRequest :: forall (m :: * -> *) initDataType initData.
(MonadDOM m, ToJSString initDataType, IsBufferSource initData) =>
MediaKeySession -> initDataType -> initData -> m ()
generateRequest MediaKeySession
self initDataType
initDataType initData
initData
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
         ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"generateRequest"
             [initDataType -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal initDataType
initDataType, initData -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal initData
initData])
            JSM JSVal -> (JSVal -> JSM JSVal) -> JSM JSVal
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM JSVal
readPromise))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.load Mozilla WebKitMediaKeySession.load documentation> 
load ::
     (MonadDOM m, ToJSString sessionId) =>
       MediaKeySession -> sessionId -> m Bool
load :: forall (m :: * -> *) sessionId.
(MonadDOM m, ToJSString sessionId) =>
MediaKeySession -> sessionId -> m Bool
load MediaKeySession
self sessionId
sessionId
  = DOM Bool -> m Bool
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"load" [sessionId -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal sessionId
sessionId]) JSM JSVal -> (JSVal -> JSM JSVal) -> JSM JSVal
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM JSVal
readPromise) JSM JSVal -> (JSVal -> DOM Bool) -> DOM Bool
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 Bool
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.load Mozilla WebKitMediaKeySession.load documentation> 
load_ ::
      (MonadDOM m, ToJSString sessionId) =>
        MediaKeySession -> sessionId -> m ()
load_ :: forall (m :: * -> *) sessionId.
(MonadDOM m, ToJSString sessionId) =>
MediaKeySession -> sessionId -> m ()
load_ MediaKeySession
self sessionId
sessionId
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"load" [sessionId -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal sessionId
sessionId]))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.update Mozilla WebKitMediaKeySession.update documentation> 
update ::
       (MonadDOM m, IsBufferSource response) =>
         MediaKeySession -> response -> m ()
update :: forall (m :: * -> *) response.
(MonadDOM m, IsBufferSource response) =>
MediaKeySession -> response -> m ()
update MediaKeySession
self response
response
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"update" [response -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal response
response]) JSM JSVal -> (JSVal -> JSM JSVal) -> JSM JSVal
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM JSVal
readPromise))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.close Mozilla WebKitMediaKeySession.close documentation> 
close :: (MonadDOM m) => MediaKeySession -> m ()
close :: forall (m :: * -> *). MonadDOM m => MediaKeySession -> m ()
close MediaKeySession
self
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"close" ()) JSM JSVal -> (JSVal -> JSM JSVal) -> JSM JSVal
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM JSVal
readPromise))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.remove Mozilla WebKitMediaKeySession.remove documentation> 
remove :: (MonadDOM m) => MediaKeySession -> m ()
remove :: forall (m :: * -> *). MonadDOM m => MediaKeySession -> m ()
remove MediaKeySession
self
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"remove" ()) JSM JSVal -> (JSVal -> JSM JSVal) -> JSM JSVal
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM JSVal
readPromise))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.sessionId Mozilla WebKitMediaKeySession.sessionId documentation> 
getSessionId ::
             (MonadDOM m, FromJSString result) => MediaKeySession -> m result
getSessionId :: forall (m :: * -> *) result.
(MonadDOM m, FromJSString result) =>
MediaKeySession -> m result
getSessionId MediaKeySession
self
  = DOM result -> m result
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaKeySession (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"sessionId") JSM JSVal -> (JSVal -> DOM result) -> DOM result
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 result
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.expiration Mozilla WebKitMediaKeySession.expiration documentation> 
getExpiration :: (MonadDOM m) => MediaKeySession -> m Double
getExpiration :: forall (m :: * -> *). MonadDOM m => MediaKeySession -> m Double
getExpiration MediaKeySession
self
  = DOM Double -> m Double
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaKeySession (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"expiration") JSM JSVal -> (JSVal -> DOM Double) -> DOM Double
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 Double
forall value. ToJSVal value => value -> DOM Double
valToNumber)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.closed Mozilla WebKitMediaKeySession.closed documentation> 
getClosed :: (MonadDOM m) => MediaKeySession -> m ()
getClosed :: forall (m :: * -> *). MonadDOM m => MediaKeySession -> m ()
getClosed MediaKeySession
self
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaKeySession (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"closed") JSM JSVal -> (JSVal -> JSM JSVal) -> JSM JSVal
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM JSVal
readPromise))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.keyStatuses Mozilla WebKitMediaKeySession.keyStatuses documentation> 
getKeyStatuses ::
               (MonadDOM m) => MediaKeySession -> m MediaKeyStatusMap
getKeyStatuses :: forall (m :: * -> *).
MonadDOM m =>
MediaKeySession -> m MediaKeyStatusMap
getKeyStatuses MediaKeySession
self
  = DOM MediaKeyStatusMap -> m MediaKeyStatusMap
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaKeySession
self MediaKeySession
-> Getting (JSM JSVal) MediaKeySession (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaKeySession (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"keyStatuses") JSM JSVal
-> (JSVal -> DOM MediaKeyStatusMap) -> DOM MediaKeyStatusMap
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 MediaKeyStatusMap
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.onkeystatuseschange Mozilla WebKitMediaKeySession.onkeystatuseschange documentation> 
keystatuseschange :: EventName MediaKeySession onkeystatuseschange
keystatuseschange :: forall onkeystatuseschange.
EventName MediaKeySession onkeystatuseschange
keystatuseschange
  = DOMString -> EventName MediaKeySession onkeystatuseschange
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"keystatuseschange")

-- | <https://developer.mozilla.org/en-US/docs/Web/API/WebKitMediaKeySession.onmessage Mozilla WebKitMediaKeySession.onmessage documentation> 
message :: EventName MediaKeySession MessageEvent
message :: EventName MediaKeySession MessageEvent
message = DOMString -> EventName MediaKeySession MessageEvent
forall t e. DOMString -> EventName t e
unsafeEventNameAsync (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"message")