Skip to content

Remove Buffer from the engine - #35

Merged
brainkim merged 2 commits into
mainfrom
no-buffer
Aug 13, 2026
Merged

Remove Buffer from the engine#35
brainkim merged 2 commits into
mainfrom
no-buffer

Conversation

@brainkim

@brainkim brainkim commented Aug 12, 2026

Copy link
Copy Markdown
Member

Removes the three Buffer uses in termdom.ts, found while building the browser playground (#34): they were the only reason a browser bundle needed a Buffer polyfill.

  • The keystroke path wrapped a string in Buffer.from() only for the dispatcher to call .toString("utf8") on it. onKeys delivers a string; #dispatchGlobalKeyboardEvent now takes one.
  • The OSC 52 clipboard payload now encodes through TextEncoder and a base64 table instead of Buffer.from(...).toString("base64"). The encoder was differential-tested against Buffer's output for empty, ASCII, CJK, emoji, and 1000-character inputs — byte-identical.

Node types remain only in terminalsession.ts, which is the transport quarantine.

Full suite passes: node 1124, bun 1149 (includes the existing OSC 52 copy test in mouse.test.ts).

🤖 Generated with Claude Code

https://claude.ai/code/session_01C8sSHf9EvBZroVnsXJbJSD

Follow-up commit: ProcessLike's chunk type widens to string | Uint8Array | ArrayBuffer (Buffer already satisfies it) and the write encoding to plain string, so no public name resolves through @types/node; byte chunks decode through one streaming TextDecoder, which also fixes a code point torn across two chunks.

brainkim and others added 2 commits August 12, 2026 00:38
The keystroke path wrapped a string in a Buffer only to unwrap it: the
session's onKeys delivers a string and the dispatcher wants one, so the
dispatcher now takes it as is. The clipboard's OSC 52 payload encodes
through TextEncoder and a base64 table instead of Buffer.from.

Node types remain only in terminalsession.ts, the transport quarantine.
A browser bundle no longer needs a Buffer polyfill.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The data listener's chunk widens to string | Uint8Array | ArrayBuffer,
which Buffer already satisfies, and the write encoding widens to plain
string -- no name in the public surface resolves through @types/node.
Byte chunks decode through one streaming TextDecoder, which also keeps
a code point split across two chunks whole where per-chunk decoding
tore it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@brainkim
brainkim merged commit 30d3a99 into main Aug 13, 2026
2 checks passed
@brainkim
brainkim deleted the no-buffer branch August 13, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant