maplibre-gl 6.2.0 → 6.4.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 (150) hide show
  1. package/dist/maplibre-gl-dev.mjs +1108 -427
  2. package/dist/maplibre-gl-dev.mjs.map +1 -1
  3. package/dist/maplibre-gl-shared-dev.mjs +359 -291
  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 +467 -151
  13. package/dist/maplibre-gl.mjs +49 -49
  14. package/dist/maplibre-gl.mjs.map +1 -1
  15. package/package.json +12 -22
  16. package/src/data/bucket/fill_extrusion_bucket.ts +1 -13
  17. package/src/data/bucket/round_polygon_corners.test.ts +84 -36
  18. package/src/data/bucket/round_polygon_corners.ts +90 -39
  19. package/src/data/extent_bounds.ts +28 -1
  20. package/src/data/feature_index.bench.ts +21 -0
  21. package/src/data/segment.test.ts +2 -2
  22. package/src/geo/edge_insets.test.ts +1 -1
  23. package/src/geo/lng_lat.test.ts +7 -7
  24. package/src/geo/lng_lat_bounds.test.ts +4 -4
  25. package/src/geo/mercator_coordinate.test.ts +2 -2
  26. package/src/geo/projection/camera_helper.ts +5 -0
  27. package/src/geo/projection/globe_transform.test.ts +154 -1
  28. package/src/geo/projection/globe_transform.ts +7 -3
  29. package/src/geo/projection/globe_utils.ts +189 -2
  30. package/src/geo/projection/mercator_camera_helper.ts +1 -1
  31. package/src/geo/projection/mercator_transform.ts +21 -5
  32. package/src/geo/projection/vertical_perspective_camera_helper.test.ts +24 -0
  33. package/src/geo/projection/vertical_perspective_camera_helper.ts +71 -41
  34. package/src/geo/projection/vertical_perspective_transform.ts +7 -1
  35. package/src/geo/transform_interface.ts +13 -1
  36. package/src/index.ts +7 -2
  37. package/src/render/image_atlas.test.ts +180 -0
  38. package/src/render/image_atlas.ts +52 -6
  39. package/src/render/image_manager.test.ts +111 -0
  40. package/src/render/image_manager.ts +143 -144
  41. package/src/render/painter.ts +6 -14
  42. package/src/render/pattern_atlas.test.ts +131 -0
  43. package/src/render/pattern_atlas.ts +144 -0
  44. package/src/render/update_pattern_positions_in_program.test.ts +1 -1
  45. package/src/shaders/glsl/_prelude.vertex.glsl +10 -11
  46. package/src/shaders/glsl/_prelude.vertex.glsl.g.ts +1 -1
  47. package/src/shaders/glsl/circle.vertex.glsl +4 -4
  48. package/src/shaders/glsl/circle.vertex.glsl.g.ts +1 -1
  49. package/src/shaders/glsl/color_relief.fragment.glsl +1 -2
  50. package/src/shaders/glsl/color_relief.fragment.glsl.g.ts +1 -1
  51. package/src/shaders/glsl/fill_extrusion.vertex.glsl +3 -3
  52. package/src/shaders/glsl/fill_extrusion.vertex.glsl.g.ts +1 -1
  53. package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl +5 -5
  54. package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
  55. package/src/shaders/glsl/heatmap.vertex.glsl +4 -4
  56. package/src/shaders/glsl/heatmap.vertex.glsl.g.ts +1 -1
  57. package/src/shaders/glsl/hillshade_prepare.fragment.glsl +12 -12
  58. package/src/shaders/glsl/hillshade_prepare.fragment.glsl.g.ts +1 -1
  59. package/src/shaders/glsl/line.vertex.glsl +7 -7
  60. package/src/shaders/glsl/line.vertex.glsl.g.ts +1 -1
  61. package/src/shaders/glsl/line_gradient.vertex.glsl +6 -6
  62. package/src/shaders/glsl/line_gradient.vertex.glsl.g.ts +1 -1
  63. package/src/shaders/glsl/line_gradient_sdf.vertex.glsl +7 -7
  64. package/src/shaders/glsl/line_gradient_sdf.vertex.glsl.g.ts +1 -1
  65. package/src/shaders/glsl/line_pattern.vertex.glsl +7 -7
  66. package/src/shaders/glsl/line_pattern.vertex.glsl.g.ts +1 -1
  67. package/src/shaders/glsl/line_sdf.vertex.glsl +7 -7
  68. package/src/shaders/glsl/line_sdf.vertex.glsl.g.ts +1 -1
  69. package/src/shaders/glsl/raster.fragment.glsl +4 -4
  70. package/src/shaders/glsl/raster.fragment.glsl.g.ts +1 -1
  71. package/src/shaders/glsl/raster.vertex.glsl +11 -6
  72. package/src/shaders/glsl/raster.vertex.glsl.g.ts +1 -1
  73. package/src/shaders/glsl/symbol_icon.vertex.glsl +5 -5
  74. package/src/shaders/glsl/symbol_icon.vertex.glsl.g.ts +1 -1
  75. package/src/shaders/glsl/symbol_sdf.vertex.glsl +5 -5
  76. package/src/shaders/glsl/symbol_sdf.vertex.glsl.g.ts +1 -1
  77. package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl +6 -6
  78. package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
  79. package/src/source/canvas_source.test.ts +31 -0
  80. package/src/source/canvas_source.ts +2 -1
  81. package/src/source/geojson_worker_source.test.ts +88 -0
  82. package/src/source/geojson_worker_source.ts +22 -39
  83. package/src/source/image_source.test.ts +246 -38
  84. package/src/source/image_source.ts +132 -19
  85. package/src/source/raster_dem_tile_source.test.ts +37 -3
  86. package/src/source/raster_dem_tile_source.ts +1 -2
  87. package/src/source/raster_dem_tile_worker_source.test.ts +1 -1
  88. package/src/source/raster_tile_source.test.ts +5 -26
  89. package/src/source/raster_tile_source.ts +4 -3
  90. package/src/source/vector_tile_worker_source.test.ts +94 -2
  91. package/src/source/vector_tile_worker_source.ts +18 -27
  92. package/src/source/video_source.test.ts +12 -8
  93. package/src/source/worker_tile.bench.ts +10 -0
  94. package/src/source/worker_tile.ts +0 -3
  95. package/src/style/create_style_layer.bench.ts +15 -0
  96. package/src/style/properties.bench.ts +81 -0
  97. package/src/style/style.test.ts +75 -10
  98. package/src/style/style.ts +37 -64
  99. package/src/style/style_image.ts +67 -9
  100. package/src/style/style_layer.bench.ts +65 -0
  101. package/src/style/style_layer.test.ts +1 -1
  102. package/src/style/style_layer.ts +2 -2
  103. package/src/style/validate_style.bench.ts +11 -0
  104. package/src/style/validate_style.test.ts +2 -2
  105. package/src/symbol/anchor.test.ts +2 -2
  106. package/src/symbol/collision_index.bench.ts +116 -0
  107. package/src/symbol/cross_tile_symbol_index.bench.ts +49 -0
  108. package/src/symbol/cross_tile_symbol_index.test.ts +31 -0
  109. package/src/symbol/cross_tile_symbol_index.ts +67 -37
  110. package/src/symbol/shaping.test.ts +2 -1
  111. package/src/symbol/symbol_layout.bench.ts +30 -0
  112. package/src/tile/tile_id.test.ts +1 -1
  113. package/src/tile/tile_manager.test.ts +69 -1
  114. package/src/tile/tile_manager.ts +16 -11
  115. package/src/ui/control/fullscreen_control.test.ts +10 -10
  116. package/src/ui/control/geolocate_control.test.ts +3 -5
  117. package/src/ui/control/globe_control.test.ts +6 -6
  118. package/src/ui/events.ts +1 -1
  119. package/src/ui/handler/scroll_zoom.test.ts +50 -0
  120. package/src/ui/handler/two_fingers_touch.test.ts +17 -6
  121. package/src/ui/handler_inertia.test.ts +91 -0
  122. package/src/ui/handler_inertia.ts +65 -14
  123. package/src/ui/handler_manager.test.ts +243 -3
  124. package/src/ui/handler_manager.ts +79 -16
  125. package/src/ui/map.ts +17 -3
  126. package/src/ui/map_tests/map_cross_window.test.ts +2 -2
  127. package/src/ui/map_tests/map_events.test.ts +3 -3
  128. package/src/ui/map_tests/map_images.test.ts +55 -0
  129. package/src/ui/map_tests/map_style.test.ts +9 -8
  130. package/src/ui/map_tests/map_webgl.test.ts +30 -0
  131. package/src/ui/marker.test.ts +177 -42
  132. package/src/ui/marker.ts +120 -10
  133. package/src/ui/popup.test.ts +14 -14
  134. package/src/util/evented.test.ts +33 -28
  135. package/src/util/evented.ts +69 -43
  136. package/src/util/image_request.ts +31 -1
  137. package/src/util/test/null_gl.ts +10 -0
  138. package/src/util/test/util.ts +2 -1
  139. package/src/util/util.test.ts +1 -1
  140. package/src/util/web_worker_transfer.test.ts +5 -5
  141. package/src/webgl/context.ts +20 -0
  142. package/src/webgl/draw/draw_background.ts +1 -1
  143. package/src/webgl/draw/draw_raster.ts +11 -6
  144. package/src/webgl/program/pattern.ts +3 -3
  145. package/src/webgl/program/raster_program.ts +11 -0
  146. package/src/webgl/program.ts +31 -16
  147. package/src/webgl/texture.test.ts +16 -1
  148. package/src/webgl/texture.ts +3 -0
  149. package/src/webgl/vertex_buffer.test.ts +17 -2
  150. package/src/webgl/vertex_buffer.ts +24 -13
