Effect CommunityEC
Effect Community•3mo ago•
2 replies
Lloyd

Creating a Browser-Based Terminal with Effect and Web Components

no one asked for this, but partly inspired from kit šŸ‘† and his ansi output'd svgs I thought what a fun poc it would be to create a terminal for the browser.

šŸ•¹ļø https://proj-effect-box-web-components.vercel.app/ (near the bottom)
šŸ”— https://github.com/lloydrichards/proj_effect-box-web-components/blob/main/lib/components/prompt-terminal.ts

This is part of a recent dive into using effect with web-components but this is the CLI channel so maybe the interesting part here is how to represent terminal application in the web for demo purposes šŸ¤” While i love making little CLI tools, they are always a pain to show off without people installing them themselves.

The kind of top level explanations here:
1. state changes trigger effect
1. effect-box for rendering TUI using ANSI
1. Everything composed together with
Effect.all

1. fancyAnsi used to format Ansi into Html
1. lit renders the html as part of the web-component (<pre>)

TL;DR: State → Effect[Box] → Effect[ANSI string] → HTML → Browser

Have a play around and let me know what you think
Was this page helpful?