ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/WindowClient.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from service-workers (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.WindowClient
(js_focus, js_navigate, js_getVisibilityState, js_getFocused, focus, focus_, navigate, navigate_, navigateUnsafe, navigateUnchecked, getVisibilityState, getFocused, WindowClient(..), gTypeWindowClient)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums
foreign import javascript interruptible "(($1, $c) => { return $1[\"focus\"]().then(function(s) { $c(null, s);}, function(e) { $c(e, null);}); })"
js_focus :: WindowClient -> IO (JSVal, WindowClient)
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/focus MDN WindowClient.focus documentation>
focus :: (MonadDOM m) => WindowClient -> m WindowClient
focus self = liftDOM (((js_focus (self)) >>= checkPromiseResult))
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/focus MDN WindowClient.focus documentation>
focus_ :: (MonadDOM m) => WindowClient -> m ()
focus_ self = liftDOM (void (((js_focus (self)) >>= checkPromiseResult)))
foreign import javascript interruptible "(($1, $2, $c) => { return $1[\"navigate\"]($2).then(function(s) { $c(null, s);}, function(e) { $c(e, null);}); })"
js_navigate :: WindowClient -> JSString -> IO (JSVal, JSVal)
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/navigate MDN WindowClient.navigate documentation>
navigate :: (MonadDOM m, ToJSString url) => WindowClient -> url -> m (Maybe WindowClient)
navigate self url = liftDOM ((((js_navigate (self) (toJSString url)) >>= checkPromiseResult) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/navigate MDN WindowClient.navigate documentation>
navigate_ :: (MonadDOM m, ToJSString url) => WindowClient -> url -> m ()
navigate_ self url = liftDOM (void (((js_navigate (self) (toJSString url)) >>= checkPromiseResult)))
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/navigate MDN WindowClient.navigate documentation>
navigateUnsafe :: (MonadDOM m, ToJSString url, HasCallStack) => WindowClient -> url -> m WindowClient
navigateUnsafe self url = liftDOM (((((js_navigate (self) (toJSString url)) >>= checkPromiseResult) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/navigate MDN WindowClient.navigate documentation>
navigateUnchecked :: (MonadDOM m, ToJSString url) => WindowClient -> url -> m WindowClient
navigateUnchecked self url = liftDOM ((pFromJSVal <$> ((js_navigate (self) (toJSString url)) >>= checkPromiseResult)))
foreign import javascript unsafe "(($1) => { return $1[\"visibilityState\"]; })"
js_getVisibilityState :: WindowClient -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/visibilityState MDN WindowClient.visibilityState documentation>
getVisibilityState :: (MonadDOM m) => WindowClient -> m DocumentVisibilityState
getVisibilityState self = liftDOM (((js_getVisibilityState (self)) >>= fromJSValUnchecked))
foreign import javascript unsafe "(($1) => { return $1[\"focused\"]; })"
js_getFocused :: WindowClient -> IO Bool
-- | <https://developer.mozilla.org/docs/Web/API/WindowClient/focused MDN WindowClient.focused documentation>
getFocused :: (MonadDOM m) => WindowClient -> m Bool
getFocused self = liftDOM ((js_getFocused (self)))