Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 38 commits into from
Feb 12, 2024
Merged

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

merged 38 commits into from
Feb 12, 2024

Conversation

nminaylov
Copy link
Member

@nminaylov nminaylov commented Dec 12, 2023

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

Copy link

github-actions bot commented Dec 12, 2023

PVS-Studio report for commit 471df948:

Copy link

github-actions bot commented Dec 12, 2023

Compiled f7 firmware for commit 0e8a785a:

@hedger hedger added Applications Non-core applications New Feature Contains an IMPLEMENTATION of a new feature App Loader FAP loader + API-related labels Dec 12, 2023
@nminaylov nminaylov changed the title JavaScript runner [FL-3579, FL-3601] JavaScript runner Dec 12, 2023
@nminaylov nminaylov marked this pull request as ready for review December 12, 2023 14:38
@cowchimp
Copy link

so excited about this 🤩

@nminaylov nminaylov changed the title [FL-3579, FL-3601] JavaScript runner [FL-3579, FL-3601, FL-3714] JavaScript runner Dec 29, 2023
@vtrenton
Copy link

vtrenton commented Jan 5, 2024

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?

@jessycormier
Copy link

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.

@vtrenton
Copy link

vtrenton commented Jan 5, 2024

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.

@nvx
Copy link
Contributor

nvx commented Jan 9, 2024

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

@ghost
Copy link

ghost commented Jan 10, 2024

Looking forward to this!

@dogtopus
Copy link
Contributor

dogtopus commented Jan 30, 2024

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

@skotopes skotopes merged commit 0154018 into dev Feb 12, 2024
9 checks passed
@skotopes skotopes deleted the nm/js_runner branch February 12, 2024 08:54
@Bachar-official
Copy link

Great news! Wanna see docs about this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Loader FAP loader + API-related Applications Non-core applications New Feature Contains an IMPLEMENTATION of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants