Allow running `ink` in the browser
See original GitHub issueI tried out running ink
in the browser and there seem to be the following complications:
First point of failure is, that readline
doesn’t exist in the browser
https://github.com/vadimdemedes/ink/blob/master/src/components/App.js#L1
As we just want a non-interactive renderer which we plug in to xterm.js, we don’t need readline.
Removing readline gives the next error: stdin
not defined.
That can also be fixed, by passing it into the render function.
Last problem: Chalk doesn’t render the colors, even though xterm is able to render them.
I created an example app that even supports the keyboard events and rerendering with a spinner component: https://github.com/timsuchanek/ink-browser
Demo: https://ink-demo.netlify.com/
You can click into the terminal and go up and down in the select 😉
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Here’s a demo running ink with xtermjs in a browser https://ink-storybook.netlify.app/ - Would be cool to actually make this into a storybook component 😃 - see https://github.com/storybookjs/storybook/issues/11607 as well
this feature could make this project more interesting.