-
Notifications
You must be signed in to change notification settings - Fork 11
Description
When using WebGL, you might use WebGL.load to load a texture and store it in the model so you can use it later to render WebGL stuff. However, that type contains a function, which has a few problems:
- It can’t be transferred correctly from and old app to a new app when migrating during a release. Your new app will crash when it tries to use the texture.
- There is no compilation error if you put it in
ToFrontendandToBackendmsgs, but it can’t be serialized due to the function inside.
The File type from elm/file used to have the same problems, but Lamdera has added support for it. We should do the same for Texture.
-
Support
Texturein the wire format using references:compiler/extra/Lamdera/Wire3/Decoder.hs
Lines 351 to 352 in 74a141e
-- Frontend only JS reference types TType (Module.Canonical (Name "elm" "file") "File") "File" params -> callDecoder "decodeRef" tipe compiler/extra/Lamdera/Wire3/Encoder.hs
Lines 214 to 216 in 74a141e
-- Frontend only JS reference types TType (Module.Canonical (Name "elm" "file") "File") "File" _ -> (a (VarForeign mLamdera_Wire "encodeRef" (Forall Map.empty (TLambda tipe tLamdera_Wire_Encoder)))) compiler/extra/Lamdera/Wire3/Helpers.hs
Lines 123 to 125 in 74a141e
-- JS types we are supporting through JS ref encodings. These serialisations -- CANNOT BE DECODED OUTSIDE OF THE JS SCOPE THEY WERE ENCODED IN! TType (Module.Canonical (Name "elm" "file") "File") "File" _ -> False
-
Disallow
Textureunless insideFrontendMsgorFrontendModel:compiler/extra/Lamdera/TypeHash.hs
Lines 390 to 395 in 74a141e
-- Frontend JS Kernel types ("elm", "file", "File", "File") -> if targetName `elem` ["FrontendMsg", "FrontendModel"] then DKernelBrowser "File.File" else kernelErrorBrowserOnly
There might be a test case or something that needs updating too.