Repository navigation
Add platform bindings for Node and xterm.js - #79
Draft
natemoo-re wants to merge 1 commit into
Draft
natemoo-re wants to merge 1 commit into
natemoo-re wants to merge 1 commit into
Conversation
commit: |
cowboyd
reviewed
Nov 16, 2026
cowboyd
left a comment
Contributor
There was a problem hiding this comment.
Looks great! One thing to consider is the order of operations with some of the TTY refactors
Comment on lines
+46
to
+51
| platform.write(term.update([{ type: 'resize', width, height }])).then( | ||
| () => render.request(), | ||
| () => stop.abort(), | ||
| ); | ||
| }, | ||
| interrupt: () => stop.abort(), |
Contributor
There was a problem hiding this comment.
we won't need to write anything in the future if term.update() is going to return void. We should probably settle that change in tty first first.
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.
What does this PR do?
Follow-up to #74, spiking on @cowboyd's point that we can't assume
processor SIGINT when running in a browser on xterm.js.Host-specific code now lives behind a small
Platforminterface. The package's export conditions pick the binding, so callers never create one themselves:UIOptionskeeps the same fields, but they're all optional now, so this works:index.ts): output defaults toprocess.stdout. Size iswidth/heightif passed, otherwise the TTY'scolumns/rows, otherwise 80×24. The UI follows terminal resizes. It stops on SIGINT/SIGTERM only when nosignalis passed; if you pass one, signal handling stays yours, so existing callers behave the same.index.browser.ts, via thebrowsercondition):createUI({ output: terminal, signal }), whereterminalis an xterm.js terminal. This entry has its ownUIOptionsand its own types under the condition.XtermTerminalonly describes the part of xterm's API we use, so there's no@xterm/xtermdependency.Also:
bench/helpers.ts, which Require an AbortSignal for UI lifetime #74 left callingcreateUIwithout asignal(flagged by @dreyfus92).createUI()exited right away with an unsettled top-level await (code 13), becauseinputis never read and signal listeners don't hold the process open. The same thing happens onmainwhenever the caller doesn't hold the process open themselves.Notes
#platformsubpath imports:bsh buildruns tsdown withconfig: false, which resolves#platformat build time and bakes the Node binding intodist/ui.mjs. If we taught@bomb.sh/toolsto leave#imports unresolved, we could collapse the two entry points into one.Deno.stdoutbinding doesn't buy anything while@bomb.sh/ttydepends onnode:modules.Open questions
esm/wasm.jsusesbrotliDecompressSyncfromnode:zlib, andesm/terminfo.jsimportsnode:fs/promises,node:urlandnode:process;mod.jsre-exports terminfo statically. Until that's split, the browser entry won't actually load in a browser. The xterm binding is only tested against a fake terminal.\x03rather than SIGINT, sointerruptprobably needs to come from input parsing too. Input likely becomes anotherlistenevent.Type of change
Checklist
pnpm test)pnpm format)AI-generated code disclosure