feat: pure .ws parser with zod validation (#40) - #43
Merged
Conversation
First shippable slice of WebSocket support: pure parser in src/core/ws.ts, no VS Code or undici deps, plus 13 vitest cases covering target, headers, directives, interleaved send/recv frames, multi-line bodies, and error paths. Extension wiring, undici WS client, and webview land in follow-up PRs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #40 (partial — first slice)
What changed
src/core/ws.ts— pure.wsfile parser with zero VS Code /undicidependencies. Returns a zod-validatedParsedWebSocketRequest(url, scheme, headers, directives, send/recv frames).test/ws.test.tscovering target parsing, ws/wss schemes, directive + header preamble, interleaved--- send/--- recvframes, multi-line frame bodies, case-insensitive markers, and every error path.Format shipped
Mirrors the
.grpcprecedent: dedicated file kind, pure parser first, thin extension layer on top later.What's left for #40 (follow-up PRs)
src/core/wsClient.ts—undici-backed WS wrapper (thin, no VS Code)src/extension/wsView.ts— Preact webview with frame log + send box.wsfile association + syntax highlighting (reuse header grammar)▶ Open WebSocketcodelens.requests/.history/Keeping this PR small and reviewable per PLAN.md philosophy.
Verification
npm run lint✅npm run typecheck✅npm run test:unit✅ (366 tests, +13)