maplibre-gl 3.1.0 → 3.2.0-pre.2

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 (338) hide show
  1. package/README.md +7 -7
  2. package/build/generate-doc-images.ts +73 -0
  3. package/build/generate-docs.ts +100 -0
  4. package/build/generate-struct-arrays.ts +9 -12
  5. package/dist/maplibre-gl-csp-worker.js +1 -1
  6. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  7. package/dist/maplibre-gl-csp.js +1 -1
  8. package/dist/maplibre-gl-csp.js.map +1 -1
  9. package/dist/maplibre-gl-dev.js +3303 -3398
  10. package/dist/maplibre-gl-dev.js.map +1 -1
  11. package/dist/maplibre-gl.d.ts +3899 -3531
  12. package/dist/maplibre-gl.js +3 -3
  13. package/dist/maplibre-gl.js.map +1 -1
  14. package/package.json +28 -25
  15. package/src/data/array_types.g.ts +14 -48
  16. package/src/data/bucket/circle_bucket.ts +11 -14
  17. package/src/data/bucket/fill_bucket.test.ts +6 -6
  18. package/src/data/bucket/fill_bucket.ts +10 -12
  19. package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
  20. package/src/data/bucket/heatmap_bucket.ts +3 -6
  21. package/src/data/bucket/line_attributes.ts +1 -2
  22. package/src/data/bucket/line_attributes_ext.ts +1 -2
  23. package/src/data/bucket/line_bucket.test.ts +5 -5
  24. package/src/data/bucket/line_bucket.ts +18 -21
  25. package/src/data/bucket/pattern_attributes.ts +1 -3
  26. package/src/data/bucket/pattern_bucket_features.ts +3 -3
  27. package/src/data/bucket/symbol_bucket.test.ts +5 -5
  28. package/src/data/bucket/symbol_bucket.ts +12 -15
  29. package/src/data/bucket.ts +7 -11
  30. package/src/data/dem_data.test.ts +1 -1
  31. package/src/data/dem_data.ts +1 -1
  32. package/src/data/evaluation_feature.ts +4 -5
  33. package/src/data/extent.ts +1 -4
  34. package/src/data/feature_index.ts +14 -13
  35. package/src/data/feature_position_map.test.ts +4 -4
  36. package/src/data/feature_position_map.ts +1 -1
  37. package/src/data/index_array_type.ts +0 -1
  38. package/src/data/load_geometry.test.ts +1 -1
  39. package/src/data/load_geometry.ts +3 -4
  40. package/src/data/program_configuration.ts +6 -11
  41. package/src/data/segment.ts +9 -6
  42. package/src/geo/edge_insets.test.ts +1 -1
  43. package/src/geo/edge_insets.ts +36 -26
  44. package/src/geo/lng_lat.test.ts +1 -1
  45. package/src/geo/lng_lat.ts +61 -44
  46. package/src/geo/lng_lat_bounds.test.ts +2 -2
  47. package/src/geo/lng_lat_bounds.ts +88 -68
  48. package/src/geo/mercator_coordinate.test.ts +2 -2
  49. package/src/geo/mercator_coordinate.ts +34 -27
  50. package/src/geo/transform.test.ts +3 -3
  51. package/src/geo/transform.ts +58 -79
  52. package/src/gl/color_mode.ts +1 -3
  53. package/src/gl/context.ts +12 -11
  54. package/src/gl/cull_face_mode.ts +1 -3
  55. package/src/gl/depth_mode.ts +1 -3
  56. package/src/gl/framebuffer.ts +5 -4
  57. package/src/gl/index_buffer.ts +5 -4
  58. package/src/gl/render_pool.test.ts +2 -2
  59. package/src/gl/render_pool.ts +5 -5
  60. package/src/gl/state.test.ts +1 -1
  61. package/src/gl/stencil_mode.ts +1 -3
  62. package/src/gl/value.ts +1 -1
  63. package/src/gl/vertex_buffer.test.ts +2 -2
  64. package/src/gl/vertex_buffer.ts +8 -14
  65. package/src/index.test.ts +2 -2
  66. package/src/index.ts +121 -113
  67. package/src/render/draw_background.ts +7 -9
  68. package/src/render/draw_circle.ts +13 -15
  69. package/src/render/draw_collision_debug.ts +11 -13
  70. package/src/render/draw_custom.ts +6 -8
  71. package/src/render/draw_debug.test.ts +4 -4
  72. package/src/render/draw_debug.ts +8 -10
  73. package/src/render/draw_fill.test.ts +13 -13
  74. package/src/render/draw_fill.ts +9 -11
  75. package/src/render/draw_fill_extrusion.ts +10 -12
  76. package/src/render/draw_heatmap.ts +12 -14
  77. package/src/render/draw_hillshade.ts +10 -12
  78. package/src/render/draw_line.ts +9 -9
  79. package/src/render/draw_raster.ts +9 -11
  80. package/src/render/draw_symbol.test.ts +16 -16
  81. package/src/render/draw_symbol.ts +15 -16
  82. package/src/render/draw_terrain.ts +11 -11
  83. package/src/render/glyph_atlas.ts +10 -1
  84. package/src/render/glyph_manager.test.ts +3 -3
  85. package/src/render/glyph_manager.ts +7 -7
  86. package/src/render/image_atlas.ts +6 -3
  87. package/src/render/image_manager.ts +3 -5
  88. package/src/render/line_atlas.test.ts +1 -1
  89. package/src/render/line_atlas.ts +19 -14
  90. package/src/render/painter.ts +85 -65
  91. package/src/render/program/background_program.ts +2 -2
  92. package/src/render/program/circle_program.ts +5 -5
  93. package/src/render/program/clipping_mask_program.ts +1 -1
  94. package/src/render/program/collision_program.ts +4 -4
  95. package/src/render/program/debug_program.ts +1 -1
  96. package/src/render/program/fill_extrusion_program.ts +3 -3
  97. package/src/render/program/fill_program.ts +3 -3
  98. package/src/render/program/heatmap_program.ts +5 -5
  99. package/src/render/program/hillshade_program.ts +7 -7
  100. package/src/render/program/line_program.ts +6 -6
  101. package/src/render/program/pattern.ts +3 -3
  102. package/src/render/program/raster_program.ts +2 -2
  103. package/src/render/program/symbol_program.ts +2 -2
  104. package/src/render/program/terrain_program.ts +1 -1
  105. package/src/render/program.ts +18 -16
  106. package/src/render/render_to_texture.test.ts +15 -15
  107. package/src/render/render_to_texture.ts +10 -10
  108. package/src/render/terrain.test.ts +38 -7
  109. package/src/render/terrain.ts +103 -67
  110. package/src/render/texture.ts +5 -4
  111. package/src/render/uniform_binding.test.ts +1 -1
  112. package/src/render/uniform_binding.ts +7 -1
  113. package/src/render/update_pattern_positions_in_program.ts +5 -5
  114. package/src/render/vertex_array_object.ts +9 -8
  115. package/src/shaders/encode_attribute.ts +0 -2
  116. package/src/shaders/shaders.ts +1 -3
  117. package/src/source/canvas_source.test.ts +6 -6
  118. package/src/source/canvas_source.ts +46 -60
  119. package/src/source/geojson_source.test.ts +5 -5
  120. package/src/source/geojson_source.ts +75 -59
  121. package/src/source/geojson_source_diff.ts +39 -2
  122. package/src/source/geojson_worker_source.test.ts +3 -3
  123. package/src/source/geojson_worker_source.ts +20 -26
  124. package/src/source/geojson_wrapper.test.ts +3 -3
  125. package/src/source/geojson_wrapper.ts +2 -4
  126. package/src/source/image_source.test.ts +9 -8
  127. package/src/source/image_source.ts +49 -35
  128. package/src/source/load_tilejson.ts +2 -2
  129. package/src/source/pixels_to_tile_units.ts +2 -3
  130. package/src/source/query_features.test.ts +3 -3
  131. package/src/source/query_features.ts +50 -19
  132. package/src/source/raster_dem_tile_source.test.ts +3 -3
  133. package/src/source/raster_dem_tile_source.ts +23 -10
  134. package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
  135. package/src/source/raster_dem_tile_worker_source.ts +3 -5
  136. package/src/source/raster_tile_source.test.ts +3 -3
  137. package/src/source/raster_tile_source.ts +38 -11
  138. package/src/source/rtl_text_plugin.ts +4 -1
  139. package/src/source/source.ts +67 -59
  140. package/src/source/source_cache.test.ts +7 -7
  141. package/src/source/source_cache.ts +17 -38
  142. package/src/source/source_state.ts +2 -5
  143. package/src/source/terrain_source_cache.test.ts +8 -8
  144. package/src/source/terrain_source_cache.ts +42 -27
  145. package/src/source/tile.test.ts +3 -3
  146. package/src/source/tile.ts +32 -38
  147. package/src/source/tile_bounds.ts +2 -4
  148. package/src/source/tile_cache.test.ts +2 -2
  149. package/src/source/tile_cache.ts +20 -30
  150. package/src/source/tile_id.ts +11 -2
  151. package/src/source/vector_tile_source.test.ts +3 -3
  152. package/src/source/vector_tile_source.ts +34 -24
  153. package/src/source/vector_tile_worker_source.test.ts +4 -4
  154. package/src/source/vector_tile_worker_source.ts +11 -23
  155. package/src/source/video_source.test.ts +5 -5
  156. package/src/source/video_source.ts +21 -28
  157. package/src/source/worker.ts +6 -8
  158. package/src/source/worker_source.ts +6 -8
  159. package/src/source/worker_tile.test.ts +5 -5
  160. package/src/source/worker_tile.ts +13 -16
  161. package/src/style/create_style_layer.ts +31 -26
  162. package/src/style/evaluation_parameters.ts +5 -4
  163. package/src/style/format_section_override.test.ts +2 -2
  164. package/src/style/format_section_override.ts +1 -1
  165. package/src/style/light.test.ts +2 -2
  166. package/src/style/light.ts +3 -5
  167. package/src/style/load_glyph_range.test.ts +1 -1
  168. package/src/style/load_glyph_range.ts +3 -3
  169. package/src/style/load_sprite.test.ts +1 -1
  170. package/src/style/load_sprite.ts +3 -3
  171. package/src/style/parse_glyph_pbf.ts +1 -1
  172. package/src/style/pauseable_placement.ts +7 -9
  173. package/src/style/properties.ts +4 -53
  174. package/src/style/query_utils.ts +3 -3
  175. package/src/style/style.test.ts +22 -19
  176. package/src/style/style.ts +118 -84
  177. package/src/style/style_glyph.ts +6 -0
  178. package/src/style/style_image.ts +39 -33
  179. package/src/style/style_layer/background_style_layer.ts +2 -4
  180. package/src/style/style_layer/circle_style_layer.ts +7 -6
  181. package/src/style/style_layer/custom_style_layer.ts +23 -48
  182. package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
  183. package/src/style/style_layer/fill_style_layer.ts +5 -7
  184. package/src/style/style_layer/heatmap_style_layer.ts +8 -7
  185. package/src/style/style_layer/hillshade_style_layer.ts +2 -4
  186. package/src/style/style_layer/line_style_layer.ts +6 -8
  187. package/src/style/style_layer/overlap_mode.test.ts +3 -3
  188. package/src/style/style_layer/overlap_mode.ts +3 -0
  189. package/src/style/style_layer/raster_style_layer.ts +2 -4
  190. package/src/style/style_layer/symbol_style_layer.ts +6 -8
  191. package/src/style/style_layer/typed_style_layer.ts +7 -7
  192. package/src/style/style_layer.test.ts +5 -5
  193. package/src/style/style_layer.ts +7 -6
  194. package/src/style/style_layer_index.test.ts +1 -1
  195. package/src/style/style_layer_index.ts +3 -5
  196. package/src/style/zoom_history.ts +1 -3
  197. package/src/symbol/anchor.test.ts +1 -1
  198. package/src/symbol/anchor.ts +1 -3
  199. package/src/symbol/check_max_angle.test.ts +8 -2
  200. package/src/symbol/check_max_angle.ts +10 -13
  201. package/src/symbol/clip_line.test.ts +1 -1
  202. package/src/symbol/clip_line.ts +6 -9
  203. package/src/symbol/collision_feature.test.ts +2 -2
  204. package/src/symbol/collision_feature.ts +7 -12
  205. package/src/symbol/collision_index.test.ts +2 -2
  206. package/src/symbol/collision_index.ts +5 -11
  207. package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
  208. package/src/symbol/cross_tile_symbol_index.ts +5 -7
  209. package/src/symbol/get_anchors.ts +2 -2
  210. package/src/symbol/grid_index.test.ts +1 -1
  211. package/src/symbol/grid_index.ts +4 -5
  212. package/src/symbol/merge_lines.test.ts +1 -1
  213. package/src/symbol/merge_lines.ts +1 -1
  214. package/src/symbol/opacity_state.ts +1 -3
  215. package/src/symbol/path_interpolator.test.ts +1 -1
  216. package/src/symbol/path_interpolator.ts +1 -3
  217. package/src/symbol/placement.ts +9 -9
  218. package/src/symbol/projection.ts +61 -34
  219. package/src/symbol/quads.ts +7 -11
  220. package/src/symbol/shaping.ts +1 -1
  221. package/src/symbol/symbol_layout.ts +9 -12
  222. package/src/symbol/symbol_size.ts +1 -1
  223. package/src/symbol/symbol_style_layer.test.ts +4 -4
  224. package/src/symbol/transform_text.ts +2 -2
  225. package/src/types/callback.ts +14 -14
  226. package/src/types/cancelable.ts +3 -0
  227. package/src/types/transferable.ts +3 -0
  228. package/src/ui/anchor.ts +4 -0
  229. package/src/ui/camera.test.ts +6 -6
  230. package/src/ui/camera.ts +392 -361
  231. package/src/ui/control/attribution_control.test.ts +1 -1
  232. package/src/ui/control/attribution_control.ts +34 -30
  233. package/src/ui/control/control.ts +14 -20
  234. package/src/ui/control/fullscreen_control.test.ts +1 -1
  235. package/src/ui/control/fullscreen_control.ts +21 -26
  236. package/src/ui/control/geolocate_control.test.ts +5 -5
  237. package/src/ui/control/geolocate_control.ts +181 -194
  238. package/src/ui/control/logo_control.ts +20 -16
  239. package/src/ui/control/navigation_control.test.ts +1 -1
  240. package/src/ui/control/navigation_control.ts +46 -42
  241. package/src/ui/control/scale_control.test.ts +1 -1
  242. package/src/ui/control/scale_control.ts +30 -21
  243. package/src/ui/control/terrain_control.test.ts +1 -1
  244. package/src/ui/control/terrain_control.ts +14 -18
  245. package/src/ui/default_locale.ts +1 -3
  246. package/src/ui/events.ts +570 -1281
  247. package/src/ui/handler/box_zoom.test.ts +2 -2
  248. package/src/ui/handler/box_zoom.ts +16 -11
  249. package/src/ui/handler/click_zoom.ts +11 -3
  250. package/src/ui/handler/cooperative_gestures.test.ts +3 -3
  251. package/src/ui/handler/dblclick_zoom.test.ts +1 -1
  252. package/src/ui/handler/drag_handler.ts +30 -22
  253. package/src/ui/handler/drag_move_state_manager.ts +1 -1
  254. package/src/ui/handler/drag_pan.test.ts +2 -2
  255. package/src/ui/handler/drag_rotate.test.ts +3 -3
  256. package/src/ui/handler/keyboard.test.ts +2 -2
  257. package/src/ui/handler/keyboard.ts +22 -13
  258. package/src/ui/handler/map_event.test.ts +2 -2
  259. package/src/ui/handler/map_event.ts +1 -1
  260. package/src/ui/handler/mouse.ts +1 -1
  261. package/src/ui/handler/mouse_rotate.test.ts +3 -3
  262. package/src/ui/handler/scroll_zoom.test.ts +3 -3
  263. package/src/ui/handler/scroll_zoom.ts +45 -52
  264. package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
  265. package/src/ui/handler/shim/drag_pan.ts +34 -14
  266. package/src/ui/handler/shim/drag_rotate.ts +20 -12
  267. package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
  268. package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
  269. package/src/ui/handler/tap_drag_zoom.ts +18 -10
  270. package/src/ui/handler/tap_recognizer.ts +1 -1
  271. package/src/ui/handler/tap_zoom.ts +4 -3
  272. package/src/ui/handler/touch_pan.ts +3 -2
  273. package/src/ui/handler/transform-provider.ts +4 -6
  274. package/src/ui/handler/two_fingers_touch.test.ts +3 -3
  275. package/src/ui/handler/two_fingers_touch.ts +64 -47
  276. package/src/ui/handler_inertia.ts +4 -4
  277. package/src/ui/handler_manager.ts +86 -52
  278. package/src/ui/hash.test.ts +1 -1
  279. package/src/ui/hash.ts +21 -28
  280. package/src/ui/map/isMoving.test.ts +3 -3
  281. package/src/ui/map/isRotating.test.ts +3 -3
  282. package/src/ui/map/isZooming.test.ts +3 -3
  283. package/src/ui/map.test.ts +97 -8
  284. package/src/ui/map.ts +856 -702
  285. package/src/ui/map_events.test.ts +1 -1
  286. package/src/ui/marker.test.ts +35 -15
  287. package/src/ui/marker.ts +220 -141
  288. package/src/ui/popup.test.ts +2 -2
  289. package/src/ui/popup.ts +179 -147
  290. package/src/util/actor.test.ts +7 -7
  291. package/src/util/actor.ts +25 -22
  292. package/src/util/ajax.ts +37 -17
  293. package/src/util/browser.test.ts +1 -1
  294. package/src/util/browser.ts +2 -6
  295. package/src/util/classify_rings.test.ts +1 -1
  296. package/src/util/classify_rings.ts +1 -1
  297. package/src/util/color_ramp.ts +0 -2
  298. package/src/util/config.ts +6 -3
  299. package/src/util/debug.ts +0 -2
  300. package/src/util/dictionary_coder.ts +1 -4
  301. package/src/util/dispatcher.test.ts +3 -3
  302. package/src/util/dispatcher.ts +4 -9
  303. package/src/util/dom.ts +1 -1
  304. package/src/util/evented.ts +23 -18
  305. package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
  306. package/src/util/find_pole_of_inaccessibility.ts +4 -5
  307. package/src/util/global_worker_pool.ts +2 -3
  308. package/src/util/image.ts +10 -4
  309. package/src/util/image_request.test.ts +3 -3
  310. package/src/util/image_request.ts +15 -14
  311. package/src/util/is_char_in_unicode_block.ts +1 -3
  312. package/src/util/offscreen_canvas_supported.ts +1 -1
  313. package/src/util/performance.ts +1 -2
  314. package/src/util/request_manager.ts +4 -0
  315. package/src/util/resolve_tokens.test.ts +1 -1
  316. package/src/util/resolve_tokens.ts +3 -6
  317. package/src/util/script_detection.ts +1 -4
  318. package/src/util/smart_wrap.ts +3 -5
  319. package/src/util/struct_array.ts +18 -14
  320. package/src/util/style.ts +2 -2
  321. package/src/util/task_queue.test.ts +1 -1
  322. package/src/util/task_queue.ts +1 -3
  323. package/src/util/test/mock_webgl.ts +6 -0
  324. package/src/util/test/util.ts +2 -2
  325. package/src/util/throttle.test.ts +1 -1
  326. package/src/util/throttle.ts +1 -2
  327. package/src/util/throttled_invoker.ts +1 -5
  328. package/src/util/transferable_grid_index.test.ts +1 -1
  329. package/src/util/transferable_grid_index.ts +1 -3
  330. package/src/util/util.test.ts +1 -14
  331. package/src/util/util.ts +44 -107
  332. package/src/util/vectortile_to_geojson.ts +13 -3
  333. package/src/util/verticalize_punctuation.ts +1 -1
  334. package/src/util/web_worker.ts +2 -2
  335. package/src/util/web_worker_transfer.ts +11 -8
  336. package/src/util/webp_supported.ts +2 -4
  337. package/src/util/worker_pool.test.ts +1 -1
  338. package/src/util/worker_pool.ts +4 -5