@@ -3,7 +3,6 @@ import { GeoJSONVTOptions } from "@maplibre/geojson-vt";
3
3
  import { AllLayoutProperties, AllPaintProperties, Color, ColorArray, CompositeExpression, DiffCommand, DiffOperations, Feature, FeatureFilter, FeatureState, FilterSpecification, Formatted, FormattedSection, GeoJSONSourceSpecification, GlobalProperties, ICanonicalTileID, IMercatorCoordinate, ImageSourceSpecification, InterpolationType, LayerSpecification, LightSpecification, NumberArray, Padding, ProjectionSpecification, PromoteIdSpecification, PropertyValueSpecification, RasterDEMSourceSpecification, RasterSourceSpecification, ResolvedImage, SkySpecification, SourceExpression, SourceSpecification, SpriteSpecification, StateSpecification, StylePropertyExpression, StylePropertySpecification, StyleSpecification, TerrainSpecification, TransitionSpecification, ValidationError, VariableAnchorOffsetCollection, VectorSourceSpecification, VideoSourceSpecification, VisibilityExpression, VisibilitySpecification } from "@maplibre/maplibre-gl-style-spec";
4
4
  import { VectorTileFeatureLike, VectorTileLayerLike } from "@maplibre/vt-pbf";
5
5
  import { mat2, mat4, vec3, vec4 } from "gl-matrix";
6
- import { PotpackBox } from "potpack";
7
6
  import KDBush from "kdbush";
8
7
  import TinySDF from "@mapbox/tiny-sdf";
9
8
  export type * from "@maplibre/maplibre-gl-style-spec";
@@ -994,19 +993,31 @@ declare class OverscaledTileID {
994
993
  /**
995
994
  * A listener method used as a callback to events
996
995
  */
997
- type Listener = (a: any) => any;
998
- type Listeners<EventType extends Record<string, any>> = { [_ in keyof EventType]?: Listener[]; };
996
+ type Listener<E extends Event$1 = Event$1> = (event: E) => any;
997
+ /**
998
+ * A mapping between event names and the event each of them carries.
999
+ */
1000
+ type EventTypeMap = Record<string, Event$1>;
1001
+ /**
1002
+ * The event names of an {@link EventTypeMap}.
1003
+ */
1004
+ type EventNames<EventType extends EventTypeMap> = Extract<keyof EventType, string>;
1005
+ /**
1006
+ * Properties merged into every event bubbled up to an evented parent.
1007
+ */
1008
+ type EventedParentData = Record<string, unknown>;
1009
+ type Listeners<EventType extends EventTypeMap> = { [K in keyof EventType]?: Array<Listener<EventType[K]>>; };
999
1010
  /**
1000
1011
  * The event class
1001
1012
  */
1002
- declare class Event$1 {
1003
- readonly type: string;
1013
+ declare class Event$1<TType extends string = string> {
1014
+ readonly type: TType;
1004
1015
  /**
1005
1016
  * The object that fired the event. Set when the event is fired, and narrowed to a more
1006
1017
  * specific type (e.g. `Map`, `Marker`) by the event subclasses.
1007
1018
  */
1008
1019
  target?: unknown;
1009
- constructor(type: string, data?: any);
1020
+ constructor(type: TType, data?: object);
1010
1021
  }
1011
1022
  type ErrorLike = {
1012
1023
  message: string;
@@ -1014,20 +1025,26 @@ type ErrorLike = {
1014
1025
  /**
1015
1026
  * An error event
1016
1027
  */
1017
- declare class ErrorEvent$1 extends Event$1 {
1028
+ declare class ErrorEvent extends Event$1<"error"> {
1018
1029
  error: ErrorLike;
1019
- constructor(error: ErrorLike, data?: any);
1030
+ constructor(error: ErrorLike, data?: object);
1020
1031
  }
1032
+ /**
1033
+ * The event map of an {@link Evented} that only reports errors.
1034
+ */
1035
+ type ErrorEventType = {
1036
+ error: ErrorEvent;
1037
+ };
1021
1038
  /**
1022
1039
  * Methods mixed in to other classes for event capabilities.
1023
1040
  *
1024
1041
  * @group Event Related
1025
1042
  */
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);
1043
+ declare abstract class Evented<EventType extends EventTypeMap = EventTypeMap> {
1044
+ _listeners?: Listeners<EventType>;
1045
+ _oneTimeListeners?: Listeners<EventType>;
1046
+ _eventedParent?: Evented;
1047
+ _eventedParentData?: EventedParentData | (() => EventedParentData);
1031
1048
  /**
1032
1049
  * Adds a listener to a specified event type.
1033
1050
  *
@@ -1036,14 +1053,14 @@ declare abstract class Evented<EventType extends Record<string, any> = Record<st
1036
1053
  * The listener function is called with the data object passed to `fire`,
1037
1054
  * extended with `target` and `type` properties.
1038
1055
  */
1039
- on<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): Subscription;
1056
+ on<T extends EventNames<EventType>>(type: T, listener: (event: EventType[T]) => void): Subscription;
1040
1057
  /**
1041
1058
  * Removes a previously registered event listener.
1042
1059
  *
1043
1060
  * @param type - The event type to remove listeners for.
1044
1061
  * @param listener - The listener function to remove.
1045
1062
  */
1046
- off<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): this;
1063
+ off<T extends EventNames<EventType>>(type: T, listener: (event: EventType[T]) => void): this;
1047
1064
  /**
1048
1065
  * Adds a listener that will be called only once to a specified event type.
1049
1066
  *
@@ -1052,7 +1069,7 @@ declare abstract class Evented<EventType extends Record<string, any> = Record<st
1052
1069
  * @param type - The event type to listen for.
1053
1070
  * @returns a promise that resolves with the event
1054
1071
  */
1055
- once<T extends keyof EventType>(type: T): Promise<EventType[T]>;
1072
+ once<T extends EventNames<EventType>>(type: T): Promise<EventType[T]>;
1056
1073
  /**
1057
1074
  * Adds a listener that will be called only once to a specified event type.
1058
1075
  *
@@ -1062,19 +1079,28 @@ declare abstract class Evented<EventType extends Record<string, any> = Record<st
1062
1079
  * @param listener - The function to be called when the event is fired the first time.
1063
1080
  * @returns `this` when a listener is provided
1064
1081
  */
1065
- once<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): this;
1066
- fire(event: Event$1 | string, properties?: any): this;
1082
+ once<T extends EventNames<EventType>>(type: T, listener: (event: EventType[T]) => void): this;
1083
+ /**
1084
+ * Calls every listener registered for the event's type.
1085
+ */
1086
+ fire(event: EventType[EventNames<EventType>]): this;
1087
+ /**
1088
+ * Compatibility with the (type: string, properties: Object) signature from previous versions.
1089
+ * See https://github.com/mapbox/mapbox-gl-js/issues/6522,
1090
+ * https://github.com/mapbox/mapbox-gl-draw/issues/766
1091
+ */
1092
+ fire(type: EventNames<EventType>, properties?: object): this;
1067
1093
  /**
1068
1094
  * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
1069
1095
  *
1070
1096
  * @param type - The event type
1071
1097
  * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise
1072
1098
  */
1073
- listens(type: string): boolean;
1099
+ listens(type: EventNames<EventType>): boolean;
1074
1100
  /**
1075
1101
  * Bubble all events fired by this instance of Evented to this parent instance of Evented.
1076
1102
  */
1077
- setEventedParent(parent?: Evented | null, data?: any | (() => any)): this;
1103
+ setEventedParent(parent?: Evented | null, data?: EventedParentData | (() => EventedParentData)): this;
1078
1104
  }
1079
1105
  //#endregion
1080
1106
  //#region src/util/vectortile_to_geojson.d.ts
@@ -2089,6 +2115,7 @@ type StyleImageData = {
2089
2115
  data: RGBAImage;
2090
2116
  version?: number;
2091
2117
  hasRenderCallback?: boolean;
2118
+ isWebGLImage?: boolean;
2092
2119
  userImage?: StyleImageInterface;
2093
2120
  spriteData?: SpriteOnDemandStyleImage;
2094
2121
  };
@@ -2149,6 +2176,46 @@ type StyleImageMetadata = {
2149
2176
  * the style's image, including data and metedata
2150
2177
  */
2151
2178
  type StyleImage = StyleImageData & StyleImageMetadata;
2179
+ /**
2180
+ * Where a {@link StyleImageWebGLData.renderWithWebGL} callback writes its pixels.
2181
+ */
2182
+ type StyleImageWebGLTarget = {
2183
+ gl: WebGL2RenderingContext;
2184
+ /**
2185
+ * The icon atlas to write into. MapLibre does not bind it for you, so start with
2186
+ * `gl.bindTexture(gl.TEXTURE_2D, texture)` or attach it to your own framebuffer.
2187
+ */
2188
+ texture: WebGLTexture;
2189
+ x: number;
2190
+ y: number;
2191
+ width: number;
2192
+ height: number;
2193
+ };
2194
+ /**
2195
+ * What a {@link StyleImageInterface} gives as its `data` when it renders itself with WebGL rather
2196
+ * than handing over an array of pixels.
2197
+ *
2198
+ * @see [Animate an icon on the GPU.](https://maplibre.org/maplibre-gl-js/docs/examples/animate-an-icon-on-the-gpu/)
2199
+ */
2200
+ type StyleImageWebGLData = {
2201
+ /**
2202
+ * Render exactly `width` x `height` premultiplied-alpha pixels at (`x`, `y`) of
2203
+ * `target.texture`. That rectangle is the only part of the shared atlas that belongs to this
2204
+ * image; drawing outside it corrupts the others.
2205
+ *
2206
+ * This is the image's counterpart to {@link CustomLayerInterface.render}, and the context
2207
+ * arrives in the same state a custom layer's is given: cull face, active texture and the pixel
2208
+ * store settings at their WebGL defaults, and no vertex array bound. Everything is yours to
2209
+ * change, and MapLibre restores its own state afterwards. The scissor test is the one
2210
+ * exception: MapLibre never touches it, so an image that enables it has to disable it again.
2211
+ *
2212
+ * Called before the first frame the image is used in, again whenever
2213
+ * {@link StyleImageInterface.render} returns `true`, and again for each atlas holding a slot
2214
+ * this image has never rendered into, so one change may mean several calls with different
2215
+ * targets.
2216
+ */
2217
+ renderWithWebGL: (target: StyleImageWebGLTarget) => void;
2218
+ };
2152
2219
  /**
2153
2220
  * Interface for dynamically generated style images. This is a specification for
2154
2221
  * implementers to model: it is not an exported method or class.
@@ -2205,7 +2272,13 @@ type StyleImage = StyleImageData & StyleImageMetadata;
2205
2272
  interface StyleImageInterface {
2206
2273
  width: number;
2207
2274
  height: number;
2208
- data: Uint8Array | Uint8ClampedArray;
2275
+ /**
2276
+ * The image's pixels, in the same format as `ImageData`, or a {@link StyleImageWebGLData}
2277
+ * callback that renders them with WebGL. A WebGL image renders straight into its slot of the
2278
+ * shared icon atlas. Nothing new is possible that pixels could not express, but an image that
2279
+ * changes often, such as an animated icon, gets much cheaper: no CPU pixel work and no upload.
2280
+ */
2281
+ data: Uint8Array | Uint8ClampedArray | StyleImageWebGLData;
2209
2282
  /**
2210
2283
  * This method is called once before every frame where the icon will be used.
2211
2284
  * The method can optionally update the image's `data` member with a new image.
@@ -2213,6 +2286,9 @@ interface StyleImageInterface {
2213
2286
  * If the method updates the image it must return `true` to commit the change.
2214
2287
  * If the method returns `false` or nothing the image is assumed to not have changed.
2215
2288
  *
2289
+ * An image whose `data` renders with WebGL has nothing to update here; returning `true` is how
2290
+ * it asks for {@link StyleImageWebGLData.renderWithWebGL} to be called again.
2291
+ *
2216
2292
  * If updates are infrequent it maybe easier to use {@link Map.updateImage} to update
2217
2293
  * the image instead of implementing this method.
2218
2294
  *
@@ -2228,10 +2304,125 @@ interface StyleImageInterface {
2228
2304
  /**
2229
2305
  * Optional method called when the icon is removed from the map with {@link Map.removeImage}.
2230
2306
  * This gives the image a chance to clean up resources and event listeners.
2307
+ *
2308
+ * This also fires when the WebGL context is lost, after which the same image is added back
2309
+ * without a matching `onAdd`, so the image has to be able to build again whatever it
2310
+ * released here.
2231
2311
  */
2232
2312
  onRemove?: () => void;
2233
2313
  }
2234
2314
  //#endregion
2315
+ //#region src/render/image_manager.d.ts
2316
+ type MissingImageRequestHandler = (id: string) => void | Promise<void>;
2317
+ type ImageManagerEventType = {
2318
+ error: ErrorEvent;
2319
+ styleimagemissing: MapStyleImageMissingEvent;
2320
+ };
2321
+ /**
2322
+ * Owns every image of the style - the ones the sprites bring in as well as the ones added at
2323
+ * runtime - and tracks requests for them from the tile workers, sending responses when the
2324
+ * requests are fulfilled.
2325
+ */
2326
+ declare class ImageManager extends Evented<ImageManagerEventType> {
2327
+ images: Record<string, StyleImage>;
2328
+ /**
2329
+ * Incremented on every {@link ImageManager.updateImage} call. {@link ImageAtlas} instances
2330
+ * compare it against the value they last patched against, so that a tile whose atlas is up to
2331
+ * date can skip its patching work entirely.
2332
+ */
2333
+ updateVersion: number;
2334
+ loaded: boolean;
2335
+ /**
2336
+ * This is used to track requests for images that are not yet available. When the image is loaded,
2337
+ * the requestors will be notified.
2338
+ */
2339
+ requestors: Array<{
2340
+ ids: string[];
2341
+ promiseResolve: (value: GetImagesResponse | PromiseLike<GetImagesResponse>) => void;
2342
+ }>;
2343
+ missingImageResolver: MissingImageRequestHandler | null;
2344
+ /**
2345
+ * The images whose `render` callback already ran in the current frame. A given image usually
2346
+ * sits in the atlas of several tiles, so it would otherwise be asked to re-render once per
2347
+ * tile that holds it.
2348
+ */
2349
+ private _renderCallbacksDispatchedThisFrame;
2350
+ /**
2351
+ * The ids of the images each sprite has brought in, keyed by sprite id, so that they can be
2352
+ * removed again when that sprite is reloaded or removed.
2353
+ */
2354
+ private _spriteImagesIds;
2355
+ /** Cached result of {@link ImageManager.listImages}, invalidated whenever an image is added or removed */
2356
+ private _imagesIds;
2357
+ constructor();
2358
+ destroy(): void;
2359
+ isLoaded(): boolean;
2360
+ setLoaded(loaded: boolean): void;
2361
+ getImage(id: string): StyleImage;
2362
+ addImage(id: string, image: StyleImage): void;
2363
+ _validate(id: string, image: StyleImage): boolean;
2364
+ _validateStretch(stretch: Array<[number, number]>, size: number): boolean;
2365
+ _validateContent(content: [number, number, number, number], image: StyleImage): boolean;
2366
+ /**
2367
+ * Replaces an image that is already known under this id, bumping its version so that the
2368
+ * atlases holding it notice.
2369
+ *
2370
+ * The old record is read directly rather than through {@link ImageManager.getImage}, which
2371
+ * would force a synchronous decode of the sprite data of the very image being replaced. Its
2372
+ * size therefore comes from whichever of the two the pixels are still in, since an image that
2373
+ * came from a sprite and was never rendered has not been decoded yet, and its version is
2374
+ * defaulted, since images start out without one.
2375
+ *
2376
+ * @param validate - whether to reject an image of a different size than the one it replaces
2377
+ */
2378
+ updateImage(id: string, image: StyleImage, validate?: boolean): void;
2379
+ removeImage(id: string): void;
2380
+ /**
2381
+ * @returns the ids of every image currently held, sprite images and runtime ones alike. The
2382
+ * returned array is shared between callers and must not be modified.
2383
+ */
2384
+ listImages(): string[];
2385
+ /**
2386
+ * Images of the `default` sprite keep their plain id, the ones of any other sprite are
2387
+ * namespaced by their sprite's id.
2388
+ */
2389
+ private _getSpriteImageId;
2390
+ /**
2391
+ * Takes over the images of a single sprite: adds the new ones, updates the ones that are
2392
+ * already known, and removes the ones that a previous load of this same sprite had brought in
2393
+ * but that are not part of it anymore.
2394
+ *
2395
+ * @param spriteId - the id of the sprite the images belong to
2396
+ * @param images - the sprite's images, keyed by their id within the sprite
2397
+ * @returns the ids of the images that this sprite now provides, and the ids of the ones that
2398
+ * were removed because they are no longer part of it
2399
+ */
2400
+ setSpriteImages(spriteId: string, images: Record<string, StyleImage>): {
2401
+ loaded: string[];
2402
+ removed: string[];
2403
+ };
2404
+ /**
2405
+ * Removes all the images a single sprite has brought in.
2406
+ * @returns the ids of the removed images
2407
+ */
2408
+ removeSpriteImages(spriteId: string): string[];
2409
+ /**
2410
+ * Removes the images of every sprite, leaving the images added at runtime alone.
2411
+ * @returns the ids of the removed images
2412
+ */
2413
+ removeAllSpriteImages(): string[];
2414
+ setMissingImageResolver(resolver: MissingImageRequestHandler | null): void;
2415
+ getImages(ids: string[]): Promise<GetImagesResponse>;
2416
+ _getImagesForIds(ids: string[]): Promise<GetImagesResponse>;
2417
+ beginFrame(): void;
2418
+ /**
2419
+ * Re-renders the images among `ids` that were added with a `render` callback (see
2420
+ * `StyleImageInterface`), at most once per frame each.
2421
+ */
2422
+ dispatchRenderCallbacks(ids: string[]): void;
2423
+ cloneImages(): Record<string, StyleImage>;
2424
+ }
2425
+ //#endregion
2235
2426
  //#region src/webgl/texture.d.ts
2236
2427
  type TextureFormat = WebGLRenderingContextBase["RGBA"] | WebGLRenderingContextBase["ALPHA"];
2237
2428
  type TextureFilter = WebGLRenderingContextBase["LINEAR"] | WebGLRenderingContextBase["LINEAR_MIPMAP_NEAREST"] | WebGLRenderingContextBase["NEAREST"];
@@ -2276,76 +2467,6 @@ declare class Texture {
2276
2467
  destroy(): void;
2277
2468
  }
2278
2469
  //#endregion
2279
- //#region src/render/image_manager.d.ts
2280
- type MissingImageRequestHandler = (id: string) => void | Promise<void>;
2281
- type Pattern = {
2282
- bin: PotpackBox;
2283
- position: ImagePosition;
2284
- };
2285
- /**
2286
- * ImageManager does three things:
2287
- *
2288
- * 1. Tracks requests for icon images from tile workers and sends responses when the requests are fulfilled.
2289
- * 2. Builds a texture atlas for pattern images.
2290
- * 3. Rerenders renderable images once per frame
2291
- *
2292
- * These are disparate responsibilities and should eventually be handled by different classes. When we implement
2293
- * data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time
2294
- * to refactor this.
2295
- */
2296
- declare class ImageManager extends Evented {
2297
- images: {
2298
- [_: string]: StyleImage;
2299
- };
2300
- updatedImages: {
2301
- [_: string]: boolean;
2302
- };
2303
- callbackDispatchedThisFrame: {
2304
- [_: string]: boolean;
2305
- };
2306
- loaded: boolean;
2307
- /**
2308
- * This is used to track requests for images that are not yet available. When the image is loaded,
2309
- * the requestors will be notified.
2310
- */
2311
- requestors: Array<{
2312
- ids: string[];
2313
- promiseResolve: (value: GetImagesResponse | PromiseLike<GetImagesResponse>) => void;
2314
- }>;
2315
- missingImageResolver: MissingImageRequestHandler | null;
2316
- patterns: {
2317
- [_: string]: Pattern;
2318
- };
2319
- atlasImage: RGBAImage;
2320
- atlasTexture: Texture;
2321
- dirty: boolean;
2322
- constructor();
2323
- destroy(): void;
2324
- isLoaded(): boolean;
2325
- setLoaded(loaded: boolean): void;
2326
- getImage(id: string): StyleImage;
2327
- addImage(id: string, image: StyleImage): void;
2328
- _validate(id: string, image: StyleImage): boolean;
2329
- _validateStretch(stretch: Array<[number, number]>, size: number): boolean;
2330
- _validateContent(content: [number, number, number, number], image: StyleImage): boolean;
2331
- updateImage(id: string, image: StyleImage, validate?: boolean): void;
2332
- removeImage(id: string): void;
2333
- listImages(): string[];
2334
- setMissingImageResolver(resolver: MissingImageRequestHandler | null): void;
2335
- getImages(ids: string[]): Promise<GetImagesResponse>;
2336
- _getImagesForIds(ids: string[]): Promise<GetImagesResponse>;
2337
- getPixelSize(): {
2338
- width: number;
2339
- height: number;
2340
- };
2341
- getPattern(id: string): ImagePosition;
2342
- bind(context: Context): void;
2343
- _updatePatternAtlas(): void;
2344
- beginFrame(): void;
2345
- dispatchRenderCallbacks(ids: string[]): void;
2346
- cloneImages(): Record<string, StyleImage>;
2347
- }
2348
- //#endregion
2349
2470
  //#region src/style/style_glyph.d.ts
2350
2471
  /**
2351
2472
  * Some metices related to a glyph
@@ -2401,36 +2522,57 @@ declare class ImagePosition {
2401
2522
  paddedRect: Rect;
2402
2523
  pixelRatio: number;
2403
2524
  version: number;
2525
+ needsFirstWebGLRender: boolean;
2404
2526
  stretchY: Array<[number, number]>;
2405
2527
  stretchX: Array<[number, number]>;
2406
2528
  content: [number, number, number, number];
2407
2529
  textFitWidth: TextFit;
2408
2530
  textFitHeight: TextFit;
2409
- constructor(paddedRect: Rect, { pixelRatio, version, stretchX, stretchY, content, textFitWidth, textFitHeight }: StyleImage);
2531
+ constructor(paddedRect: Rect, { pixelRatio, version, isWebGLImage, stretchX, stretchY, content, textFitWidth, textFitHeight }: StyleImage);
2410
2532
  get tl(): [number, number];
2411
2533
  get br(): [number, number];
2412
2534
  get tlbr(): number[];
2413
2535
  get displaySize(): [number, number];
2414
2536
  }
2415
2537
  /**
2416
- * A class holding all the images
2538
+ * A single tile's packed copy of the icons and patterns its features reference, built in the
2539
+ * worker so that the symbol layout can bake the positions within it straight into the vertex
2540
+ * buffers. Each tile owns one, along with the texture it is uploaded to - as opposed to
2541
+ * {@link ImageManager}, which owns the images of the whole style.
2542
+ * @internal
2417
2543
  */
2418
2544
  declare class ImageAtlas {
2419
2545
  image: RGBAImage;
2420
- iconPositions: {
2421
- [_: string]: ImagePosition;
2422
- };
2423
- patternPositions: {
2424
- [_: string]: ImagePosition;
2425
- };
2546
+ iconPositions: Record<string, ImagePosition>;
2547
+ patternPositions: Record<string, ImagePosition>;
2426
2548
  haveRenderCallbacks: string[];
2427
2549
  uploaded: boolean;
2550
+ /**
2551
+ * The {@link ImageManager.updateVersion} this atlas' texture was last patched against.
2552
+ * Starts out at `-1` so that a freshly transferred atlas always patches once: images may have
2553
+ * been updated between the moment the worker snapshotted them and the moment the atlas arrives.
2554
+ */
2555
+ patchedUpdateVersion: number;
2428
2556
  constructor(icons: GetImagesResponse, patterns: GetImagesResponse);
2429
2557
  addImages(images: {
2430
2558
  [_: string]: StyleImage;
2431
2559
  }, positions: {
2432
2560
  [_: string]: ImagePosition;
2433
2561
  }, bins: Rect[]): void;
2562
+ /**
2563
+ * Brings this atlas' texture back in sync with the images it was built from, re-uploading the
2564
+ * ones that were replaced in the meantime.
2565
+ *
2566
+ * This runs for every in-view tile on every frame, so the common case of nothing having
2567
+ * changed has to cost nothing: a single comparison against {@link ImageManager.updateVersion}
2568
+ * ends the call. When something did change, only the images this atlas actually holds are
2569
+ * looked at - a handful per tile - and {@link ImageAtlas.patchUpdatedImage} then skips the
2570
+ * ones whose version still matches, leaving just the genuinely stale ones to upload.
2571
+ *
2572
+ * The render callbacks are dispatched first because they may update images themselves, and
2573
+ * those updates have to be part of the version this call catches up with - otherwise an
2574
+ * animated image would always be uploaded a frame late.
2575
+ */
2434
2576
  patchUpdatedImages(imageManager: ImageManager, texture: Texture): void;
2435
2577
  patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture): void;
2436
2578
  }
