feat: support MapLibre V5 in hubble.gl tool #3436
Draft
lixun910 wants to merge 2 commits into
Draft
Conversation
…mpatibility - Introduced `getHubbleMapLib` function to lazily load the MapLibre library. - Created `HubbleMapLibreMap` class extending MapLibre's Map with custom transformations. - Added compatibility patches for MapLibre's transform methods to support Hubble-specific functionality. - Enhanced property descriptors for better integration with Hubble's requirements.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Hubble video export integration to work with MapLibre v5 by providing a compatibility shim that restores setter-style access for transform properties expected by Hubble’s Mapbox adapter.
Changes:
- Replace direct
import('maplibre-gl')usage ingetStaticMapPropswith a cachedgetHubbleMapLib()that returns a patched MapLibre module. - Add a
HubbleMapLibreMapsubclass that patches the map’stransforminstance after construction. - Introduce transform patching helpers that re-add setters for read-only transform accessors and stub missing internal methods.
Comments suppressed due to low confidence (1)
src/components/src/modals/hubble-utils.ts:201
- Same issue as
_constrain:_calcMatricesis defined as a no-op unconditionally, which can override an existing implementation (breaking rendering/interaction) or throw if the property is non-configurable. It should only be stubbed when it does not already exist (and the descriptor is configurable).
Object.defineProperty(transform, '_calcMatrices', {
value() {},
writable: true,
configurable: true
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+141
to
+155
| _hubbleMapLibPromise = import('maplibre-gl').then(module => { | ||
| const maplibre = (module as any).default || module; | ||
|
|
||
| class HubbleMapLibreMap extends maplibre.Map { | ||
| constructor(options: any) { | ||
| super(options); | ||
| patchMapLibreTransformForHubble((this as any).transform); | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| ...maplibre, | ||
| Map: HubbleMapLibreMap | ||
| }; | ||
| }); |
Comment on lines
+151
to
+154
| return { | ||
| ...maplibre, | ||
| Map: HubbleMapLibreMap | ||
| }; |
Comment on lines
+191
to
+201
| Object.defineProperty(transform, '_constrain', { | ||
| value() {}, | ||
| writable: true, | ||
| configurable: true | ||
| }); | ||
|
|
||
| Object.defineProperty(transform, '_calcMatrices', { | ||
| value() {}, | ||
| writable: true, | ||
| configurable: true | ||
| }); |
Comment on lines
+161
to
+166
| function patchMapLibreTransformForHubble(transform: any): void { | ||
| if (!transform) return; | ||
|
|
||
| if (transform.__hubbleCompatPatched) return; | ||
|
|
||
| addTransformSetter(transform, 'bearing', 'setBearing'); |
Collaborator
Author
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Hubble's ExportVideoPanelPreview internally calls
applyViewStateToTransform, which directly assigns to the map's transform properties (tr.bearing = ..., tr.pitch = ..., etc.).In MapLibre v4, transform.bearing and similar properties had writable setters, so this worked fine.
In MapLibre v5, these properties were changed to getter-only (read-only accessors). When the Mapbox adapter tries to write to them, it throws error.
The fix provide a compatibility shim:
getHubbleMapLib()dynamically imports maplibre-gl and returns a patched version: