With type declarations and various missing parts added by Willy-JL
with some parts from PR by Willy-JL https://github.com/flipperdevices/flipperzero-firmware/pull/3980/files