| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Runtime.Internal
Description
Overview
Miso.Runtime.Internal is a testing-only facade that re-exports the miso runtime's global mutable state from the internal runtime module.
Do not import this module in application code. Mutating any of
the exported IORef values will corrupt the component
lifecycle and produce undefined behaviour. The module exists solely to
give the miso-tests integration-test package direct access to
component state for assertions.
Exported names
components— globalIORefmappingComponentIdtoComponentStatefor every mounted component.componentIds— monotonically increasingIORefused to assign fresh component identifiers.rootComponentId— the well-known identifier of the top-level app component.ComponentState— record holding the live model, scheduler mailbox, and other per-component runtime fields.schedulerThread—IORefholding theThreadIdof the event-loop scheduler thread.unmountComponent/freeLifecycleHooks— teardown functions normally only invoked internally, exposed here so tests can exercise unmounting a specificComponentStatedirectly instead of going through a full diff-driven removal.
See also
- Miso.Reload — uses these internals to kill and restart the scheduler on
:r
Synopsis
- components :: IORef (IntMap (ComponentState context props model action))
- componentIds :: IORef Int
- rootComponentId :: ComponentId
- data ComponentState context props model action = ComponentState {
- _componentId :: ComponentId
- _componentKey :: Maybe Key
- _componentStaticKey :: Maybe StaticKey
- _componentParentId :: ComponentId
- _componentProps :: props
- _prevComponentProps :: props
- _componentSubThreads :: IORef (Map MisoString ThreadId)
- _componentDOMRef :: DOMRef
- _componentVTree :: IORef VTree
- _componentSink :: action -> IO ()
- _componentPostEffect :: Sink action
- _componentModel :: model
- _componentScripts :: [DOMRef]
- _componentEvents :: Events
- _componentUseContext :: Bool
- _componentMailbox :: Value -> Maybe action
- _componentDraw :: model -> IO ()
- _componentHydrate :: model -> IO ()
- _componentPropsPhase :: props -> props -> IO ()
- _componentModelDirty :: model -> model -> Bool
- _componentApplyActions :: Seq action -> model -> props -> context -> (model, [Schedule context action])
- _componentTopics :: Map MisoString (Value -> IO ())
- _componentChildren :: ComponentIds
- type ComponentIds = IntSet
- schedulerThread :: IORef ThreadId
- unmountComponent :: Eq context => ComponentState context props model action -> IO ()
- freeLifecycleHooks :: ComponentState context props model action -> IO ()
- inline :: (FromJSVal return, ToObject object) => MisoString -> object -> IO return
- newtype Event = Event JSVal
- diff :: Object -> Object -> JSVal -> IO ()
- flush :: IO ()
- select :: MisoString -> IO ()
- set :: ToJSVal v => MisoString -> v -> Object -> IO ()
- newtype Image = Image JSVal
- cookieGet :: MisoString -> (JSVal -> IO ()) -> (MisoString -> IO ()) -> IO ()
- cookieGetAll :: (JSVal -> IO ()) -> (MisoString -> IO ()) -> IO ()
- cookieSet :: JSVal -> IO () -> (MisoString -> IO ()) -> IO ()
- cookieDelete :: MisoString -> IO () -> (MisoString -> IO ()) -> IO ()
- cookieDeleteWith :: JSVal -> IO () -> (MisoString -> IO ()) -> IO ()
- newtype Date = Date JSVal
- toLocaleString :: Date -> IO MisoString
- getMilliseconds :: Date -> IO Double
- getSeconds :: Date -> IO Double
- callFunction :: ToArgs args => JSVal -> MisoString -> args -> IO JSVal
- syncCallback :: IO () -> IO JSVal
- syncCallback1 :: (JSVal -> IO ()) -> IO JSVal
- syncCallback2 :: (JSVal -> JSVal -> IO ()) -> IO JSVal
- asyncCallback :: IO () -> IO JSVal
- asyncCallback1 :: (JSVal -> IO ()) -> IO JSVal
- asyncCallback2 :: (JSVal -> JSVal -> IO ()) -> IO JSVal
- data CONTENT_TYPE
- data Response body = Response {
- status :: Maybe Int
- headers :: Map MisoString MisoString
- errorMessage :: Maybe MisoString
- body :: body
- fetch :: (FromJSVal success, FromJSVal error) => MisoString -> MisoString -> Maybe JSVal -> [(MisoString, MisoString)] -> (Response success -> IO ()) -> (Response error -> IO ()) -> CONTENT_TYPE -> IO ()
- newtype Blob = Blob JSVal
- newtype FormData = FormData JSVal
- newtype ArrayBuffer = ArrayBuffer JSVal
- newtype Uint8Array = Uint8Array JSVal
- now :: IO Double
- consoleLog :: MisoString -> IO ()
- consoleLog' :: ToArgs a => a -> IO ()
- consoleError :: MisoString -> IO ()
- consoleWarn :: MisoString -> IO ()
- getElementById :: MisoString -> IO JSVal
- focus :: MisoString -> IO ()
- blur :: MisoString -> IO ()
- setSelectionRange :: MisoString -> Int -> Int -> IO ()
- alert :: MisoString -> IO ()
- getProperty :: JSVal -> MisoString -> IO JSVal
- castJSVal :: FromJSVal a => JSVal -> IO (Maybe a)
- removeChild :: JSVal -> JSVal -> IO ()
- addStyle :: MisoString -> IO JSVal
- addStyleSheet :: MisoString -> Bool -> IO JSVal
- addSrc :: MisoString -> Bool -> IO JSVal
- addScript :: Bool -> MisoString -> IO JSVal
- addScriptImportMap :: MisoString -> IO JSVal
- setDrawingContext :: MisoString -> IO ()
- windowInnerWidth :: IO Int
- windowInnerHeight :: IO Int
- locationReload :: IO ()
- newImage :: MisoString -> IO Image
- newDate :: IO Date
- nextSibling :: JSVal -> IO JSVal
- previousSibling :: JSVal -> IO JSVal
- click :: () -> JSVal -> IO ()
- setValue :: JSVal -> MisoString -> IO ()
- files :: JSVal -> IO [JSVal]
- isOnLine :: IO Bool
- onBTS :: IO Bool
- onMTS :: IO Bool
- getThreads :: IO (Bool, Bool, Bool)
- newtype File = File JSVal
- newtype URLSearchParams = URLSearchParams JSVal
- newtype FileReader = FileReader JSVal
- newFileReader :: IO FileReader
- addEventListener :: JSVal -> MisoString -> (JSVal -> IO ()) -> IO Function
- removeEventListener :: JSVal -> MisoString -> Function -> IO ()
- dispatchEvent :: Event -> IO ()
- newEvent :: ToArgs args => args -> IO Event
- newCustomEvent :: ToArgs args => args -> IO Event
- eventPreventDefault :: JSVal -> IO ()
- eventStopPropagation :: JSVal -> IO ()
- scrollIntoView :: MisoString -> IO ()
- requestFullscreen :: IO ()
- splitmix32 :: Double -> IO JSVal
- mathRandom :: IO Double
- getUserMedia :: Bool -> Bool -> (JSVal -> IO ()) -> (JSVal -> IO ()) -> IO ()
- copyClipboard :: MisoString -> IO () -> (JSVal -> IO ()) -> IO ()
- geolocation :: (JSVal -> IO ()) -> (JSVal -> IO ()) -> IO ()
- delegator :: JSVal -> JSVal -> Bool -> IO JSVal -> IO ()
- hydrate :: Bool -> JSVal -> JSVal -> IO JSVal
- windowAddEventListener :: MisoString -> (JSVal -> IO ()) -> IO Function
- windowRemoveEventListener :: MisoString -> Function -> IO ()
- eventJSON :: JSVal -> JSVal -> IO JSVal
- getBody :: IO JSVal
- getDocument :: IO JSVal
- getDrawingContext :: IO JSVal
- getHydrationContext :: IO JSVal
- getEventContext :: IO JSVal
- getHead :: IO JSVal
- websocketConnect :: MisoString -> IO () -> (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> (JSVal -> IO ()) -> Bool -> IO JSVal
- websocketClose :: JSVal -> IO ()
- websocketSend :: JSVal -> JSVal -> IO ()
- eventSourceConnect :: MisoString -> IO () -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> (JSVal -> IO ()) -> Bool -> IO JSVal
- eventSourceClose :: JSVal -> IO ()
- cookieStoreAddEventListener :: (JSVal -> IO ()) -> IO Function
- cookieStoreRemoveEventListener :: Function -> IO ()
- populateClass :: JSVal -> [MisoString] -> IO ()
- updateRef :: ToJSVal val => val -> val -> IO ()
- getRandomValue :: IO Double
Documentation
components :: IORef (IntMap (ComponentState context props model action)) Source #
componentIds :: IORef Int Source #
The global store of ComponentId, for internal-use only.
Used internally freshComponentId to allocate new ComponentId on
mount.
rootComponentId :: ComponentId Source #
This is used to demarcate the ROOT of a page. This ID will *never*
exist in the components map.
data ComponentState context props model action Source #
Constructors
| ComponentState | |
Fields
| |
type ComponentIds = IntSet Source #
The set of child ComponentIds a component currently has
mounted (the _componentChildren field of ComponentState).
schedulerThread :: IORef ThreadId Source #
Placeholder passed to a Props constructor when only the resulting
SomeComponent's types (model / props / action) are needed, not a
real props value — e.g. to recover the action type for decoding. Safe
because every Props built by mount_ / mountWithProps / (+>) is lazy
in its props argument, so applying it never forces this.
Used for unidirectional BTS -> MTS communication
dmj: This only runs on the MTS.
Dispatch a main-thread (MTS) event on the Haskell layer.
Invoked synchronously by the MTS delegator (see ts/miso/native/mts/context.ts)
with a { componentId, staticKey, event, target } object. Recovers the event
handler by its StaticKey, runs it against the owning component's Sink to
install its decode+dispatch closure on a scratch node, then invokes that
closure with the live event and target DOMRef. No BTS round-trip — the
handler runs entirely on the main thread, and its update/effects run there
(the scheduler suppresses the redraw; see scheduler).
N.B. unsafeLookupStaticPtr recovers the handler at the component's action
type. This is sound because the (componentId, staticKey) pair is emitted
together from the same component's setAttrs; the handler's action unifies
with the sink's via the quantified components CAF (no unsafeCoerce).
Dispatches a COMPONENT lifecycle message (BTS → MTS) on the
"Miso.components" channel. No-op for components without a StaticKey
(e.g. the root), since the MTS locates the component via unsafeLookupStaticPtr.
Dispatches an EFFECT message carrying a serialized action across the
Lynx thread boundary on the "Miso.effects" channel:
- MTS → BTS when called on the main thread (
mts). - BTS → MTS when called on the background thread (
bts).
A no-op on plain web builds (neither mts nor bts).
Global variable to hold the scheduler thread
N.B. undefined is safe here, it will always get populated.
Also, we use this in cleanup when interactive mode (GHCi) is detected
in that circumstance schedulerThread will always be populated. It's an
invariant.
unmountComponent :: Eq context => ComponentState context props model action -> IO () Source #
Helper function for cleanly destroying a Component
freeLifecycleHooks :: ComponentState context props model action -> IO () Source #
Helper to drop all lifecycle and mounting hooks if defined.
inline :: (FromJSVal return, ToObject object) => MisoString -> object -> IO return Source #
Convenience function to write inline javascript.
Prefer this function over the use of eval.
This function takes as arguments a JavaScript object and makes the keys available in the function body.
data Person = Person { name :: MisoString, age :: Int }
deriving stock (Generic)
deriving anyclass (ToJSVal, ToObject)
logNameGetAge :: Person -> IO Int
logNameGetAge = inline
"""
console.log(name, name);
return age;
"""
Diff two virtual DOMs
Flush is used to force a draw of the render tree. This is currently only used when targeting platforms other than the browser (like mobile).
select :: MisoString -> IO () Source #
Fails silently if the element is not found.
Analogous to document.querySelector(.# + id).select()
Arguments
| :: ToJSVal v | |
| => MisoString | Property name to set |
| -> v | Value to assign |
| -> Object | JavaScript object to mutate |
| -> IO () |
Set property on object
Type that holds an Image.
Arguments
| :: MisoString | Cookie name |
| -> (JSVal -> IO ()) | Successful callback |
| -> (MisoString -> IO ()) | Errorful callback |
| -> IO () |
Retrieve a single cookie by name from the CookieStore API.
The successful callback receives a null JSVal when no cookie with
that name exists. The errorful callback receives the error message string.
See https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/get
Since: 1.13.0.0
Arguments
| :: (JSVal -> IO ()) | Successful callback (receives a JS array of cookie objects) |
| -> (MisoString -> IO ()) | Errorful callback |
| -> IO () |
Retrieve all cookies from the CookieStore API.
See https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/getAll
Since: 1.13.0.0
Arguments
| :: JSVal | Cookie options object (serialised |
| -> IO () | Successful callback |
| -> (MisoString -> IO ()) | Errorful callback |
| -> IO () |
Set a cookie via the CookieStore API.
See https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/set
Since: 1.13.0.0
Arguments
| :: MisoString | Cookie name |
| -> IO () | Successful callback |
| -> (MisoString -> IO ()) | Errorful callback |
| -> IO () |
Delete a cookie by name via the CookieStore API.
See https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/delete
Since: 1.13.0.0
Arguments
| :: JSVal | Cookie options object (name, path, domain, partitioned) |
| -> IO () | Successful callback |
| -> (MisoString -> IO ()) | Errorful callback |
| -> IO () |
Delete a cookie by options object via the CookieStore API.
See https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/delete
Since: 1.13.0.0
toLocaleString :: Date -> IO MisoString Source #
Date conversion function to produce a locale
callFunction :: ToArgs args => JSVal -> MisoString -> args -> IO JSVal Source #
Calls a function on a JSVal
Example usage:
callFunction domRef "focus" () callFunction domRef "setSelectionRange" (0, 3, "none")
syncCallback2 :: (JSVal -> JSVal -> IO ()) -> IO JSVal Source #
A synchronous callback with two arguments
asyncCallback2 :: (JSVal -> JSVal -> IO ()) -> IO JSVal Source #
A asynchronous callback with two arguments
data CONTENT_TYPE Source #
List of possible content types that are available for use with the fetch API
Instances
| Show CONTENT_TYPE Source # | |
Defined in Miso.FFI.Internal Methods showsPrec :: Int -> CONTENT_TYPE -> ShowS # show :: CONTENT_TYPE -> String # showList :: [CONTENT_TYPE] -> ShowS # | |
| Eq CONTENT_TYPE Source # | |
Defined in Miso.FFI.Internal | |
| ToJSVal CONTENT_TYPE Source # | |
Defined in Miso.FFI.Internal | |
Type returned from a fetch request
Constructors
| Response | |
Fields
| |
Arguments
| :: (FromJSVal success, FromJSVal error) | |
| => MisoString | url |
| -> MisoString | method |
| -> Maybe JSVal | body |
| -> [(MisoString, MisoString)] | headers |
| -> (Response success -> IO ()) | successful callback |
| -> (Response error -> IO ()) | errorful callback |
| -> CONTENT_TYPE | content type |
| -> IO () |
Retrieve JSON via Fetch API
Basic GET of JSON using Fetch API, will be expanded upon.
See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
newtype ArrayBuffer Source #
Constructors
| ArrayBuffer JSVal |
Instances
| Eq ArrayBuffer Source # | |
Defined in Miso.FFI.Internal | |
| FromJSVal ArrayBuffer Source # | |
Defined in Miso.FFI.Internal Methods fromJSVal :: JSVal -> IO (Maybe ArrayBuffer) Source # fromJSValUnchecked :: JSVal -> IO ArrayBuffer Source # | |
| ToJSVal ArrayBuffer Source # | |
Defined in Miso.FFI.Internal | |
newtype Uint8Array Source #
Constructors
| Uint8Array JSVal |
Instances
| FromJSVal Uint8Array Source # | |
Defined in Miso.FFI.Internal Methods fromJSVal :: JSVal -> IO (Maybe Uint8Array) Source # fromJSValUnchecked :: JSVal -> IO Uint8Array Source # | |
| ToJSVal Uint8Array Source # | |
Defined in Miso.FFI.Internal | |
Retrieve high resolution time stamp
See https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
Lynx's *background* thread realm has no performance global at all - only
the main thread does - so the obvious performance.now() throws
cannot read property there. Everything that timestamps
from the BTS goes through here, including gesture handling like
double-tap detection, so that throw took real features down rather than
merely losing precision. Falls back to now of undefinedDate.now(), which every realm has.
consoleLog :: MisoString -> IO () Source #
Outputs a message to the web console
See https://developer.mozilla.org/en-US/docs/Web/API/Console/log
Console logging of JavaScript strings.
consoleLog' :: ToArgs a => a -> IO () Source #
Console-logging of JSVal
consoleError :: MisoString -> IO () Source #
Outputs an error message to the web console
See https://developer.mozilla.org/en-US/docs/Web/API/Console/error
Console logging of JavaScript strings.
consoleWarn :: MisoString -> IO () Source #
Outputs a warning message to the web console
See https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
Console logging of JavaScript strings.
getElementById :: MisoString -> IO JSVal Source #
Returns an Element object representing the element whose id property matches the specified string.
See https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById
focus :: MisoString -> IO () Source #
Fails silently if the element is not found.
Analogous to document.getElementById(id).focus().
blur :: MisoString -> IO () Source #
Fails silently if the element is not found.
Analogous to document.getElementById(id).blur()
Arguments
| :: MisoString | DOM element |
| -> Int | Selection start index (inclusive) |
| -> Int | Selection end index (exclusive) |
| -> IO () |
Fails silently if the element is not found.
Analogous to document.querySelector(.# + id).setSelectionRange(start, end, 'none')
alert :: MisoString -> IO () Source #
Calls the alert() function.
Arguments
| :: JSVal | JavaScript object to read from |
| -> MisoString | Property name to retrieve |
| -> IO JSVal |
Get a property of a JSVal
Example usage:
Just (value :: String) <- fromJSVal =<< getProperty domRef "value"
castJSVal :: FromJSVal a => JSVal -> IO (Maybe a) Source #
Marshalling of JSVal, useful for getProperty
removeChild :: JSVal -> JSVal -> IO () Source #
Removes a child node from a parent node.
Calls miso.drawingContext.removeChild(parent, child).
Since: 1.9.0.0
addStyleSheet :: MisoString -> Bool -> IO JSVal Source #
addSrc :: MisoString -> Bool -> IO JSVal Source #
Appends a <script> element to head_
addSrc "https://example.com/script.js"
addScriptImportMap :: MisoString -> IO JSVal Source #
Appends a script_ element containing a JS import map.
addScript "{ \"import\" : { \"three\" : \"url\" } }"setDrawingContext :: MisoString -> IO () Source #
Used to select a drawing context. Users can override the default DOM renderer by implementing their own Context, and exporting it to the global scope. This opens the door to different rendering engines, ala miso-lynx.
windowInnerWidth :: IO Int Source #
Retrieves the width (in pixels) of the browser window viewport including if rendered, the vertical scrollbar.
See https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth
windowInnerHeight :: IO Int Source #
Retrieves the height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.
See https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
locationReload :: IO () Source #
Calls the location.reload() function.
setValue :: JSVal -> MisoString -> IO () Source #
Sets the .value property on a DOMRef.
Useful for resetting the value property on an input element.
setValue domRef ("" :: MisoString)
files :: JSVal -> IO [JSVal] Source #
When working with <input type="file">, this is useful for
extracting out the selected files.
update (InputClicked inputElement) = withSink $ \sink -> do
files_ <- files inputElement
forM_ files_ $ \file -> sink (Upload file)
update (Upload file) = do
fetch "https://localhost:8080/upload" "POST" (Just file) []
Successful Errorful
Since: 1.9.0.0
Navigator function to query the current online status of the user's computer
See navigator.onLine
Returns True when executing on the Lynx background thread (BTS),
False on the main thread or in a web build.
Backed by miso.onBTS(), which uses the BACKGROUND compile-time
define injected by rspeedy. In web builds where BACKGROUND is
undefined the function safely returns false.
Since: 1.13.0.0
Returns True when executing on the Lynx main thread (MTS),
False on the background thread and in web builds.
Since: 1.13.0.0
getThreads :: IO (Bool, Bool, Bool) Source #
Returns (mts, bts, web): whether the current execution context is the
Lynx main thread, Lynx background thread, or a plain web build.
Since: 1.13.0.0
newtype URLSearchParams Source #
Constructors
| URLSearchParams JSVal |
Instances
| Eq URLSearchParams Source # | |
Defined in Miso.FFI.Internal Methods (==) :: URLSearchParams -> URLSearchParams -> Bool # (/=) :: URLSearchParams -> URLSearchParams -> Bool # | |
| FromJSVal URLSearchParams Source # | |
Defined in Miso.FFI.Internal | |
| ToJSVal URLSearchParams Source # | |
Defined in Miso.FFI.Internal | |
| ToObject URLSearchParams Source # | |
Defined in Miso.FFI.Internal | |
newtype FileReader Source #
Constructors
| FileReader JSVal |
Instances
| Eq FileReader Source # | |
Defined in Miso.FFI.Internal | |
| FromJSVal FileReader Source # | |
Defined in Miso.FFI.Internal Methods fromJSVal :: JSVal -> IO (Maybe FileReader) Source # fromJSValUnchecked :: JSVal -> IO FileReader Source # | |
| ToJSVal FileReader Source # | |
Defined in Miso.FFI.Internal | |
| ToObject FileReader Source # | |
Defined in Miso.FFI.Internal | |
newFileReader :: IO FileReader Source #
Smart constructor for building a FileReader
Arguments
| :: JSVal | Event target on which we want to register event listener |
| -> MisoString | Type of event to listen to (e.g. "click") |
| -> (JSVal -> IO ()) | Callback which will be called when the event occurs, the event will be passed to it as a parameter. |
| -> IO Function |
Register an event listener on given target.
Arguments
| :: JSVal | Event target from which we want to remove event listener |
| -> MisoString | Type of event to listen to (e.g. "click") |
| -> Function | Callback which will be called when the event occurs, the event will be passed to it as a parameter. |
| -> IO () |
Removes an event listener from given target.
dispatchEvent :: Event -> IO () Source #
Invokes document.dispatchEvent
update ChangeTheme = io_ $ do
themeEvent <- newEvent "basecoat:theme"
dispatchEvent themeEvent
newEvent :: ToArgs args => args -> IO Event Source #
Creates a new Event
update ChangeTheme = io_ $ do
themeEvent <- newEvent "basecoat:theme"
dispatchEvent themeEvent
newCustomEvent :: ToArgs args => args -> IO Event Source #
Creates a new Event
update ToggleSidebar = io_ $ do
themeEvent <- newCustomEvent "basecoat:sidebar"
dispatchEvent themeEvent
eventPreventDefault :: JSVal -> IO () Source #
Prevent default event behavior
eventStopPropagation :: JSVal -> IO () Source #
Stop propagation of events
scrollIntoView :: MisoString -> IO () Source #
Calls document.getElementById(id).scrollIntoView()
requestFullscreen :: IO () Source #
Calls document.documentElement.requestFullscreen(), falling back to
webkitRequestFullscreen for Safari.
mathRandom :: IO Double Source #
Uses the 'Math.random()' function.
Get Camera on user's device
https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
Arguments
| :: MisoString | Text to copy |
| -> IO () | successful |
| -> (JSVal -> IO ()) | errorful |
| -> IO () |
geolocation :: (JSVal -> IO ()) -> (JSVal -> IO ()) -> IO () Source #
Reads the device position via navigator.geolocation.getCurrentPosition.
Since: 1.13.0.0
delegator :: JSVal -> JSVal -> Bool -> IO JSVal -> IO () Source #
Initialize event delegation from a mount point.
hydrate :: Bool -> JSVal -> JSVal -> IO JSVal Source #
Copies DOM pointers into virtual dom entry point into isomorphic javascript
See hydration)
windowAddEventListener Source #
Arguments
| :: MisoString | Type of event to listen to (e.g. "click") |
| -> (JSVal -> IO ()) | Callback which will be called when the event occurs, the event will be passed to it as a parameter. |
| -> IO Function |
Registers an event listener on window
windowRemoveEventListener Source #
Arguments
| :: MisoString | Type of event to listen to (e.g. "click") |
| -> Function | Callback which will be called when the event occurs, the event will be passed to it as a parameter. |
| -> IO () |
Removes an event listener from window
Convert a JavaScript object to JSON JSONified representation of events
Retrieves a reference to document body.
See https://developer.mozilla.org/en-US/docs/Web/API/Document/body
getDocument :: IO JSVal Source #
Retrieves a reference to the document.
See https://developer.mozilla.org/en-US/docs/Web/API/Document
getDrawingContext :: IO JSVal Source #
Retrieves a reference to the drawing context.
This is a miso specific construct used to provide an identical interface for both native (iOS / Android, etc.) and browser environments.
getHydrationContext :: IO JSVal Source #
Retrieves a reference to the hydration context.
This is a miso specific construct used to provide an identical interface for both native (iOS / Android, etc.) and browser environments.
getEventContext :: IO JSVal Source #
Retrieves a reference to the event context.
This is a miso specific construct used to provide an identical interface for both native (iOS / Android, etc.) and browser environments.
Retrieves a reference to the renderer's "head" mount.
Calls miso.drawingContext.getHead().
Note: custom renderers should implement this method.
Since: 1.9.0.0
websocketConnect :: MisoString -> IO () -> (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> (JSVal -> IO ()) -> Bool -> IO JSVal Source #
Establishes a WebSocket connection
websocketClose :: JSVal -> IO () Source #
Closes an open WebSocket.
Since: 1.13.0.0
websocketSend :: JSVal -> JSVal -> IO () Source #
Sends a payload over an open WebSocket.
Since: 1.13.0.0
eventSourceConnect :: MisoString -> IO () -> Maybe (JSVal -> IO ()) -> Maybe (JSVal -> IO ()) -> (JSVal -> IO ()) -> Bool -> IO JSVal Source #
Opens a Server-Sent Events connection and wires up its callbacks.
Since: 1.13.0.0
eventSourceClose :: JSVal -> IO () Source #
Closes an open Server-Sent Events connection.
Since: 1.13.0.0
cookieStoreAddEventListener :: (JSVal -> IO ()) -> IO Function Source #
Register a listener for
cookieStore change
events. Returns the Function handle needed to remove the listener later.
When the CookieStore API is unavailable (e.g. Firefox, insecure contexts)
no listener is registered and an inert Function handle is returned.
cookieStoreRemoveEventListener :: Function -> IO () Source #
Remove a previously registered cookieStore change listener.
When the CookieStore API is unavailable this is a no-op.
Arguments
| :: JSVal | Node |
| -> [MisoString] | classes |
| -> IO () |
Populate the classList Set on the virtual DOM.
updateRef :: ToJSVal val => val -> val -> IO () Source #
Used to update the JavaScript reference post-diff.
getRandomValue :: IO Double Source #
Uses the first element of 'crypto.getRandomValues()'.