jsaddle-dom-0.10.0.0: src/JSDOM/Generated/ChapterInformationInit.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from mediasession (webref). Do not edit.
module JSDOM.Generated.ChapterInformationInit
(newChapterInformationInit, setTitle, getTitle, getTitleUnsafe, getTitleUnchecked, setStartTime, getStartTime, getStartTimeUnsafe, getStartTimeUnchecked, setArtwork, getArtwork, getArtworkUnsafe, getArtworkUnchecked, ChapterInformationInit(..), gTypeChapterInformationInit)
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://w3c.github.io/mediasession/#dictdef-chapterinformationinit ChapterInformationInit specification>
newChapterInformationInit :: (MonadDOM m) => m ChapterInformationInit
newChapterInformationInit = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-title ChapterInformationInit.title specification>
setTitle :: (MonadDOM m, ToJSString val) => ChapterInformationInit -> val -> m ()
setTitle self val = liftDOM (void (self ^. jss "title" (toJSVal val)))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-title ChapterInformationInit.title specification>
getTitle :: (MonadDOM m, FromJSString result) => ChapterInformationInit -> m (Maybe result)
getTitle self = liftDOM (((self ^. js "title") >>= fromMaybeJSString))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-title ChapterInformationInit.title specification>
getTitleUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => ChapterInformationInit -> m result
getTitleUnsafe self = liftDOM ((((self ^. js "title") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-title ChapterInformationInit.title specification>
getTitleUnchecked :: (MonadDOM m, FromJSString result) => ChapterInformationInit -> m result
getTitleUnchecked self = liftDOM (((self ^. js "title") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-starttime ChapterInformationInit.startTime specification>
setStartTime :: (MonadDOM m) => ChapterInformationInit -> Double -> m ()
setStartTime self val = liftDOM (void (self ^. jss "startTime" (toJSVal val)))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-starttime ChapterInformationInit.startTime specification>
getStartTime :: (MonadDOM m) => ChapterInformationInit -> m (Maybe Double)
getStartTime self = liftDOM (((self ^. js "startTime") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-starttime ChapterInformationInit.startTime specification>
getStartTimeUnsafe :: (MonadDOM m, HasCallStack) => ChapterInformationInit -> m Double
getStartTimeUnsafe self = liftDOM ((((self ^. js "startTime") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-starttime ChapterInformationInit.startTime specification>
getStartTimeUnchecked :: (MonadDOM m) => ChapterInformationInit -> m Double
getStartTimeUnchecked self = liftDOM (((self ^. js "startTime") >>= valToNumber))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-artwork ChapterInformationInit.artwork specification>
setArtwork :: (MonadDOM m) => ChapterInformationInit -> [MediaImage] -> m ()
setArtwork self val = liftDOM (void (self ^. jss "artwork" (toJSVal val)))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-artwork ChapterInformationInit.artwork specification>
getArtwork :: (MonadDOM m) => ChapterInformationInit -> m (Maybe [MediaImage])
getArtwork self = liftDOM (((self ^. js "artwork") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-artwork ChapterInformationInit.artwork specification>
getArtworkUnsafe :: (MonadDOM m, HasCallStack) => ChapterInformationInit -> m [MediaImage]
getArtworkUnsafe self = liftDOM ((((self ^. js "artwork") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/mediasession/#dom-chapterinformationinit-artwork ChapterInformationInit.artwork specification>
getArtworkUnchecked :: (MonadDOM m) => ChapterInformationInit -> m [MediaImage]
getArtworkUnchecked self = liftDOM (((self ^. js "artwork") >>= fromJSValUnchecked))