@@ -4625,8 +4767,10 @@ interface ITransformMutators {
4625
4767
  * Set's the transform's center so that the given point on screen is at the given world coordinates.
4626
4768
  * @param lnglat - Desired world coordinates of the point.
4627
4769
  * @param point - The screen point that should lie at the given coordinates.
4770
+ * @param elevation - Optional ground elevation in meters above sea level at `lnglat`,
4771
+ * defaults to the elevation at the map's center. Ignored when rendering the globe.
4628
4772
  */
4629
- setLocationAtPoint(lnglat: LngLat, point: Point$1): void;
4773
+ setLocationAtPoint(lnglat: LngLat, point: Point$1, elevation?: number): void;
4630
4774
  /**
4631
4775
  * Sets or clears the map's geographical constraints.
4632
4776
  * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map.
@@ -4739,6 +4883,15 @@ interface IReadonlyTransform extends ITransformGetters {
4739
4883
  * @returns lnglat location
4740
4884
  */
4741
4885
  screenPointToLocation(p: Point$1, terrain?: Terrain): LngLat;
4886
+ /**
4887
+ * @internal
4888
+ * Given a point on screen, return its LngLat location assuming the ground there
4889
+ * lies at the given elevation. When rendering the globe the elevation is ignored.
4890
+ * @param p - screen point
4891
+ * @param elevation - ground elevation in meters above sea level
4892
+ * @returns lnglat location
4893
+ */
4894
+ screenPointToLocationAtElevation(p: Point$1, elevation: number): LngLat;
4742
4895
  /**
4743
4896
  * @internal
4744
4897
  * Given a point on screen, return its mercator coordinate.
@@ -4986,6 +5139,41 @@ declare class CanvasSource extends ImageSource {
4986
5139
  _hasInvalidDimensions(): boolean;
4987
5140
  }
4988
5141
  //#endregion
5142
+ //#region src/style/style_layer/raster_style_layer_properties.g.d.ts
5143
+ type RasterPaintProps = {
5144
+ "raster-opacity": DataConstantProperty<number>;
5145
+ "raster-hue-rotate": DataConstantProperty<number>;
5146
+ "raster-brightness-min": DataConstantProperty<number>;
5147
+ "raster-brightness-max": DataConstantProperty<number>;
5148
+ "raster-saturation": DataConstantProperty<number>;
5149
+ "raster-contrast": DataConstantProperty<number>;
5150
+ "resampling": DataConstantProperty<"linear" | "nearest">;
5151
+ "raster-resampling": DataConstantProperty<"linear" | "nearest">;
5152
+ "raster-fade-duration": DataConstantProperty<number>;
5153
+ };
5154
+ type RasterPaintPropsPossiblyEvaluated = {
5155
+ "raster-opacity": number;
5156
+ "raster-hue-rotate": number;
5157
+ "raster-brightness-min": number;
5158
+ "raster-brightness-max": number;
5159
+ "raster-saturation": number;
5160
+ "raster-contrast": number;
5161
+ "resampling": "linear" | "nearest";
5162
+ "raster-resampling": "linear" | "nearest";
5163
+ "raster-fade-duration": number;
5164
+ };
5165
+ //#endregion
5166
+ //#region src/style/style_layer/raster_style_layer.d.ts
5167
+ declare class RasterStyleLayer extends StyleLayer {
5168
+ _transitionablePaint: Transitionable<RasterPaintProps>;
5169
+ _transitioningPaint: Transitioning<RasterPaintProps>;
5170
+ paint: PossiblyEvaluated<RasterPaintProps, RasterPaintPropsPossiblyEvaluated>;
5171
+ constructor(layer: LayerSpecification, globalState: Record<string, any>);
5172
+ }
5173
+ //#endregion
5174
+ //#region src/webgl/program/raster_program.d.ts
5175
+ type RasterPerspectiveTransform = [number, number, number];
5176
+ //#endregion
4989
5177
  //#region src/source/image_source.d.ts
4990
5178
  /**
4991
5179
  * Four geographical coordinates,
@@ -5106,9 +5294,11 @@ declare class ImageSource extends Evented<SourceEventType> implements Source {
5106
5294
  image: ImageSourceImage;
5107
5295
  tileID: CanonicalTileID;
5108
5296
  tileCoords: Point$1[];
5297
+ perspectiveTransform: RasterPerspectiveTransform;
5109
5298
  flippedWindingOrder: boolean;
5110
5299
  _loaded: boolean;
5111
- _request: AbortController;
5300
+ _abortController: AbortController;
5301
+ private _imageDirty;
5112
5302
  /** @internal */
5113
5303
  constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented);