@@ -1,23 +1,21 @@
1
- import DepthMode from '../gl/depth_mode';
2
- import StencilMode from '../gl/stencil_mode';
3
- import ColorMode from '../gl/color_mode';
4
- import CullFaceMode from '../gl/cull_face_mode';
1
+ import {DepthMode} from '../gl/depth_mode';
2
+ import {StencilMode} from '../gl/stencil_mode';
3
+ import {ColorMode} from '../gl/color_mode';
4
+ import {CullFaceMode} from '../gl/cull_face_mode';
5
5
  import {
6
6
  fillExtrusionUniformValues,
7
7
  fillExtrusionPatternUniformValues,
8
8
  } from './program/fill_extrusion_program';
9
9
 
10
- import type Painter from './painter';
11
- import type SourceCache from '../source/source_cache';
12
- import type FillExtrusionStyleLayer from '../style/style_layer/fill_extrusion_style_layer';
13
- import type FillExtrusionBucket from '../data/bucket/fill_extrusion_bucket';
10
+ import type {Painter} from './painter';
11
+ import type {SourceCache} from '../source/source_cache';
12
+ import type {FillExtrusionStyleLayer} from '../style/style_layer/fill_extrusion_style_layer';
13
+ import type {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket';
14
14
  import type {OverscaledTileID} from '../source/tile_id';
15
15
 
16
- import updatePatternPositionsInProgram from './update_pattern_positions_in_program';
16
+ import {updatePatternPositionsInProgram} from './update_pattern_positions_in_program';
17
17
 
18
- export default draw;
19
-
20
- function draw(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLayer, coords: Array<OverscaledTileID>) {
18
+ export function drawFillExtrusion(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLayer, coords: Array<OverscaledTileID>) {
21
19
  const opacity = layer.paint.get('fill-extrusion-opacity');
22
20
  if (opacity === 0) {
23
21
  return;
@@ -1,25 +1,23 @@
1
- import Texture from './texture';
1
+ import {Texture} from './texture';
2
2
  import {Color} from '@maplibre/maplibre-gl-style-spec';
3
- import DepthMode from '../gl/depth_mode';
4
- import StencilMode from '../gl/stencil_mode';
5
- import ColorMode from '../gl/color_mode';
6
- import CullFaceMode from '../gl/cull_face_mode';
7
- import Context from '../gl/context';
8
- import Framebuffer from '../gl/framebuffer';
3
+ import {DepthMode} from '../gl/depth_mode';
4
+ import {StencilMode} from '../gl/stencil_mode';
5
+ import {ColorMode} from '../gl/color_mode';
6
+ import {CullFaceMode} from '../gl/cull_face_mode';
7
+ import {Context} from '../gl/context';
8
+ import {Framebuffer} from '../gl/framebuffer';
9
9
  import {
10
10
  heatmapUniformValues,
11
11
  heatmapTextureUniformValues
12
12
  } from './program/heatmap_program';
13
13
 
14
- import type Painter from './painter';
15
- import type SourceCache from '../source/source_cache';
16
- import type HeatmapStyleLayer from '../style/style_layer/heatmap_style_layer';
17
- import type HeatmapBucket from '../data/bucket/heatmap_bucket';
14
+ import type {Painter} from './painter';
15
+ import type {SourceCache} from '../source/source_cache';
16
+ import type {HeatmapStyleLayer} from '../style/style_layer/heatmap_style_layer';
17
+ import type {HeatmapBucket} from '../data/bucket/heatmap_bucket';
18
18
  import type {OverscaledTileID} from '../source/tile_id';
19
19
 
20
- export default drawHeatmap;
21
-
22
- function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapStyleLayer, coords: Array<OverscaledTileID>) {
20
+ export function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapStyleLayer, coords: Array<OverscaledTileID>) {
23
21
  if (layer.paint.get('heatmap-opacity') === 0) {
24
22
  return;
25
23
  }
@@ -1,22 +1,20 @@
1
- import Texture from './texture';
2
- import StencilMode from '../gl/stencil_mode';
3
- import DepthMode from '../gl/depth_mode';
4
- import CullFaceMode from '../gl/cull_face_mode';
5
- import ColorMode from '../gl/color_mode';
6
- import Tile from '../source/tile';
1
+ import {Texture} from './texture';
2
+ import {StencilMode} from '../gl/stencil_mode';
3
+ import {DepthMode} from '../gl/depth_mode';
4
+ import {CullFaceMode} from '../gl/cull_face_mode';
5
+ import {ColorMode} from '../gl/color_mode';
6
+ import {Tile} from '../source/tile';
7
7
  import {
8
8
  hillshadeUniformValues,
9
9
  hillshadeUniformPrepareValues
10
10
  } from './program/hillshade_program';
11
11
 
12
- import type Painter from './painter';
13
- import type SourceCache from '../source/source_cache';
14
- import type HillshadeStyleLayer from '../style/style_layer/hillshade_style_layer';
12
+ import type {Painter} from './painter';
13
+ import type {SourceCache} from '../source/source_cache';
14
+ import type {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer';
15
15
  import type {OverscaledTileID} from '../source/tile_id';
16
16
 
17
- export default drawHillshade;
18
-
19
- function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: HillshadeStyleLayer, tileIDs: Array<OverscaledTileID>) {
17
+ export function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: HillshadeStyleLayer, tileIDs: Array<OverscaledTileID>) {
20
18
  if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') return;
21
19
 
22
20
  const context = painter.context;
@@ -1,6 +1,6 @@
1
- import DepthMode from '../gl/depth_mode';
2
- import CullFaceMode from '../gl/cull_face_mode';
3
- import Texture from './texture';
1
+ import {DepthMode} from '../gl/depth_mode';
2
+ import {CullFaceMode} from '../gl/cull_face_mode';
3
+ import {Texture} from './texture';
4
4
  import {
5
5
  lineUniformValues,
6
6
  linePatternUniformValues,
@@ -8,16 +8,16 @@ import {
8
8
  lineGradientUniformValues
9
9
  } from './program/line_program';
10
10
 
11
- import type Painter from './painter';
12
- import type SourceCache from '../source/source_cache';
13
- import type LineStyleLayer from '../style/style_layer/line_style_layer';
14
- import type LineBucket from '../data/bucket/line_bucket';
11
+ import type {Painter} from './painter';
12
+ import type {SourceCache} from '../source/source_cache';
13
+ import type {LineStyleLayer} from '../style/style_layer/line_style_layer';
14
+ import type {LineBucket} from '../data/bucket/line_bucket';
15
15
  import type {OverscaledTileID} from '../source/tile_id';
16
16
  import {clamp, nextPowerOfTwo} from '../util/util';
17
17
  import {renderColorRamp} from '../util/color_ramp';
18
- import EXTENT from '../data/extent';
18
+ import {EXTENT} from '../data/extent';
19
19
 
20
- export default function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array<OverscaledTileID>) {
20
+ export function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array<OverscaledTileID>) {
21
21
  if (painter.renderPass !== 'translucent') return;
22
22
 
23
23
  const opacity = layer.paint.get('line-opacity');
@@ -1,20 +1,18 @@
1
1
  import {clamp} from '../util/util';
2
2
 
3
- import ImageSource from '../source/image_source';
4
- import browser from '../util/browser';
5
- import StencilMode from '../gl/stencil_mode';
6
- import DepthMode from '../gl/depth_mode';
7
- import CullFaceMode from '../gl/cull_face_mode';
3
+ import {ImageSource} from '../source/image_source';
4
+ import {browser} from '../util/browser';
5
+ import {StencilMode} from '../gl/stencil_mode';
6
+ import {DepthMode} from '../gl/depth_mode';
7
+ import {CullFaceMode} from '../gl/cull_face_mode';
8
8
  import {rasterUniformValues} from './program/raster_program';
9
9
 
10
- import type Painter from './painter';
11
- import type SourceCache from '../source/source_cache';
12
- import type RasterStyleLayer from '../style/style_layer/raster_style_layer';
10
+ import type {Painter} from './painter';
11
+ import type {SourceCache} from '../source/source_cache';
12
+ import type {RasterStyleLayer} from '../style/style_layer/raster_style_layer';
13
13
  import type {OverscaledTileID} from '../source/tile_id';
14
14
 
15
- export default drawRaster;
16
-
17
- function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array<OverscaledTileID>) {
15
+ export function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array<OverscaledTileID>) {
18
16
  if (painter.renderPass !== 'translucent') return;
19
17
  if (layer.paint.get('raster-opacity') === 0) return;
20
18
  if (!tileIDs.length) return;
@@ -1,19 +1,19 @@
1
1
  import {mat4} from 'gl-matrix';
2
2
  import {OverscaledTileID} from '../source/tile_id';
3
- import SymbolBucket from '../data/bucket/symbol_bucket';
4
- import SourceCache from '../source/source_cache';
5
- import Tile from '../source/tile';
6
- import SymbolStyleLayer from '../style/style_layer/symbol_style_layer';
7
- import Painter from './painter';
8
- import Program from './program';
9
- import drawSymbol from './draw_symbol';
3
+ import {SymbolBucket} from '../data/bucket/symbol_bucket';
4
+ import {SourceCache} from '../source/source_cache';
5
+ import {Tile} from '../source/tile';
6
+ import {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';
7
+ import {Painter} from './painter';
8
+ import {Program} from './program';
9
+ import {drawSymbols} from './draw_symbol';
10
10
  import * as symbolProjection from '../symbol/projection';
11
- import type ZoomHistory from '../style/zoom_history';
12
- import type Map from '../ui/map';
13
- import Transform from '../geo/transform';
14
- import type EvaluationParameters from '../style/evaluation_parameters';
11
+ import type {ZoomHistory} from '../style/zoom_history';
12
+ import type {Map} from '../ui/map';
13
+ import {Transform} from '../geo/transform';
14
+ import type {EvaluationParameters} from '../style/evaluation_parameters';
15
15
  import type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec';
16
- import Style from '../style/style';
16
+ import {Style} from '../style/style';
17
17
 
18
18
  jest.mock('./painter');
19
19
  jest.mock('./program');
@@ -27,7 +27,7 @@ describe('drawSymbol', () => {
27
27
  const mockPainter = new Painter(null, null);
28
28
  mockPainter.renderPass = 'opaque';
29
29
 
30
- drawSymbol(mockPainter, null, null, null, null);
30
+ drawSymbols(mockPainter, null, null, null, null);
31
31
 
32
32
  expect(mockPainter.colorModeForRenderPass).not.toHaveBeenCalled();
33
33
  });
@@ -88,7 +88,7 @@ describe('drawSymbol', () => {
88
88
  (sourceCacheMock.getTile as jest.Mock).mockReturnValue(tile);
89
89
  sourceCacheMock.map = {showCollisionBoxes: false} as any as Map;
90
90
 
91
- drawSymbol(painterMock, sourceCacheMock, layer, [tileId], null);
91
+ drawSymbols(painterMock, sourceCacheMock, layer, [tileId], null);
92
92
 
93
93
  expect(programMock.draw).toHaveBeenCalledTimes(1);
94
94
  });
@@ -154,7 +154,7 @@ describe('drawSymbol', () => {
154
154
  } as any as Style;
155
155
 
156
156
  const spy = jest.spyOn(symbolProjection, 'updateLineLabels');
157
- drawSymbol(painterMock, sourceCacheMock, layer, [tileId], null);
157
+ drawSymbols(painterMock, sourceCacheMock, layer, [tileId], null);
158
158
 
159
159
  expect(spy.mock.calls[0][9]).toBeFalsy(); // rotateToLine === false
160
160
  });
@@ -215,7 +215,7 @@ describe('drawSymbol', () => {
215
215
  (sourceCacheMock.getTile as jest.Mock).mockReturnValue(tile);
216
216
  sourceCacheMock.map = {showCollisionBoxes: false} as any as Map;
217
217
 
218
- drawSymbol(painterMock, sourceCacheMock, layer, [tileId], null);
218
+ drawSymbols(painterMock, sourceCacheMock, layer, [tileId], null);
219
219
 
220
220
  expect(programMock.draw).toHaveBeenCalledTimes(0);
221
221
  });
@@ -1,14 +1,14 @@
1
1
  import Point from '@mapbox/point-geometry';
2
- import drawCollisionDebug from './draw_collision_debug';
2
+ import {drawCollisionDebug} from './draw_collision_debug';
3
3
 
4
- import SegmentVector from '../data/segment';
5
- import pixelsToTileUnits from '../source/pixels_to_tile_units';
4
+ import {SegmentVector} from '../data/segment';
5
+ import {pixelsToTileUnits} from '../source/pixels_to_tile_units';
6
6
  import * as symbolProjection from '../symbol/projection';
7
7
  import {EvaluatedZoomSize, evaluateSizeForFeature, evaluateSizeForZoom} from '../symbol/symbol_size';
8
8
  import {mat4} from 'gl-matrix';
9
- import StencilMode from '../gl/stencil_mode';
10
- import DepthMode from '../gl/depth_mode';
11
- import CullFaceMode from '../gl/cull_face_mode';
9
+ import {StencilMode} from '../gl/stencil_mode';
10
+ import {DepthMode} from '../gl/depth_mode';
11
+ import {CullFaceMode} from '../gl/cull_face_mode';
12
12
  import {addDynamicAttributes} from '../data/bucket/symbol_bucket';
13
13
 
14
14
  import {getAnchorAlignment, WritingMode} from '../symbol/shaping';
@@ -22,22 +22,21 @@ import {
22
22
  symbolTextAndIconUniformValues
23
23
  } from './program/symbol_program';
24
24
 
25
- import type Painter from './painter';
26
- import type SourceCache from '../source/source_cache';
27
- import type SymbolStyleLayer from '../style/style_layer/symbol_style_layer';
25
+ import type {Painter} from './painter';
26
+ import type {SourceCache} from '../source/source_cache';
27
+ import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';
28
28
 
29
- import type Texture from '../render/texture';
29
+ import type {Texture} from '../render/texture';
30
30
  import type {OverscaledTileID} from '../source/tile_id';
31
31
  import type {UniformValues} from './uniform_binding';
32
32
  import type {SymbolSDFUniformsType} from '../render/program/symbol_program';
33
33
  import type {CrossTileID, VariableOffset} from '../symbol/placement';
34
- import type SymbolBucket from '../data/bucket/symbol_bucket';
35
- import type {SymbolBuffers} from '../data/bucket/symbol_bucket';
34
+ import type {SymbolBucket, SymbolBuffers} from '../data/bucket/symbol_bucket';
36
35
  import type {TerrainData} from '../render/terrain';
37
36
  import type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec';
38
- import type Transform from '../geo/transform';
39
- import type ColorMode from '../gl/color_mode';
40
- import type Program from './program';
37
+ import type {Transform} from '../geo/transform';
38
+ import type {ColorMode} from '../gl/color_mode';
39
+ import type {Program} from './program';
41
40
 
42
41
  type SymbolTileRenderState = {
43
42
  segments: SegmentVector;
@@ -58,7 +57,7 @@ type SymbolTileRenderState = {
58
57
 
59
58
  const identityMat4 = mat4.identity(new Float32Array(16));
60
59
 
61
- export default function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array<OverscaledTileID>, variableOffsets: {
60
+ export function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array<OverscaledTileID>, variableOffsets: {
62
61
  [_ in CrossTileID]: VariableOffset;
63
62
  }) {
64
63
  if (painter.renderPass !== 'translucent') return;
@@ -1,17 +1,17 @@
1
- import StencilMode from '../gl/stencil_mode';
2
- import DepthMode from '../gl/depth_mode';
1
+ import {StencilMode} from '../gl/stencil_mode';
2
+ import {DepthMode} from '../gl/depth_mode';
3
3
  import {terrainUniformValues, terrainDepthUniformValues, terrainCoordsUniformValues} from './program/terrain_program';
4
- import type Painter from './painter';
5
- import type Tile from '../source/tile';
6
- import CullFaceMode from '../gl/cull_face_mode';
4
+ import type {Painter} from './painter';
5
+ import type {Tile} from '../source/tile';
6
+ import {CullFaceMode} from '../gl/cull_face_mode';
7
7
  import {Color} from '@maplibre/maplibre-gl-style-spec';
8
- import ColorMode from '../gl/color_mode';
9
- import Terrain from './terrain';
8
+ import {ColorMode} from '../gl/color_mode';
9
+ import {Terrain} from './terrain';
10
10
 
11
11
  /**
12
12
  * Redraw the Depth Framebuffer
13
- * @param {Painter} painter - the painter
14
- * @param {Terrain} terrain - the terrain
13
+ * @param painter - the painter
14
+ * @param terrain - the terrain
15
15
  */
16
16
  function drawDepth(painter: Painter, terrain: Terrain) {
17
17
  const context = painter.context;
@@ -36,8 +36,8 @@ function drawDepth(painter: Painter, terrain: Terrain) {
36
36
 
37
37
  /**
38
38
  * Redraw the Coords Framebuffers
39
- * @param {Painter} painter - the painter
40
- * @param {Terrain} terrain - the terrain
39
+ * @param painter - the painter
40
+ * @param terrain - the terrain
41
41
  */
42
42
  function drawCoords(painter: Painter, terrain: Terrain) {
43
43
  const context = painter.context;
@@ -6,6 +6,9 @@ import type {GlyphMetrics, StyleGlyph} from '../style/style_glyph';
6
6
 
7
7
  const padding = 1;
8
8
 
9
+ /**
10
+ * A rectangle type with postion, width and height.
11
+ */
9
12
  export type Rect = {
10
13
  x: number;
11
14
  y: number;
@@ -13,18 +16,24 @@ export type Rect = {
13
16
  h: number;
14
17
  };
15
18
 
19
+ /**
20
+ * The glyph's position
21
+ */
16
22
  export type GlyphPosition = {
17
23
  rect: Rect;
18
24
  metrics: GlyphMetrics;
19
25
  };
20
26
 
27
+ /**
28
+ * The glyphs' positions
29
+ */
21
30
  export type GlyphPositions = {
22
31
  [_: string]: {
23
32
  [_: number]: GlyphPosition;
24
33
  };
25
34
  };
26
35
 
27
- export default class GlyphAtlas {
36
+ export class GlyphAtlas {
28
37
  image: AlphaImage;
29
38
  positions: GlyphPositions;
30
39
 
@@ -1,10 +1,10 @@
1
- import parseGlyphPBF from '../style/parse_glyph_pbf';
2
- import GlyphManager from './glyph_manager';
1
+ import {parseGlyphPbf} from '../style/parse_glyph_pbf';
2
+ import {GlyphManager} from './glyph_manager';
3
3
  import fs from 'fs';
4
4
  import {RequestManager} from '../util/request_manager';
5
5
 
6
6
  const glyphs = {};
7
- for (const glyph of parseGlyphPBF(fs.readFileSync('./test/unit/assets/0-255.pbf'))) {
7
+ for (const glyph of parseGlyphPbf(fs.readFileSync('./test/unit/assets/0-255.pbf'))) {
8
8
  glyphs[glyph.id] = glyph;
9
9
  }
10
10
 
@@ -1,7 +1,7 @@
1
- import loadGlyphRange from '../style/load_glyph_range';
1
+ import {loadGlyphRange} from '../style/load_glyph_range';
2
2
 
3
3
  import TinySDF from '@mapbox/tiny-sdf';
4
- import isChar from '../util/is_char_in_unicode_block';
4
+ import {unicodeBlockLookup} from '../util/is_char_in_unicode_block';
5
5
  import {asyncAll} from '../util/util';
6
6
  import {AlphaImage} from '../util/image';
7
7
 
@@ -25,7 +25,7 @@ type Entry = {
25
25
  tinySDF?: TinySDF;
26
26
  };
27
27
 
28
- export default class GlyphManager {
28
+ export class GlyphManager {
29
29
  requestManager: RequestManager;
30
30
  localIdeographFontFamily: string;
31
31
  entries: {
@@ -163,10 +163,10 @@ export default class GlyphManager {
163
163
  _doesCharSupportLocalGlyph(id: number): boolean {
164
164
  /* eslint-disable new-cap */
165
165
  return !!this.localIdeographFontFamily &&
166
- (isChar['CJK Unified Ideographs'](id) ||
167
- isChar['Hangul Syllables'](id) ||
168
- isChar['Hiragana'](id) ||
169
- isChar['Katakana'](id));
166
+ (unicodeBlockLookup['CJK Unified Ideographs'](id) ||
167
+ unicodeBlockLookup['Hangul Syllables'](id) ||
168
+ unicodeBlockLookup['Hiragana'](id) ||
169
+ unicodeBlockLookup['Katakana'](id));
170
170
  /* eslint-enable new-cap */
171
171
  }
172
172
 
@@ -4,8 +4,8 @@ import {register} from '../util/web_worker_transfer';
4
4
  import potpack from 'potpack';
5
5
 
6
6
  import type {StyleImage} from '../style/style_image';
7
- import type ImageManager from './image_manager';
8
- import type Texture from './texture';
7
+ import type {ImageManager} from './image_manager';
8
+ import type {Texture} from './texture';
9
9
  import type {Rect} from './glyph_atlas';
10
10
 
11
11
  const IMAGE_PADDING: number = 1;
@@ -60,7 +60,10 @@ export class ImagePosition {
60
60
  }
61
61
  }
62
62
 
63
- export default class ImageAtlas {
63
+ /**
64
+ * A class holding all the images
65
+ */
66
+ export class ImageAtlas {
64
67
  image: RGBAImage;
65
68
  iconPositions: {[_: string]: ImagePosition};
66
69
  patternPositions: {[_: string]: ImagePosition};
@@ -4,12 +4,12 @@ import potpack from 'potpack';
4
4
  import {Event, ErrorEvent, Evented} from '../util/evented';
5
5
  import {RGBAImage} from '../util/image';
6
6
  import {ImagePosition} from './image_atlas';
7
- import Texture from './texture';
7
+ import {Texture} from './texture';
8
8
  import {renderStyleImage} from '../style/style_image';
9
9
  import {warnOnce} from '../util/util';
10
10
 
11
11
  import type {StyleImage} from '../style/style_image';
12
- import type Context from '../gl/context';
12
+ import type {Context} from '../gl/context';
13
13
  import type {PotpackBox} from 'potpack';
14
14
  import type {Callback} from '../types/callback';
15
15
 
@@ -35,7 +35,7 @@ const padding = 1;
35
35
  data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time
36
36
  to refactor this.
37
37
  */
38
- class ImageManager extends Evented {
38
+ export class ImageManager extends Evented {
39
39
  images: {[_: string]: StyleImage};
40
40
  updatedImages: {[_: string]: boolean};
41
41
  callbackDispatchedThisFrame: {[_: string]: boolean};
@@ -326,5 +326,3 @@ class ImageManager extends Evented {
326
326
  }
327
327
  }
328
328
  }
329
-
330
- export default ImageManager;
@@ -1,4 +1,4 @@
1
- import LineAtlas from './line_atlas';
1
+ import {LineAtlas} from './line_atlas';
2
2
 
3
3
  describe('LineAtlas', () => {
4
4
  const lineAtlas = new LineAtlas(64, 64);
@@ -1,23 +1,31 @@
1
1
  import {warnOnce} from '../util/util';
2
2
 
3
- import type Context from '../gl/context';
3
+ import type {Context} from '../gl/context';
4
+
5
+ /**
6
+ * A dash entry
7
+ */
8
+ type DashEntry = {
9
+ y: number;
10
+ height: number;
11
+ width: number;
12
+ }
4
13
 
5
14
  /**
6
15
  * A LineAtlas lets us reuse rendered dashed lines
7
16
  * by writing many of them to a texture and then fetching their positions
8
- * using .getDash.
17
+ * using {@link LineAtlas#getDash}.
9
18
  *
10
- * @param {number} width
11
- * @param {number} height
12
- * @private
19
+ * @param width - the width
20
+ * @param height - the height
13
21
  */
14
- class LineAtlas {
22
+ export class LineAtlas {
15
23
  width: number;
16
24
  height: number;
17
25
  nextRow: number;
18
26
  bytes: number;
19
27
  data: Uint8Array;
20
- dashEntry: {[_: string]: any};
28
+ dashEntry: {[_: string]: DashEntry};
21
29
  dirty: boolean;
22
30
  texture: WebGLTexture;
23
31
 
@@ -34,10 +42,9 @@ class LineAtlas {
34
42
  /**
35
43
  * Get or create a dash line pattern.
36
44
  *
37
- * @param {Array<number>} dasharray
38
- * @param {boolean} round whether to add circle caps in between dash segments
39
- * @returns {Object} position of dash texture in { y, height, width }
40
- * @private
45
+ * @param dasharray - the key (represented by numbers) to get the dash texture
46
+ * @param round - whether to add circle caps in between dash segments
47
+ * @returns position of dash texture in {@link DashEntry}
41
48
  */
42
49
  getDash(dasharray: Array<number>, round: boolean) {
43
50
  const key = dasharray.join(',') + String(round);
@@ -148,7 +155,7 @@ class LineAtlas {
148
155
  }
149
156
  }
150
157
 
151
- addDash(dasharray: Array<number>, round: boolean) {
158
+ addDash(dasharray: Array<number>, round: boolean): DashEntry {
152
159
  const n = round ? 7 : 0;
153
160
  const height = 2 * n + 1;
154
161
 
@@ -204,5 +211,3 @@ class LineAtlas {
204
211
  }
205
212
  }
206
213
  }
207
-
208
- export default LineAtlas;