-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add standalone Reactotron server and update dependencies #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
467fc16
to
02abeb7
Compare
- Introduced a bundled standalone Reactotron server that starts automatically with the macOS app. - Added a new script to bundle the server code using esbuild. - Updated package.json to include esbuild as a dependency. - Enhanced README with instructions for running the server and details about the embedded server functionality. - Updated Podfile.lock to reflect changes in dependencies. - Minor adjustments to existing scripts and configurations for better integration.
- Added .eslintignore to exclude bundled files from linting. - Removed Reactotron server start command from metro.config.js. - Updated package.json to change the output format of the bundled server. - Improved connection status handling in SidebarMenu with manual reconnect functionality. - Enhanced logging in standalone-server.js for better connection tracking and error handling. - Implemented reconnect logic in connectToServer.ts to manage connection attempts and status updates. - Updated AppDelegate.mm to use the user's default shell for running commands, improving compatibility with nvm/asdf setups. - Added new patch for reactotron-core-server to address compatibility issues.
02abeb7
to
66253d3
Compare
@@ -0,0 +1,7 @@ | |||
diff --git a/node_modules/reactotron-core-server/dist/index.js b/node_modules/reactotron-core-server/dist/index.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Fixed ESM/CJS interop issue in bundled [email protected]
. The package's pre-compiled code does var mitt=require("mitt")
but mitt v3 exports { default: fn }
instead of the function directly. Added mitt=mitt.default||mitt;
after the require to handle both cases.
This patch is here for hacking but we can replace with a real upstream fix soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things to consider
|
||
#pragma mark - Reactotron Server Management | ||
|
||
- (NSString *)findNodeBinary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider moving this into a TurboModule function so we can call it from JS whenever we want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing a little research about how to move this logic into IRRunShellCommand
.
- Enhanced logging to indicate detected user shell and fallback behavior. - Added NSLog statements for better visibility during shell detection process.
…logging - Introduced a constant for the Reactotron server bundle name to enhance code readability. - Simplified logging logic in the output handler to reduce unnecessary checks.
- Simplified the logging logic in the output and error handlers by removing unnecessary length checks. - Enhanced readability by using early returns for empty data conditions.
struct passwd *pw = getpwuid(getuid()); | ||
if (pw && pw->pw_shell) { | ||
NSString *detectedShell = [NSString stringWithUTF8String:pw->pw_shell]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: apparently there is a default shell property on the user password struct? Old OS library code is weird.
- Added a new hook, useReactotronServer, to manage the lifecycle of the Reactotron server, starting it on component mount and stopping it on unmount. - Introduced IRReactotronServer and NativeIRReactotronServer to handle server interactions. - Enhanced IRRunShellCommand to support user shell detection and command execution with shell options. - Updated App.tsx to utilize the new Reactotron server management functionality. - Improved logging for server output and completion events for better debugging.
/** | ||
* Returns the path to the bundled Reactotron server script. | ||
*/ | ||
- (NSString *)getBundlePath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: since metro doesn't touch the server bundle, unfortunately this needs to be a native module :(
What does this PR do?
This PR adds an embedded Reactotron server that runs directly inside the reactotron-macos application. The server automatically starts on port 9292 when the app launches, eliminating the need to run a separate standalone server process. This provides a seamless out-of-the-box experience for users.
Key changes:
IRReactotronServer
native module to bundle and run the standalone Reactotron serveruseReactotronServer
hook to manage server lifecycle (start on mount, stop on unmount)IRRunShellCommand
to detect user's default shell for better compatibilityWhat GitHub issues does this PR fix?
Resolves #35
How to verify this code works?
reactotron-macos setup for this PR
gh pr checkout 52
npm install
npm run pod
npm run start
npm run macos
reactotron example app setup for this PR
yarn install
Add Reactotron standalone server port to example app configuration
yarn workspace example-app start
i
to launch in iOS simulatorCmd + Shift + R
to reload reactotron-macos to get connectionStep by step of how to test this PR
Screenshot/Video of "How to test this PR?"
Screen.Recording.2025-10-09.at.4.30.05.PM.mov