5114
5304
  load(newCoordinates?: Coordinates): Promise<void>;
@@ -5124,6 +5314,10 @@ declare class ImageSource extends Evented<SourceEventType> implements Source {
5124
5314
  * @param options - The options object.
5125
5315
  */
5126
5316
  updateImage(options: UpdateImageOptions): this;
5317
+ /** Loaded tiles hold `this.texture`, so the wrapper has to outlive the images in it. */
5318
+ private _setImage;
5319
+ /** Teardown only: dropping the reference alone leaves the allocation to the GC. */
5320
+ private _disposeTexture;
5127
5321
  _finishLoading(): void;
5128
5322
  onAdd(map: Map$1): void;
5129
5323
  onRemove(): void;
@@ -5533,6 +5727,10 @@ type ProjectionPreludeUniformsType = {
5533
5727
  //#endregion
5534
5728
  //#region src/webgl/program.d.ts
5535
5729
  type DrawMode = WebGLRenderingContextBase["LINES"] | WebGLRenderingContextBase["TRIANGLES"] | WebGL2RenderingContext["LINE_STRIP"];
5730
+ type ProgramAttribute = {
5731
+ location: number;
5732
+ isInteger: boolean;
5733
+ };
5536
5734
  /**
5537
5735
  * @internal
5538
5736
  * A webgl program to execute in the GPU space
@@ -5540,7 +5738,7 @@ type DrawMode = WebGLRenderingContextBase["LINES"] | WebGLRenderingContextBase["
5540
5738
  declare class Program<Us extends UniformBindings> {
5541
5739
  program: WebGLProgram;
5542
5740
  attributes: {
5543
- [_: string]: number;
5741
+ [_: string]: ProgramAttribute;
5544
5742
  };
5545
5743
  numAttributes: number;
5546
5744
  fixedUniforms: Us;
@@ -5635,6 +5833,17 @@ declare class Context {
5635
5833
  constructor(gl: WebGL2RenderingContext);
5636
5834
  setDefault(): void;
5637
5835
  setDirty(): void;
5836
+ /**
5837
+ * Reset some GL state to default values before handing users the raw context, as we do for
5838
+ * custom layers and WebGL style images, to avoid hard-to-debug bugs in their code.
5839
+ *
5840
+ * MapLibre restores all of its own state afterwards, so the only state worth resetting first
5841
+ * is state users would be surprised to find dirty: `CULL_FACE`, `TEXTURE0` and the three
5842
+ * `UNPACK_` settings, whose defaults are meaningful enough that most code assumes them.
5843
+ * The vertex array is unbound rather than reset, so that MapLibre never has to track it and
5844
+ * a user's `vertexAttribPointer` calls cannot land on one of ours.
5845
+ */
5846
+ setCustomLayerDefaults(): void;
5638
5847
  createIndexBuffer(array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean): IndexBuffer;
5639
5848
  createVertexBuffer(array: StructArray, attributes: readonly StructArrayMember[], dynamicDraw?: boolean): VertexBuffer;
5640
5849
  createRenderbuffer(storageFormat: number, width: number, height: number): WebGLRenderbuffer;
@@ -5958,7 +6167,7 @@ type TileResult = {
5958
6167
  * - unloading cached tiles not needed to render a given viewport
5959
6168
  * - managing tile state and feature state
5960
6169
  */
5961
- declare class TileManager extends Evented {
6170
+ declare class TileManager extends Evented<SourceEventType> {
5962
6171
  id: string;
5963
6172
  dispatcher: Dispatcher;
5964
6173
  map: Map$1;
@@ -6004,7 +6213,7 @@ declare class TileManager extends Evented {
6004
6213
  getState(): SourceFeatureState;
6005
6214
  pause(): void;
6006
6215
  resume(): void;
6007
- _loadTile(tile: Tile, id: string, state: TileState): Promise<void>;
6216
+ _loadTile(tile: Tile, id: string, state: TileState, hadData: boolean): Promise<void>;
6008
6217
  _unloadTile(tile: Tile): void;
6009
6218
  _abortTile(tile: Tile): void;
6010
6219
  serialize(): any;
@@ -6022,7 +6231,7 @@ declare class TileManager extends Evented {
6022
6231
  */
6023
6232
  reload(sourceDataChanged?: boolean, shouldReloadTileOptions?: any): void;
6024
6233
  _reloadTile(id: string, state: TileState): Promise<void>;
6025
- _tileLoaded(tile: Tile, id: string, previousState: TileState, result: LoadTileResult): void;
6234
+ _tileLoaded(tile: Tile, id: string, previousState: TileState, hadData: boolean, result: LoadTileResult): void;
6026
6235
  /**
6027
6236
  * Get a specific tile by TileID
6028
6237
  */
@@ -6190,6 +6399,34 @@ declare class TileLayerIndex {
6190
6399
  findMatches(symbolInstances: SymbolInstanceArray, newTileID: OverscaledTileID, zoomCrossTileIDs: {
6191
6400
  [crossTileID: number]: boolean;
6192
6401
  }): void;
6402
+ /**
6403
+ * Matches a symbol instance against an entry backed by a KDBush spatial index
6404
+ * (used for keys with more than {@link KDBUSH_THRESHHOLD} symbols).
6405
+ *
6406
+ * Matches any symbol with the same key whose coordinates are within one grid
6407
+ * unit (with a 4px grid, this covers a 12px by 12px area). The lowest-index
6408
+ * unclaimed candidate is claimed in a single pass rather than sorting the
6409
+ * whole result set on every query: `range()` can return many candidates where
6410
+ * symbols are coincident (e.g. stacked point markers), so a per-query sort
6411
+ * would dominate placement cost on dense layers.
6412
+ *
6413
+ * Once a symbol is marked duplicate against a parent symbol, no other symbol
6414
+ * at the same zoom level may duplicate against the same parent (see issue #5993).
6415
+ */
6416
+ private findMatchesForIndexedEntry;
6417
+ /**
6418
+ * Matches a symbol instance against an entry that stores its positions as a
6419
+ * plain array (used for keys with at most {@link KDBUSH_THRESHHOLD} symbols).
6420
+ *
6421
+ * Matches any symbol with the same key whose coordinates are within one grid
6422
+ * unit (with a 4px grid, this covers a 12px by 12px area). Positions are
6423
+ * stored in symbol-instance order, so the first unclaimed match is also the
6424
+ * lowest-index one.
6425
+ *
6426
+ * Once a symbol is marked duplicate against a parent symbol, no other symbol
6427
+ * at the same zoom level may duplicate against the same parent (see issue #5993).
6428
+ */
6429
+ private findMatchesForNonIndexedEntry;
6193
6430
  getCrossTileIDsLists(): number[][];
6194
6431
  }
6195
6432
  declare class CrossTileIDs {
@@ -6513,38 +6750,6 @@ declare function drawHillshade(painter: Painter, tileManager: TileManager, layer
6513
6750
  //#region src/webgl/draw/draw_color_relief.d.ts
6514
6751
  declare function drawColorRelief(painter: Painter, tileManager: TileManager, layer: ColorReliefStyleLayer, tileIDs: OverscaledTileID[], renderOptions: RenderOptions): void;
6515
6752
  //#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
6753
  //#region src/webgl/draw/draw_raster.d.ts
6549
6754
  declare function drawRaster(painter: Painter, tileManager: TileManager, layer: RasterStyleLayer, tileIDs: OverscaledTileID[], renderOptions: RenderOptions): void;
6550
6755
  //#endregion
@@ -6945,6 +7150,32 @@ type DrawFunctions = {
6945
7150
  terrainCoords: typeof drawCoords;
6946
7151
  };
6947
7152
  //#endregion
7153
+ //#region src/render/pattern_atlas.d.ts
7154
+ /**
7155
+ * A texture atlas of the pattern images that are drawn without a tile's own {@link ImageAtlas},
7156
+ * i.e. `background-pattern`. Entries are packed on demand and re-packed whenever one of them is
7157
+ * added or changes, which is rare enough for the repacking cost not to matter.
7158
+ */
7159
+ declare class PatternAtlas {
7160
+ private _imageManager;
7161
+ private _entries;
7162
+ private _image;
7163
+ private _texture;
7164
+ private _dirty;
7165
+ constructor(imageManager: ImageManager);
7166
+ destroy(): void;
7167
+ getPixelSize(): {
7168
+ width: number;
7169
+ height: number;
7170
+ };
7171
+ /**
7172
+ * @returns the position of the pattern within the atlas, or `null` if there is no such image
7173
+ */
7174
+ getPattern(id: string): ImagePosition;
7175
+ bind(context: Context): void;
7176
+ private _update;
7177
+ }
7178
+ //#endregion
6948
7179
  //#region src/util/request_manager.d.ts
6949
7180
  /**
6950
7181
  * A type of MapLibre resource.
@@ -7136,6 +7367,7 @@ declare class Painter {
7136
7367
  options: PainterOptions;
7137
7368
  lineAtlas: LineAtlas;
7138
7369
  imageManager: ImageManager;
7370
+ patternAtlas: PatternAtlas;
7139
7371
  glyphManager: GlyphManager;
7140
7372
  depthRangeFor3D: DepthRangeType;
7141
7373
  opaquePassCutoff: number;
@@ -9103,6 +9335,7 @@ declare class Style extends Evented<MapEventType> {
9103
9335
  stylesheet: StyleSpecification;
9104
9336
  dispatcher: Dispatcher;
9105
9337
  imageManager: ImageManager;
9338
+ patternAtlas: PatternAtlas;
9106
9339
  glyphManager: GlyphManager;
9107
9340
  lineAtlas: LineAtlas;
9108
9341
  light: Light;
@@ -9142,10 +9375,6 @@ declare class Style extends Evented<MapEventType> {
9142
9375
  [layer: string]: true;
9143
9376
  };
9144
9377
  _layerOrderChanged: boolean;
9145
- _spritesImagesIds: {
9146
- [spriteId: string]: string[];
9147
- };
9148
- _availableImages: string[];
9149
9378
  _globalState: Record<string, any>;
9150
9379
  crossTileSymbolIndex: CrossTileSymbolIndex;
9151
9380
  pauseablePlacement: PauseablePlacement;
@@ -9169,7 +9398,7 @@ declare class Style extends Evented<MapEventType> {
9169
9398
  loadEmpty(): void;
9170
9399
  _load(json: StyleSpecification, options: StyleSwapOptions & StyleSetterOptions, previousStyle?: StyleSpecification): void;
9171
9400
  private _createLayers;
9172
- _loadSprite(sprite: SpriteSpecification, isUpdate?: boolean, completion?: (err: Error) => void): void;
9401
+ _loadSprite(sprite: SpriteSpecification, isUpdate?: boolean, completion?: (err: Error) => void): Promise<void>;
9173
9402
  _unloadSprite(): void;
9174
9403
  _validateLayer(layer: StyleLayer): void;
9175
9404
  loaded(): boolean;
@@ -9217,6 +9446,11 @@ declare class Style extends Evented<MapEventType> {
9217
9446
  getImage(id: string): StyleImage;
9218
9447
  setMissingImageResolver(resolver: MissingImageRequestHandler | null): void;
9219
9448
  removeImage(id: string): void;
9449
+ /**
9450
+ * Queues the tiles that depend on these images to be reloaded on the next update, which is
9451
+ * needed whenever an image appears, disappears or changes size.
9452
+ */
9453
+ _markImagesChanged(ids: string[]): void;
9220
9454
  _afterImageUpdated(id: string): void;
9221
9455
  listImages(): string[];
9222
9456
  addSource(id: string, source: SourceSpecification | CanvasSourceSpecification, options?: StyleSetterOptions): void;
@@ -9430,7 +9664,7 @@ type QueryIntersectsFeatureParams = {
9430
9664
  /**
9431
9665
  * A base class for style layers
9432
9666
  */
9433
- declare abstract class StyleLayer extends Evented {
9667
+ declare abstract class StyleLayer extends Evented<ErrorEventType> {
9434
9668
  id: string;
9435
9669
  metadata: unknown;
9436
9670
  type: LayerSpecification["type"] | CustomLayerInterface["type"];
@@ -10177,6 +10411,11 @@ type MapControlsDeltas = {
10177
10411
  pitchDelta: number;
10178
10412
  rollDelta: number;
10179
10413
  around: Point$1;
10414
+ /**
10415
+ * Elevation in meters of the terrain under `around` at gesture start; when set,
10416
+ * pan and zoom keep the terrain at this elevation under `around`.
10417
+ */
10418
+ aroundElevation?: number;
10180
10419
  };
10181
10420
  type CameraForBoxAndBearingHandlerResult = {
10182
10421
  center: LngLat;
@@ -10688,16 +10927,36 @@ declare class Camera extends Evented<MapEventType> {
10688
10927
  }
10689
10928
  //#endregion
10690
10929
  //#region src/ui/handler_inertia.d.ts
10930
+ type InertiaBufferEntry = {
10931
+ time: number;
10932
+ settings: HandlerResult;
10933
+ };
10691
10934
  declare class HandlerInertia {
10692
10935
  _map: Map$1;
10693
- _inertiaBuffer: Array<{
10694
- time: number;
10695
- settings: any;
10696
- }>;
10936
+ _inertiaBuffer: InertiaBufferEntry[];
10697
10937
  constructor(map: Map$1);
10698
10938
  clear(): void;
10699
- record(settings: any): void;
10939
+ record(settings: HandlerResult): void;
10700
10940
  _drainInertiaBuffer(): void;
10941
+ /**
10942
+ * Returns the entries the velocity is measured from: everything recorded within
10943
+ * {@link VELOCITY_WINDOW} before now, but never fewer than the last two, so that
10944
+ * inertia also works below two recorded updates per window.
10945
+ */
10946
+ _getVelocityEntries(): InertiaBufferEntry[];
10947
+ /**
10948
+ * Returns the ease which continues the gesture that has just ended.
10949
+ *
10950
+ * The velocity is measured over the time up to the release and not up to the last
10951
+ * recorded movement, so that a gesture held still before being released has a lower
10952
+ * velocity, down to no inertia at all. The delta of an entry happened before it was
10953
+ * recorded, so the first entry only marks the start of the measured interval; anchors
10954
+ * are the exception, as they describe the state at the moment of their entry.
10955
+ *
10956
+ * @param panInertiaOptions - overrides for the pan inertia defaults
10957
+ * @returns the ease options, or `undefined` when the measured interval holds no
10958
+ * movement, which terrain gestures produce by recording updates without any delta
10959
+ */
10701
10960
  _onMoveEnd(panInertiaOptions?: DragPanOptions | boolean): EaseToOptions;
10702
10961
  }
10703
10962
  //#endregion
@@ -10843,6 +11102,11 @@ declare class HandlerManager {
10843
11102
  [handlerName: string]: Event$1;
10844
11103
  }]>;
10845
11104
  _terrainMovement: boolean;
11105
+ /**
11106
+ * Elevation in meters of the terrain point grabbed at gesture start; kept for the
11107
+ * same lifetime as the elevation freeze. Null when that terrain was not available.
11108
+ */
11109
+ _terrainGestureAnchorElevation: number | null;
10846
11110
  _zoom: {
10847
11111
  handlerName: string;
10848
11112
  };
@@ -10883,6 +11147,30 @@ declare class HandlerManager {
10883
11147
  _updateMapTransform(combinedResult: HandlerResult, combinedEventsInProgress: EventsInProgress, deactivatedHandlers: {
10884
11148
  [handlerName: string]: Event$1;
10885
11149
  }): void;
11150
+ /**
11151
+ * The gesture's anchor point: the pinch midpoint when pinching, otherwise the
11152
+ * pan's anchor, clamped to the center point when it does not lie on the map.
11153
+ */
11154
+ _resolveAround(combinedResult: HandlerResult, terrain: Terrain | null, tr: ITransform): {
11155
+ around: Point$1;
11156
+ aroundOnSurface: boolean;
11157
+ };
11158
+ /**
11159
+ * The elevation of the plane a terrain gesture is solved on: the elevation of the
11160
+ * terrain point grabbed at gesture start, captured here on the gesture's first
11161
+ * frame. Undefined means the gesture is solved at the center's elevation instead —
11162
+ * when the grabbed terrain is not loaded, the anchor is the center point (a
11163
+ * center-point anchor is skipped by the camera helper and would lose the pan), or
11164
+ * the anchor plane is too close to the camera for a stable ray-plane solve.
11165
+ */
11166
+ _terrainGestureElevation(terrain: Terrain, around: Point$1, aroundOnSurface: boolean, tr: ITransform, combinedEventsInProgress: EventsInProgress): number | undefined;
11167
+ /**
11168
+ * The location that was under `around` before this frame's deltas — the point the
11169
+ * camera helper re-anchors after zooming — solved at `aroundElevation` when a
11170
+ * terrain gesture provides one. When rotating about the center point, the
11171
+ * transform's center is used directly to avoid numerical issues near the horizon.
11172
+ */
11173
+ _computePreZoomAroundLoc(tr: ITransform, around: Point$1, panDelta: Point$1 | undefined, aroundElevation: number | undefined): LngLat;
10886
11174
  _handleMapControls({ terrain, tr, deltasForHelper, preZoomAroundLoc, combinedEventsInProgress, panDelta }: MapControlsScenarioOptions): void;
10887
11175
  _fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {
10888
11176
  [handlerName: string]: Event$1;
@@ -15162,6 +15450,10 @@ type MarkerOptions = {
15162
15450
  scale?: number;
15163
15451
  /**
15164
15452
  * A boolean indicating whether or not a marker is able to be dragged to a new position on the map.
15453
+ * A draggable default marker also becomes keyboard focusable and, while focused, moves by
15454
+ * 1 screen pixel per arrow-key press (10 with Shift), firing the same `dragstart`/`drag`/`dragend`
15455
+ * events as pointer dragging. Markers with a custom `element` keep their focusability and
15456
+ * keyboard behavior application-owned.
15165
15457
  * @defaultValue false
15166
15458
  */
15167
15459
  draggable?: boolean;
@@ -15328,12 +15620,13 @@ declare class Marker extends Evented<MarkerEventType> {
15328
15620
  _rotation: number;
15329
15621
  _pitchAlignment: Alignment;
15330
15622
  _rotationAlignment: Alignment;
15331
- _originalTabIndex: string;
15332
15623
  _opacity: string;
15333
15624
  _opacityWhenCovered: string;
15334
15625
  _opacityTimeout: ReturnType<typeof setTimeout>;
15335
15626
  _subpixelPositioning: boolean;
15336
15627
  _roleManaged: boolean;
15628
+ _tabIndexManaged: boolean;
15629
+ _keyboardDragActive: boolean;
15337
15630
  /**
15338
15631
  * @param options - the options
15339
15632
  */
@@ -15423,6 +15716,18 @@ declare class Marker extends Evented<MarkerEventType> {
15423
15716
  setSubpixelPositioning(value: boolean): this;
15424
15717
  _onClick: (e: MouseEvent) => void;
15425
15718
  _onKeyPress: (e: KeyboardEvent) => void;
15719
+ /**
15720
+ * Move a focused draggable default marker with the arrow keys
15721
+ * (1 screen pixel per keydown; 10 with Shift).
15722
+ * Mirrors the pointer drag gesture: the position updates before `dragstart`
15723
+ * fires on the first movement, every movement fires `drag`, and releasing
15724
+ * the arrow key (or losing focus) fires `dragend`. Holding a key down
15725
+ * produces repeated `drag` events within a single gesture.
15726
+ */
15727
+ _onKeyDown: (e: KeyboardEvent) => void;
15728
+ _onKeyUp: (e: KeyboardEvent) => void;
15729
+ _onBlur: () => void;
15730
+ _endKeyboardDrag(): void;
15426
15731
  _onMapClick: (e: MapMouseEvent) => void;
15427
15732
  /**
15428
15733
  * Returns the {@link Popup} instance that is bound to the {@link Marker}.
@@ -15507,7 +15812,10 @@ declare class Marker extends Evented<MarkerEventType> {
15507
15812
  _onUp: () => void;
15508
15813
  _addDragHandler: (e: MapMouseEvent | MapTouchEvent) => void;
15509
15814
  /**
15510
- * Sets the `draggable` property and functionality of the marker
15815
+ * Sets the `draggable` property and functionality of the marker.
15816
+ * A draggable default marker is also keyboard focusable and movable with the
15817
+ * arrow keys (see {@link MarkerOptions.draggable}); custom marker elements keep
15818
+ * their focusability and keyboard behavior application-owned.
15511
15819
  * @param shouldBeDraggable - Turns drag functionality on/off
15512
15820
  */
15513
15821
  setDraggable(shouldBeDraggable?: boolean): this;
@@ -15516,6 +15824,14 @@ declare class Marker extends Evented<MarkerEventType> {
15516
15824
  * @returns True if the marker is draggable.
15517
15825
  */
15518
15826
  isDraggable(): boolean;
15827
+ /**
15828
+ * Keep the marker element focusable while it has built-in keyboard behavior.
15829
+ * A popup makes any marker element interactive; dragging only manages
15830
+ * focusability for the default marker so custom elements stay
15831
+ * application-owned (#7790). A tabindex supplied by the application is
15832
+ * never added, changed, or removed here.
15833
+ */
15834
+ _updateTabIndex(): void;
15519
15835
  /**
15520
15836
  * Keep the default marker role aligned with interactivity.
15521
15837
  * Default markers need a role because `aria-label` is set in {@link Marker.addTo}.
@@ -16762,4 +17078,4 @@ declare function setWorkerUrl(value: string): void;
16762
17078
  */
16763
17079
  declare function importScriptInWorkers(workerUrl: string): Promise<void>;
16764
17080
  //#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 };
17081
+ 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 };