{"_id":"@diyawanna/lan-bridge","_rev":"2-4e4c735cb9b50a242883d1ef00f0bc7c","name":"@diyawanna/lan-bridge","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@diyawanna/lan-bridge","version":"0.0.1","author":{"name":"wsmr"},"license":"ISC","_id":"@diyawanna/lan-bridge@0.0.1","maintainers":[{"name":"diyawanna","email":"wije.sahan@gmail.com"}],"homepage":"https://github.com/Diyawanna/npm-lan-bridge#readme","bugs":{"url":"https://github.com/Diyawanna/npm-lan-bridge/issues"},"dist":{"shasum":"55255d18067e95b8d76e961ad14621c3fd6e72d1","tarball":"https://registry.npmjs.org/@diyawanna/lan-bridge/-/lan-bridge-0.0.1.tgz","fileCount":6,"integrity":"sha512-pBHUVMJsusAQokXBPOCyD+POMK0TxrcWeZMg0nWvdOYqCu6psfh/ptY3FP1BA+9KELW/X0ZiABaDHG5Y2lAzmA==","signatures":[{"sig":"MEUCIFBQPdUB3xcnfgd+h/HFsk+eZ8t5tjHHTkdwhnsFl+FdAiEA23ytbNkKxCwBIWMpnxykBPJ6Ph5/mJCi9an9Yw+5sv0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6564},"main":"dist/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsup"},"_npmUser":{"name":"diyawanna","email":"wije.sahan@gmail.com"},"repository":{"url":"git+https://github.com/Diyawanna/npm-lan-bridge.git","type":"git"},"_npmVersion":"10.8.1","description":"LAN-based communication module","directories":{},"_nodeVersion":"22.3.0","dependencies":{"ws":"^8.18.2"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.8.3"},"_npmOperationalInternal":{"tmp":"tmp/lan-bridge_0.0.1_1749628826635_0.6525424138636624","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@diyawanna/lan-bridge","version":"0.0.2","description":"LAN-based communication module","main":"dist/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsup"},"repository":{"type":"git","url":"git+https://github.com/Diyawanna/npm-lan-bridge.git"},"author":{"name":"wsmr"},"license":"ISC","bugs":{"url":"https://github.com/Diyawanna/npm-lan-bridge/issues"},"homepage":"https://github.com/Diyawanna/npm-lan-bridge#readme","dependencies":{"ws":"^8.18.2"},"devDependencies":{"tsup":"^8.5.0","typescript":"^5.8.3"},"_id":"@diyawanna/lan-bridge@0.0.2","gitHead":"c11ea0a71b5cf5a19d82aed9aec754825c109496","_nodeVersion":"22.3.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-yjwI/6ze40KZEKNO9F1mejVyxIeKCoYa9EgQILXImmVGGQ8fTPcnXe/KIAw4invi/JnUBFfq7QSVgZgByqom4Q==","shasum":"366bc6fad170d5c9b8f74fb0b60aeaecf2dcce5b","tarball":"https://registry.npmjs.org/@diyawanna/lan-bridge/-/lan-bridge-0.0.2.tgz","fileCount":7,"unpackedSize":10634,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICoueiLs8OHQseWszxt20S/sEeVNfBDG2PZrfM8a3AZzAiEA13X6x0cwAOl8D1eGrYeCjv5e+RPDwmy32v2hPHUNrX0="}]},"_npmUser":{"name":"diyawanna","email":"wije.sahan@gmail.com"},"directories":{},"maintainers":[{"name":"diyawanna","email":"wije.sahan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lan-bridge_0.0.2_1749631314928_0.3853156244958469"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-11T08:00:26.509Z","modified":"2025-06-11T08:41:55.279Z","0.0.1":"2025-06-11T08:00:26.794Z","0.0.2":"2025-06-11T08:41:55.118Z"},"bugs":{"url":"https://github.com/Diyawanna/npm-lan-bridge/issues"},"author":{"name":"wsmr"},"license":"ISC","homepage":"https://github.com/Diyawanna/npm-lan-bridge#readme","repository":{"type":"git","url":"git+https://github.com/Diyawanna/npm-lan-bridge.git"},"description":"LAN-based communication module","maintainers":[{"name":"diyawanna","email":"wije.sahan@gmail.com"}],"readme":"# @diyawanna/lan-bridge\n\n**LAN-based Peer Communication Bridge for JavaScript & TypeScript Projects**\n\n> Communicate between devices over the same local Wi-Fi/LAN network using WebSockets with zero backend hosting. Ideal for React, Angular, Vite, or any frontend projects.\n\n---\n\n## 🧠 Idea & Concept\n\nIf you're building a project that runs on multiple devices (mobile, laptop, etc.) **on the same Wi-Fi or LAN**, this module lets those devices:\n\n- 🔍 Detect each other through a WebSocket server\n- 📡 Send and receive data (`text`, `images`, `files`) in JSON format\n- 🔁 Handle real-time communication in both directions\n- 🧑‍💻 Assign and identify devices by code (`name(IP address)` style)\n\nUse this in Vite, React, Angular, or any modern frontend stack.\n\n---\n\n## 🚀 Features\n\n- 📡 LAN WebSocket Server & Client\n- 🔒 Private & local-only communication (no internet required)\n- 📨 Send/Receive typed JSON payloads\n- ⚡ Instant peer-to-peer-like messaging\n- 🧰 Written in clean TypeScript with type definitions\n\n---\n\n## 📦 Installation\n\nInstall via npm:\n\n```bash\nnpm install @diyawanna/lan-bridge\n```\n\n## ⚙️ Tools Used\n\n| Tool/Library | Purpose |\n|---|---|\n| TypeScript | Strongly-typed development |\n| ws | WebSocket server/client |\n| tsup | Modern TypeScript bundler |\n| npm | Package publishing |\n\n## 🧱 Project Structure\n\n```bash\nlan-bridge/\n├── src/\n│   └── index.ts         # Core logic (server/client)\n├── dist/                # Compiled output (built with tsup)\n├── tsup.config.ts       # Build config\n├── tsconfig.json        # TypeScript config\n└── package.json\n```\n\n## 🌐 How It Works\n\nStart a LAN WebSocket server on one device (e.g. your laptop).\n\nConnect from multiple devices (e.g. phone/tablet) using the LAN IP.\n\nUse simple APIs to send/receive data in JSON format.\n\n## ✍️ Usage Example\n\n### Start Server (on laptop):\n\n```ts\nimport { startServer } from '@diyawanna/lan-bridge';\n\nstartServer(9000); // Opens ws://<local-ip>:9000\n```\n\n### Connect Client (on phone or other devices):\n\n```ts\nimport { connectClient, send } from '@diyawanna/lan-bridge';\n\nconst socket = connectClient('ws://192.168.1.10:9000', (msg) => {\n  console.log('Received:', msg);\n});\n\n// Send data\nsend(socket, {\n  from: 'my-phone',\n  type: 'text',\n  payload: 'Hello from phone!'\n});\n```\n\n🧠 Tip: You can find your local IP address from your Vite dev server logs (➜ Network: http://192.168.x.x:5173).\n\n## 🧪 Supported Message Types\n\nThe module currently supports:\n\n- `text`\n- `image` (as base64)\n- `file` (as base64 or metadata)\n\n### Message Format:\n\n```ts\ntype Message = {\n  from: string;\n  type: 'text' | 'image' | 'file';\n  payload: any;\n};\n```\n\n## 📋 API Reference\n\n### `startServer(port?: number): void`\n\nStarts a WebSocket server listening on all interfaces (0.0.0.0) at the specified port.\n\n### `connectClient(url: string, onMessage: (msg: Message) => void): WebSocket`\n\nConnects to the LAN server and starts listening for messages.\n\n### `send(socket: WebSocket, message: Message): void`\n\nSends a message through an open WebSocket connection.\n\n## 🌍 Example Use Cases\n\n- Send a file from your mobile to your PC by scanning a QR code.\n- Display a live shared whiteboard across multiple devices on LAN.\n- Instantly sync user actions between devices in a local event or classroom.\n\n## 🔐 Security Note\n\nThis module uses raw WebSocket communication over LAN without encryption. Do not use on public or unsafe networks.\n\n## 📦 Publishing\n\nThis package is published to:\n\n👉 [npmjs.com/package/@diyawanna/lan-bridge](https://www.npmjs.com/package/@diyawanna/lan-bridge)\n\nPublished under MIT License by @diyawanna.\n\n## 📜 License\n\nMIT\n\n## ✉️ Contact / Feedback\n\nCreated by @diyawanna\nOpen issues or suggestions on GitHub!\n\n---\n\nWould you like me to:\n- Generate the full GitHub repo structure (`.gitignore`, `LICENSE`, etc.)?\n- Add a QR code feature for easier LAN access?\n- Help set up image/file sending via blob/base64 encoding?\n\nLet’s get this package awesome and user-friendly!\n\n\n","readmeFilename":"README.md"}