comfy-table icon indicating copy to clipboard operation
comfy-table copied to clipboard

ANSI and Styling for non-terminal target (wasm)

Open alexgavrushenko opened this issue 5 months ago • 5 comments

A detailed description of the feature you would like to see added.

It would be nice to move out terminal-related references from custom_styling feature to tty

Explain your usecase of the requested feature

I made a wasm wrapper for library to use it in JS application, but when I went to using ANSI coloring (Application shows logs from docker containers) I have a number of problems with sys::size(), sys::window_size() and other calls, that can't work with wasm target.

Alternatives

No response

Additional context

No response

alexgavrushenko avatar Jul 16 '25 20:07 alexgavrushenko

I've drafted a commit https://github.com/alexgavrushenko/comfy-table/commit/593b07b27866efb02c3363e6797bf77bcad74037

alexgavrushenko avatar Jul 16 '25 21:07 alexgavrushenko

Neat :D

I'm currently thinking about how we can test this. We would have to build this with wasm and run the tests on that. I've never interacted with wasm before, so this is definitely new territory for me!

Nukesor avatar Jul 17 '25 01:07 Nukesor

I've built wasm wrapper and test suite here https://alexgavrushenko.github.io/comfy-table-wasm/test/comprehensive-test.html, but it's definitely out of scope, just shows how it works in browser)

I think the best way to test wasm is:

  • Build for web and bundler targets
  • Add tests for nodejs like https://github.com/alexgavrushenko/comfy-table-wasm/blob/main/test/test.js or mirror existing rust tests

Also complete testing web and bundler targets will require Selenium or other heavy things - so I don't think it is necessary

alexgavrushenko avatar Jul 17 '25 09:07 alexgavrushenko

Thinking about it, it should be enough to simply test the logic with the correct feature flags :)

The wasm build shouldn't be something we need to test. As long as that logic works on another architecture, it should work on wasm as well :)

Nukesor avatar Jul 23 '25 19:07 Nukesor

@alexgavrushenko Feel free to create a pull request for this one. Sorry for not being more direct, my previous comment was meant as a "Yeah, let's just go ahead and skip the tests.".

Nukesor avatar Sep 21 '25 11:09 Nukesor