Repository navigation
feat(hono): add Hono JSX compiler target - #92
Conversation
|
@kotarotaniguchi0523 is attempting to deploy a commit to the Ripple Team Team on Vercel. A member of the Team first needs to authorize it. |
93efc9b to
ff9facf
Compare
ff2e0a3 to
cea4efb
Compare
7b216a6 to
3dc04d0
Compare
8db29f2 to
cd76e61
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8f55456. Configure here.
3b6f45b to
8855c1b
Compare
|
@leonidaz, could you please review PR #92 when you have time? This PR adds Hono support to TSRX, including the server and DOM compilers and the Vite and Bun integrations. It also incorporates the compile-time platform flags introduced in PR #98 into the Hono compiler, Vite plugin, and Bun plugin. Since you also reviewed PR #98, I would greatly appreciate it if you could check whether its behavior and contracts have been carried over correctly to the Hono integration, especially:
The relevant Hono tests and typechecks are passing, and There is no rush, and I would be very grateful for any feedback. Thank you very much for your time. |
8855c1b to
7faf672
Compare
3713ad9 to
d3eb6a0
Compare
…OM async check (#1226) * fix(hono): treat a registry that escapes as possibly written in the DOM async check Hono DOM's async-component check stays silent on a value it cannot prove (#92), but it only counted direct writes, writes through a tracked alias and the first argument of Object.assign-like built-ins. A registry passed to a function, or held by an object or array that is then written through, was still reported, though the code renders a sync replacement. The check now classifies every reference of every binding by where its value goes. Reads, copies (spreads and rest elements), host JSX values and calls to built-ins that only read (console.*, JSON.stringify, Object.keys and similar) leave it alone. A write, an argument, a method call's object, a returned or yielded value, a component prop, a tagged template and any place the check does not know expose the value: members below the reached path may be replaced. Exposures are path-aware, so memo(UI.App) or register(App) keeps <UI.App /> and <App /> reported. Aliases now record where they reach each root (the alias's value at `held` is the root's value at `path`, with `*` for a dynamic key, array element or iteration step). Object and array literals, sequences, assignment values, parameter and destructuring defaults and for...of heads create aliases, and an exposed alias exposes the part of each root it reaches. This replaces the coarse written set: a write to x.k now counts as replacing members of x only, so App.displayName = ... no longer hides an async App. * fix(hono): bound alias exposure paths and clear arrow-method calls Review fixes for the DOM async check: - Aliases reassigned from each other (`a = [b.a.a, b.b.b]; b = [a.a.a, a.b.b]`) made a new member path for every order of their members, so compiling never finished. A binding's exposure now drops the paths a new one covers, propagates only the path it grew by, and past 16 paths keeps one path that covers them all, with `*` where they differ. Each widening covers more, so cycles end; the four-element cycle compiles as fast as the one-element one. - A method call exposed its object even when the method was an arrow function, which can't reach it through `this`, so `UI.App()` silenced `<UI.App />`. A call whose callee resolves through known initializers to an arrow function no longer exposes the object. - `Object.freeze`, `Object.values`, `Object.entries`, `Object.getOwnPropertyDescriptor(s)`, `Object.getPrototypeOf` and the matching `Reflect` readers join the read-only built-ins. - Array literals and array patterns now match by index, so `const [, r] = [UI, Other]` links `r` to `Other` only. An element after a spread still matches any index. * fix(hono): expose members handed on by built-ins, keep direct paths, cache method lookups Review fixes for the DOM async check: - `Object.freeze` returns its argument, and `Object.values`, `entries`, `getOwnPropertyDescriptor(s)` and `getPrototypeOf` (and the matching `Reflect` readers) return its members, so code can write members of those: `Object.values(UI)[1].App = …` replaced `UI.nested.App` but was still reported. These calls now expose every member (`*`). Only the built-ins that return no part of their argument stay read-only. - The 16-path limit merged a binding's own exposures too, so 17 `patch(UI.kN)` calls widened to `*` and silenced `<UI.nested.App />`, which nothing exposed. The limit now applies only to paths passed on through aliases; paths from the binding's own references are kept. - Each arrow-method check walked the alias chain from scratch, copying the cycle guard at every step, so 1000 aliases with 1000 calls took tens of seconds. Resolution now keeps one guard stack and caches the function each initializer and member path resolve to: a step always leads to the same next step, so the result is the same from wherever it is reached. 1000 aliases with 1000 calls compile in about 190 ms. * fix(hono): count the check's work in tests, honour stringify replacers, don't cache cycle cuts Review fixes for the DOM async check: - The two scaling tests compared wall-clock times against a baseline of about a millisecond, so a GC pause could fail them under load. The check now counts its resolution steps and exposure updates in an internal `hono_dom_validation_work` object, and the tests compare those counts: 1000 aliases with a call each take 2005 steps against 205 for 100 (503503 against 5353 without the cache), and a branching alias cycle takes 191 exposure updates with four elements against 35 with one (it doesn't finish without the path limit). - `JSON.stringify` with a function replacer passes the replacer every value, which can write `UI.App`. It is read-only now only without a replacer or with `null`, `undefined`, a literal or an array. - A resolution the `seen` guard cut short was cached, but the same initializer can still resolve with another member path, so after `<A.x />` reached `A.y` mid-resolution, `<A.y />` was silenced. A null result is cached only when no cut happened while computing it. * fix(hono): count a spread onto a component as handing on the registry A component receives a spread's members as its props, so `<Patch {...box} />` with `box = { ui: UI }` hands `UI` itself to `Patch`, which can replace `UI.App` before render. The check counted every `JSXSpreadAttribute` as a read, so it still reported `<UI.App />` while `<Patch ui={box.ui} />` was silent. A spread onto a component now exposes the members of what it spreads: `<Patch {...box} />` and `<Patch {...{ ui: UI }} />` silence `<UI.App />`, and `<Patch {...UI} />` silences `<UI.nested.App />` but not `<UI.App />`, since the props hold a copy of `UI.App`. A spread onto a host element is still a read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46

closes #91
Summary
Add Hono as a TSRX target with separate server (
hono/jsx) and DOM (hono/jsx/dom) compiler modes, Vite/Bun integrations, and TypeScript/MCP tooling.The website playground now offers Hono (server) and Hono (DOM). Supported shared examples are available for both, with seven additional Hono examples covering server routes, streaming, DOM state and refs, context, Suspense, keyed lists with empty states, and dynamic tags. Target choices are shared between the UI and compile API.
Hono's own runtime APIs handle rendering, streaming, hooks, context, refs, CSS, and ErrorBoundary behavior. No changes are made under
packages/tsrx/**.Compiler behavior
use(promise)with a pending boundary for asynchronous work.@tsrx/hono/domexplicitly withtsrx.compilerfor DOM editor diagnostics. Vite and Bun select their compiler through a build-widemode: 'server' | 'dom'option.tsrx.platformsetting. The integrations read platform configuration from tsconfig and support an explicit matching override.@catch (error)is supported; Hono does not provide a reset callback.Requires Hono
^4.13.7; the Vite integration requires Vite^8.0.0.Validation
pnpm typecheck,pnpm format:check, andpnpm changeset:checkpassed.packages/tsrx/**remains unchanged.The website's separate standalone typecheck still reports pre-existing declaration/configuration errors; a before/after comparison found no new errors. Interactive browser testing was unavailable in this environment.
Closes #91.
Note
Medium Risk
Large new compiler surface (server vs DOM semantics, DOM async validation, and bundler CSS/HMR) plus MCP and editor resolution paths; mitigated by extensive tests but still a broad integration change.
Overview
Adds Hono as a first-class TSRX target with separate
hono/jsx(server) andhono/jsx/dom(browser) compilers in@tsrx/hono, plus@tsrx/vite-plugin-honoand@tsrx/bun-plugin-honothat pick the mode at build time, run the matching JSX transform, and handle extracted<style>CSS (including Vite HMR and per-environment CSS caches).The Hono platform layer adapts TSRX features to Hono’s contracts:
classis preserved, error boundaries emitfallbackRender(no reset callback), server allows async components while DOM disables static hoisting, requires module-scoped hook helpers, and runs a conservative same-module validator for explicitasynccomponents (including destructuring and static object members, while later properties/spreads can override earlier async definitions).Tooling and docs wire Hono through the TypeScript plugin (including explicit
@tsrx/hono/dom), MCP (target: 'hono',mode: 'client'→ DOM), README/llms.txt, a DOM playground, website playground targets/snippets/API tests, root typecheck/CI (including Bun native Hono tests), and a changeset for the new packages.Reviewed by Cursor Bugbot for commit 5b0438f. Bugbot is set up for automated code reviews on this repo. Configure here.