Installing an NPM package on Bangle.js 2? #6753
Replies: 1 comment
-
Posted at 2024-04-09 by user140377 I would grab the unified version from cdn and put it in the espruino ide and see what happens. Usual approach is to fetch the library as a single javascript file and save a copy in the bangle repo, e.g. see suncalc.js Posted at 2024-04-09 by user157902 Thanks a lot! How would I find "the unified version" and which CDN would I use? Also, how would I fetch the library as a single JS file? Sorry, I am a bit of a newbie with this ... I noticed that my library in question (https://www.npmjs.com/package/discrete-wavelets) also contains TS code. In another post (https://forum.espruino.com/conversations/341987/) it was mentioned that TS needs to be built/compiled before uploading it to Bangle. I am wondering what would be the easiest way to achieve that? Posted at 2024-04-09 by user157902 I think I found what you meant. The npm website for the package mentions a CDN option (https://cdn.jsdelivr.net/npm/discrete-wavelets@5/dist/discrete-wavelets.umd.min.js) which seems to be the minified, single-file version of that module. :-) I will try to get this running as described by you. Posted at 2024-04-09 by user140377 Indeed. Also if you trop the .min from the name you get a human readable version: Posted at 2024-04-10 by user157902 Thank you, that worked really well! 🙂 In case anybody else is looking for it, here is what I did:
Example for the above module:
When using the library with a real-world sample of 250 values (not just [1,2,3,4]), I seem to get a timeout problem ("Prompt not detected - upload failed"). But I look into solving this using the advice from https://forum.espruino.com/conversations/289212/ . Posted at 2024-04-10 by @gfwilliams
Yes, that's just that it's taking a while to execute - and when you upload via the IDE it checks that after the upload completes the device responds within a certain time. If you can upload the minified file ( Posted at 2024-04-10 by user157902 Thank you for the ideas, Gordon! :-) I actually looked into the minified file fist, but found the renamed functions rather confusing. Checking out the map file attached didn't make this smoother, at least not at first glance. I also searched for "semi-minified" options, to minify but keep function names, but could not find such a tool yet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2024-04-08 by user157902
For a project I would like to run a discrete wavelets tranform on my Bangle.js 2 watch.
Because of that, I am wondering if it is possible to install an existing npm package (namely https://www.npmjs.com/package/discrete-wavelets ) in Espruino, to make its functionality available within my JS project.
Concrete questions I am pondering about:
Thanks in advance for any help and hints! :-)
Beta Was this translation helpful? Give feedback.
All reactions