Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapbox-gl-rtl-text v0.3.0 support #4850

Closed
dbauszus-glx opened this issue Oct 17, 2024 · 3 comments · Fixed by #4860
Closed

mapbox-gl-rtl-text v0.3.0 support #4850

dbauszus-glx opened this issue Oct 17, 2024 · 3 comments · Fixed by #4860

Comments

@dbauszus-glx
Copy link
Contributor

We are loading maplibre-gl 4.7.1 dynamically from esm which works well.

This allows us to use the [email protected] loaded from the unpkg cdn.

When we are trying to update the plugin to the latest version https://unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-rtl-text.js we hit an error on plugin registration and arabix text is not displayed.

image

"RTL Text Plugin failed to import scripts from https://unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-rtl-text.js"

This is not a big issue since 0.2.3 version is working as expected though I would like to understand the nature of the issue.

  // Create promise to load maplibre from esm.sh
  if (!promise) promise = new Promise(async resolve => {

    try {

      const mod = await import('https://esm.sh/[email protected]')

      maplibregl = mod.default

      // Avoid loading RTL Text Plugin twice, else it will error
      if (!['deferred', 'loaded'].includes(maplibregl.getRTLTextPluginStatus())) {
        maplibregl.setRTLTextPlugin(
          'https://unpkg.com/@mapbox/[email protected]/mapbox-gl-rtl-text.min.js',
          true // Lazy load the plugin
        );
      }

      resolve()

    } catch {

      console.error('Failed to load maplibre-gl library.')
      resolve()
    }
  })
@HarelM
Copy link
Collaborator

HarelM commented Oct 17, 2024

I think version 0.3.0 is loading the method in a async manner, and the code expects it to run immediately.
I'm not sure I know how to solve this without a "sleep".
I'll look into it.
The code is here basically if you want to try and tackle this:

this.self.importScripts(urlToLoad);

The following method is expected to call right await, but it doesn't in the new version:

this.self.registerRTLTextPlugin = (rtlTextPlugin: RTLTextPlugin) => {

@HarelM
Copy link
Collaborator

HarelM commented Oct 20, 2024

I've created a PR to fix this issue, any chance you can also test it on your end?

@dbauszus-glx
Copy link
Contributor Author

Awesome. Thanks so much for picking this up quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants