Protocol implementations so Ecto/Decimal types survive the trip from the LiveView socket to a LiveSvelte Svelte component as sensible JSON values instead of struct dumps.
Covers two structs that every generated CRUD page trips over:
Decimal— the Ecto:decimaltype. Without a custom encoder, LiveSvelte's fallback serialises a%Decimal{}as%{coef: _, exp: _, sign: _}, which Svelte then stringifies as[object Object]. This impl emits the normalised decimal string (matching the generated TypeScriptstringtype for:decimalfields).Ecto.Association.NotLoaded— when a schema field is never preloaded, the default encoding leaks internal module names (__owner__,__field__) to the browser. This impl replaces the not-loaded sentinel withnil.
The impls live under a Code.ensure_loaded?/1 guard so the file is
safe to compile even when LiveSvelte is absent or older than 0.18
(where the LiveSvelte.Encoder protocol first landed).
This module has no runtime API — it exists solely to host the two
defimpl blocks below, which Elixir's protocol consolidation picks
up automatically.