-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ci: test MapLibre v4/v5 and export GlobeControl #2600
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
Changes from all commits
19a6b2a
ca4d8f2
31f199a
b377e39
4363759
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ import type { | |
| TerrainSpecification, | ||
| LogoControl, | ||
| LogoControlOptions, | ||
| GlobeControl | ||
| IControl | ||
| } from 'maplibre-gl'; | ||
|
|
||
| export type { | ||
|
|
@@ -44,10 +44,17 @@ export type { | |
| TerrainControl as TerrainControlInstance, | ||
| LogoControl as LogoControlInstance, | ||
| LogoControlOptions, | ||
| GlobeControl as GlobeControlInstance, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building against v4 produced three TypeScript errors: these two GlobeControl exports don't exist, and one incompatible MapLib assignment. The fix preserves v4 support while making GlobeControl explicitly optional and unavailable at runtime on versions that don’t provide it. Wdyt, @Pessimistress? This was previously undetected since we don't run CI on v4 anymore |
||
| CustomLayerInterface | ||
| } from 'maplibre-gl'; | ||
|
|
||
| type MaplibreModule = typeof import('maplibre-gl'); | ||
|
|
||
| export type GlobeControlInstance = MaplibreModule extends { | ||
| GlobeControl: new () => infer Instance; | ||
| } | ||
| ? Instance | ||
| : IControl & {_container: HTMLElement}; | ||
|
|
||
| /** | ||
| * A user-facing type that represents the minimal intersection between Mapbox and Maplibre | ||
| * User provided `mapLib` is supposed to implement this interface | ||
|
|
@@ -76,5 +83,5 @@ export interface MapLib { | |
|
|
||
| LogoControl: {new (options: LogoControlOptions): LogoControl}; | ||
|
|
||
| GlobeControl: {new (options: any): GlobeControl}; | ||
| GlobeControl?: {new (options: any): GlobeControlInstance}; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,10 +18,20 @@ const Components = [ | |
| 'ScaleControl' | ||
| ] as const; | ||
|
|
||
| function getMissingExports(module: any): null | string[] { | ||
| const MaplibreComponents = [ | ||
| ...Components, | ||
| 'TerrainControl', | ||
| 'LogoControl', | ||
| 'GlobeControl' | ||
| ] as const; | ||
|
|
||
| function getMissingExports( | ||
| module: any, | ||
| components = Components as readonly string[] | ||
| ): null | string[] { | ||
| const missingExports: string[] = []; | ||
| for (const key of Components) { | ||
| if (!legacyComponents[key]) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems to be an old typo. the |
||
| for (const key of components) { | ||
| if (!module[key]) { | ||
| missingExports.push(key); | ||
| } | ||
| } | ||
|
|
@@ -30,7 +40,10 @@ function getMissingExports(module: any): null | string[] { | |
|
|
||
| test('Consistent component names#legacy', t => { | ||
| t.notOk(getMissingExports(legacyComponents), 'Legacy endpoint contains all components'); | ||
| t.notOk(getMissingExports(maplibreComponents), 'Maplibre endpoint contains all components'); | ||
| t.notOk( | ||
| getMissingExports(maplibreComponents, MaplibreComponents), | ||
| 'Maplibre endpoint contains all components' | ||
| ); | ||
| t.notOk(getMissingExports(mapboxComponents), 'Mapbox endpoint contains all components'); | ||
| t.end(); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GlobeControl exists only in MapLibre v5+