npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2025 โ€“ย Pkg Stats / Ryan Hefner

debug-time-machine-react-client

v1.0.13

Published

๐Ÿ•ฐ๏ธ ์™„์ „ ์ž๋™ํ™”๋œ React ๋””๋ฒ„๊น… ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ - ์„ค์น˜ํ•˜๊ณ  ๋ฐ”๋กœ ์‚ฌ์šฉํ•˜์„ธ์š”!

Readme

debug-time-machine-react-client

React ์•ฑ์—์„œ Debug Time Machine์„ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” React Hook ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค.

์„ค์น˜

npm install debug-time-machine-react-client
# ๋˜๋Š”
yarn add debug-time-machine-react-client
# ๋˜๋Š”
pnpm add debug-time-machine-react-client

์‚ฌ์šฉ๋ฒ•

๊ธฐ๋ณธ ์‚ฌ์šฉ๋ฒ•

import { useDebugTimeMachine } from 'debug-time-machine-react-client';

function App() {
  const { isConnected, clientId } = useDebugTimeMachine();
  
  return (
    <div>
      {isConnected ? (
        <p>โœ… Time Machine connected! Client ID: {clientId}</p>
      ) : (
        <p>๐Ÿ”„ Connecting to Time Machine...</p>
      )}
      
      <YourAppContent />
    </div>
  );
}

๊ณ ๊ธ‰ ์„ค์ •

import { useDebugTimeMachine } from 'debug-time-machine-react-client';

function App() {
  const timeMachine = useDebugTimeMachine({
    websocketUrl: 'ws://localhost:3001/ws',
    debugMode: true,
    captureUserActions: true,
    captureErrors: true,
    captureStateChanges: true,
    maxReconnectAttempts: 5,
    reconnectInterval: 3000,
    developmentOnly: true,
  });
  
  // ์ˆ˜๋™์œผ๋กœ ์ƒํƒœ ๋ณ€๊ฒฝ ์บก์ฒ˜
  const handleStateChange = () => {
    timeMachine.captureStateChange(
      'MyComponent',
      { count: 0 },
      { count: 1 },
      { userId: 123 }
    );
  };
  
  // ์ˆ˜๋™์œผ๋กœ ์—๋Ÿฌ ์บก์ฒ˜
  const handleError = () => {
    try {
      throw new Error('Something went wrong!');
    } catch (error) {
      timeMachine.captureError(error, { context: 'user action' });
    }
  };
  
  return (
    <div>
      <h1>Debug Time Machine Demo</h1>
      
      <div>
        <p>์—ฐ๊ฒฐ ์ƒํƒœ: {timeMachine.isConnected ? 'โœ… ์—ฐ๊ฒฐ๋จ' : 'โŒ ์—ฐ๊ฒฐ ์•ˆ๋จ'}</p>
        <p>ํด๋ผ์ด์–ธํŠธ ID: {timeMachine.clientId || 'N/A'}</p>
        <p>์žฌ์—ฐ๊ฒฐ ์‹œ๋„: {timeMachine.connectionInfo.reconnectAttempts}</p>
        {timeMachine.connectionInfo.lastError && (
          <p>๋งˆ์ง€๋ง‰ ์—๋Ÿฌ: {timeMachine.connectionInfo.lastError}</p>
        )}
      </div>
      
      <div>
        <button onClick={handleStateChange}>์ƒํƒœ ๋ณ€๊ฒฝ ์บก์ฒ˜</button>
        <button onClick={handleError}>์—๋Ÿฌ ์บก์ฒ˜</button>
        <button onClick={timeMachine.reconnect}>์ˆ˜๋™ ์žฌ์—ฐ๊ฒฐ</button>
      </div>
    </div>
  );
}

API

useDebugTimeMachine(config?)

Debug Time Machine ์„œ๋ฒ„์™€ ์—ฐ๊ฒฐํ•˜๊ณ  ์ด๋ฒคํŠธ ์บก์ฒ˜๋ฅผ ์ž๋™์œผ๋กœ ์„ค์ •ํ•˜๋Š” React Hook์ž…๋‹ˆ๋‹ค.

Parameters

  • config?: DebugTimeMachineConfig - ์˜ต์…˜ ์„ค์ • ๊ฐ์ฒด

Returns

