{"_id":"@aituber-onair/bushitsu-client","_rev":"4-9e32bac35cf543a4827998716e7bb1a8","name":"@aituber-onair/bushitsu-client","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@aituber-onair/bushitsu-client","version":"0.1.0","keywords":["websocket","react","chat","client","aituber","bushitsu"],"author":{"name":"shinshin86"},"license":"MIT","_id":"@aituber-onair/bushitsu-client@0.1.0","maintainers":[{"name":"shinshin86","email":"shinshin86npm@gmail.com"}],"homepage":"https://github.com/shinshin86/aituber-onair#readme","bugs":{"url":"https://github.com/shinshin86/aituber-onair/issues"},"dist":{"shasum":"cf60356efe8b2ff58993c5da0ca86cc8bf059fcc","tarball":"https://registry.npmjs.org/@aituber-onair/bushitsu-client/-/bushitsu-client-0.1.0.tgz","fileCount":2,"integrity":"sha512-LkuCuvg7HQzKGE+hVINeXHot0ST52NZ/zLWiUHHvrpVoR7g30gg2R2gufxaFY9WCuhTGT//YFEzpBJ5hK8knvA==","signatures":[{"sig":"MEQCIAUDJRSk3qHgTPJfuAWo1ozFDMivukG+h1cT5dtn5+NfAiAh9HDPJEOFxgkWZAnzPSix7A/flfLpoPXgnB5t9C6jUA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15287},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"gitHead":"65703f63e3e66aeb35e6fae3549e8ddfa48a872e","scripts":{"fmt":"biome format --write ./src ./tests","lint":"biome lint ./src ./tests","test":"npm run typecheck && vitest run","build":"npm run build:clean && npm run build:cjs && npm run build:esm && npm run build:types","check":"biome check ./src ./tests","lint:fix":"biome lint --fix ./src ./tests","test:run":"vitest run","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","check:fix":"biome check --fix ./src ./tests","fmt:check":"biome format ./src ./tests","typecheck":"tsc --noEmit","build:clean":"rm -rf dist","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationDir dist/types"},"_npmUser":{"name":"shinshin86","email":"shinshin86npm@gmail.com"},"repository":{"url":"git+https://github.com/shinshin86/aituber-onair.git","type":"git","directory":"packages/bushitsu-client"},"_npmVersion":"10.8.2","description":"WebSocket client for chat functionality with React hooks support","directories":{},"_nodeVersion":"20.19.3","_hasShrinkwrap":false,"devDependencies":{"react":"^18.3.1","vitest":"^2.1.6","typescript":"^5.7.2","@types/react":"^18.3.12","@biomejs/biome":"^1.9.4","@testing-library/react":"^15.0.7","@testing-library/jest-dom":"^6.6.3"},"peerDependencies":{"react":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bushitsu-client_0.1.0_1752571941083_0.7523266662760282","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aituber-onair/bushitsu-client","version":"0.1.1","keywords":["websocket","react","chat","client","aituber","bushitsu"],"author":{"name":"shinshin86"},"license":"MIT","_id":"@aituber-onair/bushitsu-client@0.1.1","maintainers":[{"name":"shinshin86","email":"shinshin86npm@gmail.com"}],"homepage":"https://github.com/shinshin86/aituber-onair#readme","bugs":{"url":"https://github.com/shinshin86/aituber-onair/issues"},"dist":{"shasum":"3095c670a4b80c0e1a51f6c3064f08c4f503b537","tarball":"https://registry.npmjs.org/@aituber-onair/bushitsu-client/-/bushitsu-client-0.1.1.tgz","fileCount":37,"integrity":"sha512-xJVOyfvVonSR/5zandxwglCxjmJA2x8+523hQ5W0/XYQQOckJY+Yclkb8s5Tz/k49g6xoVAcmgqUFyC68jXFTA==","signatures":[{"sig":"MEYCIQC2ysE5oBMFEGK1+PBHwMbbICWQ41mb5n5i4rY9Z/wXMQIhAJg/YikL3SU0GML2gGsHvDieWe1vykzHKetkE+rLF0A+","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":83463},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"gitHead":"98a0571a0c18e2e6f7b3d290aa2018bfcc6a17cb","scripts":{"fmt":"biome format --write ./src ./tests","lint":"biome lint ./src ./tests","test":"npm run typecheck && vitest run","build":"npm run build:clean && npm run build:cjs && npm run build:esm && npm run build:types","check":"biome check ./src ./tests","lint:fix":"biome lint --fix ./src ./tests","test:run":"vitest run","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","check:fix":"biome check --fix ./src ./tests","fmt:check":"biome format ./src ./tests","typecheck":"tsc --noEmit","build:clean":"rm -rf dist","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationDir dist/types","prepublishOnly":"npm run build"},"_npmUser":{"name":"shinshin86","email":"shinshin86npm@gmail.com"},"repository":{"url":"git+https://github.com/shinshin86/aituber-onair.git","type":"git","directory":"packages/bushitsu-client"},"_npmVersion":"10.8.2","description":"WebSocket client for chat functionality with React hooks support","directories":{},"_nodeVersion":"20.19.3","_hasShrinkwrap":false,"devDependencies":{"react":"^18.3.1","vitest":"^2.1.6","typescript":"^5.7.2","@types/react":"^18.3.12","@biomejs/biome":"^1.9.4","@testing-library/react":"^15.0.7","@testing-library/jest-dom":"^6.6.3"},"peerDependencies":{"react":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bushitsu-client_0.1.1_1752574307801_0.8030086061833275","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@aituber-onair/bushitsu-client","version":"0.2.0","keywords":["websocket","react","chat","client","aituber","bushitsu"],"author":{"name":"shinshin86"},"license":"MIT","_id":"@aituber-onair/bushitsu-client@0.2.0","maintainers":[{"name":"shinshin86","email":"shinshin86npm@gmail.com"}],"homepage":"https://github.com/shinshin86/aituber-onair#readme","bugs":{"url":"https://github.com/shinshin86/aituber-onair/issues"},"dist":{"shasum":"abf76eebc509ec9ebc6c6e703afd42d8d2589e28","tarball":"https://registry.npmjs.org/@aituber-onair/bushitsu-client/-/bushitsu-client-0.2.0.tgz","fileCount":62,"integrity":"sha512-z5yagy/u3g8IGrDFmAnUlhQL1fHo7ceuwzHwoyMQ2BSZo9C6Lk34c7CYUv+OivS6U+h/iDB+oCpPOriHG1r5Uw==","signatures":[{"sig":"MEQCIBK26evp1JP6DyIXQ4i2f3u7YMwS/G3UmGuo5zPyEMPXAiAaTrp8oiECtkDemzFA4rQLQgrwlxlvUNs0mJ516gz45Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":115013},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./gas":{"types":"./dist/types/gas/index.d.ts","import":"./dist/esm/gas/index.js","require":"./dist/cjs/gas/index.js"},"./node":{"types":"./dist/types/node/index.d.ts","import":"./dist/esm/node/index.js","require":"./dist/cjs/node/index.js"},"./react":{"types":"./dist/types/react/index.d.ts","import":"./dist/esm/react/index.js","require":"./dist/cjs/react/index.js"}},"gitHead":"63b7489cfb749f067ecddcd72cc2e5e2e095738e","scripts":{"fmt":"biome format --write ./src ./tests","lint":"biome lint ./src ./tests","test":"npm run typecheck && vitest run","build":"npm run build:clean && npm run build:cjs && npm run build:esm && npm run build:types","check":"biome check ./src ./tests","lint:fix":"biome lint --fix ./src ./tests","test:run":"vitest run","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","check:fix":"biome check --fix ./src ./tests","fmt:check":"biome format ./src ./tests","typecheck":"tsc --noEmit","build:clean":"rm -rf dist","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationDir dist/types","prepublishOnly":"npm run build"},"_npmUser":{"name":"shinshin86","email":"shinshin86npm@gmail.com"},"repository":{"url":"git+https://github.com/shinshin86/aituber-onair.git","type":"git","directory":"packages/bushitsu-client"},"_npmVersion":"10.8.2","description":"WebSocket client for chat functionality with React hooks support","directories":{},"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"react":"^18.3.1","vitest":"^2.1.6","typescript":"^5.7.2","@types/react":"^18.3.12","@biomejs/biome":"^1.9.4","@testing-library/react":"^15.0.7","@testing-library/jest-dom":"^6.6.3"},"peerDependencies":{"react":"^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bushitsu-client_0.2.0_1758439364109_0.37013396685328614","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@aituber-onair/bushitsu-client","version":"0.2.1","description":"WebSocket client for chat functionality with React hooks support","keywords":["websocket","react","chat","client","aituber","bushitsu"],"author":{"name":"shinshin86"},"license":"MIT","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"},"./node":{"require":"./dist/cjs/node/index.js","import":"./dist/esm/node/index.js","types":"./dist/types/node/index.d.ts"},"./gas":{"require":"./dist/cjs/gas/index.js","import":"./dist/esm/gas/index.js","types":"./dist/types/gas/index.d.ts"},"./react":{"require":"./dist/cjs/react/index.js","import":"./dist/esm/react/index.js","types":"./dist/types/react/index.d.ts"}},"repository":{"type":"git","url":"git+https://github.com/shinshin86/aituber-onair.git","directory":"packages/bushitsu-client"},"bugs":{"url":"https://github.com/shinshin86/aituber-onair/issues"},"scripts":{"build":"npm run build:clean && npm run build:cjs && npm run build:esm && npm run build:types","build:clean":"rm -rf dist","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationDir dist/types","typecheck":"tsc --noEmit","test":"npm run typecheck && vitest run","test:run":"vitest run","fmt":"biome format --write ./src ./tests","fmt:check":"biome format ./src ./tests","lint":"biome lint ./src ./tests","lint:fix":"biome lint --fix ./src ./tests","check":"biome check ./src ./tests","check:fix":"biome check --fix ./src ./tests","prepublishOnly":"npm run build"},"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"devDependencies":{"@biomejs/biome":"^1.9.4","@testing-library/jest-dom":"^6.6.3","@testing-library/react":"^16.3.1","@types/react":"^19.0.10","@types/react-dom":"^19.0.4","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.7.2","vitest":"^2.1.6"},"_id":"@aituber-onair/bushitsu-client@0.2.1","gitHead":"a8f94abe723112ab2a61d7f494ce5f8ed4e6d6ce","homepage":"https://github.com/shinshin86/aituber-onair#readme","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-zkoGsYaFtM7shWGF3TWryFqoGSBuzPO+tyPpzr4fdaNwEUTrZSf/4UmcW2tpy0pO/dbfwIx7HvKGjUxAP19vaA==","shasum":"679e492b938c51a28bcde80c9ad8e62885c334f2","tarball":"https://registry.npmjs.org/@aituber-onair/bushitsu-client/-/bushitsu-client-0.2.1.tgz","fileCount":62,"unpackedSize":115087,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCtlEvy2k4vZ1anIeiDvPmTpLzes3QzuWhex+pfKVyj5gIhAJSFIr9EhCMdho1yNELXGWqbMSOwMDTAg5+w2m4CeF6/"}]},"_npmUser":{"name":"shinshin86","email":"shinshin86npm@gmail.com"},"directories":{},"maintainers":[{"name":"shinshin86","email":"shinshin86npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bushitsu-client_0.2.1_1768302571807_0.7705063187807883"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-15T09:32:20.973Z","modified":"2026-01-13T11:09:32.135Z","0.1.0":"2025-07-15T09:32:21.254Z","0.1.1":"2025-07-15T10:11:48.019Z","0.2.0":"2025-09-21T07:22:44.281Z","0.2.1":"2026-01-13T11:09:31.939Z"},"bugs":{"url":"https://github.com/shinshin86/aituber-onair/issues"},"author":{"name":"shinshin86"},"license":"MIT","homepage":"https://github.com/shinshin86/aituber-onair#readme","keywords":["websocket","react","chat","client","aituber","bushitsu"],"repository":{"type":"git","url":"git+https://github.com/shinshin86/aituber-onair.git","directory":"packages/bushitsu-client"},"description":"WebSocket client for chat functionality with React hooks support","maintainers":[{"name":"shinshin86","email":"shinshin86npm@gmail.com"}],"readme":"# @aituber-onair/bushitsu-client\n\n![@aituber-onair/bushitsu-client logo](./images/aituber-onair-bushitsu-client.png)\n\nA transport-agnostic chat client for [AITuber OnAir Bushitsu](https://github.com/shinshin86/aituber-onair-bushitsu). It provides:\n\n- A reconnecting WebSocket client with rate limiting and mention handling\n- React hooks for browser apps\n- A Node.js helper that works with `ws`\n- A send-only helper tailored for Google Apps Script\n- Low-level transport adapters so you can plug in any runtime\n\nThe package is distributed as an npm workspace and can be imported from environment-specific entry points.\n\n---\n\n## Installation\n\n```bash\nnpm install @aituber-onair/bushitsu-client\n```\n\nIf you plan to use the Node.js helper, also install a WebSocket implementation such as [`ws`](https://www.npmjs.com/package/ws).\n\n```bash\nnpm install ws\n```\n\n---\n\n## Quick Start (React)\n\n```tsx\nimport { useBushitsuClient } from '@aituber-onair/bushitsu-client/react';\n\nfunction ChatComponent() {\n  const { isConnected, sendMessage } = useBushitsuClient({\n    serverUrl: 'http://localhost:8080',\n    room: 'lobby',\n    userName: 'Viewer',\n    isEnabled: true,\n    onComment: (text, from, isMention) => {\n      console.log(`${from}: ${text}${isMention ? ' (mention)' : ''}`);\n    },\n  });\n\n  return (\n    <div>\n      <p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>\n      <button onClick={() => sendMessage('Hello from React!')}>\n        Send\n      </button>\n    </div>\n  );\n}\n```\n\n> **Note**: React-specific exports live in `@aituber-onair/bushitsu-client/react` to keep the core runtime-agnostic.\n\n---\n\n## Node.js Usage\n\nUse the `createNodeBushitsuClient` helper together with a WebSocket implementation such as `ws`.\n\n```ts\nimport { createNodeBushitsuClient } from '@aituber-onair/bushitsu-client/node';\nimport WebSocket from 'ws';\n\nconst client = createNodeBushitsuClient({\n  serverUrl: 'http://localhost:8080',\n  room: 'lobby',\n  userName: 'NodeBot',\n  webSocketImpl: WebSocket as unknown as typeof WebSocket,\n  onReceiveMessage: (text, from, isMention) => {\n    console.log(`${from}: ${text}${isMention ? ' (mention)' : ''}`);\n  },\n  onConnectionChange: (connected) => {\n    console.log(`[status] connected=${connected}`);\n  },\n});\n\nawait client.connect();\nclient.sendMessage('Hello from Node.js');\n```\n\nSee `examples/node-basic` for a full runnable script with graceful shutdown and heartbeats.\n\n---\n\n## Google Apps Script (Send Only)\n\n`createGasBushitsuMessageSender` provides a thin helper for Apps Script environments where only outgoing messages are required.\n\n```ts\nimport { createGasBushitsuMessageSender } from '@aituber-onair/bushitsu-client/gas';\n\nconst sender = createGasBushitsuMessageSender({\n  endpoint: 'https://example.com/api/chat/send',\n  room: 'lobby',\n  userName: 'GasBot',\n  fetchFn: (url, params) => UrlFetchApp.fetch(url, params),\n});\n\nsender.sendMessage('Hello from GAS!');\n```\n\n- Uses `UrlFetchApp.fetch` by default if you do not pass `fetchFn`\n- The default payload is `{ room, userName, text, mentionTo }`\n- Pass a `payloadBuilder` when your bridge expects a custom JSON schema\n\nSee `examples/gas-send-only` for a complete Apps Script snippet.\n\n---\n\n## Custom Transports\n\nThe core client is transport-agnostic. Supply your own implementation via the `transport` dependency injection point.\n\n```ts\nimport { BushitsuClient } from '@aituber-onair/bushitsu-client';\nimport { createWebSocketTransport } from '@aituber-onair/bushitsu-client';\nimport SomePlatformWebSocket from 'some-platform-ws';\n\nconst transport = createWebSocketTransport((url) => new SomePlatformWebSocket(url));\n\nconst client = new BushitsuClient(\n  {\n    serverUrl: 'http://localhost:8080',\n    room: 'lobby',\n    userName: 'CustomClient',\n    onReceiveMessage: (text, from) => console.log(from, text),\n  },\n  { transport },\n);\n```\n\nThe client handles:\n\n- Reconnection with exponential backoff (configurable constants available)\n- Message deduplication and rate limiting\n- Mention filtering and session tracking\n\n---\n\n## API Overview\n\n### Core\n\n- `BushitsuClient(options, dependencies?)`\n  - `options.serverUrl`: Base HTTP/HTTPS URL to your Bushitsu server\n  - `options.room`, `options.userName`\n  - `options.onReceiveMessage(text, from, isMention)` (required)\n  - `options.onConnectionChange?(connected)` (optional)\n  - `dependencies.transport?`: Custom transport implementing `BushitsuTransport`\n- `BushitsuTransport` interface and helpers in `core/transport`\n- Constants (rate limits, reconnection) exported from `client/constants`\n\n### React (`/react` entry point)\n\n- `useBushitsuClient`\n- `useBushitsuInitiative` (priority-aware messaging helper)\n- Shared types re-exported for convenience\n\n### Node (`/node` entry point)\n\n- `createNodeBushitsuClient(options)`\n  - Accepts `webSocketImpl` or `createWebSocket` factory\n  - Returns a configured `BushitsuClient`\n\n### Google Apps Script (`/gas` entry point)\n\n- `createGasBushitsuMessageSender(options)`\n  - Supports `fetchFn`, `payloadBuilder`, `contentType`, and `muteHttpExceptions`\n\n### Transport Utilities\n\n- `createBrowserWebSocketTransport()`\n- `createWebSocketTransport(factory)`\n- `WebSocketFactory`, `WebSocketLike` types for custom integrations\n\n---\n\n## Examples\n\n- `examples/node-basic/` – minimal Node.js bot using `ws`\n- `examples/gas-send-only/` – send-only Apps Script functions\n- `examples/react-basic/` – Vite + React UI hooked up to `useBushitsuClient`\n- Additional React demos live in the `packages/chat` workspace\n\nRun the repository setup:\n\n```bash\nnpm ci\nnpm -w @aituber-onair/bushitsu-client run build\nnpm -w @aituber-onair/bushitsu-client run test\n```\n\n---\n\n## License\n\nMIT\n","readmeFilename":"README.md"}