Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 75 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"eslint-plugin-react": "^7.5.1",
"gui": "^0.5.0",
"jest": "^22.0.3",
"react": "^16.2.0"
"react": "^16.2.0",
"react-devtools-core": "^3.2.3",
"ws": "^5.2.0"
},
"license": "MIT",
"babel": {
Expand Down
22 changes: 22 additions & 0 deletions src/devtools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
// src https://github.com/iamdustan/react-hardware/blob/master/src/devtools/setupDevtoolsFiber.js

const defineProperty = Object.defineProperty
defineProperty(global, 'WebSocket', {
value: require('ws'),
})
defineProperty(global, 'window', {
value: global,
})

const { connectToDevTools } = require('react-devtools-core')

connectToDevTools({
isAppActive() {
// Don't steal the DevTools from currently active app.
return true
},
host: 'localhost',
// default port? port: ,
resolveRNStyle: null, // TODO maybe: require('flattenStyle')
})
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// TODO: have to force "production" env or the react-reconciler will
// swallow errors in non-browser environments

if (process.env.NODE_ENV !== 'production') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can there be another flag other than just if it's not in production? Perhaps another variable such as INSPECT or something along those lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the question is, do we want to ship the extra libraries it requires on a production bundle too? React DOM is always enabled despite it being a production bundle or not. If that's the case, how about DEBUG then it can be shared with the debug module?

require('./devtools.js')
}

const { render } = require('./renderer')

module.exports = {
Expand Down
7 changes: 7 additions & 0 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ function render(element, guiContainer, callback) {
root = guiContainer._reactRootContainer = newRoot
}

YueRenderer.injectIntoDevTools({
bundleType: 1, // 0 for PROD, 1 for DEV
version: require('../package.json').version, // version for your renderer
rendererPackageName: 'react-yue', // package name
findHostInstanceByFiber: YueRenderer.findHostInstance, // host instance (root)
})

return YueRenderer.updateContainer(element, root, null, callback)
}

Expand Down