maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
186 stars 106 forks source link

[FEATURE] Compile for WASM #473

Open srmncnk opened 4 days ago

srmncnk commented 4 days ago

Feature Description

I want to build maplibre for web but using the wasm switch.

Describe alternatives you've considered

Mapbox has a few implementation out there but none are as good as this repository.

Additional context

Migration guide: https://dart.dev/interop/js-interop https://dart.dev/interop/js-interop/package-web

Errors while building for wasm:

^
../maplibre_gl_web/lib/src/interop/style/style_image_interop.dart:4:1: Error: JS interop library 'package:js/js.dart' can't be imported when compiling to Wasm.
Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead.
import 'package:js/js.dart';
^
../maplibre_gl_web/lib/src/interop/style/style_interop.dart:4:1: Error: JS interop library 'package:js/js.dart' can't be imported when compiling to Wasm.
Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead.
import 'package:js/js.dart';
^
../maplibre_gl_web/lib/src/interop/ui/map_interop.dart:5:1: Error: JS interop library 'package:js/js.dart' can't be imported when compiling to Wasm.
Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead.
import 'package:js/js.dart';
...
josxha commented 4 days ago

Thanks for the feature request @srmncnk. I allowed myself to shorten the error log a bit.

The current web implementation was written when js/dart interop was still in the early days. Adding support for wasm will be a bigger migration, maybe even rewrite of the maplibre_gl_web package. However, the package has currently no funding and therefore relies on pull requests by contributors. The voluntary work by the maintainers focusses at the moment on code reviews and keeping the package up-to-date. I'd be happy to review any contribution to the package via a pull request. If you (or any other person interested in this feature) can't contribute yourself, you can offer a bounty to interest some other user to implement your feature request. If you are interested, just let me know here or on Slack. 👍

srmncnk commented 4 days ago

@josxha Thanks for the quick response. 👍 I'm aware of the scope, I took a whack at an old mapbox web implementation, but it's no longer maintained and Mapbox themselves don't bother with web in their new package either. So all those are plus points for you guys. JS interop in the early days was way less strict than it is now, it's kind of a surprise flutter took that turn.

I don't have resources to do it either, I'll be monitoring this though.