proto-socket/typescript/README.md
toki 8daf53003d 기능: 브라우저 WebSocket 진입점을 추가한다
브라우저 번들에서 Node 전용 ws 의존성을 분리하고 Go 모듈 경로를 현재 저장소명과 맞추기 위해 진입점과 import 경로를 정리한다.
2026-05-20 07:30:53 +09:00

1.4 KiB

TypeScript Proto Socket

Status: planned

This package implements Proto Socket protocol version 0.1 for TypeScript.

Scope

  • Runtime targets: Node.js TCP, Node.js WebSocket, browser native WebSocket.
  • Browser entrypoint (proto-socket): Communicator, BaseClient, BrowserWsClient, connectBrowserWs. Has no ws, node:*, or Buffer dependency.
  • Node entrypoint (proto-socket/node): all of the above plus TcpClient/TcpServer, NodeWsClient/NodeWsServer, connectNodeWs/connectNodeWss.

Import

// browser
import { connectBrowserWs } from "proto-socket";

// node
import { connectNodeWs, NodeWsServer, TcpClient } from "proto-socket/node";

Runtime Dependencies

ws is declared as an optional peer dependency. Install it only when using the Node WebSocket entrypoint (NodeWsClient/NodeWsServer/connectNodeWs/connectNodeWss):

npm install ws

The browser entrypoint and Node TCP-only consumers do not need ws.

Proto Generation

Generated bindings live in src/packets/.

cd typescript
PATH="$PWD/node_modules/.bin:$PATH" protoc \
  --proto_path ../proto \
  --es_out src/packets \
  --es_opt target=ts \
  message_common.proto

After generation, run from the repository root:

tools/check_proto_sync.sh

Validation

cd typescript
npx tsc --noEmit
npx vitest run
cd go
go run ./crosstest/go_typescript.go