You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mobile resources on ios not loaded by obelisk's static when using a staticFiles derivation #1135
obelisk's static did not handle our staticFiles derivation in nix on ios builds. To fix this, I wrote the following stub. However, the in-module CPP splice breaks HLS when imported and so it should probably be factored into conditional source files.
I've reproduced the inline version here so it can be incorporated upstream without our domain specific cruft.
importCommon.FrontendSite (FrontendSite (..), toFrontendSite)
importControl.Monad.IO.Class (liftIO)
importqualifiedData.TextasTimportLanguage.Haskell.TH (Exp, Q)
importObelisk.Generated.Static (static)
#if !defined(ghcjs_HOST_OS) && !defined(linux_HOST_OS)
importLanguage.Javascript.JSaddle.WKWebView (mainBundleResourcePath)
importqualifiedData.ByteString.Char8asBS8#endif--| Wrap Obelisk's 'static' to produce a path adjusted for mobile builds.---- On iOS/Android (mobile builds) paths must not be absolute (leading '/'),-- otherwise WKWebView/Android WebView may fail to resolve bundled assets.-- We detect mobile via 'Environment' (Stage ∈ {Staging, Prod} with explicit-- Host) and drop any leading '/'. Web builds keep absolute paths.staticWithEnvJSM::FilePath->QExp
staticWithEnvJSM fp =
[|\env ->dolet p =$(static fp) ::T.Textcase toFrontendSite env ofOnMobile _ _ ->dolet p0 =T.dropWhile (=='/') p
p1 =ifT.any (=='/') p0 then p0 else ("static/"<> p0)
#if !defined(ghcjs_HOST_OS) && !defined(linux_HOST_OS)
mbr <- liftIO mainBundleResourcePath
let br =maybe"" (\bs ->T.pack ("file://"<>BS8.unpack bs <>"/")) mbr
pure (br <> p1)
#elsepure p1
#endifOnWeb _ ->pure p
|]
Activity