on master help sign in
Rename WebKit2GTK to WebKitGTK
4a88ba0Hamish Mackenzie
jsaddle-warp/jsaddle-warp.cabal+1
@@ -17,6 +17,7 @@ author: Hamish Mackenzie
17source-repository head
17source-repository head
18 type: git
18 type: git
19 location: https://github.com/ghcjs/jsaddle
19 location: https://github.com/ghcjs/jsaddle
20+ subdir: jsaddle-warp
20
21
21library
22library
22
23
jsaddle-webkit2gtk/jsaddle-webkit2gtk.cabal+6−2
@@ -1,5 +1,5 @@
1name: jsaddle-webkit2gtk
1name: jsaddle-webkit2gtk
2−version: 0.8.0.0
2+version: 0.8.1.0
3cabal-version: >=1.10
3cabal-version: >=1.10
4build-type: Simple
4build-type: Simple
5license: MIT
5license: MIT
@@ -17,11 +17,15 @@ author: Hamish Mackenzie
17source-repository head
17source-repository head
18 type: git
18 type: git
19 location: https://github.com/ghcjs/jsaddle
19 location: https://github.com/ghcjs/jsaddle
20+ subdir: jsaddle-webkit2gtk
20
21
21library
22library
22 exposed-modules:
23 exposed-modules:
23− Language.Javascript.JSaddle.WebKit2GTK
24+ Language.Javascript.JSaddle.WebKitGTK
24 build-depends:
25 build-depends:
26+ base <5
27+ if !impl(ghcjs -any)
28+ build-depends:
25 aeson >=0.8.0.2 && <1.1,
29 aeson >=0.8.0.2 && <1.1,
26 base <5,
30 base <5,
27 bytestring >=0.10.6.0 && <0.11,
31 bytestring >=0.10.6.0 && <0.11,
jsaddle-webkit2gtk/src/Language/Javascript/JSaddle/WebKit2GTK.hs → jsaddle-webkit2gtk/src/Language/Javascript/JSaddle/WebKitGTK.hsrenamed+22−9
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE PatternSynonyms #-}
4{-# LANGUAGE PatternSynonyms #-}
@@ -13,12 +14,22 @@
13-- |
14-- |
14--
15--
15-----------------------------------------------------------------------------
16-----------------------------------------------------------------------------
16−module Language.Javascript.JSaddle.WebKit2GTK (
17+module Language.Javascript.JSaddle.WebKitGTK (
17 -- * Running JSM in a WebView
18 -- * Running JSM in a WebView
18 run
19 run
20+#ifndef ghcjs_HOST_OS
19 , runInWebView
21 , runInWebView
22+#endif
20 ) where
23 ) where
21
24
25+#ifdef ghcjs_HOST_OS
26+
27+run = IO () -> IO ()
28+run = id
29+{-# INLINE run #-}
30+
31+#else
32+
22import Control.Monad (void)
33import Control.Monad (void)
23import Control.Monad.IO.Class (MonadIO(..), MonadIO)
34import Control.Monad.IO.Class (MonadIO(..), MonadIO)
24import Control.Concurrent (forkIO, yield)
35import Control.Concurrent (forkIO, yield)
@@ -166,11 +177,13 @@ addJSaddleHandler webView processResult = do
166 void $ userContentManagerRegisterScriptMessageHandler manager "jsaddle"
177 void $ userContentManagerRegisterScriptMessageHandler manager "jsaddle"
167
178
168jsaddleJs :: LB.ByteString
179jsaddleJs :: LB.ByteString
169−jsaddleJs = ghcjsHelpers <> "\
180+jsaddleJs = ghcjsHelpers <> mconcat
170− \runJSaddleBatch = (function() {\n\
181+ [ "runJSaddleBatch = (function() {\n"
171− \ " <> initState <> "\n\
182+ , initState
172− \ return function(batch) {\n\
183+ , "\nreturn function(batch) {\n"
173− \ " <> runBatch (\a -> "window.webkit.messageHandlers.jsaddle.postMessage(JSON.stringify(" <> a <> "));") <> "\
184+ , runBatch (\a -> "window.webkit.messageHandlers.jsaddle.postMessage(JSON.stringify(" <> a <> "));\n")
174− \ };\n\
185+ , "};\n"
175− \})()\n\
186+ , "})()"
176− \"
187+ ]
188+
189+#endif
jsaddle-webkitgtk/jsaddle-webkitgtk.cabal+2−1
@@ -1,5 +1,5 @@
1name: jsaddle-webkitgtk
1name: jsaddle-webkitgtk
2−version: 0.8.0.0
2+version: 0.8.1.0
3cabal-version: >=1.10
3cabal-version: >=1.10
4build-type: Simple
4build-type: Simple
5license: MIT
5license: MIT
@@ -17,6 +17,7 @@ author: Hamish Mackenzie
17source-repository head
17source-repository head
18 type: git
18 type: git
19 location: https://github.com/ghcjs/jsaddle
19 location: https://github.com/ghcjs/jsaddle
20+ subdir: jsaddle-webkitgtk
20
21
21library
22library
22 exposed-modules:
23 exposed-modules:
jsaddle-webkitgtk/src/Language/Javascript/JSaddle/WebKitGTK.hs+24−10
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE PatternSynonyms #-}
4{-# LANGUAGE PatternSynonyms #-}
@@ -16,15 +17,26 @@
16module Language.Javascript.JSaddle.WebKitGTK (
17module Language.Javascript.JSaddle.WebKitGTK (
17 -- * Running JSM in a WebView
18 -- * Running JSM in a WebView
18 run
19 run
20+#ifndef ghcjs_HOST_OS
19 , runInWebView
21 , runInWebView
22+#endif
20 ) where
23 ) where
21
24
25+#ifdef ghcjs_HOST_OS
26+
27+run = IO () -> IO ()
28+run = id
29+{-# INLINE run #-}
30+
31+#else
32+
22import Control.Monad (when, void)
33import Control.Monad (when, void)
23import qualified Control.Exception as E (catch)
34import qualified Control.Exception as E (catch)
24import Control.Exception (SomeException(..))
35import Control.Exception (SomeException(..))
25import Control.Concurrent (forkIO, yield)
36import Control.Concurrent (forkIO, yield)
26
37
27−import System.Posix.Signals (installHandler)
38+import System.Posix.Signals
39+ (Handler(..), keyboardSignal, installHandler)
28import System.Directory (getCurrentDirectory)
40import System.Directory (getCurrentDirectory)
29
41
30import Data.Monoid ((<>))
42import Data.Monoid ((<>))
@@ -200,12 +212,14 @@ addJSaddleHandler ctxRef processResult = do
200 jsvaluemakeundefined ctxRef
212 jsvaluemakeundefined ctxRef
201
213
202jsaddleJs :: LB.ByteString
214jsaddleJs :: LB.ByteString
203−jsaddleJs = ghcjsHelpers <> "\
215+jsaddleJs = ghcjsHelpers <> mconcat
204− \(function() {\n\
216+ [ "(function() {\n"
205− \ " <> initState <> "\n\
217+ , initState
206− \ return function(batchJSON) {\n\
218+ , "\nreturn function(batchJSON) {\n"
207− \ var batch = JSON.parse(batchJSON);\n\
219+ , " var batch = JSON.parse(batchJSON);\n"
208− \ " <> runBatch (\a -> "window.jsaddleCallback(JSON.stringify(" <> a <> "));") <> "\
220+ , runBatch (\a -> "window.jsaddleCallback(JSON.stringify(" <> a <> "));\n")
209− \ };\n\
221+ , "};\n"
210− \})()\n\
222+ , "})()\n"
211− \"
223+ ]
224+
225+#endif
jsaddle/jsaddle.cabal+1
@@ -17,6 +17,7 @@ author: Hamish Mackenzie
17source-repository head
17source-repository head
18 type: git
18 type: git
19 location: https://github.com/ghcjs/jsaddle
19 location: https://github.com/ghcjs/jsaddle
20+ subdir: jsaddle
20
21
21library
22library
22
23