maplibre-gl 6.2.0 → 6.3.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 (124) hide show
  1. package/dist/maplibre-gl-dev.mjs +522 -223
  2. package/dist/maplibre-gl-dev.mjs.map +1 -1
  3. package/dist/maplibre-gl-shared-dev.mjs +103 -58
  4. package/dist/maplibre-gl-shared-dev.mjs.map +1 -1
  5. package/dist/maplibre-gl-shared.mjs +2 -2
  6. package/dist/maplibre-gl-shared.mjs.map +1 -1
  7. package/dist/maplibre-gl-worker-dev.mjs +23 -49
  8. package/dist/maplibre-gl-worker-dev.mjs.map +1 -1
  9. package/dist/maplibre-gl-worker.mjs +2 -2
  10. package/dist/maplibre-gl-worker.mjs.map +1 -1
  11. package/dist/maplibre-gl.css +1 -1
  12. package/dist/maplibre-gl.d.ts +214 -59
  13. package/dist/maplibre-gl.mjs +44 -44
  14. package/dist/maplibre-gl.mjs.map +1 -1
  15. package/package.json +10 -20
  16. package/src/data/feature_index.bench.ts +21 -0
  17. package/src/data/segment.test.ts +2 -2
  18. package/src/geo/edge_insets.test.ts +1 -1
  19. package/src/geo/lng_lat.test.ts +7 -7
  20. package/src/geo/lng_lat_bounds.test.ts +4 -4
  21. package/src/geo/mercator_coordinate.test.ts +2 -2
  22. package/src/geo/projection/camera_helper.ts +5 -0
  23. package/src/geo/projection/globe_transform.test.ts +25 -0
  24. package/src/geo/projection/globe_transform.ts +7 -3
  25. package/src/geo/projection/mercator_camera_helper.ts +1 -1
  26. package/src/geo/projection/mercator_transform.ts +21 -5
  27. package/src/geo/projection/vertical_perspective_camera_helper.ts +60 -31
  28. package/src/geo/projection/vertical_perspective_transform.ts +7 -1
  29. package/src/geo/transform_interface.ts +13 -1
  30. package/src/index.ts +7 -2
  31. package/src/render/image_atlas.test.ts +72 -0
  32. package/src/render/image_atlas.ts +17 -2
  33. package/src/render/image_manager.test.ts +46 -0
  34. package/src/render/image_manager.ts +9 -2
  35. package/src/render/painter.ts +1 -12
  36. package/src/render/update_pattern_positions_in_program.test.ts +1 -1
  37. package/src/shaders/glsl/_prelude.vertex.glsl +2 -3
  38. package/src/shaders/glsl/_prelude.vertex.glsl.g.ts +1 -1
  39. package/src/shaders/glsl/circle.vertex.glsl +4 -4
  40. package/src/shaders/glsl/circle.vertex.glsl.g.ts +1 -1
  41. package/src/shaders/glsl/fill_extrusion.vertex.glsl +3 -3
  42. package/src/shaders/glsl/fill_extrusion.vertex.glsl.g.ts +1 -1
  43. package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl +5 -5
  44. package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
  45. package/src/shaders/glsl/heatmap.vertex.glsl +4 -4
  46. package/src/shaders/glsl/heatmap.vertex.glsl.g.ts +1 -1
  47. package/src/shaders/glsl/line.vertex.glsl +7 -7
  48. package/src/shaders/glsl/line.vertex.glsl.g.ts +1 -1
  49. package/src/shaders/glsl/line_gradient.vertex.glsl +6 -6
  50. package/src/shaders/glsl/line_gradient.vertex.glsl.g.ts +1 -1
  51. package/src/shaders/glsl/line_gradient_sdf.vertex.glsl +7 -7
  52. package/src/shaders/glsl/line_gradient_sdf.vertex.glsl.g.ts +1 -1
  53. package/src/shaders/glsl/line_pattern.vertex.glsl +7 -7
  54. package/src/shaders/glsl/line_pattern.vertex.glsl.g.ts +1 -1
  55. package/src/shaders/glsl/line_sdf.vertex.glsl +7 -7
  56. package/src/shaders/glsl/line_sdf.vertex.glsl.g.ts +1 -1
  57. package/src/shaders/glsl/raster.fragment.glsl +4 -4
  58. package/src/shaders/glsl/raster.fragment.glsl.g.ts +1 -1
  59. package/src/shaders/glsl/raster.vertex.glsl +11 -6
  60. package/src/shaders/glsl/raster.vertex.glsl.g.ts +1 -1
  61. package/src/shaders/glsl/symbol_icon.vertex.glsl +5 -5
  62. package/src/shaders/glsl/symbol_icon.vertex.glsl.g.ts +1 -1
  63. package/src/shaders/glsl/symbol_sdf.vertex.glsl +5 -5
  64. package/src/shaders/glsl/symbol_sdf.vertex.glsl.g.ts +1 -1
  65. package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl +6 -6
  66. package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
  67. package/src/source/canvas_source.test.ts +31 -0
  68. package/src/source/canvas_source.ts +2 -1
  69. package/src/source/geojson_worker_source.test.ts +88 -0
  70. package/src/source/geojson_worker_source.ts +22 -39
  71. package/src/source/image_source.test.ts +205 -7
  72. package/src/source/image_source.ts +118 -4
  73. package/src/source/raster_dem_tile_worker_source.test.ts +1 -1
  74. package/src/source/vector_tile_worker_source.test.ts +94 -2
  75. package/src/source/vector_tile_worker_source.ts +18 -27
  76. package/src/source/video_source.test.ts +12 -8
  77. package/src/source/worker_tile.bench.ts +10 -0
  78. package/src/source/worker_tile.ts +0 -3
  79. package/src/style/create_style_layer.bench.ts +15 -0
  80. package/src/style/properties.bench.ts +81 -0
  81. package/src/style/style.test.ts +11 -10
  82. package/src/style/style_image.ts +67 -9
  83. package/src/style/style_layer.bench.ts +65 -0
  84. package/src/style/style_layer.test.ts +1 -1
  85. package/src/style/style_layer.ts +2 -2
  86. package/src/style/validate_style.bench.ts +11 -0
  87. package/src/style/validate_style.test.ts +2 -2
  88. package/src/symbol/anchor.test.ts +2 -2
  89. package/src/symbol/collision_index.bench.ts +116 -0
  90. package/src/symbol/cross_tile_symbol_index.bench.ts +49 -0
  91. package/src/symbol/shaping.test.ts +2 -1
  92. package/src/symbol/symbol_layout.bench.ts +30 -0
  93. package/src/tile/tile_id.test.ts +1 -1
  94. package/src/tile/tile_manager.ts +2 -2
  95. package/src/ui/control/fullscreen_control.test.ts +10 -10
  96. package/src/ui/control/geolocate_control.test.ts +3 -5
  97. package/src/ui/control/globe_control.test.ts +6 -6
  98. package/src/ui/events.ts +1 -1
  99. package/src/ui/handler/scroll_zoom.test.ts +50 -0
  100. package/src/ui/handler/two_fingers_touch.test.ts +3 -3
  101. package/src/ui/handler_manager.test.ts +243 -3
  102. package/src/ui/handler_manager.ts +79 -16
  103. package/src/ui/map.ts +17 -3
  104. package/src/ui/map_tests/map_cross_window.test.ts +2 -2
  105. package/src/ui/map_tests/map_events.test.ts +3 -3
  106. package/src/ui/map_tests/map_images.test.ts +29 -0
  107. package/src/ui/map_tests/map_style.test.ts +9 -8
  108. package/src/ui/map_tests/map_webgl.test.ts +29 -0
  109. package/src/ui/marker.test.ts +26 -42
  110. package/src/ui/popup.test.ts +14 -14
  111. package/src/util/evented.test.ts +33 -28
  112. package/src/util/evented.ts +69 -43
  113. package/src/util/test/null_gl.ts +10 -0
  114. package/src/util/test/util.ts +2 -1
  115. package/src/util/util.test.ts +1 -1
  116. package/src/util/web_worker_transfer.test.ts +5 -5
  117. package/src/webgl/context.ts +20 -0
  118. package/src/webgl/draw/draw_raster.ts +11 -6
  119. package/src/webgl/program/raster_program.ts +11 -0
  120. package/src/webgl/program.ts +31 -16
  121. package/src/webgl/texture.test.ts +16 -1
  122. package/src/webgl/texture.ts +3 -0
  123. package/src/webgl/vertex_buffer.test.ts +17 -2
  124. package/src/webgl/vertex_buffer.ts +24 -13
