Registry / http-networking / reactotron-core-contract

reactotron-core-contract

JSON →
library0.3.2jsnpmunverified

Reactotron Core Contract (reactotron-core-contract) is a TypeScript-first package that defines the canonical interfaces and types for the WebSocket messages exchanged between the Reactotron desktop application (the server) and various client-side libraries (like reactotron-react-native or reactotron-react-js). Introduced with Reactotron 3.0, its primary purpose is to ensure strong type safety and compatibility across the entire Reactotron ecosystem, both for internal package consistency and for external plugin development. It formalizes the communication protocol, making it easier to build robust custom plugins and maintain reliable connections. The package is part of the larger Reactotron monorepo, currently at version 0.3.2, and its release cadence is tied to the evolution of the main Reactotron project, typically released when changes accumulate or align with other Reactotron component updates.

npm install reactotron-core-contract
INSTALL
IMPORT
SIG · REACTOTRON-CORE-CO
R
reactotron-core-contract
http-networkingjavascriptv0.3.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ClientMessage
import { ClientMessage } from 'reactotron-core-contract'
Represents a message sent from a Reactotron client to the desktop app.
ServerMessage
import { ServerMessage } from 'reactotron-core-contract'
Represents a message sent from the Reactotron desktop app to a client.
ClientCommand
import { ClientCommand } from 'reactotron-core-contract'
Defines the structure for commands a client sends to the Reactotron server.
Reactotron
import { Reactotron } from 'reactotron-core-contract'
Provides the overall interface for the Reactotron instance, useful for type extension.
Host
import { Host } from 'reactotron-core-contract'
Describes the host information for a Reactotron connection.

Demonstrates importing core contract types like `ClientCommand`, `ServerCommand`, `ClientMessage`, and `ServerMessage`, and how to define custom commands or messages adhering to these contracts for type safety.

import { ClientCommand, ServerCommand, ClientMessage, ServerMessage, Reactotron } from 'reactotron-core-contract'; // Example of a custom client command type definition type MyCustomCommand = ClientCommand<'my.custom.command', { data: string, timestamp: number }>; // Example of a custom server message type definition type MyServerStatusMessage = ServerMessage<'server.status', { uptime: number, connections: number }>; // A dummy function illustrating how you might use these types function processClientCommand(command: ClientCommand | MyCustomCommand): void { if (command.type === 'my.custom.command') { console.log(`Received custom command: ${command.type} with data: ${command.payload.data}`); } else { console.log(`Received standard command: ${command.type}`); } } function sendServerMessage(reactotron: Reactotron, message: ServerMessage | MyServerStatusMessage): void { // In a real scenario, this would send over a WebSocket console.log(`Sending message from server: ${message.type}`); } // Simulate a Reactotron instance for type checking const mockReactotron: Reactotron = { host: 'localhost', port: 9090, version: '3.x.x', // ... other Reactotron properties (omitted for brevity) }; processClientCommand({ type: 'log', payload: { level: 'debug', message: 'Hello from client' }, important: false }); processClientCommand({ type: 'my.custom.command', payload: { data: 'Special data', timestamp: Date.now() }, important: true }); sendServerMessage(mockReactotron, { type: 'server.status', payload: { uptime: 1200, connections: 5 } });
Debug
Known issues
breakingMajor version updates of the main Reactotron project (e.g., from v2 to v3) often involve fundamental changes to the WebSocket communication protocol. As `reactotron-core-contract` defines these protocol types, such changes are inherently breaking and require updating this package along with all client and server implementations to maintain compatibility. Reactotron 3.0 introduced this package for improved type safety.
fix
Always align the versions of `reactotron-core-contract` with the major version of your `reactotron-core-client` or `reactotron-core-server` packages. Consult the main Reactotron project's changelog for migration guides between major versions.
affects: <3.0.0 (overall Reactotron ecosystem), <0.3.0 (specific package contract changes)
gotchaThis package primarily exports TypeScript types and interfaces. Attempting to import or use it in a JavaScript-only runtime environment for executable code will result in runtime errors as there are no actual runnable exports, only type definitions.
fix
Ensure `reactotron-core-contract` is only imported for type declarations within TypeScript files or for type-checking purposes. It is typically a dev dependency.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'reactotron-core-contract'
The package `reactotron-core-contract` is not installed or incorrectly referenced.
fix
Install the package using `npm install reactotron-core-contract` or `yarn add reactotron-core-contract`. Ensure it's listed in your `package.json`.
TS2307: Cannot find module 'reactotron-core-contract' or its corresponding type declarations.
This error occurs in a TypeScript project when the package is installed but TypeScript cannot locate its type definitions. This is less common for a types-first package but can happen if `skipLibCheck` is true and types are subtly misconfigured, or if an older version of TypeScript is used.
fix
Ensure `typescript` is installed and configured correctly in your project. Verify `reactotron-core-contract` is in `devDependencies`. If the issue persists, check your `tsconfig.json` for `typeRoots` or `types` configurations, or consider updating TypeScript.
TS2345: Argument of type '{ type: "my.custom.command"; payload: { data: string; timestamp: number; }; }' is not assignable to parameter of type 'ClientCommand'.
You are attempting to use a custom command or message type in a context expecting a standard `ClientCommand` or `ServerCommand` without explicitly defining it as a union type.
fix
When using custom command or message types, ensure the function signatures or variable types are correctly defined as a union of the standard types and your custom types, e.g., `command: ClientCommand | MyCustomCommand`.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
reactotron-core-contract — npm install reactotron-core-contract · libregistry