dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
tianshu 2018-02-25T16:38:37.000109Z

@darwin Is it possible to use devtools or dirac in React Native development?

2018-02-25T16:39:20.000056Z

it should be possible, but I’m not very familiar with that stack

2018-02-25T16:39:40.000087Z

I tried it a few years back and in it was rough

tianshu 2018-02-25T16:43:25.000100Z

just test devtools can work

2018-02-25T16:50:30.000047Z

?

tianshu 2018-02-25T16:56:08.000064Z

devtools works, but dirac not.

tianshu 2018-02-25T16:56:47.000011Z

looks like dirac use js/document

ReferenceError: document is not defined
    at Object.clojure.browser.repl.bootstrap.goog.writeScriptTag__ (repl.cljs?rel=1519577273852:149)
    at clojure.browser.repl.bootstrap.goog.writeScriptTag_ (repl.cljs?rel=1519577273852:165)
    at Object.goog.importScript_ (base.js:951)
    at Object.goog.writeScripts_ (base.js:1394)
    at goog.require (base.js:706)
    at figwheel-bridge.js:215
    at syncImportScripts (figwheel-bridge.js:134)
    at importJs (figwheel-bridge.js:148)
    at figwheel-bridge.js:210
    at syncImportScripts (figwheel-bridge.js:134)

tianshu 2018-02-25T16:57:19.000110Z

however, this is not exist in react native.

2018-02-25T16:58:54.000031Z

hmm, this callstack does not look like related to dirac

2018-02-25T16:59:07.000126Z

it looks like figwheel

tianshu 2018-02-25T17:00:54.000077Z

this is because to make figwheel work in react native there's a figwheel_bridge.js do a lot of shim work, so the error stack looks meaningless.

tianshu 2018-02-25T17:01:50.000086Z

does dirac require the JS runtime which it works with, must be a browser environment?

2018-02-25T17:02:27.000064Z

no

2018-02-25T17:02:53.000090Z

dirac can work with nodejs javascript environment for example

2018-02-25T17:03:31.000033Z

^ this may be outdated, but it worked at some point

2018-02-25T17:05:20.000127Z

I think you only need to instruct dirac to connect to javascript context in your React Native “shell”

2018-02-25T17:06:09.000095Z

the problem could be that the shell has pretty old version, so the debugger protocol between dirac devtools (devtools) and shell does not match

2018-02-25T17:06:41.000003Z

at least that was my problem when I tried it a few years ago, RN shell was 6+ months old

2018-02-25T17:07:21.000098Z

because it was using electron-shell, which was behind

tianshu 2018-02-25T17:08:44.000073Z

the shell stands for what?

tianshu 2018-02-25T17:09:05.000031Z

some stuff run on the mobile?

2018-02-25T17:09:17.000020Z

no

2018-02-25T17:10:37.000077Z

maybe terminology changed? I don’t know - back in the old days, electron-shell was that componet in electron which was wrapping chrome engine

tianshu 2018-02-25T17:11:34.000146Z

that make sense

2018-02-25T17:12:57.000111Z

actually it is this subproject: https://github.com/electron/libchromiumcontent

2018-02-25T17:13:15.000132Z

electron is using it as “chrome engine”, it depends what version do you have

2018-02-25T17:13:44.000004Z

you can easily detect it by asking for navigator.userAgent

2018-02-25T17:13:59.000061Z

in javascript context inside your RN app

tianshu 2018-02-25T17:15:51.000101Z

in react native, although you can open a devtool for logging and debugging, you can't evaluate javascript code, if you try to do alert, it will alert in the chrome, not the app. will this still be a problem for cljs repl, if dirac install success on RN?

tianshu 2018-02-25T17:16:45.000094Z

the technology here looks really complex.

2018-02-25T17:17:24.000004Z

I’m not surprised that alert shows in the browser instead of native app.

2018-02-25T17:17:48.000111Z

I would guess you have to use RN-specific apis to affect state of your native app

2018-02-25T17:18:03.000098Z

I’m sorry I have never used RN seriously. I cannot help here.

2018-02-25T17:19:40.000022Z

In general you want run javascript context in your RN app with remote debugging enabled and then connect to it with dirac (running in your browser as extension). If both RN js context and dirac versions roughly match, then they should be able to talk and you should be able to issue cljs commands which will compile to javascript which exectutes in your RN js context. This will allow you to do everything javascript code can do in that context.,

tianshu 2018-02-25T17:27:13.000073Z

okay, tomorrow i will try to use dirac without figwheel. maybe will get more useful information. and devtools satisfies me at this moment.

tianshu 2018-02-25T17:27:29.000040Z

thanks for all the help!!

2018-02-25T17:28:36.000097Z

good luck!