{"name":"react-devtools-core","version":"6.1.0","license":"MIT","_id":"react-devtools-core@6.1.0","homepage":"https://github.com/facebook/react#readme","bugs":{"url":"https://github.com/facebook/react/issues"},"dist":{"shasum":"d6398a57dad7a1bc65ed84dceb423b3212200335","tarball":"http://registry-npm.ywwl.com/react-devtools-core/download/react-devtools-core-6.1.0.tgz","fileCount":15,"integrity":"sha512-sA8gF/pUhjoGAN3s1Ya43h+F4Q0z7cv9RgqbUfhP7bJI0MbqeshLYFb6hiHgZorovGr8AXqhLi22eQ7V3pru/Q==","signatures":[{"sig":"MEYCIQDXGQxjfUwg43J7xnGvmgHvL8QStzSkBQia1INPFwGrJwIhAN9ql7UHSStz8CSMYaR/4H9NIW1/KJ6YFGs2VDWqEVjf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18472651,"size":4199606,"noattachment":false,"key":"/react-devtools-core/-/react-devtools-core-6.1.0.tgz"},"main":"./dist/backend.js","gitHead":"b000019578a417ec0a1aeec8bda689db240cb28e","scripts":{"build":"yarn build:backend && yarn build:standalone","prepublish":"yarn run build","build:backend":"cross-env NODE_ENV=production webpack --config webpack.backend.js","start:backend":"cross-env NODE_ENV=development webpack --config webpack.backend.js --watch","build:backend:fb":"cross-env NODE_ENV=production FEATURE_FLAG_TARGET=core/backend-fb webpack --config webpack.backend.js","build:standalone":"cross-env NODE_ENV=production webpack --config webpack.standalone.js","start:standalone":"cross-env NODE_ENV=development webpack --config webpack.standalone.js --watch","build:standalone:fb":"cross-env NODE_ENV=production FEATURE_FLAG_TARGET=core/standalone-fb webpack --config webpack.standalone.js"},"_npmUser":{"name":"hoxyq","email":"rdlesyutin@gmail.com"},"repository":{"url":"git+https://github.com/facebook/react.git","type":"git","directory":"packages/react-devtools-core"},"_npmVersion":"9.6.7","description":"Use react-devtools outside of the browser","directories":{},"_nodeVersion":"20.3.0","dependencies":{"ws":"^7","shell-quote":"^1.6.1"},"_hasShrinkwrap":false,"devDependencies":{"process":"0.11.10","webpack":"^5.82.1","cross-env":"^3.1.4","webpack-cli":"^5.1.1","workerize-loader":"^2.0.2"},"_npmOperationalInternal":{"tmp":"tmp/react-devtools-core_6.1.0_1737902774437_0.4329724549220453","host":"s3://npm-registry-packages-npm-production"},"readme":"# `react-devtools-core`\n\nThis package provides low-level APIs to support renderers like [React Native](https://github.com/facebook/react-native). If you're looking for the standalone React DevTools UI, **we suggest using [`react-devtools`](https://github.com/facebook/react/tree/main/packages/react-devtools) instead of using this package directly**.\n\nThis package provides two entrypoints: labeled \"backend\" and \"standalone\" (frontend). Both APIs are described below.\n\n# Backend API\n\nBackend APIs are embedded in _development_ builds of renderers like [React Native](https://github.com/facebook/react-native) in order to connect to the React DevTools UI.\n\n### Example\n\nIf you are building a non-browser-based React renderer, you can use the backend API like so:\n\n```js\nif (process.env.NODE_ENV !== 'production') {\n  const { initialize, connectToDevTools } = require(\"react-devtools-core\");\n\n  initialize(settings);\n  // Must be called before packages like react or react-native are imported\n  connectToDevTools({...config});\n}\n```\n\n> **NOTE** that this API (`connectToDevTools`) must be (1) run in the same context as React and (2) must be called before React packages are imported (e.g. `react`, `react-dom`, `react-native`).\n\n### `initialize` arguments\n| Argument   | Description                                                                                                                                                                                                                                                                                   |\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `settings` | Optional. If not specified, or received as null, then default settings are used. Can be plain object or a Promise that resolves with the [plain settings object](#Settings). If Promise rejects, the console will not be patched and some console features from React DevTools will not work. |\n\n#### `Settings`\n| Spec                                                                                                                                                                           | Default value                                                                                                                                                        |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| <pre>{<br>  appendComponentStack: boolean,<br>  breakOnConsoleErrors: boolean,<br>  showInlineWarningsAndErrors: boolean,<br>  hideConsoleLogsInStrictMode: boolean<br>}</pre> | <pre>{<br>  appendComponentStack: true,<br>  breakOnConsoleErrors: false,<br>  showInlineWarningsAndErrors: true,<br>  hideConsoleLogsInStrictMode: false<br>}</pre> |\n\n### `connectToDevTools` options\n| Prop                   | Default       | Description                                                                                                               |\n|------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------|\n| `host`                 | `\"localhost\"` | Socket connection to frontend should use this host.                                                                       |\n| `isAppActive`          |               | (Optional) function that returns true/false, telling DevTools when it's ready to connect to React.                        |\n| `port`                 | `8097`        | Socket connection to frontend should use this port.                                                                       |\n| `resolveRNStyle`       |               | (Optional) function that accepts a key (number) and returns a style (object); used by React Native.                       |\n| `retryConnectionDelay` | `200`         | Delay (ms) to wait between retrying a failed Websocket connection                                                         |\n| `useHttps`             | `false`       | Socket connection to frontend should use secure protocol (wss).                                                           |\n| `websocket`            |               | Custom `WebSocket` connection to frontend; overrides `host` and `port` settings.                                          |\n| `onSettingsUpdated`    |               | A callback that will be called when the user updates the settings in the UI. You can use it for persisting user settings. |                                                                                         |\n\n\n### `connectWithCustomMessagingProtocol` options\n| Prop                | Description                                                                                                                                                    |\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `onSubscribe`       | Function, which receives listener (function, with a single argument) as an argument. Called when backend subscribes to messages from the other end (frontend). |\n| `onUnsubscribe`     | Function, which receives listener (function) as an argument. Called when backend unsubscribes to messages from the other end (frontend).                       |\n| `onMessage`         | Function, which receives 2 arguments: event (string) and payload (any). Called when backend emits a message, which should be sent to the frontend.             |\n| `onSettingsUpdated` | A callback that will be called when the user updates the settings in the UI. You can use it for persisting user settings.                                      |       \n\nUnlike `connectToDevTools`, `connectWithCustomMessagingProtocol` returns a callback, which can be used for unsubscribing the backend from the global DevTools hook.\n\n# Frontend API\n\nFrontend APIs can be used to render the DevTools UI into a DOM node. One example of this is [`react-devtools`](https://github.com/facebook/react/tree/main/packages/react-devtools) which wraps DevTools in an Electron app.\n\n### Example\n```js\nimport DevtoolsUI from \"react-devtools-core/standalone\";\n\n// See the full list of API methods in documentation below.\nconst { setContentDOMNode, startServer } = DevtoolsUI;\n\n// Render DevTools UI into a DOM element.\nsetContentDOMNode(document.getElementById(\"container\"));\n\n// Start socket server used to communicate between backend and frontend.\nstartServer(\n  // Port defaults to 8097\n  1234,\n\n  // Host defaults to \"localhost\"\n  \"example.devserver.com\",\n\n  // Optional config for secure socket (WSS).\n  {\n    key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),\n    cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')\n  }\n);\n```\n\n### Exported methods\nThe `default` export is an object defining the methods described below.\n\nThese methods support chaining for convenience. For example:\n```js\nconst DevtoolsUI = require(\"react-devtools-core/standalone\");\nDevtoolsUI.setContentDOMNode(element).startServer();\n```\n\n#### `connectToSocket(socket: WebSocket)`\n> This is an advanced config function that is typically not used.\n\nCustom `WebSocket` connection to use for communication between DevTools frontend and backend. Calling this method automatically initializes the DevTools UI (similar to calling `startServer()`).\n\n#### `openProfiler()`\nAutomatically select the \"Profiler\" tab in the DevTools UI.\n\n#### `setContentDOMNode(element: HTMLElement)`\nSet the DOM element DevTools UI should be rendered into on initialization.\n\n#### `setDisconnectedCallback(callback: Function)`\n_Optional_ callback to be notified when DevTools `WebSocket` closes (or errors).\n\n#### `setProjectRoots(roots: Array<string>)`\n_Optional_ set of root directories for source files. These roots can be used to open an inspected component's source code using an IDE.\n\n#### `setStatusListener(callback: Function)`\n_Optional_ callback to be notified of socket server events (e.g. initialized, errored, connected).\n\nThis callback receives two parameters:\n```js\nfunction onStatus(\n  message: string,\n  status: 'server-connected' | 'devtools-connected' | 'error'\n): void {\n  // ...\n}\n```\n\n#### `startServer(port?: number, host?: string, httpsOptions?: Object, loggerOptions?: Object)`\nStart a socket server (used to communicate between backend and frontend) and renders the DevTools UI.\n\nThis method accepts the following parameters:\n| Name | Default | Description |\n|---|---|---|\n| `port` | `8097` | Socket connection to backend should use this port. |\n| `host` | `\"localhost\"` | Socket connection to backend should use this host. |\n| `httpsOptions` | | _Optional_ object defining `key` and `cert` strings. |\n| `loggerOptions` | | _Optional_ object defining a `surface` string (to be included with DevTools logging events). |\n\n# Development\n\nWatch for changes made to the backend entry point and rebuild:\n```sh\nyarn start:backend\n```\n\nWatch for changes made to the standalone UI entry point and rebuild:\n```sh\nyarn start:standalone\n```\n\nRun the standalone UI using `yarn start` in the [`react-devtools`](https://github.com/facebook/react/tree/main/packages/react-devtools).\n","publish_time":1737902774811,"maintainers":[{"name":"sebmarkbage","email":"sebastian@calyptus.eu"},{"name":"gaearon","email":"dan.abramov@gmail.com"},{"name":"acdlite","email":"npm@andrewclark.io"},{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},{"name":"ryancat","email":"xryanchen@gmail.com"},{"name":"jstejada","email":"juans.tejada@gmail.com"},{"name":"xiaobu","email":"yaotianyu0512@gmail.com"},{"name":"mondaychen","email":"monday.chen@gmail.com"},{"name":"sophiebits","email":"npm@sophiebits.com"},{"name":"lunaruan","email":"lunaris.ruan@gmail.com"},{"name":"hoxyq","email":"rdlesyutin@gmail.com"}],"_cnpm_publish_time":1737902774811,"dist-tags":{"alpha":"3.5.0-alpha.0","latest":"8.0.0","next":"4.0.6","old":"4.10.4"}}