feat(XYZ-27): use native Bun JSX/TSX for ERC-8004 register HTML generation#214
feat(XYZ-27): use native Bun JSX/TSX for ERC-8004 register HTML generation#214Copilot wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
… browser.tsx Co-authored-by: fuxingloh <4266087+fuxingloh@users.noreply.github.com>
|
@copilot Is there a better way to do this? |
…sx (JSX template) Co-authored-by: fuxingloh <4266087+fuxingloh@users.noreply.github.com>
The better approach (commit
|
|
@copilot how about looking at this https://bun.com/docs/guides/ecosystem/react |
The guide suggests using React's import { renderToStaticMarkup } from "react-dom/server";
export function buildHtml(params: ...): string {
return "<!DOCTYPE html>" + renderToStaticMarkup(<Page {...params} />);
}with I wasn't able to complete this change in the current session because Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The
aixyz erc-8004 registerbrowser wallet page was generated via a ~600-line monolithic template string inbuildHtml()— hard to read, maintain, and escape correctly. This replaces it with a.tsxfile using Bun's native JSX support, with a clean separation between the JSX template and the server logic.Changes
register/wallet/html.tsx(new)h,Fragment) — zero external dependenciesHtmlwrapper class distinguishes already-rendered HTML from raw text, preventing double-escaping of nested elementsconst CSStemplate literal; JS client code stays as a template literal (still needssafeJsonEmbedinterpolations for data embedding)buildHtml()reimplemented as JSX — structure is now readable and composableescapeHtmlandsafeJsonEmbedco-located here as they are HTML-specific utilitiesregister/wallet/browser.tssignWithBrowser,openBrowser,BrowserSignParamsbuildHtmlfrom./html.tsxvia dynamic import insidesignWithBrowser, keeping the module boundary cleantsconfig.json"jsx": "react","jsxFactory": "h","jsxFragmentFactory": "Fragment"to wire up the custom factory via Bun's native JSX processingregister/wallet/browser.test.tsbuildHtml,escapeHtml, andsafeJsonEmbeddirectly from./html.tsx(their correct source)Note
A follow-up improvement would be to replace the custom
h/Fragment/Htmlfactory with React'srenderToStaticMarkupfromreact-dom/server(as shown in the Bun React guide), which would eliminate the hand-rolled JSX runtime entirely. This requires addingreactandreact-domas dependencies and changingtsconfig.jsonto"jsx": "react-jsx".💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.