@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE ScopedTypeVariables #-}
23{-# LANGUAGE OverloadedStrings #-}
34{-# LANGUAGE PatternSynonyms #-}
@@ -16,15 +17,26 @@
1617module Language.Javascript.JSaddle.WebKitGTK (
1718 -- * Running JSM in a WebView
1819 run
20+#ifndef ghcjs_HOST_OS
1921 , runInWebView
22+#endif
2023 ) where
2124
25+#ifdef ghcjs_HOST_OS
26+
27+run = IO () -> IO ()
28+run = id
29+{-# INLINE run #-}
30+
31+#else
32+
2233import Control.Monad (when, void)
2334import qualified Control.Exception as E (catch)
2435import Control.Exception (SomeException(..))
2536import Control.Concurrent (forkIO, yield)
2637
27−import System.Posix.Signals (installHandler)
38+import System.Posix.Signals
39+ (Handler(..), keyboardSignal, installHandler)
2840import System.Directory (getCurrentDirectory)
2941
3042import Data.Monoid ((<>))
@@ -200,12 +212,14 @@ addJSaddleHandler ctxRef processResult = do
200212 jsvaluemakeundefined ctxRef
201213
202214jsaddleJs :: LB.ByteString
203−jsaddleJs = ghcjsHelpers <> "\
204− \(function() {\n\
205− \ " <> initState <> "\n\
206− \ return function(batchJSON) {\n\
207− \ var batch = JSON.parse(batchJSON);\n\
208− \ " <> runBatch (\a -> "window.jsaddleCallback(JSON.stringify(" <> a <> "));") <> "\
209− \ };\n\
210− \})()\n\
211− \"
215+jsaddleJs = ghcjsHelpers <> mconcat
216+ [ "(function() {\n"
217+ , initState
218+ , "\nreturn function(batchJSON) {\n"
219+ , " var batch = JSON.parse(batchJSON);\n"
220+ , runBatch (\a -> "window.jsaddleCallback(JSON.stringify(" <> a <> "));\n")
221+ , "};\n"
222+ , "})()\n"
223+ ]
224+
225+#endif