@@ -994,19 +994,31 @@ declare class OverscaledTileID {
994
994
  /**
995
995
  * A listener method used as a callback to events
996
996
  */
997
- type Listener = (a: any) => any;
998
- type Listeners<EventType extends Record<string, any>> = { [_ in keyof EventType]?: Listener[]; };
997
+ type Listener<E extends Event$1 = Event$1> = (event: E) => any;
998
+ /**
999
+ * A mapping between event names and the event each of them carries.
1000
+ */
1001
+ type EventTypeMap = Record<string, Event$1>;
1002
+ /**
1003
+ * The event names of an {@link EventTypeMap}.
1004
+ */
1005
+ type EventNames<EventType extends EventTypeMap> = Extract<keyof EventType, string>;
1006
+ /**
1007
+ * Properties merged into every event bubbled up to an evented parent.
1008
+ */
1009
+ type EventedParentData = Record<string, unknown>;
1010
+ type Listeners<EventType extends EventTypeMap> = { [K in keyof EventType]?: Array<Listener<EventType[K]>>; };
999
1011
  /**
1000
1012
  * The event class
1001
1013
  */
1002
- declare class Event$1 {
1003
- readonly type: string;
1014
+ declare class Event$1<TType extends string = string> {
1015
+ readonly type: TType;
1004
1016
  /**
1005
1017
  * The object that fired the event. Set when the event is fired, and narrowed to a more
1006
1018
  * specific type (e.g. `Map`, `Marker`) by the event subclasses.
1007
1019
  */
1008
1020
  target?: unknown;
1009
- constructor(type: string, data?: any);
1021
+ constructor(type: TType, data?: object);
1010
1022
  }
1011
1023
  type ErrorLike = {
1012
1024
  message: string;
@@ -1014,20 +1026,26 @@ type ErrorLike = {
1014
1026
  /**
1015
1027
  * An error event
1016
1028
  */
1017
- declare class ErrorEvent$1 extends Event$1 {
1029
+ declare class ErrorEvent extends Event$1<"error"> {
1018
1030
  error: ErrorLike;
1019
- constructor(error: ErrorLike, data?: any);
1031
+ constructor(error: ErrorLike, data?: object);
1020
1032
  }
1033
+ /**
1034
+ * The event map of an {@link Evented} that only reports errors.
1035
+ */
1036
+ type ErrorEventType = {
1037
+ error: ErrorEvent;
1038
+ };
1021
1039
  /**
1022
1040
  * Methods mixed in to other classes for event capabilities.
1023
1041
  *
1024
1042
  * @group Event Related
1025
1043
  */
1026
- declare abstract class Evented<EventType extends Record<string, any> = Record<string, any>> {
1027
- _listeners: Listeners<EventType>;
1028
- _oneTimeListeners: Listeners<EventType>;
1029
- _eventedParent: Evented;
1030
- _eventedParentData: any | (() => any);
1044
+ declare abstract class Evented<EventType extends EventTypeMap = EventTypeMap> {
1045
+ _listeners?: Listeners<EventType>;
1046
+ _oneTimeListeners?: Listeners<EventType>;
1047
+ _eventedParent?: Evented;
1048
+ _eventedParentData?: EventedParentData | (() => EventedParentData);
1031
1049
  /**
1032
1050
  * Adds a listener to a specified event type.
1033
1051
  *
@@ -1036,14 +1054,14 @@ declare abstract class Evented<EventType extends Record<string, any> = Record<st
1036
1054
  * The listener function is called with the data object passed to `fire`,
1037
1055
  * extended with `target` and `type` properties.
1038
1056
  */
1039
- on<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): Subscription;
1057
+ on<T extends EventNames<EventType>>(type: T, listener: (event: EventType[T]) => void): Subscription;
1040
1058
  /**
1041
1059
  * Removes a previously registered event listener.
1042
1060
  *
1043
1061
  * @param type - The event type to remove listeners for.
1044
1062
  * @param listener - The listener function to remove.
1045
1063
  */
1046
- off<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): this;
1064
+ off<T extends EventNames<EventType>>(type: T, listener: (event: EventType[T]) => void): this;
1047
1065
  /**
1048
1066
  * Adds a listener that will be called only once to a specified event type.
1049
1067
  *
@@ -1052,7 +1070,7 @@ declare abstract class Evented<EventType extends Record<string, any> = Record<st
1052
1070
  * @param type - The event type to listen for.
1053
1071
  * @returns a promise that resolves with the event
1054
1072
  */
1055
- once<T extends keyof EventType>(type: T): Promise<EventType[T]>;
1073
+ once<T extends EventNames<EventType>>(type: T): Promise<EventType[T]>;
1056
1074
  /**
1057
1075
  * Adds a listener that will be called only once to a specified event type.
1058
1076
  *
@@ -1062,19 +1080,28 @@ declare abstract class Evented<EventType extends Record<string, any> = Record<st
1062
1080
  * @param listener - The function to be called when the event is fired the first time.
1063
1081
  * @returns `this` when a listener is provided
1064
1082
  */
1065
- once<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): this;
1066
- fire(event: Event$1 | string, properties?: any): this;
1083
+ once<T extends EventNames<EventType>>(type: T, listener: (event: EventType[T]) => void): this;
1084
+ /**
1085
+ * Calls every listener registered for the event's type.
1086
+ */
1087
+ fire(event: EventType[EventNames<EventType>]): this;
1088
+ /**
1089
+ * Compatibility with the (type: string, properties: Object) signature from previous versions.
1090
+ * See https://github.com/mapbox/mapbox-gl-js/issues/6522,
1091
+ * https://github.com/mapbox/mapbox-gl-draw/issues/766
1092
+ */
1093
+ fire(type: EventNames<EventType>, properties?: object): this;
1067
1094
  /**
1068
1095
  * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
1069
1096
  *
1070
1097
  * @param type - The event type
1071
1098
  * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise
1072
1099
  */
1073
- listens(type: string): boolean;
1100
+ listens(type: EventNames<EventType>): boolean;
1074
1101
  /**
1075
1102
  * Bubble all events fired by this instance of Evented to this parent instance of Evented.
1076
1103
  */
1077
- setEventedParent(parent?: Evented | null, data?: any | (() => any)): this;
1104
+ setEventedParent(parent?: Evented | null, data?: EventedParentData | (() => EventedParentData)): this;
1078
1105
  }
1079
1106
  //#endregion
1080
1107
  //#region src/util/vectortile_to_geojson.d.ts
@@ -2089,6 +2116,7 @@ type StyleImageData = {
2089
2116
  data: RGBAImage;
2090
2117
  version?: number;
2091
2118
  hasRenderCallback?: boolean;
2119
+ isWebGLImage?: boolean;
2092
2120
  userImage?: StyleImageInterface;
2093
2121
  spriteData?: SpriteOnDemandStyleImage;
2094
2122
  };
@@ -2149,6 +2177,46 @@ type StyleImageMetadata = {
2149
2177
  * the style's image, including data and metedata
2150
2178
  */
2151
2179
  type StyleImage = StyleImageData & StyleImageMetadata;
2180
+ /**
2181
+ * Where a {@link StyleImageWebGLData.renderWithWebGL} callback writes its pixels.
2182
+ */
2183
+ type StyleImageWebGLTarget = {
2184
+ gl: WebGL2RenderingContext;
2185
+ /**
2186
+ * The icon atlas to write into. MapLibre does not bind it for you, so start with
2187
+ * `gl.bindTexture(gl.TEXTURE_2D, texture)` or attach it to your own framebuffer.
2188
+ */
2189
+ texture: WebGLTexture;
2190
+ x: number;
2191
+ y: number;
2192
+ width: number;
2193
+ height: number;
2194
+ };
2195
+ /**
2196
+ * What a {@link StyleImageInterface} gives as its `data` when it renders itself with WebGL rather
2197
+ * than handing over an array of pixels.
2198
+ *
2199
+ * @see [Animate an icon on the GPU.](https://maplibre.org/maplibre-gl-js/docs/examples/animate-an-icon-on-the-gpu/)
2200
+ */
2201
+ type StyleImageWebGLData = {
2202
+ /**
2203
+ * Render exactly `width` x `height` premultiplied-alpha pixels at (`x`, `y`) of
2204
+ * `target.texture`. That rectangle is the only part of the shared atlas that belongs to this
2205
+ * image; drawing outside it corrupts the others.
2206
+ *
2207
+ * This is the image's counterpart to {@link CustomLayerInterface.render}, and the context
2208
+ * arrives in the same state a custom layer's is given: cull face, active texture and the pixel
2209
+ * store settings at their WebGL defaults, and no vertex array bound. Everything is yours to
2210
+ * change, and MapLibre restores its own state afterwards. The scissor test is the one
2211
+ * exception: MapLibre never touches it, so an image that enables it has to disable it again.
2212
+ *
2213
+ * Called before the first frame the image is used in, again whenever
2214
+ * {@link StyleImageInterface.render} returns `true`, and again for each atlas holding a slot
2215
+ * this image has never rendered into, so one change may mean several calls with different
2216
+ * targets.
2217
+ */
2218
+ renderWithWebGL: (target: StyleImageWebGLTarget) => void;
2219
+ };
2152
2220
  /**
2153
2221
  * Interface for dynamically generated style images. This is a specification for
2154
2222
  * implementers to model: it is not an exported method or class.
@@ -2205,7 +2273,13 @@ type StyleImage = StyleImageData & StyleImageMetadata;
2205
2273
  interface StyleImageInterface {
2206
2274
  width: number;
2207
2275
  height: number;
2208
- data: Uint8Array | Uint8ClampedArray;
2276
+ /**
2277
+ * The image's pixels, in the same format as `ImageData`, or a {@link StyleImageWebGLData}
2278
+ * callback that renders them with WebGL. A WebGL image renders straight into its slot of the
2279
+ * shared icon atlas. Nothing new is possible that pixels could not express, but an image that
2280
+ * changes often, such as an animated icon, gets much cheaper: no CPU pixel work and no upload.
2281
+ */
2282
+ data: Uint8Array | Uint8ClampedArray | StyleImageWebGLData;
2209
2283
  /**
2210
2284
  * This method is called once before every frame where the icon will be used.
2211
2285
  * The method can optionally update the image's `data` member with a new image.
@@ -2213,6 +2287,9 @@ interface StyleImageInterface {
2213
2287
  * If the method updates the image it must return `true` to commit the change.
2214
2288
  * If the method returns `false` or nothing the image is assumed to not have changed.
2215
2289
  *
2290
+ * An image whose `data` renders with WebGL has nothing to update here; returning `true` is how
2291
+ * it asks for {@link StyleImageWebGLData.renderWithWebGL} to be called again.
2292
+ *
2216
2293
  * If updates are infrequent it maybe easier to use {@link Map.updateImage} to update
2217
2294
  * the image instead of implementing this method.
2218
2295
  *
@@ -2228,6 +2305,10 @@ interface StyleImageInterface {
2228
2305
  /**
2229
2306
  * Optional method called when the icon is removed from the map with {@link Map.removeImage}.
2230
2307
  * This gives the image a chance to clean up resources and event listeners.
2308
+ *
2309
+ * This also fires when the WebGL context is lost, after which the same image is added back
2310
+ * without a matching `onAdd`, so the image has to be able to build again whatever it
2311
+ * released here.
2231
2312
  */
2232
2313
  onRemove?: () => void;
2233
2314
  }
@@ -2282,6 +2363,10 @@ type Pattern = {
2282
2363
  bin: PotpackBox;
2283
2364
  position: ImagePosition;
2284
2365
  };
2366
+ type ImageManagerEventType = {
2367
+ error: ErrorEvent;
2368
+ styleimagemissing: MapStyleImageMissingEvent;
2369
+ };
2285
2370
  /**
2286
2371
  * ImageManager does three things:
2287
2372
  *
@@ -2293,7 +2378,7 @@ type Pattern = {
2293
2378
  * data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time
2294
2379
  * to refactor this.
2295
2380
  */
2296
- declare class ImageManager extends Evented {
2381
+ declare class ImageManager extends Evented<ImageManagerEventType> {
2297
2382
  images: {
2298
2383
  [_: string]: StyleImage;
2299
2384
  };
@@ -2401,12 +2486,13 @@ declare class ImagePosition {
2401
2486
  paddedRect: Rect;
2402
2487
  pixelRatio: number;
2403
2488
  version: number;
2489
+ needsFirstWebGLRender: boolean;
2404
2490
  stretchY: Array<[number, number]>;
2405
2491
  stretchX: Array<[number, number]>;
2406
2492
  content: [number, number, number, number];
2407
2493
  textFitWidth: TextFit;
2408
2494
  textFitHeight: TextFit;
2409
- constructor(paddedRect: Rect, { pixelRatio, version, stretchX, stretchY, content, textFitWidth, textFitHeight }: StyleImage);
2495
+ constructor(paddedRect: Rect, { pixelRatio, version, isWebGLImage, stretchX, stretchY, content, textFitWidth, textFitHeight }: StyleImage);
2410
2496
  get tl(): [number, number];
2411
2497
  get br(): [number, number];
2412
2498
  get tlbr(): number[];
@@ -4625,8 +4711,10 @@ interface ITransformMutators {
4625
4711
  * Set's the transform's center so that the given point on screen is at the given world coordinates.
4626
4712
  * @param lnglat - Desired world coordinates of the point.
4627
4713
  * @param point - The screen point that should lie at the given coordinates.
4714
+ * @param elevation - Optional ground elevation in meters above sea level at `lnglat`,
4715
+ * defaults to the elevation at the map's center. Ignored when rendering the globe.
4628
4716
  */
4629
- setLocationAtPoint(lnglat: LngLat, point: Point$1): void;
4717
+ setLocationAtPoint(lnglat: LngLat, point: Point$1, elevation?: number): void;
4630
4718
  /**
4631
4719
  * Sets or clears the map's geographical constraints.
4632
4720
  * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map.
@@ -4739,6 +4827,15 @@ interface IReadonlyTransform extends ITransformGetters {
4739
4827
  * @returns lnglat location
4740
4828
  */
4741
4829
  screenPointToLocation(p: Point$1, terrain?: Terrain): LngLat;
4830
+ /**
4831
+ * @internal
4832
+ * Given a point on screen, return its LngLat location assuming the ground there
4833
+ * lies at the given elevation. When rendering the globe the elevation is ignored.
4834
+ * @param p - screen point
4835
+ * @param elevation - ground elevation in meters above sea level
4836
+ * @returns lnglat location
4837
+ */
4838
+ screenPointToLocationAtElevation(p: Point$1, elevation: number): LngLat;
4742
4839
  /**
4743
4840
  * @internal
4744
4841
  * Given a point on screen, return its mercator coordinate.
@@ -4986,6 +5083,41 @@ declare class CanvasSource extends ImageSource {
4986
5083
  _hasInvalidDimensions(): boolean;
4987
5084
  }
4988
5085
  //#endregion
5086
+ //#region src/style/style_layer/raster_style_layer_properties.g.d.ts
5087
+ type RasterPaintProps = {
5088
+ "raster-opacity": DataConstantProperty<number>;
5089
+ "raster-hue-rotate": DataConstantProperty<number>;
5090
+ "raster-brightness-min": DataConstantProperty<number>;
5091
+ "raster-brightness-max": DataConstantProperty<number>;
5092
+ "raster-saturation": DataConstantProperty<number>;
5093
+ "raster-contrast": DataConstantProperty<number>;
5094
+ "resampling": DataConstantProperty<"linear" | "nearest">;
5095
+ "raster-resampling": DataConstantProperty<"linear" | "nearest">;
5096
+ "raster-fade-duration": DataConstantProperty<number>;
5097
+ };
5098
+ type RasterPaintPropsPossiblyEvaluated = {
5099
+ "raster-opacity": number;
5100
+ "raster-hue-rotate": number;
5101
+ "raster-brightness-min": number;
5102
+ "raster-brightness-max": number;
5103
+ "raster-saturation": number;
5104
+ "raster-contrast": number;
5105
+ "resampling": "linear" | "nearest";
5106
+ "raster-resampling": "linear" | "nearest";
5107
+ "raster-fade-duration": number;
5108
+ };
5109
+ //#endregion
5110
+ //#region src/style/style_layer/raster_style_layer.d.ts
5111
+ declare class RasterStyleLayer extends StyleLayer {
5112
+ _transitionablePaint: Transitionable<RasterPaintProps>;
5113
+ _transitioningPaint: Transitioning<RasterPaintProps>;
5114
+ paint: PossiblyEvaluated<RasterPaintProps, RasterPaintPropsPossiblyEvaluated>;
5115
+ constructor(layer: LayerSpecification, globalState: Record<string, any>);
5116
+ }
5117
+ //#endregion
5118
+ //#region src/webgl/program/raster_program.d.ts
5119
+ type RasterPerspectiveTransform = [number, number, number];
5120
+ //#endregion
4989
5121
  //#region src/source/image_source.d.ts
4990
5122
  /**
4991
5123
  * Four geographical coordinates,
@@ -5106,9 +5238,11 @@ declare class ImageSource extends Evented<SourceEventType> implements Source {
5106
5238
  image: ImageSourceImage;
5107
5239
  tileID: CanonicalTileID;
5108
5240
  tileCoords: Point$1[];
5241
+ perspectiveTransform: RasterPerspectiveTransform;
5109
5242
  flippedWindingOrder: boolean;
5110
5243
  _loaded: boolean;
5111
5244
  _request: AbortController;
5245
+ private _imageDirty;
5112
5246
  /** @internal */
5113
5247
  constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented);
5114
5248
  load(newCoordinates?: Coordinates): Promise<void>;
@@ -5124,6 +5258,10 @@ declare class ImageSource extends Evented<SourceEventType> implements Source {
5124
5258
  * @param options - The options object.
5125
5259
  */
5126
5260
  updateImage(options: UpdateImageOptions): this;
5261
+ /** Loaded tiles hold `this.texture`, so the wrapper has to outlive the images in it. */
5262
+ private _setImage;
5263
+ /** Teardown only: dropping the reference alone leaves the allocation to the GC. */
5264
+ private _disposeTexture;
5127
5265
  _finishLoading(): void;
5128
5266
  onAdd(map: Map$1): void;
5129
5267
  onRemove(): void;
@@ -5533,6 +5671,10 @@ type ProjectionPreludeUniformsType = {
5533
5671
  //#endregion
5534
5672
  //#region src/webgl/program.d.ts
5535
5673
  type DrawMode = WebGLRenderingContextBase["LINES"] | WebGLRenderingContextBase["TRIANGLES"] | WebGL2RenderingContext["LINE_STRIP"];
5674
+ type ProgramAttribute = {
5675
+ location: number;
5676
+ isInteger: boolean;
5677
+ };
5536
5678
  /**
5537
5679
  * @internal
5538
5680
  * A webgl program to execute in the GPU space
@@ -5540,7 +5682,7 @@ type DrawMode = WebGLRenderingContextBase["LINES"] | WebGLRenderingContextBase["
5540
5682
  declare class Program<Us extends UniformBindings> {
5541
5683
  program: WebGLProgram;
5542
5684
  attributes: {
5543
- [_: string]: number;
5685
+ [_: string]: ProgramAttribute;
5544
5686
  };
5545
5687
  numAttributes: number;
5546
5688
  fixedUniforms: Us;
@@ -5635,6 +5777,17 @@ declare class Context {
5635
5777
  constructor(gl: WebGL2RenderingContext);
5636
5778
  setDefault(): void;
5637
5779
  setDirty(): void;
5780
+ /**
5781
+ * Reset some GL state to default values before handing users the raw context, as we do for
5782
+ * custom layers and WebGL style images, to avoid hard-to-debug bugs in their code.
5783
+ *
5784
+ * MapLibre restores all of its own state afterwards, so the only state worth resetting first
5785
+ * is state users would be surprised to find dirty: `CULL_FACE`, `TEXTURE0` and the three
5786
+ * `UNPACK_` settings, whose defaults are meaningful enough that most code assumes them.
5787
+ * The vertex array is unbound rather than reset, so that MapLibre never has to track it and
5788
+ * a user's `vertexAttribPointer` calls cannot land on one of ours.
5789
+ */
5790
+ setCustomLayerDefaults(): void;
5638
5791
  createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean): IndexBuffer;
5639
5792
  createVertexBuffer(array: StructArray, attributes: readonly StructArrayMember[], dynamicDraw?: boolean): VertexBuffer;
5640
5793
  createRenderbuffer(storageFormat: number, width: number, height: number): WebGLRenderbuffer;
@@ -5958,7 +6111,7 @@ type TileResult = {
5958
6111
  * - unloading cached tiles not needed to render a given viewport
5959
6112
  * - managing tile state and feature state
5960
6113
  */
5961
- declare class TileManager extends Evented {
6114
+ declare class TileManager extends Evented<SourceEventType> {
5962
6115
  id: string;
5963
6116
  dispatcher: Dispatcher;
5964
6117
  map: Map$1;
@@ -6513,38 +6666,6 @@ declare function drawHillshade(painter: Painter, tileManager: TileManager, layer
6513
6666
  //#region src/webgl/draw/draw_color_relief.d.ts
6514
6667
  declare function drawColorRelief(painter: Painter, tileManager: TileManager, layer: ColorReliefStyleLayer, tileIDs: OverscaledTileID[], renderOptions: RenderOptions): void;
6515
6668
  //#endregion
6516
- //#region src/style/style_layer/raster_style_layer_properties.g.d.ts
6517
- type RasterPaintProps = {
6518
- "raster-opacity": DataConstantProperty<number>;
6519
- "raster-hue-rotate": DataConstantProperty<number>;
6520
- "raster-brightness-min": DataConstantProperty<number>;
6521
- "raster-brightness-max": DataConstantProperty<number>;
6522
- "raster-saturation": DataConstantProperty<number>;
6523
- "raster-contrast": DataConstantProperty<number>;
6524
- "resampling": DataConstantProperty<"linear" | "nearest">;
6525
- "raster-resampling": DataConstantProperty<"linear" | "nearest">;
6526
- "raster-fade-duration": DataConstantProperty<number>;
6527
- };
6528
- type RasterPaintPropsPossiblyEvaluated = {
6529
- "raster-opacity": number;
6530
- "raster-hue-rotate": number;
6531
- "raster-brightness-min": number;
6532
- "raster-brightness-max": number;
6533
- "raster-saturation": number;
6534
- "raster-contrast": number;
6535
- "resampling": "linear" | "nearest";
6536
- "raster-resampling": "linear" | "nearest";
6537
- "raster-fade-duration": number;
6538
- };
6539
- //#endregion
6540
- //#region src/style/style_layer/raster_style_layer.d.ts
6541
- declare class RasterStyleLayer extends StyleLayer {
6542
- _transitionablePaint: Transitionable<RasterPaintProps>;
6543
- _transitioningPaint: Transitioning<RasterPaintProps>;
6544
- paint: PossiblyEvaluated<RasterPaintProps, RasterPaintPropsPossiblyEvaluated>;
6545
- constructor(layer: LayerSpecification, globalState: Record<string, any>);
6546
- }
6547
- //#endregion
6548
6669
  //#region src/webgl/draw/draw_raster.d.ts
6549
6670
  declare function drawRaster(painter: Painter, tileManager: TileManager, layer: RasterStyleLayer, tileIDs: OverscaledTileID[], renderOptions: RenderOptions): void;
6550
6671
  //#endregion
@@ -9430,7 +9551,7 @@ type QueryIntersectsFeatureParams = {
9430
9551
  /**
9431
9552
  * A base class for style layers
9432
9553
  */
9433
- declare abstract class StyleLayer extends Evented {
9554
+ declare abstract class StyleLayer extends Evented<ErrorEventType> {
9434
9555
  id: string;
9435
9556
  metadata: unknown;
9436
9557
  type: LayerSpecification["type"] | CustomLayerInterface["type"];
@@ -10177,6 +10298,11 @@ type MapControlsDeltas = {
10177
10298
  pitchDelta: number;
10178
10299
  rollDelta: number;
10179
10300
  around: Point$1;
10301
+ /**
10302
+ * Elevation in meters of the terrain under `around` at gesture start; when set,
10303
+ * pan and zoom keep the terrain at this elevation under `around`.
10304
+ */
10305
+ aroundElevation?: number;
10180
10306
  };
10181
10307
  type CameraForBoxAndBearingHandlerResult = {
10182
10308
  center: LngLat;
@@ -10843,6 +10969,11 @@ declare class HandlerManager {
10843
10969
  [handlerName: string]: Event$1;
10844
10970
  }]>;
10845
10971
  _terrainMovement: boolean;
10972
+ /**
10973
+ * Elevation in meters of the terrain point grabbed at gesture start; kept for the
10974
+ * same lifetime as the elevation freeze. Null when that terrain was not available.
10975
+ */
10976
+ _terrainGestureAnchorElevation: number | null;
10846
10977
  _zoom: {
10847
10978
  handlerName: string;
10848
10979
  };
@@ -10883,6 +11014,30 @@ declare class HandlerManager {
10883
11014
  _updateMapTransform(combinedResult: HandlerResult, combinedEventsInProgress: EventsInProgress, deactivatedHandlers: {
10884
11015
  [handlerName: string]: Event$1;
10885
11016
  }): void;
11017
+ /**
11018
+ * The gesture's anchor point: the pinch midpoint when pinching, otherwise the
11019
+ * pan's anchor, clamped to the center point when it does not lie on the map.
11020
+ */
11021
+ _resolveAround(combinedResult: HandlerResult, terrain: Terrain | null, tr: ITransform): {
11022
+ around: Point$1;
11023
+ aroundOnSurface: boolean;
11024
+ };
11025
+ /**
11026
+ * The elevation of the plane a terrain gesture is solved on: the elevation of the
11027
+ * terrain point grabbed at gesture start, captured here on the gesture's first
11028
+ * frame. Undefined means the gesture is solved at the center's elevation instead —
11029
+ * when the grabbed terrain is not loaded, the anchor is the center point (a
11030
+ * center-point anchor is skipped by the camera helper and would lose the pan), or
11031
+ * the anchor plane is too close to the camera for a stable ray-plane solve.
11032
+ */
11033
+ _terrainGestureElevation(terrain: Terrain, around: Point$1, aroundOnSurface: boolean, tr: ITransform, combinedEventsInProgress: EventsInProgress): number | undefined;
11034
+ /**
11035
+ * The location that was under `around` before this frame's deltas — the point the
11036
+ * camera helper re-anchors after zooming — solved at `aroundElevation` when a
11037
+ * terrain gesture provides one. When rotating about the center point, the
11038
+ * transform's center is used directly to avoid numerical issues near the horizon.
11039
+ */
11040
+ _computePreZoomAroundLoc(tr: ITransform, around: Point$1, panDelta: Point$1 | undefined, aroundElevation: number | undefined): LngLat;
10886
11041
  _handleMapControls({ terrain, tr, deltasForHelper, preZoomAroundLoc, combinedEventsInProgress, panDelta }: MapControlsScenarioOptions): void;
10887
11042
  _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {
10888
11043
  [handlerName: string]: Event$1;
@@ -16762,4 +16917,4 @@ declare function setWorkerUrl(value: string): void;
16762
16917
  */
16763
16918
  declare function importScriptInWorkers(workerUrl: string): Promise<void>;
16764
16919
  //#endregion
16765
- export { AJAXError, type Actor, type ActorMessage, type AddLayerObject, type AddProtocolAction, type Alignment, type AlphaImage, type AnimationOptions, type AroundCenterOptions, AttributionControl, type AttributionControlOptions, type BoxZoomEndHandler, BoxZoomHandler, type BoxZoomHandlerOptions, type Bucket, type CalculateTileZoomFunction, type CameraForBoundsOptions, type CameraOptions, type CameraUpdateTransformFunction, type CanonicalTileRange, CanvasSource, type CanvasSourceSpecification, type CenterZoomBearing, type CollisionBoxArray, type Complete, type ControlPosition, CooperativeGesturesHandler, type Coordinates, type CoveringTilesOptions, type CreateTileMeshOptions, type CustomLayerInterface, type CustomLayerProjectionData, type CustomLayerProjectionDataParams, type CustomRenderMethod, type CustomRenderMethodInput, type DashEntry, type Dispatcher, type DistributiveKeys, type DistributiveOmit, DoubleClickZoomHandler, DragPanHandler, type DragPanOptions, DragRotateHandler, EXTENT, type EaseToOptions, EdgeInsets, ErrorEvent$1 as ErrorEvent, Event$1 as Event, Evented, type ExpiryData, type FeatureIdentifier, type FeatureIndex, type FitBoundsOptions, type FlyToOptions, FullscreenControl, type FullscreenControlEventType, type FullscreenControlOptions, FullscreenEvent, GPUInitializationError, type GeoJSONFeature, type GeoJSONFeatureDiff, type GeoJSONFeatureId, GeoJSONSource, type GeoJSONSourceDiff, GeolocateControl, type GeolocateControlEventType, type GeolocateControlOptions, GeolocateErrorEvent, GeolocateEvent, GeolocatePositionEvent, type GestureOptions, type GetClusterOptions, type GetResourceResponse, GlobeControl, type GlyphPosition, type GlyphPositions, type Handler, type HandlerResult, Hash, type IActor, type IControl, type ImageAtlas, ImageSource, type ImageSourceImage, type IndicesType, type JumpToOptions, KeyboardHandler, type Listener, LngLat, LngLatBounds, type LngLatBoundsLike, type LngLatLike, type LoadTileResult, LogoControl, type LogoControlOptions, Map$1 as Map, Map$1 as MapLibreMap, MapBoxZoomEvent, MapContextEvent, type MapEventType, type MapGeoJSONFeature, type MapLayerEventType, type MapLayerMouseEvent, type MapLayerTouchEvent, MapLibreEvent, MapMouseEvent, MapMovementEvent, type MapOptions, MapProjectionEvent, MapSourceDataEvent, type MapSourceDataType, MapStyleDataEvent, MapStyleImageMissingEvent, MapStyleLoadEvent, MapTerrainEvent, MapTouchEvent, MapWheelEvent, Marker, MarkerClickEvent, MarkerDragEvent, type MarkerEventType, type MarkerOptions, type Mat4f32, type Mat4f64, MercatorCoordinate, type MessageType, type MissingStyleImageResolver, NavigationControl, type NavigationControlOptions, type Offset, type OverscaledTileID, type PaddingOptions, type PaintPropertyEntry, type Painter, Point, type PointLike, Popup, PopupEvent, type PopupEventType, type PopupOptions, type PositionAnchor, type ProjectionData, type ProjectionDataParams, type ProjectionMatrix, type QueryRenderedFeaturesOptions, type QuerySourceFeatureOptions, RasterDEMTileSource, RasterTileSource, type RendererProjectionData, type RequestParameters, type RequestResponseMessageMap, type RequestTransformFunction, type RequireAtLeastOne, type ResourceType, ScaleControl, type ScaleControlOptions, ScrollZoomHandler, type SetClusterOptions, type Source, type SourceClass, type SourceEventType, Style, type StyleGlyph, type StyleImage, type StyleImageData, type StyleImageInterface, type StyleImageMetadata, type StyleImageSource, type StyleLayer, type StyleOptions, type StyleSetterOptions, type StyleSwapOptions, type Subscription, TerrainControl, type TextFit, type Tile, type TileMesh, type TransformConstrainFunction, type TransformStyleFunction, TwoFingersTouchPitchHandler, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, type Unit, type UnwrappedTileIDLiteral, type UpdateImageOptions, VectorTileSource, VideoSource, type WebGLContextAttributesWithType, type WorkerGlobalScopeInterface, type WorkerTileResult, addProtocol, addSourceType, clearPrewarmedResources, config, createTileMesh, getGlobalDispatcher, getMaxParallelImageRequests, getRTLTextPluginStatus, getVersion, getWorkerCount, getWorkerUrl, importScriptInWorkers, isTimeFrozen, now, prewarm, removeProtocol, restoreNow, setMaxParallelImageRequests, setNow, setRTLTextPlugin, setWorkerCount, setWorkerUrl };
16920
+ export { AJAXError, type Actor, type ActorMessage, type AddLayerObject, type AddProtocolAction, type Alignment, type AlphaImage, type AnimationOptions, type AroundCenterOptions, AttributionControl, type AttributionControlOptions, type BoxZoomEndHandler, BoxZoomHandler, type BoxZoomHandlerOptions, type Bucket, type CalculateTileZoomFunction, type CameraForBoundsOptions, type CameraOptions, type CameraUpdateTransformFunction, type CanonicalTileRange, CanvasSource, type CanvasSourceSpecification, type CenterZoomBearing, type CollisionBoxArray, type Complete, type ControlPosition, CooperativeGesturesHandler, type Coordinates, type CoveringTilesOptions, type CreateTileMeshOptions, type CustomLayerInterface, type CustomLayerProjectionData, type CustomLayerProjectionDataParams, type CustomRenderMethod, type CustomRenderMethodInput, type DashEntry, type Dispatcher, type DistributiveKeys, type DistributiveOmit, DoubleClickZoomHandler, DragPanHandler, type DragPanOptions, DragRotateHandler, EXTENT, type EaseToOptions, EdgeInsets, ErrorEvent, type ErrorEventType, Event$1 as Event, type EventTypeMap, Evented, type EventedParentData, type ExpiryData, type FeatureIdentifier, type FeatureIndex, type FitBoundsOptions, type FlyToOptions, FullscreenControl, type FullscreenControlEventType, type FullscreenControlOptions, FullscreenEvent, GPUInitializationError, type GeoJSONFeature, type GeoJSONFeatureDiff, type GeoJSONFeatureId, GeoJSONSource, type GeoJSONSourceDiff, GeolocateControl, type GeolocateControlEventType, type GeolocateControlOptions, GeolocateErrorEvent, GeolocateEvent, GeolocatePositionEvent, type GestureOptions, type GetClusterOptions, type GetResourceResponse, GlobeControl, type GlyphPosition, type GlyphPositions, type Handler, type HandlerResult, Hash, type IActor, type IControl, type ImageAtlas, ImageSource, type ImageSourceImage, type IndicesType, type JumpToOptions, KeyboardHandler, type Listener, LngLat, LngLatBounds, type LngLatBoundsLike, type LngLatLike, type LoadTileResult, LogoControl, type LogoControlOptions, Map$1 as Map, Map$1 as MapLibreMap, MapBoxZoomEvent, MapContextEvent, type MapEventType, type MapGeoJSONFeature, type MapLayerEventType, type MapLayerMouseEvent, type MapLayerTouchEvent, MapLibreEvent, MapMouseEvent, MapMovementEvent, type MapOptions, MapProjectionEvent, MapSourceDataEvent, type MapSourceDataType, MapStyleDataEvent, MapStyleImageMissingEvent, MapStyleLoadEvent, MapTerrainEvent, MapTouchEvent, MapWheelEvent, Marker, MarkerClickEvent, MarkerDragEvent, type MarkerEventType, type MarkerOptions, type Mat4f32, type Mat4f64, MercatorCoordinate, type MessageType, type MissingStyleImageResolver, NavigationControl, type NavigationControlOptions, type Offset, type OverscaledTileID, type PaddingOptions, type PaintPropertyEntry, type Painter, Point, type PointLike, Popup, PopupEvent, type PopupEventType, type PopupOptions, type PositionAnchor, type ProjectionData, type ProjectionDataParams, type ProjectionMatrix, type QueryRenderedFeaturesOptions, type QuerySourceFeatureOptions, RasterDEMTileSource, RasterTileSource, type RendererProjectionData, type RequestParameters, type RequestResponseMessageMap, type RequestTransformFunction, type RequireAtLeastOne, type ResourceType, ScaleControl, type ScaleControlOptions, ScrollZoomHandler, type SetClusterOptions, type Source, type SourceClass, type SourceEventType, Style, type StyleGlyph, type StyleImage, type StyleImageData, type StyleImageInterface, type StyleImageMetadata, type StyleImageSource, type StyleImageWebGLData, type StyleImageWebGLTarget, type StyleLayer, type StyleOptions, type StyleSetterOptions, type StyleSwapOptions, type Subscription, TerrainControl, type TextFit, type Tile, type TileMesh, type TransformConstrainFunction, type TransformStyleFunction, TwoFingersTouchPitchHandler, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, type Unit, type UnwrappedTileIDLiteral, type UpdateImageOptions, VectorTileSource, VideoSource, type WebGLContextAttributesWithType, type WorkerGlobalScopeInterface, type WorkerTileResult, addProtocol, addSourceType, clearPrewarmedResources, config, createTileMesh, getGlobalDispatcher, getMaxParallelImageRequests, getRTLTextPluginStatus, getVersion, getWorkerCount, getWorkerUrl, importScriptInWorkers, isTimeFrozen, now, prewarm, removeProtocol, restoreNow, setMaxParallelImageRequests, setNow, setRTLTextPlugin, setWorkerCount, setWorkerUrl };