Reputation: 1
I'm making an app for school that's for speedcubers. And since speedcubers want their solves to be legit solves a lot of websites use an npm package from the most popular solving website called cstimer_module
.
This is a package that contains 1 big compressed js file and require's a NodeJs environment to work.
This package has functions that can give you official scrambles for almost every cube.
I have tried a lot, but nothing seems to work.
Is there anyone who has already done this before or knows how to do it?
Upvotes: 0
Views: 38
Reputation: 747
You can't natively include an NPM package in a Compose app - Node packages are written in JavaScript while Compose apps are compiled to Java bytecode after being written in Kotlin. I'd suggest either searching for a Java package that does something similar or implementing the functionality you need yourself.
If you're dead-set on using that module specifically, I'd suggest one of these options:
Use a different app framework that allows you to import npm modules - Have you considered React Native?
Host an API using a node-based framework like nestjs and use it to expose the module's functionality to your app (I'd personally recommend this option if you're set on writing a native Compose app)
Host a separate node-based web app and embed it in your app using a WebView (Not really a great option since you can't communicate with the embedded site)
Upvotes: 0