@@ -34,7 +34,7 @@ foreign export ccall callWithWebView :: WKWebView -> StablePtr (WKWebView -> IO
34foreign export ccall callWithCString :: CString -> StablePtr (CString -> IO ()) -> IO ()
34foreign export ccall callWithCString :: CString -> StablePtr (CString -> IO ()) -> IO ()
35foreign export ccall callIO :: StablePtr (IO ()) -> IO ()
35foreign export ccall callIO :: StablePtr (IO ()) -> IO ()
36foreign import ccall addJSaddleHandler :: WKWebView -> StablePtr (IO ()) -> StablePtr (Results -> IO ()) -> StablePtr (Results -> IO Batch) -> IO ()
36foreign import ccall addJSaddleHandler :: WKWebView -> StablePtr (IO ()) -> StablePtr (Results -> IO ()) -> StablePtr (Results -> IO Batch) -> IO ()
37−foreign import ccall loadHTMLString :: WKWebView -> CString -> IO ()
37+foreign import ccall loadHTMLStringWithBaseURL :: WKWebView -> CString -> CString -> IO ()
38foreign import ccall loadBundleFile :: WKWebView -> CString -> CString -> IO ()
38foreign import ccall loadBundleFile :: WKWebView -> CString -> CString -> IO ()
39foreign import ccall evaluateJavaScript :: WKWebView -> CString -> IO ()
39foreign import ccall evaluateJavaScript :: WKWebView -> CString -> IO ()
40foreign import ccall completeSync :: JSaddleHandler -> CString -> IO ()
40foreign import ccall completeSync :: JSaddleHandler -> CString -> IO ()
@@ -44,7 +44,9 @@ foreign import ccall mainBundleResourcePathC :: IO CString
44jsaddleMain :: JSM () -> WKWebView -> IO ()
44jsaddleMain :: JSM () -> WKWebView -> IO ()
45jsaddleMain f webView =
45jsaddleMain f webView =
46 jsaddleMain' f webView $
46 jsaddleMain' f webView $
47− useAsCString (toStrict indexHtml) $ loadHTMLString webView
47+ useAsCString (toStrict indexHtmlBaseURL) $ \url ->
48+ useAsCString (toStrict indexHtml) $ \html ->
49+ loadHTMLStringWithBaseURL webView html url
49-- | Run JSaddle in a WKWebView first loading the specified file
51-- | Run JSaddle in a WKWebView first loading the specified file
50-- from the mainBundle (relative to the resourcePath).
52-- from the mainBundle (relative to the resourcePath).
@@ -123,6 +125,10 @@ jsaddleJs = ghcjsHelpers <> "\
123 \})();\n\
125 \})();\n\
129+indexHtmlBaseURL :: ByteString
130+indexHtmlBaseURL = "file:///tmp/index.html"
126indexHtml :: ByteString
132indexHtml :: ByteString
127indexHtml =
133indexHtml =
128 "<!DOCTYPE html>\n\
134 "<!DOCTYPE html>\n\
@@ -140,4 +146,3 @@ mainBundleResourcePath = do
140 if bs == nullPtr
146 if bs == nullPtr
141 then return Nothing
147 then return Nothing
142 else Just <$> packCString bs
148 else Just <$> packCString bs