Is there any documentation about the `repl device` command available inside the CLI?
repl device Enter into a REPL with the connected device
I was not able to find any clues by using `fitbit$ repl$ console.log(Object.keys(this))`
Thanks!
Answered! Go to the Best Answer.
Best AnswerIs there an example on how to do that?
It looks like import is not available, but I can use 'require'... so I am good to go. Thanks!
fitbit$ repl device Entering REPL mode, type "exit" to quit
fitbit$ repl$ var document = require('document')
undefined
fitbit$ repl$ document.getElementById('vibration-list')
[object Object]
fitbit$ repl$ var vibration = require('haptics').vibration
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
> At this time, I beleive it only works with the simulator. But the device version should ship in the next firmware update.
Thanks!
Yes, it only works with the simulator...but how can it be used?
What can one do with the REPL.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
You should be able to move elements around on screen, update colors, change variables etc, without having to reinstall the app.
Is there an example on how to do that?
It looks like import is not available, but I can use 'require'... so I am good to go. Thanks!
fitbit$ repl device Entering REPL mode, type "exit" to quit
fitbit$ repl$ var document = require('document')
undefined
fitbit$ repl$ document.getElementById('vibration-list')
[object Object]
fitbit$ repl$ var vibration = require('haptics').vibration
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Those really should be imported in your app already during the build process. repl should be used for manipulating the existing app, not development of the app.
Best AnswerThanks for the info.
For some reason, I don't have the app objects loaded in the repl... this is why at first I was not sure if repl is functional.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
They'll be there, but not under the names you might expect. When you build your app, the code gets minified using Terser, and a function name like "myAwesomeFunc" gets mangled into "a" to save memory.
What I also find usefully is to check an existence of certain JS functions. Sometimes I forget that device supports the ES5 syntax only. So there is on implementation of Object.values for instance. So one of the usageu example is a quick check if your function will work or not.
Best AnswerIs there a way to disable name mangling ?
or is there a source map?
How are we supposed to use the repl and for which tasks ? 🙂
Thanks!
Best AnswerI think the source maps are in your app.fba, which is just a .zip file. Look for *.js.map files. They look like JSON to me. I haven't fully reverse-engineered them, but they don't look too cryptic.
The minification is probably done by an open-source tool for which online documentation exists. More clues may be available here.