DebugTimeMachineHookReturn ๊ฐ์ฒด:

  • isConnected: boolean - ์„œ๋ฒ„ ์—ฐ๊ฒฐ ์ƒํƒœ
  • clientId: string | null - ์„œ๋ฒ„์—์„œ ํ• ๋‹น๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ID
  • reconnect: () => void - ์ˆ˜๋™ ์žฌ์—ฐ๊ฒฐ ํ•จ์ˆ˜
  • sendMessage: (type: string, data: any) => boolean - ์ปค์Šคํ…€ ๋ฉ”์‹œ์ง€ ์ „์†ก
  • captureError: (error: Error, errorInfo?: any) => void - ์ˆ˜๋™ ์—๋Ÿฌ ์บก์ฒ˜
  • captureStateChange: (componentName: string, prevState: any, newState: any, props?: any) => void - ์ˆ˜๋™ ์ƒํƒœ ๋ณ€๊ฒฝ ์บก์ฒ˜
  • connectionInfo - ์—ฐ๊ฒฐ ์ •๋ณด ๊ฐ์ฒด

Configuration

DebugTimeMachineConfig

interface DebugTimeMachineConfig {
  websocketUrl?: string;          // ๊ธฐ๋ณธ๊ฐ’: 'ws://localhost:3001/ws'
  debugMode?: boolean;            // ๊ธฐ๋ณธ๊ฐ’: development ํ™˜๊ฒฝ์—์„œ true
  captureUserActions?: boolean;   // ๊ธฐ๋ณธ๊ฐ’: true
  captureErrors?: boolean;        // ๊ธฐ๋ณธ๊ฐ’: true
  captureStateChanges?: boolean;  // ๊ธฐ๋ณธ๊ฐ’: true
  maxReconnectAttempts?: number;  // ๊ธฐ๋ณธ๊ฐ’: 10
  reconnectInterval?: number;     // ๊ธฐ๋ณธ๊ฐ’: 5000 (ms)
  developmentOnly?: boolean;      // ๊ธฐ๋ณธ๊ฐ’: true
}

์ž๋™ ์บก์ฒ˜ ๊ธฐ๋Šฅ

์‚ฌ์šฉ์ž ์ƒํ˜ธ์ž‘์šฉ ์บก์ฒ˜

๋‹ค์Œ ์ด๋ฒคํŠธ๋“ค์ด ์ž๋™์œผ๋กœ ์บก์ฒ˜๋ฉ๋‹ˆ๋‹ค:

  • ํด๋ฆญ (click)
  • ์ž…๋ ฅ (input, change)
  • ํผ ์ œ์ถœ (submit)
  • ํ‚ค๋ณด๋“œ ์ž…๋ ฅ (keydown)
  • ํฌ์ปค์Šค ๋ณ€๊ฒฝ (focus, blur)

์—๋Ÿฌ ์บก์ฒ˜

๋‹ค์Œ ์—๋Ÿฌ๋“ค์ด ์ž๋™์œผ๋กœ ์บก์ฒ˜๋ฉ๋‹ˆ๋‹ค:

  • JavaScript ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ
  • Promise rejection
  • Console.error ํ˜ธ์ถœ

ํ™˜๊ฒฝ๋ณ„ ๋™์ž‘

  • Development: ๋ชจ๋“  ๊ธฐ๋Šฅ ํ™œ์„ฑํ™”, ์ฝ˜์†” ๋กœ๊ทธ ์ถœ๋ ฅ
  • Production: developmentOnly: true์ธ ๊ฒฝ์šฐ ์ž๋™ ๋น„ํ™œ์„ฑํ™”

์„œ๋ฒ„ ์„ค์ •

Debug Time Machine ๋ฐฑ์—”๋“œ ์„œ๋ฒ„๊ฐ€ ์‹คํ–‰๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

cd apps/backend
npm run dev

์„œ๋ฒ„๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ http://localhost:3001์—์„œ ์‹คํ–‰๋˜๋ฉฐ, WebSocket์€ /ws ๊ฒฝ๋กœ์—์„œ ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

TypeScript ์ง€์›

์ด ํŒจํ‚ค์ง€๋Š” ์™„์ „ํ•œ TypeScript ์ง€์›์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ํƒ€์ž…์ด ํฌํ•จ๋˜์–ด ์žˆ์–ด IDE์—์„œ ์ž๋™์™„์„ฑ๊ณผ ํƒ€์ž… ๊ฒ€์‚ฌ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ผ์ด์„ ์Šค

MIT License