git.iko.soy/typeable/entropy
on main help sign in
ghcjs: Use globalThis instead of window

This allows the global crypto object to be accessed in non-window contexts (e.g., service workers). For more info, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis

commitddda007c44390d0ec8cad58810710864dee60ddd authorAli Abrar <ali.abrar@obsidian.systems> dateThu 30 Dec 2021, 14:29 (5 years ago) parent0916ac5
2 files changed+4−4
System/EntropyGhcjs.hs+3−3 entropy.cabal+1−1
System/EntropyGhcjs.hs+3−3
@@ -19,7 +19,7 @@ import Data.ByteString as B
1919import GHCJS.DOM.Crypto as Crypto
2020import GHCJS.DOM.Types (ArrayBufferView (..), fromJSValUnchecked)
2121import GHCJS.DOM.GlobalCrypto (getCrypto)
22−import GHCJS.DOM (currentWindowUnchecked)
22+import GHCJS.DOM (globalThisUnchecked)
2323import Language.Javascript.JSaddle.Object as JS
2424
2525
@@ -36,8 +36,8 @@ hardwareRandom _ = pure Nothing
3636-- |Open a `CryptHandle`
3737openHandle :: IO CryptHandle
3838openHandle = do
39− w <- currentWindowUnchecked
40− CH <$> getCrypto w
39+ this <- globalThisUnchecked
40+ CH <$> getCrypto this
4141
4242-- |Close the `CryptHandle`
4343closeHandle :: CryptHandle -> IO ()
entropy.cabal+1−1
@@ -50,7 +50,7 @@ library
5050 default-language: Haskell2010
5151
5252 if impl(ghcjs) || os(ghcjs) {
53− build-depends: ghcjs-dom
53+ build-depends: ghcjs-dom >= 0.9.5.0 && < 1
5454 , jsaddle
5555 }
5656 else {