Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use 'repl device'

ANSWERED

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!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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

View best answer in original post

Best Answer
10 REPLIES 10

At this time, I beleive it only works with the simulator. But the device version should ship in the next firmware update.

Best Answer
0 Votes

> 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
0 Votes

You should be able to move elements around on screen, update colors, change variables etc, without having to reinstall the app.

Best Answer

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
Best Answer

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 Answer
0 Votes

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.

Best Answer
0 Votes

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.

Best Answer

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 Answer
0 Votes

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!

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer