react-bkoi-gl 1.0.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +163 -18
  2. package/dist/components/attribution-control.d.ts +4 -6
  3. package/dist/components/attribution-control.js +6 -5
  4. package/dist/components/attribution-control.js.map +1 -1
  5. package/dist/components/fullscreen-control.d.ts +4 -6
  6. package/dist/components/fullscreen-control.js +4 -4
  7. package/dist/components/fullscreen-control.js.map +1 -1
  8. package/dist/components/geolocate-control.d.ts +10 -26
  9. package/dist/components/geolocate-control.js +11 -11
  10. package/dist/components/geolocate-control.js.map +1 -1
  11. package/dist/components/layer.d.ts +7 -6
  12. package/dist/components/layer.js +8 -9
  13. package/dist/components/layer.js.map +1 -1
  14. package/dist/components/logo-control.d.ts +9 -0
  15. package/dist/components/logo-control.js +28 -0
  16. package/dist/components/logo-control.js.map +1 -0
  17. package/dist/components/map.d.ts +20 -16
  18. package/dist/components/map.js +38 -32
  19. package/dist/components/map.js.map +1 -1
  20. package/dist/components/marker.d.ts +10 -33
  21. package/dist/components/marker.js +22 -15
  22. package/dist/components/marker.js.map +1 -1
  23. package/dist/components/navigation-control.d.ts +4 -6
  24. package/dist/components/navigation-control.js +4 -4
  25. package/dist/components/navigation-control.js.map +1 -1
  26. package/dist/components/popup.d.ts +7 -25
  27. package/dist/components/popup.js +17 -28
  28. package/dist/components/popup.js.map +1 -1
  29. package/dist/components/scale-control.d.ts +4 -6
  30. package/dist/components/scale-control.js +4 -4
  31. package/dist/components/scale-control.js.map +1 -1
  32. package/dist/components/source.d.ts +3 -4
  33. package/dist/components/source.js +20 -22
  34. package/dist/components/source.js.map +1 -1
  35. package/dist/components/terrain-control.d.ts +10 -0
  36. package/dist/components/terrain-control.js +19 -0
  37. package/dist/components/terrain-control.js.map +1 -0
  38. package/dist/components/use-control.d.ts +6 -6
  39. package/dist/components/use-control.js +4 -5
  40. package/dist/components/use-control.js.map +1 -1
  41. package/dist/components/use-map.d.ts +8 -9
  42. package/dist/components/use-map.js +5 -5
  43. package/dist/components/use-map.js.map +1 -1
  44. package/dist/exports-maplibre-gl.d.ts +33 -0
  45. package/dist/exports-maplibre-gl.js +21 -0
  46. package/dist/exports-maplibre-gl.js.map +1 -0
  47. package/dist/index.cjs +590 -681
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.js +2 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/{mapbox → maplibre}/create-ref.d.ts +6 -6
  52. package/dist/maplibre/create-ref.js +30 -0
  53. package/dist/maplibre/create-ref.js.map +1 -0
  54. package/dist/maplibre/maplibre.d.ts +81 -0
  55. package/dist/maplibre/maplibre.js +387 -0
  56. package/dist/maplibre/maplibre.js.map +1 -0
  57. package/dist/styles/index.d.ts +4 -0
  58. package/dist/styles/react-bkoi-gl.css +1 -1
  59. package/dist/styles.d.js +2 -0
  60. package/dist/styles.d.js.map +1 -0
  61. package/dist/tsconfig.build.tsbuildinfo +1 -0
  62. package/dist/types/common.d.ts +2 -60
  63. package/dist/types/common.js.map +1 -1
  64. package/dist/types/events.d.ts +64 -23
  65. package/dist/types/events.js.map +1 -1
  66. package/dist/types/internal.d.ts +14 -0
  67. package/dist/types/internal.js +2 -0
  68. package/dist/types/internal.js.map +1 -0
  69. package/dist/types/lib.d.ts +16 -200
  70. package/dist/types/lib.js.map +1 -1
  71. package/dist/types/style-spec.d.ts +1 -0
  72. package/dist/types/style-spec.js +2 -0
  73. package/dist/types/style-spec.js.map +1 -0
  74. package/dist/utils/apply-react-style.d.ts +1 -1
  75. package/dist/utils/apply-react-style.js.map +1 -1
  76. package/dist/utils/compare-class-names.d.ts +2 -0
  77. package/dist/utils/compare-class-names.js +23 -0
  78. package/dist/utils/compare-class-names.js.map +1 -0
  79. package/dist/utils/deep-equal.d.ts +1 -1
  80. package/dist/utils/deep-equal.js +1 -1
  81. package/dist/utils/deep-equal.js.map +1 -1
  82. package/dist/utils/set-globals.d.ts +6 -8
  83. package/dist/utils/set-globals.js +22 -10
  84. package/dist/utils/set-globals.js.map +1 -1
  85. package/dist/utils/style-utils.d.ts +3 -2
  86. package/dist/utils/style-utils.js +4 -4
  87. package/dist/utils/style-utils.js.map +1 -1
  88. package/dist/utils/transform.d.ts +11 -19
  89. package/dist/utils/transform.js +13 -36
  90. package/dist/utils/transform.js.map +1 -1
  91. package/dist/utils/use-isomorphic-layout-effect.d.ts +1 -1
  92. package/dist/utils/use-isomorphic-layout-effect.js +2 -2
  93. package/dist/utils/use-isomorphic-layout-effect.js.map +1 -1
  94. package/package.json +42 -26
  95. package/src/components/attribution-control.ts +40 -16
  96. package/src/components/fullscreen-control.ts +40 -0
  97. package/src/components/geolocate-control.ts +45 -39
  98. package/src/components/layer.ts +37 -29
  99. package/src/components/logo-control.ts +44 -0
  100. package/src/components/map.tsx +86 -75
  101. package/src/components/marker.ts +141 -123
  102. package/src/components/navigation-control.ts +11 -12
  103. package/src/components/popup.ts +94 -97
  104. package/src/components/scale-control.ts +12 -14
  105. package/src/components/source.ts +58 -57
  106. package/src/components/terrain-control.ts +29 -0
  107. package/src/components/use-control.ts +21 -17
  108. package/src/components/use-map.tsx +26 -24
  109. package/src/exports-maplibre-gl.ts +37 -0
  110. package/src/index.ts +3 -2
  111. package/src/maplibre/create-ref.ts +70 -0
  112. package/src/maplibre/maplibre.ts +624 -0
  113. package/src/styles.d.ts +4 -0
  114. package/src/types/common.ts +12 -72
  115. package/src/types/events.ts +102 -42
  116. package/src/types/internal.ts +26 -0
  117. package/src/types/lib.ts +65 -260
  118. package/src/types/style-spec.ts +34 -0
  119. package/src/utils/apply-react-style.ts +7 -3
  120. package/src/utils/compare-class-names.ts +29 -0
  121. package/src/utils/deep-equal.ts +2 -2
  122. package/src/utils/set-globals.ts +22 -28
  123. package/src/utils/style-utils.ts +18 -9
  124. package/src/utils/transform.ts +32 -60
  125. package/src/utils/use-isomorphic-layout-effect.ts +3 -2
  126. package/bkoi-gl/package.json +0 -6
  127. package/dist/exports-bkoi-gl.cjs +0 -1512
  128. package/dist/exports-bkoi-gl.d.ts +0 -89
  129. package/dist/exports-bkoi-gl.js +0 -36
  130. package/dist/exports-bkoi-gl.js.map +0 -1
  131. package/dist/exports-mapbox.d.ts +0 -139
  132. package/dist/exports-mapbox.js +0 -36
  133. package/dist/exports-mapbox.js.map +0 -1
  134. package/dist/mapbox/create-ref.js +0 -64
  135. package/dist/mapbox/create-ref.js.map +0 -1
  136. package/dist/mapbox/mapbox.d.ts +0 -81
  137. package/dist/mapbox/mapbox.js +0 -476
  138. package/dist/mapbox/mapbox.js.map +0 -1
  139. package/dist/types/events-bkoi-gl.d.ts +0 -49
  140. package/dist/types/events-bkoi-gl.js +0 -2
  141. package/dist/types/events-bkoi-gl.js.map +0 -1
  142. package/dist/types/events-mapbox.d.ts +0 -49
  143. package/dist/types/events-mapbox.js +0 -2
  144. package/dist/types/events-mapbox.js.map +0 -1
  145. package/dist/types/index.d.ts +0 -70
  146. package/dist/types/index.js +0 -5
  147. package/dist/types/index.js.map +0 -1
  148. package/dist/types/public.d.ts +0 -2
  149. package/dist/types/public.js +0 -2
  150. package/dist/types/public.js.map +0 -1
  151. package/dist/types/style-spec-bkoi-gl.d.ts +0 -9
  152. package/dist/types/style-spec-bkoi-gl.js +0 -2
  153. package/dist/types/style-spec-bkoi-gl.js.map +0 -1
  154. package/dist/types/style-spec-mapbox.d.ts +0 -7
  155. package/dist/types/style-spec-mapbox.js +0 -2
  156. package/dist/types/style-spec-mapbox.js.map +0 -1
  157. package/src/components/fullscreen-control.tsx +0 -37
  158. package/src/exports-bkoi-gl.ts +0 -156
  159. package/src/exports-mapbox.ts +0 -159
  160. package/src/mapbox/create-ref.ts +0 -118
  161. package/src/mapbox/mapbox.ts +0 -742
  162. package/src/types/events-bkoi-gl.ts +0 -78
  163. package/src/types/events-mapbox.ts +0 -76
  164. package/src/types/index.ts +0 -93
  165. package/src/types/public.ts +0 -9
  166. package/src/types/style-spec-bkoi-gl.ts +0 -81
  167. package/src/types/style-spec-mapbox.ts +0 -80
@@ -1,224 +1,40 @@
1
- import type { PaddingOptions, LngLat, Point, LngLatLike, PointLike, ControlPosition } from './common';
2
- export interface IControl<MapT extends MapInstance = MapInstance> {
3
- onAdd(map: MapT): HTMLElement;
4
- onRemove(map: MapT): void;
5
- getDefaultPosition?: (() => string) | undefined;
6
- }
7
- type Listener = (event?: any) => any;
8
- export interface Evented {
9
- on(type: string, listener: Listener): any;
10
- off(type?: string | any, listener?: Listener): any;
11
- once(type: string, listener: Listener): any;
12
- }
13
- /**
14
- * A user-facing type that represents the minimal intersection between Mapbox.Map and Maplibre.Map
15
- * User provided `mapLib.Map` is supposed to implement this interface
16
- * Only losely typed for compatibility
17
- */
18
- export interface MapInstance extends Evented {
19
- fire(type: string, properties?: {
20
- [key: string]: any;
21
- }): any;
22
- addControl(control: IControl<this>, position?: ControlPosition): any;
23
- removeControl(control: IControl<this>): any;
24
- hasControl(control: IControl<this>): boolean;
25
- resize(): this;
26
- queryRenderedFeatures(geometry?: any, options?: any): any[];
27
- setStyle(style: any, options?: any): any;
28
- isMoving(): boolean;
29
- getStyle(): any;
30
- isStyleLoaded(): boolean | void;
31
- addSource(id: string, source: any): any;
32
- removeSource(id: string): this;
33
- getSource(id: string): any;
34
- addLayer(layer: any, before?: string): any;
35
- moveLayer(id: string, beforeId?: string): any;
36
- removeLayer(id: string): any;
37
- getLayer(id: string): any;
38
- setFilter(layer: string, filter?: any[] | boolean | null): any;
39
- setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): any;
40
- setPaintProperty(layer: string, name: string, value: any): any;
41
- setLayoutProperty(layer: string, name: string, value: any): any;
42
- project(lnglat: any): Point;
43
- unproject(point: any): LngLat;
44
- queryTerrainElevation?(lngLat: any, options?: any): number | null;
45
- getContainer(): HTMLElement;
46
- getCanvas(): HTMLCanvasElement;
47
- remove(): void;
48
- triggerRepaint(): void;
49
- setPadding(padding: PaddingOptions): any;
50
- fitBounds(bounds: any, options?: any): any;
51
- setFog?(fog: any): any;
52
- setLight?(options: any, lightOptions?: any): any;
53
- setTerrain?(terrain?: any): any;
54
- }
55
- export interface MarkerInstance extends Evented {
56
- addTo(map: MapInstance): this;
57
- remove(): this;
58
- getLngLat(): LngLat;
59
- setLngLat(lngLat: LngLatLike): this;
60
- getElement(): HTMLElement;
61
- setPopup(popup?: any): this;
62
- getPopup(): any;
63
- getOffset(): PointLike;
64
- setOffset(offset: PointLike): this;
65
- setDraggable(value: boolean): this;
66
- isDraggable(): boolean;
67
- getRotation(): number;
68
- setRotation(rotation: number): this;
69
- getRotationAlignment(): any;
70
- setRotationAlignment(alignment: any): this;
71
- getPitchAlignment(): any;
72
- setPitchAlignment(alignment: any): this;
73
- }
74
- export interface PopupInstance extends Evented {
75
- options?: any;
76
- addTo(map: MapInstance): this;
77
- remove(): this;
78
- isOpen(): boolean;
79
- getLngLat(): LngLat;
80
- setLngLat(lnglat: LngLatLike): this;
81
- getElement(): HTMLElement;
82
- setDOMContent(htmlNode: any): this;
83
- getMaxWidth(): any;
84
- setMaxWidth(maxWidth: any): this;
85
- addClassName(className: string): void;
86
- removeClassName(className: string): void;
87
- setOffset(offset?: any): this;
88
- }
89
- export interface AttributionControlInstance extends IControl {
90
- _container?: HTMLElement;
91
- }
92
- export interface FullscreenControlInstance extends IControl {
93
- _controlContainer?: HTMLElement;
94
- }
95
- export interface GeolocateControlInstance extends IControl, Evented {
96
- _container?: HTMLElement;
97
- trigger(): any;
98
- }
99
- export interface NavigationControlInstance extends IControl {
100
- _container?: HTMLElement;
101
- }
102
- export interface ScaleControlInstance extends IControl {
103
- _container?: HTMLElement;
104
- options?: any;
105
- setUnit(unit: any): void;
106
- }
1
+ import type { Map, MapOptions, Marker, MarkerOptions, Popup, PopupOptions, AttributionControl, AttributionControlOptions, FullscreenControl, FullscreenControlOptions, GeolocateControl, GeolocateControlOptions, NavigationControl, NavigationControlOptions, ScaleControl, ScaleControlOptions, TerrainControl, TerrainSpecification, LogoControl, LogoControlOptions } from "maplibre-gl";
2
+ export type { ControlPosition, IControl, Map, MapOptions, Marker, MarkerOptions, Popup, PopupOptions, AttributionControl, AttributionControlOptions, FullscreenControl, FullscreenControlOptions, GeolocateControl, GeolocateControlOptions, NavigationControl, NavigationControlOptions, ScaleControl, ScaleControlOptions, TerrainControl, LogoControl, LogoControlOptions, CustomLayerInterface, } from "maplibre-gl";
107
3
  /**
108
4
  * A user-facing type that represents the minimal intersection between Mapbox and Maplibre
109
5
  * User provided `mapLib` is supposed to implement this interface
110
6
  * Only losely typed for compatibility
111
7
  */
112
- export interface MapLib<MapT extends MapInstance> {
8
+ export interface MapLib {
113
9
  supported?: (options: any) => boolean;
114
10
  Map: {
115
- new (options: any): MapT;
11
+ new (options: MapOptions): Map;
116
12
  };
117
13
  Marker: {
118
- new (...options: any[]): MarkerInstance;
14
+ new (options: MarkerOptions): Marker;
119
15
  };
120
16
  Popup: {
121
- new (options: any): PopupInstance;
17
+ new (options: PopupOptions): Popup;
122
18
  };
123
19
  AttributionControl: {
124
- new (options: any): AttributionControlInstance;
20
+ new (options: AttributionControlOptions): AttributionControl;
125
21
  };
126
22
  FullscreenControl: {
127
- new (options: any): FullscreenControlInstance;
23
+ new (options: FullscreenControlOptions): FullscreenControl;
128
24
  };
129
25
  GeolocateControl: {
130
- new (options: any): GeolocateControlInstance;
26
+ new (options: GeolocateControlOptions): GeolocateControl;
131
27
  };
132
28
  NavigationControl: {
133
- new (options: any): NavigationControlInstance;
29
+ new (options: NavigationControlOptions): NavigationControl;
134
30
  };
135
31
  ScaleControl: {
136
- new (options: any): ScaleControlInstance;
32
+ new (options: ScaleControlOptions): ScaleControl;
137
33
  };
138
- }
139
- /**
140
- * Stub for mapbox's Transform class
141
- * https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/transform.js
142
- */
143
- export type Transform = {
144
- width: number;
145
- height: number;
146
- center: LngLat;
147
- zoom: number;
148
- bearing: number;
149
- pitch: number;
150
- padding: PaddingOptions;
151
- elevation: any;
152
- pixelsToGLUnits: [number, number];
153
- cameraElevationReference: 'ground' | 'sea';
154
- clone: () => Transform;
155
- resize: (width: number, height: number) => void;
156
- isPaddingEqual: (value: PaddingOptions) => boolean;
157
- getBounds: () => any;
158
- locationPoint: (lngLat: LngLat) => Point;
159
- pointLocation: (p: Point) => LngLat;
160
- getProjection?: () => any;
161
- setProjection?: (projection: any) => void;
162
- };
163
- export type MapInstanceInternal<MapT extends MapInstance> = MapT & {
164
- transform: Transform;
165
- _render: Function;
166
- _renderTaskQueue: {
167
- run: Function;
34
+ TerrainControl: {
35
+ new (options: TerrainSpecification): TerrainControl;
36
+ };
37
+ LogoControl: {
38
+ new (options: LogoControlOptions): LogoControl;
168
39
  };
169
- };
170
- export interface CustomLayerInterface {
171
- id: string;
172
- type: 'custom';
173
- renderingMode?: '2d' | '3d';
174
- onRemove?(map: MapInstance, gl: WebGLRenderingContext): void;
175
- onAdd?(map: MapInstance, gl: WebGLRenderingContext): void;
176
- prerender?(gl: WebGLRenderingContext, matrix: number[]): void;
177
- render(gl: WebGLRenderingContext, matrix: number[]): void;
178
- }
179
- export interface CustomSourceImplementation<TileDataT> {
180
- id: string;
181
- type: 'custom';
182
- dataType: 'raster';
183
- minzoom?: number;
184
- maxzoom?: number;
185
- scheme?: string;
186
- tileSize?: number;
187
- attribution?: string;
188
- bounds?: [number, number, number, number];
189
- hasTile?: (tileID: {
190
- z: number;
191
- x: number;
192
- y: number;
193
- }) => boolean;
194
- loadTile: (tileID: {
195
- z: number;
196
- x: number;
197
- y: number;
198
- }, options: {
199
- signal: AbortSignal;
200
- }) => Promise<TileDataT>;
201
- prepareTile?: (tileID: {
202
- z: number;
203
- x: number;
204
- y: number;
205
- }) => TileDataT | undefined;
206
- unloadTile?: (tileID: {
207
- z: number;
208
- x: number;
209
- y: number;
210
- }) => void;
211
- onAdd?: (map: MapInstance) => void;
212
- onRemove?: (map: MapInstance) => void;
213
- }
214
- export interface CustomSource<TileDataT = unknown> {
215
- id: string;
216
- type: 'custom';
217
- scheme: string;
218
- minzoom: number;
219
- maxzoom: number;
220
- tileSize: number;
221
- attribution: string;
222
- _implementation: CustomSourceImplementation<TileDataT>;
223
40
  }
224
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","names":[],"sources":["../../src/types/lib.ts"],"sourcesContent":["import type {PaddingOptions, LngLat, Point, LngLatLike, PointLike, ControlPosition} from './common';\n\nexport interface IControl<MapT extends MapInstance = MapInstance> {\n onAdd(map: MapT): HTMLElement;\n\n onRemove(map: MapT): void;\n\n getDefaultPosition?: (() => string) | undefined;\n}\n\ntype Listener = (event?: any) => any;\n\nexport interface Evented {\n on(type: string, listener: Listener);\n\n off(type?: string | any, listener?: Listener);\n\n once(type: string, listener: Listener);\n}\n\n/**\n * A user-facing type that represents the minimal intersection between Mapbox.Map and Maplibre.Map\n * User provided `mapLib.Map` is supposed to implement this interface\n * Only losely typed for compatibility\n */\nexport interface MapInstance extends Evented {\n // https://github.com/mapbox/mapbox-gl-js/issues/6522\n fire(type: string, properties?: {[key: string]: any});\n\n addControl(control: IControl<this>, position?: ControlPosition);\n\n removeControl(control: IControl<this>);\n\n hasControl(control: IControl<this>): boolean;\n\n resize(): this;\n\n queryRenderedFeatures(geometry?: any, options?: any): any[];\n\n setStyle(style: any, options?: any);\n\n isMoving(): boolean;\n\n getStyle(): any;\n\n isStyleLoaded(): boolean | void;\n\n addSource(id: string, source: any);\n\n removeSource(id: string): this;\n\n getSource(id: string): any;\n\n addLayer(layer: any, before?: string);\n\n moveLayer(id: string, beforeId?: string);\n\n removeLayer(id: string);\n\n getLayer(id: string): any;\n\n setFilter(layer: string, filter?: any[] | boolean | null);\n\n setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number);\n\n setPaintProperty(layer: string, name: string, value: any);\n\n setLayoutProperty(layer: string, name: string, value: any);\n\n project(lnglat: any): Point;\n\n unproject(point: any): LngLat;\n\n queryTerrainElevation?(lngLat: any, options?: any): number | null;\n\n getContainer(): HTMLElement;\n\n getCanvas(): HTMLCanvasElement;\n\n remove(): void;\n\n triggerRepaint(): void;\n\n setPadding(padding: PaddingOptions);\n\n fitBounds(bounds: any, options?: any);\n\n setFog?(fog: any);\n\n setLight?(options: any, lightOptions?: any);\n\n setTerrain?(terrain?: any);\n}\n\nexport interface MarkerInstance extends Evented {\n addTo(map: MapInstance): this;\n remove(): this;\n\n getLngLat(): LngLat;\n setLngLat(lngLat: LngLatLike): this;\n\n getElement(): HTMLElement;\n\n setPopup(popup?: any): this;\n getPopup(): any;\n\n getOffset(): PointLike;\n setOffset(offset: PointLike): this;\n\n setDraggable(value: boolean): this;\n isDraggable(): boolean;\n\n getRotation(): number;\n setRotation(rotation: number): this;\n\n getRotationAlignment(): any;\n setRotationAlignment(alignment: any): this;\n\n getPitchAlignment(): any;\n setPitchAlignment(alignment: any): this;\n}\n\nexport interface PopupInstance extends Evented {\n options?: any;\n\n addTo(map: MapInstance): this;\n remove(): this;\n\n isOpen(): boolean;\n\n getLngLat(): LngLat;\n setLngLat(lnglat: LngLatLike): this;\n\n getElement(): HTMLElement;\n\n setDOMContent(htmlNode: any): this;\n\n getMaxWidth(): any;\n setMaxWidth(maxWidth: any): this;\n\n addClassName(className: string): void;\n removeClassName(className: string): void;\n\n setOffset(offset?: any): this;\n}\n\nexport interface AttributionControlInstance extends IControl {\n _container?: HTMLElement;\n}\n\nexport interface FullscreenControlInstance extends IControl {\n _controlContainer?: HTMLElement;\n}\n\nexport interface GeolocateControlInstance extends IControl, Evented {\n _container?: HTMLElement;\n trigger();\n}\n\nexport interface NavigationControlInstance extends IControl {\n _container?: HTMLElement;\n}\n\nexport interface ScaleControlInstance extends IControl {\n _container?: HTMLElement;\n options?: any;\n setUnit(unit: any): void;\n}\n\n/**\n * A user-facing type that represents the minimal intersection between Mapbox and Maplibre\n * User provided `mapLib` is supposed to implement this interface\n * Only losely typed for compatibility\n */\nexport interface MapLib<MapT extends MapInstance> {\n supported?: (options: any) => boolean;\n\n Map: {new (options: any): MapT};\n\n Marker: {new (...options: any[]): MarkerInstance};\n\n Popup: {new (options: any): PopupInstance};\n\n AttributionControl: {new (options: any): AttributionControlInstance};\n\n FullscreenControl: {new (options: any): FullscreenControlInstance};\n\n GeolocateControl: {new (options: any): GeolocateControlInstance};\n\n NavigationControl: {new (options: any): NavigationControlInstance};\n\n ScaleControl: {new (options: any): ScaleControlInstance};\n}\n\n/**\n * Stub for mapbox's Transform class\n * https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/transform.js\n */\nexport type Transform = {\n width: number;\n height: number;\n center: LngLat;\n zoom: number;\n bearing: number;\n pitch: number;\n padding: PaddingOptions;\n elevation: any;\n pixelsToGLUnits: [number, number];\n cameraElevationReference: 'ground' | 'sea';\n\n clone: () => Transform;\n resize: (width: number, height: number) => void;\n isPaddingEqual: (value: PaddingOptions) => boolean;\n getBounds: () => any;\n locationPoint: (lngLat: LngLat) => Point;\n pointLocation: (p: Point) => LngLat;\n\n // Mapbox only\n getProjection?: () => any;\n setProjection?: (projection: any) => void;\n};\n\nexport type MapInstanceInternal<MapT extends MapInstance> = MapT & {\n transform: Transform;\n\n _render: Function;\n\n _renderTaskQueue: {\n run: Function;\n };\n};\n\n// Custom layer\nexport interface CustomLayerInterface {\n id: string;\n type: 'custom';\n renderingMode?: '2d' | '3d';\n\n onRemove?(map: MapInstance, gl: WebGLRenderingContext): void;\n onAdd?(map: MapInstance, gl: WebGLRenderingContext): void;\n\n prerender?(gl: WebGLRenderingContext, matrix: number[]): void;\n render(gl: WebGLRenderingContext, matrix: number[]): void;\n}\n\n// Custom source\n\nexport interface CustomSourceImplementation<TileDataT> {\n id: string;\n type: 'custom';\n dataType: 'raster';\n minzoom?: number;\n maxzoom?: number;\n scheme?: string;\n tileSize?: number;\n attribution?: string;\n bounds?: [number, number, number, number];\n hasTile?: (tileID: {z: number; x: number; y: number}) => boolean;\n loadTile: (\n tileID: {z: number; x: number; y: number},\n options: {signal: AbortSignal}\n ) => Promise<TileDataT>;\n prepareTile?: (tileID: {z: number; x: number; y: number}) => TileDataT | undefined;\n unloadTile?: (tileID: {z: number; x: number; y: number}) => void;\n onAdd?: (map: MapInstance) => void;\n onRemove?: (map: MapInstance) => void;\n}\n\nexport interface CustomSource<TileDataT = unknown> {\n id: string;\n type: 'custom';\n scheme: string;\n minzoom: number;\n maxzoom: number;\n tileSize: number;\n attribution: string;\n\n _implementation: CustomSourceImplementation<TileDataT>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"lib.js","names":[],"sources":["../../src/types/lib.ts"],"sourcesContent":["import type {\n Map,\n MapOptions,\n Marker,\n MarkerOptions,\n Popup,\n PopupOptions,\n AttributionControl,\n AttributionControlOptions,\n FullscreenControl,\n FullscreenControlOptions,\n GeolocateControl,\n GeolocateControlOptions,\n NavigationControl,\n NavigationControlOptions,\n ScaleControl,\n ScaleControlOptions,\n TerrainControl,\n TerrainSpecification,\n LogoControl,\n LogoControlOptions,\n} from \"maplibre-gl\";\n\nexport type {\n ControlPosition,\n IControl,\n Map,\n MapOptions,\n Marker,\n MarkerOptions,\n Popup,\n PopupOptions,\n AttributionControl,\n AttributionControlOptions,\n FullscreenControl,\n FullscreenControlOptions,\n GeolocateControl,\n GeolocateControlOptions,\n NavigationControl,\n NavigationControlOptions,\n ScaleControl,\n ScaleControlOptions,\n TerrainControl,\n LogoControl,\n LogoControlOptions,\n CustomLayerInterface,\n} from \"maplibre-gl\";\n\n/**\n * A user-facing type that represents the minimal intersection between Mapbox and Maplibre\n * User provided `mapLib` is supposed to implement this interface\n * Only losely typed for compatibility\n */\nexport interface MapLib {\n supported?: (options: any) => boolean;\n\n Map: { new (options: MapOptions): Map };\n\n Marker: { new (options: MarkerOptions): Marker };\n\n Popup: { new (options: PopupOptions): Popup };\n\n AttributionControl: {\n new (options: AttributionControlOptions): AttributionControl;\n };\n\n FullscreenControl: {\n new (options: FullscreenControlOptions): FullscreenControl;\n };\n\n GeolocateControl: {\n new (options: GeolocateControlOptions): GeolocateControl;\n };\n\n NavigationControl: {\n new (options: NavigationControlOptions): NavigationControl;\n };\n\n ScaleControl: { new (options: ScaleControlOptions): ScaleControl };\n\n TerrainControl: { new (options: TerrainSpecification): TerrainControl };\n\n LogoControl: { new (options: LogoControlOptions): LogoControl };\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export type { LayerSpecification, FillLayerSpecification, LineLayerSpecification, SymbolLayerSpecification, CircleLayerSpecification, HeatmapLayerSpecification, FillExtrusionLayerSpecification, RasterLayerSpecification, HillshadeLayerSpecification, BackgroundLayerSpecification, SourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification, GeoJSONSourceSpecification, VideoSourceSpecification, ImageSourceSpecification, CanvasSourceSpecification, StyleSpecification, SkySpecification, LightSpecification, TerrainSpecification, ProjectionSpecification, } from "maplibre-gl";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=style-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-spec.js","names":[],"sources":["../../src/types/style-spec.ts"],"sourcesContent":["/*\n * Maplibre Style Specification types\n * Type names are aligned with mapbox\n */\nexport type {\n // Layers\n LayerSpecification,\n FillLayerSpecification,\n LineLayerSpecification,\n SymbolLayerSpecification,\n CircleLayerSpecification,\n HeatmapLayerSpecification,\n FillExtrusionLayerSpecification,\n RasterLayerSpecification,\n HillshadeLayerSpecification,\n BackgroundLayerSpecification,\n\n // Sources\n SourceSpecification,\n VectorSourceSpecification,\n RasterSourceSpecification,\n RasterDEMSourceSpecification,\n GeoJSONSourceSpecification,\n VideoSourceSpecification,\n ImageSourceSpecification,\n CanvasSourceSpecification,\n\n // Style\n StyleSpecification,\n SkySpecification,\n LightSpecification,\n TerrainSpecification,\n ProjectionSpecification,\n} from \"maplibre-gl\";\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import * as React from 'react';
1
+ import * as React from "react";
2
2
  export declare function applyReactStyle(element: HTMLElement, styles: React.CSSProperties): void;
@@ -1 +1 @@
1
- {"version":3,"file":"apply-react-style.js","names":["unitlessNumber","applyReactStyle","element","styles","style","key","value","Number","isFinite","test"],"sources":["../../src/utils/apply-react-style.ts"],"sourcesContent":["import * as React from 'react';\n// This is a simplified version of\n// https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSPropertyOperations.js#L62\nconst unitlessNumber = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;\n\nexport function applyReactStyle(element: HTMLElement, styles: React.CSSProperties) {\n if (!element || !styles) {\n return;\n }\n const style = element.style;\n\n for (const key in styles) {\n const value = styles[key];\n if (Number.isFinite(value) && !unitlessNumber.test(key)) {\n style[key] = `${value}px`;\n } else {\n style[key] = value;\n }\n }\n}\n"],"mappings":"AAGA,MAAMA,cAAc,GAAG,yEAAyE;AAEhG,OAAO,SAASC,eAAeA,CAACC,OAAoB,EAAEC,MAA2B,EAAE;EACjF,IAAI,CAACD,OAAO,IAAI,CAACC,MAAM,EAAE;IACvB;EACF;EACA,MAAMC,KAAK,GAAGF,OAAO,CAACE,KAAK;EAE3B,KAAK,MAAMC,GAAG,IAAIF,MAAM,EAAE;IACxB,MAAMG,KAAK,GAAGH,MAAM,CAACE,GAAG,CAAC;IACzB,IAAIE,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,IAAI,CAACN,cAAc,CAACS,IAAI,CAACJ,GAAG,CAAC,EAAE;MACvDD,KAAK,CAACC,GAAG,CAAC,GAAG,GAAGC,KAAK,IAAI;IAC3B,CAAC,MAAM;MACLF,KAAK,CAACC,GAAG,CAAC,GAAGC,KAAK;IACpB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"apply-react-style.js","names":["unitlessNumber","applyReactStyle","element","styles","style","key","value","Number","isFinite","test"],"sources":["../../src/utils/apply-react-style.ts"],"sourcesContent":["import * as React from \"react\";\n// This is a simplified version of\n// https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSPropertyOperations.js#L62\nconst unitlessNumber =\n /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;\n\nexport function applyReactStyle(\n element: HTMLElement,\n styles: React.CSSProperties,\n) {\n if (!element || !styles) {\n return;\n }\n const style = element.style;\n\n for (const key in styles) {\n const value = styles[key];\n if (Number.isFinite(value) && !unitlessNumber.test(key)) {\n style[key] = `${value}px`;\n } else {\n style[key] = value;\n }\n }\n}\n"],"mappings":"AAGA,MAAMA,cAAc,GAClB,yEAAyE;AAE3E,OAAO,SAASC,eAAeA,CAC7BC,OAAoB,EACpBC,MAA2B,EAC3B;EACA,IAAI,CAACD,OAAO,IAAI,CAACC,MAAM,EAAE;IACvB;EACF;EACA,MAAMC,KAAK,GAAGF,OAAO,CAACE,KAAK;EAE3B,KAAK,MAAMC,GAAG,IAAIF,MAAM,EAAE;IACxB,MAAMG,KAAK,GAAGH,MAAM,CAACE,GAAG,CAAC;IACzB,IAAIE,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,IAAI,CAACN,cAAc,CAACS,IAAI,CAACJ,GAAG,CAAC,EAAE;MACvDD,KAAK,CAACC,GAAG,CAAC,GAAG,GAAGC,KAAK,IAAI;IAC3B,CAAC,MAAM;MACLF,KAAK,CAACC,GAAG,CAAC,GAAGC,KAAK;IACpB;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ /** Compare two classNames string and return the difference */
2
+ export declare function compareClassNames(prevClassName: string | undefined, nextClassName: string | undefined): string[] | null;
@@ -0,0 +1,23 @@
1
+ export function compareClassNames(prevClassName, nextClassName) {
2
+ if (prevClassName === nextClassName) {
3
+ return null;
4
+ }
5
+ const prevClassList = getClassList(prevClassName);
6
+ const nextClassList = getClassList(nextClassName);
7
+ const diff = [];
8
+ for (const c of nextClassList) {
9
+ if (!prevClassList.has(c)) {
10
+ diff.push(c);
11
+ }
12
+ }
13
+ for (const c of prevClassList) {
14
+ if (!nextClassList.has(c)) {
15
+ diff.push(c);
16
+ }
17
+ }
18
+ return diff.length === 0 ? null : diff;
19
+ }
20
+ function getClassList(className) {
21
+ return new Set(className ? className.trim().split(/\s+/) : []);
22
+ }
23
+ //# sourceMappingURL=compare-class-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare-class-names.js","names":["compareClassNames","prevClassName","nextClassName","prevClassList","getClassList","nextClassList","diff","c","has","push","length","className","Set","trim","split"],"sources":["../../src/utils/compare-class-names.ts"],"sourcesContent":["/** Compare two classNames string and return the difference */\nexport function compareClassNames(\n prevClassName: string | undefined,\n nextClassName: string | undefined,\n): string[] | null {\n if (prevClassName === nextClassName) {\n return null;\n }\n\n const prevClassList = getClassList(prevClassName);\n const nextClassList = getClassList(nextClassName);\n const diff: string[] = [];\n\n for (const c of nextClassList) {\n if (!prevClassList.has(c)) {\n diff.push(c);\n }\n }\n for (const c of prevClassList) {\n if (!nextClassList.has(c)) {\n diff.push(c);\n }\n }\n return diff.length === 0 ? null : diff;\n}\n\nfunction getClassList(className: string | undefined) {\n return new Set(className ? className.trim().split(/\\s+/) : []);\n}\n"],"mappings":"AACA,OAAO,SAASA,iBAAiBA,CAC/BC,aAAiC,EACjCC,aAAiC,EAChB;EACjB,IAAID,aAAa,KAAKC,aAAa,EAAE;IACnC,OAAO,IAAI;EACb;EAEA,MAAMC,aAAa,GAAGC,YAAY,CAACH,aAAa,CAAC;EACjD,MAAMI,aAAa,GAAGD,YAAY,CAACF,aAAa,CAAC;EACjD,MAAMI,IAAc,GAAG,EAAE;EAEzB,KAAK,MAAMC,CAAC,IAAIF,aAAa,EAAE;IAC7B,IAAI,CAACF,aAAa,CAACK,GAAG,CAACD,CAAC,CAAC,EAAE;MACzBD,IAAI,CAACG,IAAI,CAACF,CAAC,CAAC;IACd;EACF;EACA,KAAK,MAAMA,CAAC,IAAIJ,aAAa,EAAE;IAC7B,IAAI,CAACE,aAAa,CAACG,GAAG,CAACD,CAAC,CAAC,EAAE;MACzBD,IAAI,CAACG,IAAI,CAACF,CAAC,CAAC;IACd;EACF;EACA,OAAOD,IAAI,CAACI,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGJ,IAAI;AACxC;AAEA,SAASF,YAAYA,CAACO,SAA6B,EAAE;EACnD,OAAO,IAAIC,GAAG,CAACD,SAAS,GAAGA,SAAS,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChE","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { PointLike } from '../types';
1
+ import type { PointLike } from "../types/common";
2
2
  /**
3
3
  * Compare two points
4
4
  * @param a
@@ -25,7 +25,7 @@ export function deepEqual(a, b) {
25
25
  } else if (Array.isArray(b)) {
26
26
  return false;
27
27
  }
28
- if (typeof a === 'object' && typeof b === 'object') {
28
+ if (typeof a === "object" && typeof b === "object") {
29
29
  const aKeys = Object.keys(a);
30
30
  const bKeys = Object.keys(b);
31
31
  if (aKeys.length !== bKeys.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"deep-equal.js","names":["arePointsEqual","a","b","ax","Array","isArray","x","ay","y","bx","by","deepEqual","length","i","aKeys","Object","keys","bKeys","key","hasOwnProperty"],"sources":["../../src/utils/deep-equal.ts"],"sourcesContent":["import type {PointLike} from '../types';\n\n/**\n * Compare two points\n * @param a\n * @param b\n * @returns true if the points are equal\n */\nexport function arePointsEqual(a?: PointLike, b?: PointLike): boolean {\n const ax = Array.isArray(a) ? a[0] : a ? a.x : 0;\n const ay = Array.isArray(a) ? a[1] : a ? a.y : 0;\n const bx = Array.isArray(b) ? b[0] : b ? b.x : 0;\n const by = Array.isArray(b) ? b[1] : b ? b.y : 0;\n return ax === bx && ay === by;\n}\n\n/* eslint-disable complexity */\n/**\n * Compare any two objects\n * @param a\n * @param b\n * @returns true if the objects are deep equal\n */\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true;\n }\n if (!a || !b) {\n return false;\n }\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n } else if (Array.isArray(b)) {\n return false;\n }\n if (typeof a === 'object' && typeof b === 'object') {\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (const key of aKeys) {\n if (!b.hasOwnProperty(key)) {\n return false;\n }\n if (!deepEqual(a[key], b[key])) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n"],"mappings":"AAQA,OAAO,SAASA,cAAcA,CAACC,CAAa,EAAEC,CAAa,EAAW;EACpE,MAAMC,EAAE,GAAGC,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACK,CAAC,GAAG,CAAC;EAChD,MAAMC,EAAE,GAAGH,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACO,CAAC,GAAG,CAAC;EAChD,MAAMC,EAAE,GAAGL,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACI,CAAC,GAAG,CAAC;EAChD,MAAMI,EAAE,GAAGN,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACM,CAAC,GAAG,CAAC;EAChD,OAAOL,EAAE,KAAKM,EAAE,IAAIF,EAAE,KAAKG,EAAE;AAC/B;AASA,OAAO,SAASC,SAASA,CAACV,CAAM,EAAEC,CAAM,EAAW;EACjD,IAAID,CAAC,KAAKC,CAAC,EAAE;IACX,OAAO,IAAI;EACb;EACA,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE;IACZ,OAAO,KAAK;EACd;EACA,IAAIE,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,EAAE;IACpB,IAAI,CAACG,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,IAAID,CAAC,CAACW,MAAM,KAAKV,CAAC,CAACU,MAAM,EAAE;MAC9C,OAAO,KAAK;IACd;IACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGZ,CAAC,CAACW,MAAM,EAAEC,CAAC,EAAE,EAAE;MACjC,IAAI,CAACF,SAAS,CAACV,CAAC,CAACY,CAAC,CAAC,EAAEX,CAAC,CAACW,CAAC,CAAC,CAAC,EAAE;QAC1B,OAAO,KAAK;MACd;IACF;IACA,OAAO,IAAI;EACb,CAAC,MAAM,IAAIT,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,EAAE;IAC3B,OAAO,KAAK;EACd;EACA,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;IAClD,MAAMY,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACf,CAAC,CAAC;IAC5B,MAAMgB,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACd,CAAC,CAAC;IAC5B,IAAIY,KAAK,CAACF,MAAM,KAAKK,KAAK,CAACL,MAAM,EAAE;MACjC,OAAO,KAAK;IACd;IACA,KAAK,MAAMM,GAAG,IAAIJ,KAAK,EAAE;MACvB,IAAI,CAACZ,CAAC,CAACiB,cAAc,CAACD,GAAG,CAAC,EAAE;QAC1B,OAAO,KAAK;MACd;MACA,IAAI,CAACP,SAAS,CAACV,CAAC,CAACiB,GAAG,CAAC,EAAEhB,CAAC,CAACgB,GAAG,CAAC,CAAC,EAAE;QAC9B,OAAO,KAAK;MACd;IACF;IACA,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"file":"deep-equal.js","names":["arePointsEqual","a","b","ax","Array","isArray","x","ay","y","bx","by","deepEqual","length","i","aKeys","Object","keys","bKeys","key","hasOwnProperty"],"sources":["../../src/utils/deep-equal.ts"],"sourcesContent":["import type { PointLike } from \"../types/common\";\n\n/**\n * Compare two points\n * @param a\n * @param b\n * @returns true if the points are equal\n */\nexport function arePointsEqual(a?: PointLike, b?: PointLike): boolean {\n const ax = Array.isArray(a) ? a[0] : a ? a.x : 0;\n const ay = Array.isArray(a) ? a[1] : a ? a.y : 0;\n const bx = Array.isArray(b) ? b[0] : b ? b.x : 0;\n const by = Array.isArray(b) ? b[1] : b ? b.y : 0;\n return ax === bx && ay === by;\n}\n\n/* eslint-disable complexity */\n/**\n * Compare any two objects\n * @param a\n * @param b\n * @returns true if the objects are deep equal\n */\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true;\n }\n if (!a || !b) {\n return false;\n }\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n } else if (Array.isArray(b)) {\n return false;\n }\n if (typeof a === \"object\" && typeof b === \"object\") {\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (const key of aKeys) {\n if (!b.hasOwnProperty(key)) {\n return false;\n }\n if (!deepEqual(a[key], b[key])) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n"],"mappings":"AAQA,OAAO,SAASA,cAAcA,CAACC,CAAa,EAAEC,CAAa,EAAW;EACpE,MAAMC,EAAE,GAAGC,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACK,CAAC,GAAG,CAAC;EAChD,MAAMC,EAAE,GAAGH,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACO,CAAC,GAAG,CAAC;EAChD,MAAMC,EAAE,GAAGL,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACI,CAAC,GAAG,CAAC;EAChD,MAAMI,EAAE,GAAGN,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACM,CAAC,GAAG,CAAC;EAChD,OAAOL,EAAE,KAAKM,EAAE,IAAIF,EAAE,KAAKG,EAAE;AAC/B;AASA,OAAO,SAASC,SAASA,CAACV,CAAM,EAAEC,CAAM,EAAW;EACjD,IAAID,CAAC,KAAKC,CAAC,EAAE;IACX,OAAO,IAAI;EACb;EACA,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE;IACZ,OAAO,KAAK;EACd;EACA,IAAIE,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,EAAE;IACpB,IAAI,CAACG,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,IAAID,CAAC,CAACW,MAAM,KAAKV,CAAC,CAACU,MAAM,EAAE;MAC9C,OAAO,KAAK;IACd;IACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGZ,CAAC,CAACW,MAAM,EAAEC,CAAC,EAAE,EAAE;MACjC,IAAI,CAACF,SAAS,CAACV,CAAC,CAACY,CAAC,CAAC,EAAEX,CAAC,CAACW,CAAC,CAAC,CAAC,EAAE;QAC1B,OAAO,KAAK;MACd;IACF;IACA,OAAO,IAAI;EACb,CAAC,MAAM,IAAIT,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,EAAE;IAC3B,OAAO,KAAK;EACd;EACA,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;IAClD,MAAMY,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACf,CAAC,CAAC;IAC5B,MAAMgB,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACd,CAAC,CAAC;IAC5B,IAAIY,KAAK,CAACF,MAAM,KAAKK,KAAK,CAACL,MAAM,EAAE;MACjC,OAAO,KAAK;IACd;IACA,KAAK,MAAMM,GAAG,IAAIJ,KAAK,EAAE;MACvB,IAAI,CAACZ,CAAC,CAACiB,cAAc,CAACD,GAAG,CAAC,EAAE;QAC1B,OAAO,KAAK;MACd;MACA,IAAI,CAACP,SAAS,CAACV,CAAC,CAACiB,GAAG,CAAC,EAAEhB,CAAC,CAACgB,GAAG,CAAC,CAAC,EAAE;QAC9B,OAAO,KAAK;MACd;IACF;IACA,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
@@ -1,20 +1,18 @@
1
1
  export type GlobalSettings = {
2
- /** The map's default API URL for requesting tiles, styles, sprites, and glyphs. */
3
- baseApiUrl?: string;
4
2
  /** The maximum number of images (raster tiles, sprites, icons) to load in parallel.
5
3
  * @default 16
6
4
  */
7
5
  maxParallelImageRequests?: number;
8
6
  /** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */
9
- RTLTextPlugin?: string | false;
10
- /** Provides an interface for external module bundlers such as Webpack or Rollup to package mapbox-gl's WebWorker into a separate class and integrate it with the library.
11
- Takes precedence over `workerUrl`. */
12
- workerClass?: any;
13
- /** The number of web workers instantiated on a page with mapbox-gl maps.
7
+ RTLTextPlugin?: string | {
8
+ pluginUrl: string;
9
+ lazy?: boolean;
10
+ };
11
+ /** The number of web workers instantiated on a page with maplibre-gl maps.
14
12
  * @default 2
15
13
  */
16
14
  workerCount?: number;
17
- /** Provides an interface for loading mapbox-gl's WebWorker bundle from a self-hosted URL.
15
+ /** Provides an interface for loading maplibre-gl's WebWorker bundle from a self-hosted URL.
18
16
  * This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment
19
17
  * wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */
20
18
  workerUrl?: string;
@@ -1,19 +1,31 @@
1
- const globalSettings = ['baseApiUrl', 'maxParallelImageRequests', 'workerClass', 'workerCount', 'workerUrl'];
2
1
  export default function setGlobals(mapLib, props) {
3
- for (const key of globalSettings) {
4
- if (key in props) {
5
- mapLib[key] = props[key];
6
- }
7
- }
8
2
  const {
9
- RTLTextPlugin = 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js'
3
+ RTLTextPlugin,
4
+ maxParallelImageRequests,
5
+ workerCount,
6
+ workerUrl
10
7
  } = props;
11
- if (RTLTextPlugin && mapLib.getRTLTextPluginStatus && mapLib.getRTLTextPluginStatus() === 'unavailable') {
12
- mapLib.setRTLTextPlugin(RTLTextPlugin, error => {
8
+ if (RTLTextPlugin && mapLib.getRTLTextPluginStatus && mapLib.getRTLTextPluginStatus() === "unavailable") {
9
+ const {
10
+ pluginUrl,
11
+ lazy = true
12
+ } = typeof RTLTextPlugin === "string" ? {
13
+ pluginUrl: RTLTextPlugin
14
+ } : RTLTextPlugin;
15
+ mapLib.setRTLTextPlugin(pluginUrl, error => {
13
16
  if (error) {
14
17
  console.error(error);
15
18
  }
16
- }, true);
19
+ }, lazy);
20
+ }
21
+ if (maxParallelImageRequests !== undefined) {
22
+ mapLib.setMaxParallelImageRequests(maxParallelImageRequests);
23
+ }
24
+ if (workerCount !== undefined) {
25
+ mapLib.setWorkerCount(workerCount);
26
+ }
27
+ if (workerUrl !== undefined) {
28
+ mapLib.setWorkerUrl(workerUrl);
17
29
  }
18
30
  }
19
31
  //# sourceMappingURL=set-globals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"set-globals.js","names":["globalSettings","setGlobals","mapLib","props","key","RTLTextPlugin","getRTLTextPluginStatus","setRTLTextPlugin","error","console"],"sources":["../../src/utils/set-globals.ts"],"sourcesContent":["export type GlobalSettings = {\n /** The map's default API URL for requesting tiles, styles, sprites, and glyphs. */\n baseApiUrl?: string;\n /** The maximum number of images (raster tiles, sprites, icons) to load in parallel.\n * @default 16\n */\n maxParallelImageRequests?: number;\n /** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */\n RTLTextPlugin?: string | false;\n /** Provides an interface for external module bundlers such as Webpack or Rollup to package mapbox-gl's WebWorker into a separate class and integrate it with the library.\nTakes precedence over `workerUrl`. */\n workerClass?: any;\n /** The number of web workers instantiated on a page with mapbox-gl maps.\n * @default 2\n */\n workerCount?: number;\n /** Provides an interface for loading mapbox-gl's WebWorker bundle from a self-hosted URL.\n * This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment\n * wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */\n workerUrl?: string;\n};\n\nconst globalSettings = [\n 'baseApiUrl',\n 'maxParallelImageRequests',\n 'workerClass',\n 'workerCount',\n 'workerUrl'\n] as const;\n\nexport default function setGlobals(mapLib: any, props: GlobalSettings) {\n for (const key of globalSettings) {\n if (key in props) {\n mapLib[key] = props[key];\n }\n }\n\n const {\n RTLTextPlugin = 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js'\n } = props;\n if (\n RTLTextPlugin &&\n mapLib.getRTLTextPluginStatus &&\n mapLib.getRTLTextPluginStatus() === 'unavailable'\n ) {\n mapLib.setRTLTextPlugin(\n RTLTextPlugin,\n (error?: Error) => {\n if (error) {\n // eslint-disable-next-line\n console.error(error);\n }\n },\n true\n );\n }\n}\n"],"mappings":"AAsBA,MAAMA,cAAc,GAAG,CACrB,YAAY,EACZ,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,WAAW,CACH;AAEV,eAAe,SAASC,UAAUA,CAACC,MAAW,EAAEC,KAAqB,EAAE;EACrE,KAAK,MAAMC,GAAG,IAAIJ,cAAc,EAAE;IAChC,IAAII,GAAG,IAAID,KAAK,EAAE;MAChBD,MAAM,CAACE,GAAG,CAAC,GAAGD,KAAK,CAACC,GAAG,CAAC;IAC1B;EACF;EAEA,MAAM;IACJC,aAAa,GAAG;EAClB,CAAC,GAAGF,KAAK;EACT,IACEE,aAAa,IACbH,MAAM,CAACI,sBAAsB,IAC7BJ,MAAM,CAACI,sBAAsB,CAAC,CAAC,KAAK,aAAa,EACjD;IACAJ,MAAM,CAACK,gBAAgB,CACrBF,aAAa,EACZG,KAAa,IAAK;MACjB,IAAIA,KAAK,EAAE;QAETC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;MACtB;IACF,CAAC,EACD,IACF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"set-globals.js","names":["setGlobals","mapLib","props","RTLTextPlugin","maxParallelImageRequests","workerCount","workerUrl","getRTLTextPluginStatus","pluginUrl","lazy","setRTLTextPlugin","error","console","undefined","setMaxParallelImageRequests","setWorkerCount","setWorkerUrl"],"sources":["../../src/utils/set-globals.ts"],"sourcesContent":["export type GlobalSettings = {\n /** The maximum number of images (raster tiles, sprites, icons) to load in parallel.\n * @default 16\n */\n maxParallelImageRequests?: number;\n /** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */\n RTLTextPlugin?: string | { pluginUrl: string; lazy?: boolean };\n /** The number of web workers instantiated on a page with maplibre-gl maps.\n * @default 2\n */\n workerCount?: number;\n /** Provides an interface for loading maplibre-gl's WebWorker bundle from a self-hosted URL.\n * This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment\n * wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */\n workerUrl?: string;\n};\n\nexport default function setGlobals(mapLib: any, props: GlobalSettings) {\n const { RTLTextPlugin, maxParallelImageRequests, workerCount, workerUrl } =\n props;\n if (\n RTLTextPlugin &&\n mapLib.getRTLTextPluginStatus &&\n mapLib.getRTLTextPluginStatus() === \"unavailable\"\n ) {\n const { pluginUrl, lazy = true } =\n typeof RTLTextPlugin === \"string\"\n ? { pluginUrl: RTLTextPlugin }\n : RTLTextPlugin;\n\n mapLib.setRTLTextPlugin(\n pluginUrl,\n (error?: Error) => {\n if (error) {\n // eslint-disable-next-line\n console.error(error);\n }\n },\n lazy,\n );\n }\n if (maxParallelImageRequests !== undefined) {\n mapLib.setMaxParallelImageRequests(maxParallelImageRequests);\n }\n if (workerCount !== undefined) {\n mapLib.setWorkerCount(workerCount);\n }\n if (workerUrl !== undefined) {\n mapLib.setWorkerUrl(workerUrl);\n }\n}\n"],"mappings":"AAiBA,eAAe,SAASA,UAAUA,CAACC,MAAW,EAAEC,KAAqB,EAAE;EACrE,MAAM;IAAEC,aAAa;IAAEC,wBAAwB;IAAEC,WAAW;IAAEC;EAAU,CAAC,GACvEJ,KAAK;EACP,IACEC,aAAa,IACbF,MAAM,CAACM,sBAAsB,IAC7BN,MAAM,CAACM,sBAAsB,CAAC,CAAC,KAAK,aAAa,EACjD;IACA,MAAM;MAAEC,SAAS;MAAEC,IAAI,GAAG;IAAK,CAAC,GAC9B,OAAON,aAAa,KAAK,QAAQ,GAC7B;MAAEK,SAAS,EAAEL;IAAc,CAAC,GAC5BA,aAAa;IAEnBF,MAAM,CAACS,gBAAgB,CACrBF,SAAS,EACRG,KAAa,IAAK;MACjB,IAAIA,KAAK,EAAE;QAETC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;MACtB;IACF,CAAC,EACDF,IACF,CAAC;EACH;EACA,IAAIL,wBAAwB,KAAKS,SAAS,EAAE;IAC1CZ,MAAM,CAACa,2BAA2B,CAACV,wBAAwB,CAAC;EAC9D;EACA,IAAIC,WAAW,KAAKQ,SAAS,EAAE;IAC7BZ,MAAM,CAACc,cAAc,CAACV,WAAW,CAAC;EACpC;EACA,IAAIC,SAAS,KAAKO,SAAS,EAAE;IAC3BZ,MAAM,CAACe,YAAY,CAACV,SAAS,CAAC;EAChC;AACF","ignoreList":[]}
@@ -1,2 +1,3 @@
1
- import { ImmutableLike, MapStyle } from '../types';
2
- export declare function normalizeStyle(style: string | MapStyle | ImmutableLike<MapStyle>): string | MapStyle;
1
+ import type { StyleSpecification } from "../types/style-spec";
2
+ import type { ImmutableLike } from "../types/common";
3
+ export declare function normalizeStyle(style: string | StyleSpecification | ImmutableLike<StyleSpecification>): string | StyleSpecification;
@@ -1,12 +1,12 @@
1
- const refProps = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];
1
+ const refProps = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
2
2
  export function normalizeStyle(style) {
3
3
  if (!style) {
4
4
  return null;
5
5
  }
6
- if (typeof style === 'string') {
6
+ if (typeof style === "string") {
7
7
  return style;
8
8
  }
9
- if ('toJS' in style) {
9
+ if ("toJS" in style) {
10
10
  style = style.toJS();
11
11
  }
12
12
  if (!style.layers) {
@@ -18,7 +18,7 @@ export function normalizeStyle(style) {
18
18
  }
19
19
  const layers = style.layers.map(layer => {
20
20
  let normalizedLayer = null;
21
- if ('interactive' in layer) {
21
+ if ("interactive" in layer) {
22
22
  normalizedLayer = Object.assign({}, layer);
23
23
  delete normalizedLayer.interactive;
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"style-utils.js","names":["refProps","normalizeStyle","style","toJS","layers","layerIndex","layer","id","map","normalizedLayer","Object","assign","interactive","layerRef","ref","propName"],"sources":["../../src/utils/style-utils.ts"],"sourcesContent":["import {ImmutableLike, MapStyle} from '../types';\n\nconst refProps = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\n\n// Prepare a map style object for diffing\n// If immutable - convert to plain object\n// Work around some issues in older styles that would fail Mapbox's diffing\nexport function normalizeStyle(\n style: string | MapStyle | ImmutableLike<MapStyle>\n): string | MapStyle {\n if (!style) {\n return null;\n }\n if (typeof style === 'string') {\n return style;\n }\n if ('toJS' in style) {\n style = style.toJS();\n }\n if (!style.layers) {\n return style;\n }\n const layerIndex = {};\n\n for (const layer of style.layers) {\n layerIndex[layer.id] = layer;\n }\n\n const layers = style.layers.map(layer => {\n let normalizedLayer: typeof layer = null;\n\n if ('interactive' in layer) {\n normalizedLayer = Object.assign({}, layer);\n // Breaks style diffing :(\n // @ts-ignore legacy field not typed\n delete normalizedLayer.interactive;\n }\n\n // Style diffing doesn't work with refs so expand them out manually before diffing.\n // @ts-ignore legacy field not typed\n const layerRef = layerIndex[layer.ref];\n if (layerRef) {\n normalizedLayer = normalizedLayer || Object.assign({}, layer);\n // @ts-ignore\n delete normalizedLayer.ref;\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/deref.js\n for (const propName of refProps) {\n if (propName in layerRef) {\n normalizedLayer[propName] = layerRef[propName];\n }\n }\n }\n\n return normalizedLayer || layer;\n });\n\n // Do not mutate the style object provided by the user\n return {...style, layers};\n}\n"],"mappings":"AAEA,MAAMA,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAK7F,OAAO,SAASC,cAAcA,CAC5BC,KAAkD,EAC/B;EACnB,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,IAAI;EACb;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EACA,IAAI,MAAM,IAAIA,KAAK,EAAE;IACnBA,KAAK,GAAGA,KAAK,CAACC,IAAI,CAAC,CAAC;EACtB;EACA,IAAI,CAACD,KAAK,CAACE,MAAM,EAAE;IACjB,OAAOF,KAAK;EACd;EACA,MAAMG,UAAU,GAAG,CAAC,CAAC;EAErB,KAAK,MAAMC,KAAK,IAAIJ,KAAK,CAACE,MAAM,EAAE;IAChCC,UAAU,CAACC,KAAK,CAACC,EAAE,CAAC,GAAGD,KAAK;EAC9B;EAEA,MAAMF,MAAM,GAAGF,KAAK,CAACE,MAAM,CAACI,GAAG,CAACF,KAAK,IAAI;IACvC,IAAIG,eAA6B,GAAG,IAAI;IAExC,IAAI,aAAa,IAAIH,KAAK,EAAE;MAC1BG,eAAe,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEL,KAAK,CAAC;MAG1C,OAAOG,eAAe,CAACG,WAAW;IACpC;IAIA,MAAMC,QAAQ,GAAGR,UAAU,CAACC,KAAK,CAACQ,GAAG,CAAC;IACtC,IAAID,QAAQ,EAAE;MACZJ,eAAe,GAAGA,eAAe,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEL,KAAK,CAAC;MAE7D,OAAOG,eAAe,CAACK,GAAG;MAE1B,KAAK,MAAMC,QAAQ,IAAIf,QAAQ,EAAE;QAC/B,IAAIe,QAAQ,IAAIF,QAAQ,EAAE;UACxBJ,eAAe,CAACM,QAAQ,CAAC,GAAGF,QAAQ,CAACE,QAAQ,CAAC;QAChD;MACF;IACF;IAEA,OAAON,eAAe,IAAIH,KAAK;EACjC,CAAC,CAAC;EAGF,OAAO;IAAC,GAAGJ,KAAK;IAAEE;EAAM,CAAC;AAC3B","ignoreList":[]}
1
+ {"version":3,"file":"style-utils.js","names":["refProps","normalizeStyle","style","toJS","layers","layerIndex","layer","id","map","normalizedLayer","Object","assign","interactive","layerRef","ref","propName"],"sources":["../../src/utils/style-utils.ts"],"sourcesContent":["import type { StyleSpecification } from \"../types/style-spec\";\nimport type { ImmutableLike } from \"../types/common\";\n\nconst refProps = [\n \"type\",\n \"source\",\n \"source-layer\",\n \"minzoom\",\n \"maxzoom\",\n \"filter\",\n \"layout\",\n];\n\n// Prepare a map style object for diffing\n// If immutable - convert to plain object\n// Work around some issues in older styles that would fail Mapbox's diffing\nexport function normalizeStyle(\n style: string | StyleSpecification | ImmutableLike<StyleSpecification>,\n): string | StyleSpecification {\n if (!style) {\n return null;\n }\n if (typeof style === \"string\") {\n return style;\n }\n if (\"toJS\" in style) {\n style = style.toJS();\n }\n if (!style.layers) {\n return style;\n }\n const layerIndex = {};\n\n for (const layer of style.layers) {\n layerIndex[layer.id] = layer;\n }\n\n const layers = style.layers.map((layer) => {\n let normalizedLayer: typeof layer = null;\n\n if (\"interactive\" in layer) {\n normalizedLayer = Object.assign({}, layer);\n // Breaks style diffing :(\n // @ts-ignore legacy field not typed\n delete normalizedLayer.interactive;\n }\n\n // Style diffing doesn't work with refs so expand them out manually before diffing.\n // @ts-ignore legacy field not typed\n const layerRef = layerIndex[layer.ref];\n if (layerRef) {\n normalizedLayer = normalizedLayer || Object.assign({}, layer);\n // @ts-ignore\n delete normalizedLayer.ref;\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/deref.js\n for (const propName of refProps) {\n if (propName in layerRef) {\n normalizedLayer[propName] = layerRef[propName];\n }\n }\n }\n\n return normalizedLayer || layer;\n });\n\n // Do not mutate the style object provided by the user\n return { ...style, layers };\n}\n"],"mappings":"AAGA,MAAMA,QAAQ,GAAG,CACf,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,CACT;AAKD,OAAO,SAASC,cAAcA,CAC5BC,KAAsE,EACzC;EAC7B,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,IAAI;EACb;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EACA,IAAI,MAAM,IAAIA,KAAK,EAAE;IACnBA,KAAK,GAAGA,KAAK,CAACC,IAAI,CAAC,CAAC;EACtB;EACA,IAAI,CAACD,KAAK,CAACE,MAAM,EAAE;IACjB,OAAOF,KAAK;EACd;EACA,MAAMG,UAAU,GAAG,CAAC,CAAC;EAErB,KAAK,MAAMC,KAAK,IAAIJ,KAAK,CAACE,MAAM,EAAE;IAChCC,UAAU,CAACC,KAAK,CAACC,EAAE,CAAC,GAAGD,KAAK;EAC9B;EAEA,MAAMF,MAAM,GAAGF,KAAK,CAACE,MAAM,CAACI,GAAG,CAAEF,KAAK,IAAK;IACzC,IAAIG,eAA6B,GAAG,IAAI;IAExC,IAAI,aAAa,IAAIH,KAAK,EAAE;MAC1BG,eAAe,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEL,KAAK,CAAC;MAG1C,OAAOG,eAAe,CAACG,WAAW;IACpC;IAIA,MAAMC,QAAQ,GAAGR,UAAU,CAACC,KAAK,CAACQ,GAAG,CAAC;IACtC,IAAID,QAAQ,EAAE;MACZJ,eAAe,GAAGA,eAAe,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEL,KAAK,CAAC;MAE7D,OAAOG,eAAe,CAACK,GAAG;MAE1B,KAAK,MAAMC,QAAQ,IAAIf,QAAQ,EAAE;QAC/B,IAAIe,QAAQ,IAAIF,QAAQ,EAAE;UACxBJ,eAAe,CAACM,QAAQ,CAAC,GAAGF,QAAQ,CAACE,QAAQ,CAAC;QAChD;MACF;IACF;IAEA,OAAON,eAAe,IAAIH,KAAK;EACjC,CAAC,CAAC;EAGF,OAAO;IAAE,GAAGJ,KAAK;IAAEE;EAAO,CAAC;AAC7B","ignoreList":[]}
@@ -1,26 +1,18 @@
1
- import type { MapboxProps } from '../mapbox/mapbox';
2
- import type { Transform, ViewState } from '../types';
3
- /**
4
- * Make a copy of a transform
5
- * @param tr
6
- */
7
- export declare function cloneTransform(tr: Transform): Transform;
8
- /**
9
- * Copy projection from one transform to another. This only applies to mapbox-gl transforms
10
- * @param src the transform to copy projection settings from
11
- * @param dest to transform to copy projection settings to
12
- */
13
- export declare function syncProjection(src: Transform, dest: Transform): void;
1
+ import type { MaplibreProps } from "../maplibre/maplibre";
2
+ import type { ViewState } from "../types/common";
3
+ import type { TransformLike } from "../types/internal";
14
4
  /**
15
5
  * Capture a transform's current state
16
6
  * @param transform
17
7
  * @returns descriptor of the view state
18
8
  */
19
- export declare function transformToViewState(tr: Transform): ViewState;
9
+ export declare function transformToViewState(tr: TransformLike): ViewState;
20
10
  /**
21
- * Mutate a transform to match the given view state
22
- * @param transform
23
- * @param viewState
24
- * @returns true if the transform has changed
11
+ * Applies requested view state to a transform
12
+ * @returns an object containing detected changes
25
13
  */
26
- export declare function applyViewStateToTransform(tr: Transform, props: MapboxProps): boolean;
14
+ export declare function applyViewStateToTransform(
15
+ /** An object that describes Maplibre's camera state */
16
+ tr: TransformLike,
17
+ /** Props from Map component */
18
+ props: MaplibreProps): Partial<TransformLike>;
@@ -1,19 +1,4 @@
1
1
  import { deepEqual } from "./deep-equal.js";
2
- export function cloneTransform(tr) {
3
- const newTransform = tr.clone();
4
- newTransform.pixelsToGLUnits = tr.pixelsToGLUnits;
5
- return newTransform;
6
- }
7
- export function syncProjection(src, dest) {
8
- if (!src.getProjection) {
9
- return;
10
- }
11
- const srcProjection = src.getProjection();
12
- const destProjection = dest.getProjection();
13
- if (!deepEqual(srcProjection, destProjection)) {
14
- dest.setProjection(srcProjection);
15
- }
16
- }
17
2
  export function transformToViewState(tr) {
18
3
  return {
19
4
  longitude: tr.center.lng,
@@ -26,31 +11,23 @@ export function transformToViewState(tr) {
26
11
  }
27
12
  export function applyViewStateToTransform(tr, props) {
28
13
  const v = props.viewState || props;
29
- let changed = false;
30
- if ('zoom' in v) {
31
- const zoom = tr.zoom;
32
- tr.zoom = v.zoom;
33
- changed = changed || zoom !== tr.zoom;
14
+ const changes = {};
15
+ if ("longitude" in v && "latitude" in v && (v.longitude !== tr.center.lng || v.latitude !== tr.center.lat)) {
16
+ const LngLat = tr.center.constructor;
17
+ changes.center = new LngLat(v.longitude, v.latitude);
34
18
  }
35
- if ('bearing' in v) {
36
- const bearing = tr.bearing;
37
- tr.bearing = v.bearing;
38
- changed = changed || bearing !== tr.bearing;
19
+ if ("zoom" in v && v.zoom !== tr.zoom) {
20
+ changes.zoom = v.zoom;
39
21
  }
40
- if ('pitch' in v) {
41
- const pitch = tr.pitch;
42
- tr.pitch = v.pitch;
43
- changed = changed || pitch !== tr.pitch;
22
+ if ("bearing" in v && v.bearing !== tr.bearing) {
23
+ changes.bearing = v.bearing;
44
24
  }
45
- if (v.padding && !tr.isPaddingEqual(v.padding)) {
46
- changed = true;
47
- tr.padding = v.padding;
25
+ if ("pitch" in v && v.pitch !== tr.pitch) {
26
+ changes.pitch = v.pitch;
48
27
  }
49
- if ('longitude' in v && 'latitude' in v) {
50
- const center = tr.center;
51
- tr.center = new center.constructor(v.longitude, v.latitude);
52
- changed = changed || center !== tr.center;
28
+ if (v.padding && tr.padding && !deepEqual(v.padding, tr.padding)) {
29
+ changes.padding = v.padding;
53
30
  }
54
- return changed;
31
+ return changes;
55
32
  }
56
33
  //# sourceMappingURL=transform.js.map