minify-html icon indicating copy to clipboard operation
minify-html copied to clipboard

Request for bindings for dart and flutter and offering to contribute

Open m-haisham opened this issue 1 year ago • 5 comments

There aren't any official bindings for dart and flutter for this library. I'd like to request that official bindings be created for them so that other developers can easily use this library in their projects.

I'm willing to contribute to the effort and create the bindings myself. I'm familiar with the library and have experience creating bindings for dart. I believe this would be a valuable addition and would benefit many developers who are currently unable to use this library in their projects.

If you think this is a good idea and would like me to proceed with creating the bindings, please let me know. I'd be happy to discuss the requirements and any other details with you.

m-haisham avatar Mar 06 '23 08:03 m-haisham

Thanks for the offer, that sounds great. If you have some work already done, feel free to open a PR and I can take an initial look. Otherwise, happy to discuss an approach here.

wilsonzlin avatar Mar 06 '23 08:03 wilsonzlin

I've not yet started. I plan to write c-bindings on the rust side and compile it as a cdylib, then write bindings to it in dart with c-interop.

I'll create a PR when I have some working code

m-haisham avatar Mar 06 '23 08:03 m-haisham

Is there a Rust/Dart library that provides a safer abstraction? A cursory search came up with https://pub.dev/packages/flutter_rust_bridge. I understand it's fundamentally unsafe but if there's an existing library that is well-tested and owns the unsafe parts, that would be ideal. For example, we currently use PyO3, Neon, jni-rs, and Rutie.

Otherwise, the officially-supported c-interop approach sounds good. I have previously written Node.js bindings in C, might be worth looking at: https://github.com/wilsonzlin/minify-html/blob/ec8c4e338a659f4fe82c0499bded398ac4e77eb0/nodejs/binding.c

wilsonzlin avatar Mar 06 '23 09:03 wilsonzlin

The interaction required through the C abi is minimal, so I thought about implementing it manually. I'll create a PR with the c-interop for starters as I am more familiar with it. I will also take a look at flutter_rust_bridge in the meanwhile.

m-haisham avatar Mar 06 '23 09:03 m-haisham

I've created a draft PR #136, do take a look.

m-haisham avatar Mar 06 '23 16:03 m-haisham