{"_id":"@brngdsn/shmr","_rev":"4-9b87726f848846071f9bebfda6e17857","name":"@brngdsn/shmr","dist-tags":{"latest":"0.2.3"},"versions":{"0.2.1":{"name":"@brngdsn/shmr","version":"0.2.1","keywords":["hmr"],"author":{"name":"brn.gdsn@gmail.com"},"license":"ISC","_id":"@brngdsn/shmr@0.2.1","maintainers":[{"name":"brngdsn","email":"brn.gdsn@gmail.com"}],"homepage":"https://github.com/brngdsn/shmr#readme","bugs":{"url":"https://github.com/brngdsn/shmr/issues"},"bin":{"shmr":"src/index.js"},"dist":{"shasum":"6fb524de88eaff56d7eba9718df0f25cba0e6ef8","tarball":"https://registry.npmjs.org/@brngdsn/shmr/-/shmr-0.2.1.tgz","fileCount":4,"integrity":"sha512-c7HqOipIGmIADvmCPhU9j0Ld9umlxGktVoOHZvaHQsULUhUPvfD5f4c4c6tVXZNbr920VJprxAlWaMSNnWXXoA==","signatures":[{"sig":"MEQCIBerKh6eqUxJWBX+bcZlPzmekH6Q/TeBEakZaQOjMa+yAiBijmXffDGMeqiIWCJq7bOdWth31Vqmlk0TzBWRA4Ke8Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6412},"main":"src/index.js","type":"module","gitHead":"2eddb2c6ba1f9bb70398b1aa081c7dc707c43c9b","scripts":{"test":"test"},"_npmUser":{"name":"brngdsn","email":"brn.gdsn@gmail.com"},"repository":{"url":"git+https://github.com/brngdsn/shmr.git","type":"git"},"_npmVersion":"10.8.3","description":"simple hot module reloard","directories":{},"_nodeVersion":"20.8.0","dependencies":{"ws":"^8.18.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/shmr_0.2.1_1727705723570_0.8593683597923383","host":"s3://npm-registry-packages"}},"0.2.3":{"name":"@brngdsn/shmr","version":"0.2.3","type":"module","description":"simple hot module reloard","main":"src/index.js","bin":{"shmr":"src/index.js"},"scripts":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/brngdsn/shmr.git"},"keywords":["hmr"],"author":{"name":"brn.gdsn@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/brngdsn/shmr/issues"},"homepage":"https://github.com/brngdsn/shmr#readme","dependencies":{"ws":"^8.18.0"},"_id":"@brngdsn/shmr@0.2.3","gitHead":"416cabb47389d82a8fa926452b4c17785207c03b","_nodeVersion":"20.8.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-63PzQJrmeL7AzDfrp5Kvwy0wkbHPnonivv4I00gF3ekCceesiZL0O/ZlEX19LYrFMTBndC6+PJHPUEgxT6d5xQ==","shasum":"67a0e0ecac7233ec732732664a5116197f9006fa","tarball":"https://registry.npmjs.org/@brngdsn/shmr/-/shmr-0.2.3.tgz","fileCount":6,"unpackedSize":23614,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCCl+y0eQPykjDMsdT9bWqpXYKO2of+4OfuIUsAwfLq8QIhANZ+31vCGTlpeprlec15uL4fYtEekUMxj44BWDK7DXJS"}]},"_npmUser":{"name":"brngdsn","email":"brn.gdsn@gmail.com"},"directories":{},"maintainers":[{"name":"brngdsn","email":"brn.gdsn@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shmr_0.2.3_1727706459519_0.45362347685962545"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-30T14:15:23.458Z","modified":"2024-09-30T14:27:39.887Z","0.2.0":"2024-09-30T14:04:22.070Z","0.2.1":"2024-09-30T14:15:23.742Z","0.2.3":"2024-09-30T14:27:39.706Z"},"bugs":{"url":"https://github.com/brngdsn/shmr/issues"},"author":{"name":"brn.gdsn@gmail.com"},"license":"ISC","homepage":"https://github.com/brngdsn/shmr#readme","keywords":["hmr"],"repository":{"type":"git","url":"git+https://github.com/brngdsn/shmr.git"},"description":"simple hot module reloard","maintainers":[{"name":"brngdsn","email":"brn.gdsn@gmail.com"}],"readme":"# Simple Static Server with Hot Module Reload (HMR)\n\nA lightweight Node.js HTTP server for serving static files with built-in Hot Module Reload (HMR) support. Ideal for web development workflows, this tool automatically reloads your browser when you make changes to your files, enhancing productivity and streamlining the development process.\n\n## Features\n\n- **Static File Serving**: Serves HTML, CSS, JavaScript, JSON, images, and other static assets.\n- **Hot Module Reload (HMR)**: Automatically reloads the browser when file changes are detected.\n- **WebSocket Integration**: Utilizes WebSockets to communicate file changes to the client.\n- **Easy to Use**: Simple setup with minimal configuration.\n- **Global Installation**: Install globally via npm for easy access from any project.\n\n## Installation\n\nEnsure you have [Node.js](https://nodejs.org/) installed on your machine.\n\nInstall the package globally using npm:\n\n```bash\nnpm install -g shmr\n```\n\n## Usage\n\nNavigate to your project's root directory and start the server:\n\n```bash\nshmr\n```\n\nBy default, the server runs at [http://localhost:8080](http://localhost:8080).\n\n### Options\n\nCurrently, the server runs on port `8080` by default. To customize the port or add additional configurations, you can modify the source code as needed.\n\n## How It Works\n\n1. **HTTP Server**: Serves static files from the current directory. When a request is made, the server responds with the requested file. If an HTML file is requested, it injects a client-side HMR script before the closing `</body>` tag.\n\n2. **HMR Client Script**: The injected script establishes a WebSocket connection to the server. It listens for `reload` messages and refreshes the page when a change is detected.\n\n3. **WebSocket Server**: Manages WebSocket connections with clients. When a file change is detected, it broadcasts a `reload` message to all connected clients.\n\n4. **File Watching**: Monitors the current directory recursively for any file changes (excluding hidden files). Upon detecting a change, it logs the event and triggers a browser reload via WebSocket.\n\n## Example\n\n1. **Start the Server**:\n\n   ```bash\n   shmr\n   ```\n\n2. **Open Your Browser**:\n\n   Navigate to [http://localhost:8080](http://localhost:8080). Your static site should load with HMR enabled.\n\n3. **Make Changes**:\n\n   Modify any HTML, CSS, or JavaScript files in your project. The browser will automatically reload to reflect the changes.\n\n## Development\n\nIf you wish to contribute or modify the server, follow these steps:\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/brngdsn/shmr.git\n   ```\n\n2. **Navigate to the Project Directory**:\n\n   ```bash\n   cd shmr\n   ```\n\n3. **Install Dependencies**:\n\n   ```bash\n   npm install\n   ```\n\n4. **Run Locally**:\n\n   ```bash\n   node src/index.js\n   ```\n\n## License\n\nMIT © [brngdsn](https://github.com/brngdsn)\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request for any bugs, features, or enhancements.\n\n---\n\n*This project is a simple static server with HMR capabilities, designed to improve your web development experience by providing instant feedback on file changes.*\n","readmeFilename":"README.md"}