flipperzero-firmware icon indicating copy to clipboard operation
flipperzero-firmware copied to clipboard

[FL-3579, FL-3601, FL-3714] JavaScript runner

Open nminaylov opened this issue 8 months ago • 3 comments

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

nminaylov avatar Dec 12 '23 12:12 nminaylov

PVS-Studio report for commit 471df948:

github-actions[bot] avatar Dec 12 '23 13:12 github-actions[bot]

Compiled f7 firmware for commit 0e8a785a:

github-actions[bot] avatar Dec 12 '23 13:12 github-actions[bot]

so excited about this 🤩

cowchimp avatar Dec 21 '23 13:12 cowchimp

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?

vtrenton avatar Jan 05 '24 15:01 vtrenton

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.

jessycormier avatar Jan 05 '24 15:01 jessycormier

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.

vtrenton avatar Jan 05 '24 17:01 vtrenton

This would be perfect for NFC KDF plugins (#3197)

nvx avatar Jan 09 '24 02:01 nvx

Looking forward to this!

ghost avatar Jan 10 '24 23:01 ghost

@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.

dogtopus avatar Jan 30 '24 04:01 dogtopus

Great news! Wanna see docs about this feature.

Bachar-official avatar Mar 14 '24 07:03 Bachar-official