01-23-2019 00:51
01-23-2019 00:51
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.
01-23-2019 05:52
01-23-2019 05:52
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
01-23-2019 02:43
01-23-2019 02:43
At this time, I beleive it only works with the simulator. But the device version should ship in the next firmware update.
01-23-2019 04:25
01-23-2019 04:25
> 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.
01-23-2019 05:00
01-23-2019 05:00
You should be able to move elements around on screen, update colors, change variables etc, without having to reinstall the app.
01-23-2019 05:52
01-23-2019 05:52
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
01-23-2019 05:56
01-23-2019 05:56
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.
01-23-2019 06:48
01-23-2019 06:48
Thanks 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.
01-31-2019 10:41
01-31-2019 10:41
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.
02-01-2019 13:46
02-01-2019 13:46
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.
02-01-2019 15:11
02-01-2019 15:11
Is 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!
02-01-2019 15:22 - edited 02-01-2019 15:23
02-01-2019 15:22 - edited 02-01-2019 15:23
I 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.