flipperzero-firmware
flipperzero-firmware copied to clipboard
[FL-3579, FL-3601, FL-3714] JavaScript runner
What's new
- JS scripting engine based on MJS lib
- Plugin-based JS module system
- Initial set of JS modules: BadUSB, UART, dialog, notification, flipper
- file_browser: support for multiple extensions filter
- Running JS scripts from Apps menu or archive
Verification
- Run examples from Apps -> Scripts
Checklist (For Reviewer)
- [ ] PR has description of feature/bug or link to Confluence/Jira task
- [ ] Description contains actions to verify feature/bugfix
- [ ] I've built this code, uploaded it to the device and verified feature/bugfix
so excited about this 🤩
Just noting - JavaScript - while popular is a very heavy language compared to something like C. The flipper isn't exactly a compute powerhouse, so I'm concerned that there will be a substantial performance penalty integrating a high-level interpreted language like this. thoughts?
Just noting - JavaScript - while popular is a very heavy language compared to something like C. The flipper isn't exactly a compute powerhouse, so I'm concerned that there will be a substantial performance penalty integrating a high-level interpreted language like this. thoughts?
I believe there are available tooling to convert Js to C. I wonder if this could be part of a "build process" to enable the faster running of the Js.
I believe there are available tooling to convert Js to C. I wonder if this could be part of a "build process" to enable the faster running of the Js.
I think that would be a great idea because it allows devs more familiar with JavaScript to write applications for the Flipper platform which as I understand would be the intent of this PR. Obviously, we'd want to build BEFORE reaching the end device - no JIT stuff - because you do not want to compile C on the flipper. So you'd be able to write JS and have that build to a binary .fap
file. This PR appears to be adding a JS interpreter on the actual Flipper itself so you can run JS natively on the flipper... I personally think performance issues will start coming up quick going this route.
This would be perfect for NFC KDF plugins (#3197)
Looking forward to this!
@vtrenton It's also worth noting that MJS is not any known version of JavaScript. It's a proprietary subset that misses critical features to the point that I'm a bit hesitant to call it JavaScript. This also means no TypeScript support out of the box and no npm package transpilation (not just the heavy modules, no, not even a single line hello world program would be allowed) unless one can figure out how to polyfill.
TBH I don't know how usable this really is other than writing some really simple programs with it, since for more complex programs the development overhead might be even bigger than C especially without TypeScript support.
Great news! Wanna see docs about this feature.