maplibre-gl 2.1.0 → 2.1.4

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 (308) hide show
  1. package/build/{banner.js → banner.ts} +1 -1
  2. package/build/generate-query-test-fixtures.ts +123 -0
  3. package/build/generate-shaders.ts +35 -0
  4. package/build/generate-struct-arrays.ts +7 -7
  5. package/build/generate-style-code.ts +8 -8
  6. package/build/generate-style-spec.ts +5 -4
  7. package/build/generate-typings.ts +16 -0
  8. package/build/readme.md +8 -18
  9. package/build/release-notes.js +9 -13
  10. package/build/{rollup_plugin_minify_style_spec.js → rollup_plugin_minify_style_spec.ts} +4 -3
  11. package/build/{rollup_plugins.js → rollup_plugins.ts} +12 -26
  12. package/dist/maplibre-gl-dev.js +54885 -0
  13. package/dist/maplibre-gl.css +1 -1
  14. package/dist/maplibre-gl.d.ts +1537 -1011
  15. package/dist/maplibre-gl.js +3 -3
  16. package/dist/maplibre-gl.js.map +1 -1
  17. package/package.json +83 -107
  18. package/postinstall.js +5 -0
  19. package/src/css/maplibre-gl.css +28 -28
  20. package/src/data/{array_types.ts → array_types.g.ts} +0 -0
  21. package/src/data/bucket/circle_bucket.ts +1 -1
  22. package/src/data/bucket/fill_bucket.test.ts +1 -1
  23. package/src/data/bucket/fill_bucket.ts +4 -4
  24. package/src/data/bucket/fill_extrusion_bucket.ts +1 -1
  25. package/src/data/bucket/line_bucket.test.ts +1 -1
  26. package/src/data/bucket/line_bucket.ts +6 -6
  27. package/src/data/bucket/symbol_bucket.test.ts +16 -16
  28. package/src/data/bucket/symbol_bucket.ts +53 -53
  29. package/src/data/bucket.ts +43 -43
  30. package/src/data/dem_data.ts +12 -12
  31. package/src/data/evaluation_feature.ts +10 -10
  32. package/src/data/feature_index.ts +37 -37
  33. package/src/data/feature_position_map.ts +5 -5
  34. package/src/data/index_array_type.ts +1 -1
  35. package/src/data/load_geometry.test.ts +1 -1
  36. package/src/data/program_configuration.ts +46 -46
  37. package/src/data/segment.ts +14 -14
  38. package/src/geo/edge_insets.ts +2 -2
  39. package/src/geo/lng_lat.ts +4 -4
  40. package/src/geo/lng_lat_bounds.ts +35 -35
  41. package/src/geo/mercator_coordinate.ts +5 -5
  42. package/src/geo/transform.test.ts +1 -1
  43. package/src/geo/transform.ts +14 -14
  44. package/src/gl/context.ts +3 -3
  45. package/src/gl/types.ts +19 -19
  46. package/src/gl/value.ts +6 -6
  47. package/src/gl/vertex_buffer.test.ts +1 -1
  48. package/src/index.ts +24 -9
  49. package/src/render/draw_circle.ts +8 -8
  50. package/src/render/draw_collision_debug.ts +5 -5
  51. package/src/render/draw_line.ts +4 -4
  52. package/src/render/draw_symbol.ts +21 -21
  53. package/src/render/glyph_atlas.ts +12 -12
  54. package/src/render/glyph_manager.test.ts +10 -21
  55. package/src/render/glyph_manager.ts +33 -32
  56. package/src/render/image_manager.ts +4 -4
  57. package/src/render/painter.ts +11 -11
  58. package/src/render/program/background_program.ts +29 -29
  59. package/src/render/program/circle_program.ts +10 -10
  60. package/src/render/program/clipping_mask_program.ts +1 -1
  61. package/src/render/program/collision_program.ts +9 -9
  62. package/src/render/program/debug_program.ts +4 -4
  63. package/src/render/program/fill_extrusion_program.ts +31 -31
  64. package/src/render/program/fill_program.ts +29 -29
  65. package/src/render/program/heatmap_program.ts +12 -12
  66. package/src/render/program/hillshade_program.ts +12 -12
  67. package/src/render/program/line_program.ts +38 -38
  68. package/src/render/program/pattern.ts +28 -28
  69. package/src/render/program/raster_program.ts +21 -21
  70. package/src/render/program/symbol_program.ts +96 -96
  71. package/src/render/program.ts +25 -25
  72. package/src/render/texture.ts +9 -9
  73. package/src/render/uniform_binding.ts +1 -1
  74. package/src/render/vertex_array_object.ts +13 -13
  75. package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
  76. package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
  77. package/src/shaders/background.fragment.glsl.g.ts +2 -0
  78. package/src/shaders/background.vertex.glsl.g.ts +2 -0
  79. package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
  80. package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
  81. package/src/shaders/circle.fragment.glsl.g.ts +2 -0
  82. package/src/shaders/circle.vertex.glsl.g.ts +2 -0
  83. package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
  84. package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
  85. package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
  86. package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
  87. package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
  88. package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
  89. package/src/shaders/debug.fragment.glsl.g.ts +2 -0
  90. package/src/shaders/debug.vertex.glsl.g.ts +2 -0
  91. package/src/shaders/fill.fragment.glsl.g.ts +2 -0
  92. package/src/shaders/fill.vertex.glsl.g.ts +2 -0
  93. package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
  94. package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
  95. package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
  96. package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
  97. package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
  98. package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
  99. package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
  100. package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
  101. package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
  102. package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
  103. package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
  104. package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
  105. package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
  106. package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
  107. package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
  108. package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
  109. package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
  110. package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
  111. package/src/shaders/line.fragment.glsl.g.ts +2 -0
  112. package/src/shaders/line.vertex.glsl.g.ts +2 -0
  113. package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
  114. package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
  115. package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
  116. package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
  117. package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
  118. package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
  119. package/src/shaders/raster.fragment.glsl.g.ts +2 -0
  120. package/src/shaders/raster.vertex.glsl.g.ts +2 -0
  121. package/src/shaders/shaders.ts +52 -55
  122. package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
  123. package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
  124. package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
  125. package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
  126. package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
  127. package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
  128. package/src/source/canvas_source.test.ts +11 -12
  129. package/src/source/canvas_source.ts +4 -4
  130. package/src/source/geojson_worker_source.ts +23 -23
  131. package/src/source/geojson_wrapper.ts +8 -8
  132. package/src/source/image_source.test.ts +2 -2
  133. package/src/source/image_source.ts +6 -6
  134. package/src/source/pixels_to_tile_units.ts +6 -6
  135. package/src/source/query_features.ts +20 -20
  136. package/src/source/raster_dem_tile_source.test.ts +2 -2
  137. package/src/source/raster_tile_source.test.ts +2 -2
  138. package/src/source/rtl_text_plugin.ts +10 -10
  139. package/src/source/source.ts +29 -29
  140. package/src/source/source_cache.test.ts +32 -0
  141. package/src/source/source_cache.ts +7 -5
  142. package/src/source/source_state.ts +1 -1
  143. package/src/source/tile.test.ts +3 -3
  144. package/src/source/tile.ts +15 -15
  145. package/src/source/tile_cache.test.ts +6 -4
  146. package/src/source/tile_cache.ts +6 -6
  147. package/src/source/tile_id.test.ts +0 -1
  148. package/src/source/vector_tile_source.test.ts +16 -5
  149. package/src/source/vector_tile_source.ts +2 -3
  150. package/src/source/vector_tile_worker_source.test.ts +4 -4
  151. package/src/source/vector_tile_worker_source.ts +5 -5
  152. package/src/source/worker.test.ts +1 -1
  153. package/src/source/worker.ts +22 -22
  154. package/src/source/worker_source.ts +56 -56
  155. package/src/source/worker_tile.ts +4 -4
  156. package/src/style/evaluation_parameters.ts +3 -3
  157. package/src/style/format_section_override.test.ts +1 -1
  158. package/src/style/light.ts +10 -10
  159. package/src/style/load_glyph_range.test.ts +3 -5
  160. package/src/style/load_glyph_range.ts +6 -6
  161. package/src/style/load_sprite.ts +4 -4
  162. package/src/style/pauseable_placement.ts +1 -1
  163. package/src/style/properties.ts +69 -69
  164. package/src/style/query_utils.ts +7 -7
  165. package/src/style/style.test.ts +22 -15
  166. package/src/style/style.ts +29 -29
  167. package/src/style/style_glyph.ts +8 -8
  168. package/src/style/style_image.ts +58 -58
  169. package/src/style/style_layer/background_style_layer.ts +2 -2
  170. package/src/style/style_layer/{background_style_layer_properties.ts → background_style_layer_properties.g.ts} +0 -0
  171. package/src/style/style_layer/circle_style_layer.ts +10 -10
  172. package/src/style/style_layer/{circle_style_layer_properties.ts → circle_style_layer_properties.g.ts} +0 -0
  173. package/src/style/style_layer/custom_style_layer.ts +17 -17
  174. package/src/style/style_layer/fill_extrusion_style_layer.ts +10 -10
  175. package/src/style/style_layer/{fill_extrusion_style_layer_properties.ts → fill_extrusion_style_layer_properties.g.ts} +0 -0
  176. package/src/style/style_layer/fill_style_layer.ts +9 -9
  177. package/src/style/style_layer/{fill_style_layer_properties.ts → fill_style_layer_properties.g.ts} +0 -0
  178. package/src/style/style_layer/heatmap_style_layer.ts +2 -2
  179. package/src/style/style_layer/{heatmap_style_layer_properties.ts → heatmap_style_layer_properties.g.ts} +0 -0
  180. package/src/style/style_layer/hillshade_style_layer.ts +2 -2
  181. package/src/style/style_layer/{hillshade_style_layer_properties.ts → hillshade_style_layer_properties.g.ts} +0 -0
  182. package/src/style/style_layer/line_style_layer.ts +9 -9
  183. package/src/style/style_layer/{line_style_layer_properties.ts → line_style_layer_properties.g.ts} +0 -0
  184. package/src/style/style_layer/raster_style_layer.ts +2 -2
  185. package/src/style/style_layer/{raster_style_layer_properties.ts → raster_style_layer_properties.g.ts} +0 -0
  186. package/src/style/style_layer/symbol_style_layer.ts +7 -7
  187. package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +0 -0
  188. package/src/style/style_layer.ts +10 -10
  189. package/src/style/style_layer_index.ts +3 -3
  190. package/src/style/validate_style.ts +15 -15
  191. package/src/style-spec/error/validation_error.ts +1 -1
  192. package/src/style-spec/expression/compound_expression.ts +3 -3
  193. package/src/style-spec/expression/definitions/format.ts +11 -11
  194. package/src/style-spec/expression/definitions/interpolate.ts +5 -5
  195. package/src/style-spec/expression/definitions/match.ts +2 -2
  196. package/src/style-spec/expression/definitions/number_format.ts +11 -11
  197. package/src/style-spec/expression/expression.ts +8 -8
  198. package/src/style-spec/expression/index.ts +97 -97
  199. package/src/style-spec/expression/parsing_context.ts +11 -11
  200. package/src/style-spec/expression/types/collator.ts +9 -9
  201. package/src/style-spec/expression/types/resolved_image.ts +2 -2
  202. package/src/style-spec/expression/types.ts +14 -14
  203. package/src/style-spec/expression/values.ts +1 -1
  204. package/src/style-spec/feature_filter/index.ts +66 -66
  205. package/src/style-spec/function/convert.ts +3 -3
  206. package/src/style-spec/style-spec.ts +44 -44
  207. package/src/style-spec/util/color_spaces.ts +8 -8
  208. package/src/style-spec/util/result.ts +4 -4
  209. package/src/style-spec/validate/validate_filter.ts +58 -58
  210. package/src/style-spec/validate/validate_source.ts +63 -63
  211. package/src/style-spec/visit.ts +11 -11
  212. package/src/symbol/collision_feature.test.ts +1 -1
  213. package/src/symbol/collision_feature.ts +10 -10
  214. package/src/symbol/collision_index.ts +26 -26
  215. package/src/symbol/cross_tile_symbol_index.ts +17 -17
  216. package/src/symbol/get_anchors.ts +16 -16
  217. package/src/symbol/grid_index.ts +7 -7
  218. package/src/symbol/placement.ts +72 -72
  219. package/src/symbol/projection.ts +30 -30
  220. package/src/symbol/quads.ts +30 -30
  221. package/src/symbol/shaping.ts +160 -160
  222. package/src/symbol/symbol_layout.ts +119 -119
  223. package/src/symbol/symbol_size.ts +29 -29
  224. package/src/symbol/symbol_style_layer.test.ts +1 -1
  225. package/src/types/cancelable.ts +1 -1
  226. package/src/types/tilejson.ts +13 -13
  227. package/src/ui/anchor.ts +1 -1
  228. package/src/ui/camera.test.ts +9 -9
  229. package/src/ui/camera.ts +18 -18
  230. package/src/ui/control/attribution_control.test.ts +51 -16
  231. package/src/ui/control/attribution_control.ts +35 -16
  232. package/src/ui/control/control.ts +40 -40
  233. package/src/ui/control/fullscreen_control.ts +1 -1
  234. package/src/ui/control/geolocate_control.test.ts +1 -1
  235. package/src/ui/control/geolocate_control.ts +102 -102
  236. package/src/ui/control/logo_control.test.ts +5 -4
  237. package/src/ui/control/navigation_control.ts +3 -3
  238. package/src/ui/control/scale_control.test.ts +2 -2
  239. package/src/ui/control/scale_control.ts +5 -5
  240. package/src/ui/events.ts +289 -200
  241. package/src/ui/handler/box_zoom.test.ts +1 -1
  242. package/src/ui/handler/box_zoom.ts +1 -1
  243. package/src/ui/handler/dblclick_zoom.test.ts +1 -1
  244. package/src/ui/handler/drag_pan.test.ts +1 -1
  245. package/src/ui/handler/drag_rotate.test.ts +1 -1
  246. package/src/ui/handler/keyboard.test.ts +1 -1
  247. package/src/ui/handler/keyboard.ts +51 -51
  248. package/src/ui/handler/map_event.test.ts +1 -1
  249. package/src/ui/handler/map_event.ts +1 -1
  250. package/src/ui/handler/mouse.ts +1 -1
  251. package/src/ui/handler/mouse_rotate.test.ts +1 -1
  252. package/src/ui/handler/scroll_zoom.test.ts +3 -2
  253. package/src/ui/handler/scroll_zoom.ts +9 -9
  254. package/src/ui/handler/shim/drag_pan.ts +4 -4
  255. package/src/ui/handler/shim/drag_rotate.ts +1 -1
  256. package/src/ui/handler/shim/touch_zoom_rotate.ts +1 -1
  257. package/src/ui/handler/tap_recognizer.ts +4 -4
  258. package/src/ui/handler/touch_pan.ts +2 -2
  259. package/src/ui/handler/touch_zoom_rotate.test.ts +1 -1
  260. package/src/ui/handler/touch_zoom_rotate.ts +1 -1
  261. package/src/ui/handler_inertia.ts +6 -6
  262. package/src/ui/handler_manager.ts +44 -44
  263. package/src/ui/map/isMoving.test.ts +1 -1
  264. package/src/ui/map/isRotating.test.ts +1 -1
  265. package/src/ui/map/isZooming.test.ts +1 -1
  266. package/src/ui/map.test.ts +26 -14
  267. package/src/ui/map.ts +107 -102
  268. package/src/ui/map_events.test.ts +1 -1
  269. package/src/ui/marker.test.ts +12 -12
  270. package/src/ui/marker.ts +37 -37
  271. package/src/ui/popup.test.ts +7 -7
  272. package/src/ui/popup.ts +9 -9
  273. package/src/util/actor.test.ts +41 -10
  274. package/src/util/actor.ts +8 -8
  275. package/src/util/ajax.test.ts +29 -21
  276. package/src/util/ajax.ts +51 -30
  277. package/src/util/browser.ts +1 -1
  278. package/src/util/classify_rings.test.ts +1 -1
  279. package/src/util/color_ramp.ts +5 -5
  280. package/src/util/config.ts +2 -2
  281. package/src/util/dispatcher.ts +1 -1
  282. package/src/util/dom.ts +2 -2
  283. package/src/util/evented.ts +1 -1
  284. package/src/util/find_pole_of_inaccessibility.ts +3 -3
  285. package/src/util/image.ts +5 -5
  286. package/src/util/performance.ts +7 -7
  287. package/src/util/request_manager.ts +4 -4
  288. package/src/util/resolve_tokens.ts +4 -4
  289. package/src/util/struct_array.test.ts +1 -1
  290. package/src/util/struct_array.ts +15 -15
  291. package/src/util/task_queue.ts +3 -3
  292. package/src/util/tile_request_cache.ts +3 -3
  293. package/src/util/transferable_grid_index.ts +4 -4
  294. package/src/util/util.ts +8 -8
  295. package/src/util/web_worker.ts +4 -68
  296. package/src/util/web_worker_transfer.test.ts +3 -0
  297. package/src/util/web_worker_transfer.ts +21 -17
  298. package/src/util/worker_pool.ts +1 -1
  299. package/build/.eslintrc +0 -21
  300. package/build/glsl_to_js.js +0 -12
  301. package/build/post-ts-build.js +0 -43
  302. package/build/release-notes.md.ejs +0 -8
  303. package/build/test/build-tape.js +0 -17
  304. package/build/web_worker_replacement.js +0 -5
  305. package/dist/package.json +0 -1
  306. package/src/style-spec/validate_spec.test.ts +0 -29
  307. package/src/symbol/shaping.test.ts +0 -392
  308. package/src/types/glsl.d.ts +0 -4
@@ -12,7 +12,7 @@ import {
12
12
  } from '../source/rtl_text_plugin';
13
13
  import browser from '../util/browser';
14
14
  import {OverscaledTileID} from '../source/tile_id';
15
- import {useFakeXMLHttpRequest, fakeServer} from 'sinon';
15
+ import {fakeXhr, fakeServer} from 'nise';
16
16
  import {WorkerGlobalScopeInterface} from '../util/web_worker';
17
17
  import EvaluationParameters from './evaluation_parameters';
18
18
  import {LayerSpecification, GeoJSONSourceSpecification, FilterSpecification, SourceSpecification} from '../style-spec/types';
@@ -48,6 +48,7 @@ function createGeoJSONSource() {
48
48
  }
49
49
 
50
50
  class StubMap extends Evented {
51
+ style: Style;
51
52
  transform: Transform;
52
53
  private _requestManager: RequestManager;
53
54
 
@@ -68,6 +69,12 @@ class StubMap extends Evented {
68
69
 
69
70
  const getStubMap = () => new StubMap() as any;
70
71
 
72
+ function createStyle(map = getStubMap()) {
73
+ const style = new Style(map);
74
+ map.style = style;
75
+ return style;
76
+ }
77
+
71
78
  let sinonFakeXMLServer;
72
79
  let sinonFakeServer;
73
80
  let _self;
@@ -76,7 +83,7 @@ let mockConsoleError;
76
83
  beforeEach(() => {
77
84
  global.fetch = null;
78
85
  sinonFakeServer = fakeServer.create();
79
- sinonFakeXMLServer = useFakeXMLHttpRequest();
86
+ sinonFakeXMLServer = fakeXhr.useFakeXMLHttpRequest();
80
87
 
81
88
  _self = {
82
89
  addEventListener() {}
@@ -258,7 +265,7 @@ describe('Style#loadJSON', () => {
258
265
  });
259
266
 
260
267
  test('creates sources', done => {
261
- const style = new Style(getStubMap());
268
+ const style = createStyle();
262
269
 
263
270
  style.on('style.load', () => {
264
271
  expect(style.sourceCaches['mapLibre'] instanceof SourceCache).toBeTruthy();
@@ -276,7 +283,7 @@ describe('Style#loadJSON', () => {
276
283
  });
277
284
 
278
285
  test('creates layers', done => {
279
- const style = new Style(getStubMap());
286
+ const style = createStyle();
280
287
 
281
288
  style.on('style.load', () => {
282
289
  expect(style.getLayer('fill') instanceof StyleLayer).toBeTruthy();
@@ -302,7 +309,7 @@ describe('Style#loadJSON', () => {
302
309
  test('transforms sprite json and image URLs before request', done => {
303
310
  const map = getStubMap();
304
311
  const transformSpy = jest.spyOn(map._requestManager, 'transformRequest');
305
- const style = new Style(map);
312
+ const style = createStyle(map);
306
313
 
307
314
  style.on('style.load', () => {
308
315
  expect(transformSpy).toHaveBeenCalledTimes(2);
@@ -319,7 +326,7 @@ describe('Style#loadJSON', () => {
319
326
  });
320
327
 
321
328
  test('emits an error on non-existant vector source layer', done => {
322
- const style = new Style(getStubMap());
329
+ const style = createStyle();
323
330
  style.loadJSON(createStyleJSON({
324
331
  sources: {
325
332
  '-source-id-': {type: 'vector', tiles: []}
@@ -407,7 +414,7 @@ describe('Style#_remove', () => {
407
414
 
408
415
  describe('Style#update', () => {
409
416
  test('on error', done => {
410
- const style = new Style(getStubMap());
417
+ const style = createStyle();
411
418
  style.loadJSON({
412
419
  'version': 8,
413
420
  'sources': {
@@ -449,7 +456,7 @@ describe('Style#setState', () => {
449
456
  });
450
457
 
451
458
  test('do nothing if there are no changes', done => {
452
- const style = new Style(getStubMap());
459
+ const style = createStyle();
453
460
  style.loadJSON(createStyleJSON());
454
461
  jest.spyOn(style, 'addLayer').mockImplementation(() => done('test failed'));
455
462
  jest.spyOn(style, 'removeLayer').mockImplementation(() => done('test failed'));
@@ -574,7 +581,7 @@ describe('Style#addSource', () => {
574
581
  });
575
582
 
576
583
  test('fires "data" event', done => {
577
- const style = new Style(getStubMap());
584
+ const style = createStyle();
578
585
  style.loadJSON(createStyleJSON());
579
586
  const source = createSource();
580
587
  style.once('data', () => { done(); });
@@ -585,7 +592,7 @@ describe('Style#addSource', () => {
585
592
  });
586
593
 
587
594
  test('throws on duplicates', done => {
588
- const style = new Style(getStubMap());
595
+ const style = createStyle();
589
596
  style.loadJSON(createStyleJSON());
590
597
  const source = createSource();
591
598
  style.on('style.load', () => {
@@ -607,7 +614,7 @@ describe('Style#addSource', () => {
607
614
  done();
608
615
  }
609
616
  };
610
- const style = new Style(getStubMap());
617
+ const style = createStyle();
611
618
  style.loadJSON(createStyleJSON({
612
619
  layers: [{
613
620
  id: 'background',
@@ -795,7 +802,7 @@ describe('Style#addLayer', () => {
795
802
  });
796
803
 
797
804
  test('throws on non-existant vector source layer', done => {
798
- const style = new Style(getStubMap());
805
+ const style = createStyle();
799
806
  style.loadJSON(createStyleJSON({
800
807
  sources: {
801
808
  // At least one source must be added to trigger the load event
@@ -864,7 +871,7 @@ describe('Style#addLayer', () => {
864
871
  });
865
872
 
866
873
  test('reloads source', done => {
867
- const style = new Style(getStubMap());
874
+ const style = createStyle();
868
875
  style.loadJSON(extend(createStyleJSON(), {
869
876
  'sources': {
870
877
  'mapLibre': {
@@ -891,7 +898,7 @@ describe('Style#addLayer', () => {
891
898
  });
892
899
 
893
900
  test('#3895 reloads source (instead of clearing) if adding this layer with the same type, immediately after removing it', done => {
894
- const style = new Style(getStubMap());
901
+ const style = createStyle();
895
902
  style.loadJSON(extend(createStyleJSON(), {
896
903
  'sources': {
897
904
  'mapLibre': {
@@ -928,7 +935,7 @@ describe('Style#addLayer', () => {
928
935
  });
929
936
 
930
937
  test('clears source (instead of reloading) if adding this layer with a different type, immediately after removing it', done => {
931
- const style = new Style(getStubMap());
938
+ const style = createStyle();
932
939
  style.loadJSON(extend(createStyleJSON(), {
933
940
  'sources': {
934
941
  'mapLibre': {
@@ -37,8 +37,8 @@ import {validateCustomStyleLayer} from './style_layer/custom_style_layer';
37
37
  // to continue to allow canvas sources to be added at runtime/updated in
38
38
  // smart setStyle (see https://github.com/mapbox/mapbox-gl-js/pull/6424):
39
39
  const emitValidationErrors = (evented: Evented, errors?: ReadonlyArray<{
40
- message: string;
41
- identifier?: string;
40
+ message: string;
41
+ identifier?: string;
42
42
  }> | null) =>
43
43
  _emitValidationErrors(evented, errors && errors.filter(error => error.identifier !== 'source.canvas'));
44
44
 
@@ -88,12 +88,12 @@ const ignoredDiffOperations = pick(diffOperations, [
88
88
  const empty = emptyStyle() as StyleSpecification;
89
89
 
90
90
  export type StyleOptions = {
91
- validate?: boolean;
92
- localIdeographFontFamily?: string;
91
+ validate?: boolean;
92
+ localIdeographFontFamily?: string;
93
93
  };
94
94
 
95
95
  export type StyleSetterOptions = {
96
- validate?: boolean;
96
+ validate?: boolean;
97
97
  };
98
98
  /**
99
99
  * @private
@@ -203,7 +203,7 @@ class Style extends Evented {
203
203
  }
204
204
 
205
205
  loadURL(url: string, options: {
206
- validate?: boolean;
206
+ validate?: boolean;
207
207
  } = {}) {
208
208
  this.fire(new Event('dataloading', {dataType: 'style'}));
209
209
 
@@ -611,10 +611,10 @@ class Style extends Evented {
611
611
  }
612
612
 
613
613
  /**
614
- * Set the data of a GeoJSON source, given its id.
615
- * @param {string} id id of the source
616
- * @param {GeoJSON|string} data GeoJSON source
617
- */
614
+ * Set the data of a GeoJSON source, given its id.
615
+ * @param {string} id id of the source
616
+ * @param {GeoJSON|string} data GeoJSON source
617
+ */
618
618
  setGeoJSONSourceData(id: string, data: GeoJSON.GeoJSON | string) {
619
619
  this._checkLoaded();
620
620
 
@@ -716,7 +716,7 @@ class Style extends Evented {
716
716
  /**
717
717
  * Moves a layer to a different z-position. The layer will be inserted before the layer with
718
718
  * ID `before`, or appended if `before` is omitted.
719
- * @param {string} id ID of the layer to move
719
+ * @param {string} id ID of the layer to move
720
720
  * @param {string} [before] ID of an existing layer to insert before
721
721
  */
722
722
  moveLayer(id: string, before?: string) {
@@ -913,9 +913,9 @@ class Style extends Evented {
913
913
  }
914
914
 
915
915
  setFeatureState(target: {
916
- source: string;
917
- sourceLayer?: string;
918
- id: string | number;
916
+ source: string;
917
+ sourceLayer?: string;
918
+ id: string | number;
919
919
  }, state: any) {
920
920
  this._checkLoaded();
921
921
  const sourceId = target.source;
@@ -943,9 +943,9 @@ class Style extends Evented {
943
943
  }
944
944
 
945
945
  removeFeatureState(target: {
946
- source: string;
947
- sourceLayer?: string;
948
- id?: string | number;
946
+ source: string;
947
+ sourceLayer?: string;
948
+ id?: string | number;
949
949
  }, key?: string) {
950
950
  this._checkLoaded();
951
951
  const sourceId = target.source;
@@ -973,9 +973,9 @@ class Style extends Evented {
973
973
  }
974
974
 
975
975
  getFeatureState(target: {
976
- source: string;
977
- sourceLayer?: string;
978
- id: string | number;
976
+ source: string;
977
+ sourceLayer?: string;
978
+ id: string | number;
979
979
  }) {
980
980
  this._checkLoaded();
981
981
  const sourceId = target.source;
@@ -1218,7 +1218,7 @@ class Style extends Evented {
1218
1218
  }
1219
1219
 
1220
1220
  _validate(validate: Validator, key: string, value: any, props: any, options: {
1221
- validate?: boolean;
1221
+ validate?: boolean;
1222
1222
  } = {}) {
1223
1223
  if (options && options.validate === false) {
1224
1224
  return false;
@@ -1354,14 +1354,14 @@ class Style extends Evented {
1354
1354
  // Callbacks from web workers
1355
1355
 
1356
1356
  getImages(
1357
- mapId: string,
1358
- params: {
1359
- icons: Array<string>;
1360
- source: string;
1361
- tileID: OverscaledTileID;
1362
- type: string;
1363
- },
1364
- callback: Callback<{[_: string]: StyleImage}>
1357
+ mapId: string,
1358
+ params: {
1359
+ icons: Array<string>;
1360
+ source: string;
1361
+ tileID: OverscaledTileID;
1362
+ type: string;
1363
+ },
1364
+ callback: Callback<{[_: string]: StyleImage}>
1365
1365
  ) {
1366
1366
  this.imageManager.getImages(params.icons, callback);
1367
1367
 
@@ -1,15 +1,15 @@
1
1
  import type {AlphaImage} from '../util/image';
2
2
 
3
3
  export type GlyphMetrics = {
4
- width: number;
5
- height: number;
6
- left: number;
7
- top: number;
8
- advance: number;
4
+ width: number;
5
+ height: number;
6
+ left: number;
7
+ top: number;
8
+ advance: number;
9
9
  };
10
10
 
11
11
  export type StyleGlyph = {
12
- id: number;
13
- bitmap: AlphaImage;
14
- metrics: GlyphMetrics;
12
+ id: number;
13
+ bitmap: AlphaImage;
14
+ metrics: GlyphMetrics;
15
15
  };
@@ -3,18 +3,18 @@ import {RGBAImage} from '../util/image';
3
3
  import type Map from '../ui/map';
4
4
 
5
5
  export type StyleImageData = {
6
- data: RGBAImage;
7
- version: number;
8
- hasRenderCallback?: boolean;
9
- userImage?: StyleImageInterface;
6
+ data: RGBAImage;
7
+ version: number;
8
+ hasRenderCallback?: boolean;
9
+ userImage?: StyleImageInterface;
10
10
  };
11
11
 
12
12
  export type StyleImageMetadata = {
13
- pixelRatio: number;
14
- sdf: boolean;
15
- stretchX?: Array<[number, number]>;
16
- stretchY?: Array<[number, number]>;
17
- content?: [number, number, number, number];
13
+ pixelRatio: number;
14
+ sdf: boolean;
15
+ stretchX?: Array<[number, number]>;
16
+ stretchY?: Array<[number, number]>;
17
+ content?: [number, number, number, number];
18
18
  };
19
19
 
20
20
  export type StyleImage = StyleImageData & StyleImageMetadata;
@@ -73,55 +73,55 @@ export type StyleImage = StyleImageData & StyleImageMetadata;
73
73
  */
74
74
 
75
75
  export interface StyleImageInterface {
76
- /**
77
- * @property {number} width
78
- */
79
- width: number;
80
- /**
81
- * @property {number} height
82
- */
83
- height: number;
84
- /**
85
- * @property {Uint8Array | Uint8ClampedArray} data
86
- */
87
- data: Uint8Array | Uint8ClampedArray;
88
- /**
89
- * This method is called once before every frame where the icon will be used.
90
- * The method can optionally update the image's `data` member with a new image.
91
- *
92
- * If the method updates the image it must return `true` to commit the change.
93
- * If the method returns `false` or nothing the image is assumed to not have changed.
94
- *
95
- * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update
96
- * the image instead of implementing this method.
97
- *
98
- * @function
99
- * @memberof StyleImageInterface
100
- * @instance
101
- * @name render
102
- * @return {boolean} `true` if this method updated the image. `false` if the image was not changed.
103
- */
104
- render?: () => boolean;
105
- /**
106
- * Optional method called when the layer has been added to the Map with {@link Map#addImage}.
107
- *
108
- * @function
109
- * @memberof StyleImageInterface
110
- * @instance
111
- * @name onAdd
112
- * @param {Map} map The Map this custom layer was just added to.
113
- */
114
- onAdd?: (map: Map, id: string) => void;
115
- /**
116
- * Optional method called when the icon is removed from the map with {@link Map#removeImage}.
117
- * This gives the image a chance to clean up resources and event listeners.
118
- *
119
- * @function
120
- * @memberof StyleImageInterface
121
- * @instance
122
- * @name onRemove
123
- */
124
- onRemove?: () => void;
76
+ /**
77
+ * @property {number} width
78
+ */
79
+ width: number;
80
+ /**
81
+ * @property {number} height
82
+ */
83
+ height: number;
84
+ /**
85
+ * @property {Uint8Array | Uint8ClampedArray} data
86
+ */
87
+ data: Uint8Array | Uint8ClampedArray;
88
+ /**
89
+ * This method is called once before every frame where the icon will be used.
90
+ * The method can optionally update the image's `data` member with a new image.
91
+ *
92
+ * If the method updates the image it must return `true` to commit the change.
93
+ * If the method returns `false` or nothing the image is assumed to not have changed.
94
+ *
95
+ * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update
96
+ * the image instead of implementing this method.
97
+ *
98
+ * @function
99
+ * @memberof StyleImageInterface
100
+ * @instance
101
+ * @name render
102
+ * @return {boolean} `true` if this method updated the image. `false` if the image was not changed.
103
+ */
104
+ render?: () => boolean;
105
+ /**
106
+ * Optional method called when the layer has been added to the Map with {@link Map#addImage}.
107
+ *
108
+ * @function
109
+ * @memberof StyleImageInterface
110
+ * @instance
111
+ * @name onAdd
112
+ * @param {Map} map The Map this custom layer was just added to.
113
+ */
114
+ onAdd?: (map: Map, id: string) => void;
115
+ /**
116
+ * Optional method called when the icon is removed from the map with {@link Map#removeImage}.
117
+ * This gives the image a chance to clean up resources and event listeners.
118
+ *
119
+ * @function
120
+ * @memberof StyleImageInterface
121
+ * @instance
122
+ * @name onRemove
123
+ */
124
+ onRemove?: () => void;
125
125
  }
126
126
 
127
127
  export function renderStyleImage(image: StyleImage) {
@@ -1,9 +1,9 @@
1
1
  import StyleLayer from '../style_layer';
2
2
 
3
- import properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties';
3
+ import properties, {BackgroundPaintPropsPossiblyEvaluated} from './background_style_layer_properties.g';
4
4
  import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';
5
5
 
6
- import type {BackgroundPaintProps} from './background_style_layer_properties';
6
+ import type {BackgroundPaintProps} from './background_style_layer_properties.g';
7
7
  import type {LayerSpecification} from '../../style-spec/types';
8
8
 
9
9
  class BackgroundStyleLayer extends StyleLayer {
@@ -3,14 +3,14 @@ import StyleLayer from '../style_layer';
3
3
  import CircleBucket from '../../data/bucket/circle_bucket';
4
4
  import {polygonIntersectsBufferedPoint} from '../../util/intersection_tests';
5
5
  import {getMaximumPaintValue, translateDistance, translate} from '../query_utils';
6
- import properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties';
6
+ import properties, {CircleLayoutPropsPossiblyEvaluated, CirclePaintPropsPossiblyEvaluated} from './circle_style_layer_properties.g';
7
7
  import {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';
8
8
  import {mat4, vec4} from 'gl-matrix';
9
9
  import Point from '@mapbox/point-geometry';
10
10
  import type {FeatureState} from '../../style-spec/expression';
11
11
  import type Transform from '../../geo/transform';
12
12
  import type {Bucket, BucketParameters} from '../../data/bucket';
13
- import type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties';
13
+ import type {CircleLayoutProps, CirclePaintProps} from './circle_style_layer_properties.g';
14
14
  import type {LayerSpecification} from '../../style-spec/types';
15
15
  import type {VectorTileFeature} from '@mapbox/vector-tile';
16
16
 
@@ -38,14 +38,14 @@ class CircleStyleLayer extends StyleLayer {
38
38
  }
39
39
 
40
40
  queryIntersectsFeature(
41
- queryGeometry: Array<Point>,
42
- feature: VectorTileFeature,
43
- featureState: FeatureState,
44
- geometry: Array<Array<Point>>,
45
- zoom: number,
46
- transform: Transform,
47
- pixelsToTileUnits: number,
48
- pixelPosMatrix: mat4
41
+ queryGeometry: Array<Point>,
42
+ feature: VectorTileFeature,
43
+ featureState: FeatureState,
44
+ geometry: Array<Array<Point>>,
45
+ zoom: number,
46
+ transform: Transform,
47
+ pixelsToTileUnits: number,
48
+ pixelPosMatrix: mat4
49
49
  ): boolean {
50
50
  const translatedPolygon = translate(queryGeometry,
51
51
  this.paint.get('circle-translate'),
@@ -75,15 +75,15 @@ export interface CustomLayerInterface {
75
75
  /**
76
76
  * @property {string} id A unique layer id.
77
77
  */
78
- id: string;
78
+ id: string;
79
79
  /**
80
80
  * @property {string} type The layer's type. Must be `"custom"`.
81
81
  */
82
- type: 'custom';
82
+ type: 'custom';
83
83
  /**
84
84
  * @property {string} renderingMode Either `"2d"` or `"3d"`. Defaults to `"2d"`.
85
85
  */
86
- renderingMode: '2d' | '3d';
86
+ renderingMode: '2d' | '3d';
87
87
  /**
88
88
  * Called during a render frame allowing the layer to draw into the GL context.
89
89
  *
@@ -112,7 +112,7 @@ export interface CustomLayerInterface {
112
112
  * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate}.fromLngLat
113
113
  * can be used to project a `LngLat` to a mercator coordinate.
114
114
  */
115
- render: CustomRenderMethod;
115
+ render: CustomRenderMethod;
116
116
  /**
117
117
  * Optional method called during a render frame to allow a layer to prepare resources or render into a texture.
118
118
  *
@@ -130,7 +130,7 @@ export interface CustomLayerInterface {
130
130
  * lengths in mercator units would be rendered as a cube. {@link MercatorCoordinate}.fromLngLat
131
131
  * can be used to project a `LngLat` to a mercator coordinate.
132
132
  */
133
- prerender: CustomRenderMethod;
133
+ prerender: CustomRenderMethod;
134
134
  /**
135
135
  * Optional method called when the layer has been added to the Map with {@link Map#addLayer}. This
136
136
  * gives the layer a chance to initialize gl resources and register event listeners.
@@ -142,19 +142,19 @@ export interface CustomLayerInterface {
142
142
  * @param {Map} map The Map this custom layer was just added to.
143
143
  * @param {WebGLRenderingContext} gl The gl context for the map.
144
144
  */
145
- onAdd(map: Map, gl: WebGLRenderingContext): void;
145
+ onAdd(map: Map, gl: WebGLRenderingContext): void;
146
146
  /**
147
- * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This
148
- * gives the layer a chance to clean up gl resources and event listeners.
149
- *
150
- * @function
151
- * @memberof CustomLayerInterface
152
- * @instance
153
- * @name onRemove
154
- * @param {Map} map The Map this custom layer was just added to.
155
- * @param {WebGLRenderingContext} gl The gl context for the map.
156
- */
157
- onRemove(map: Map, gl: WebGLRenderingContext): void;
147
+ * Optional method called when the layer has been removed from the Map with {@link Map#removeLayer}. This
148
+ * gives the layer a chance to clean up gl resources and event listeners.
149
+ *
150
+ * @function
151
+ * @memberof CustomLayerInterface
152
+ * @instance
153
+ * @name onRemove
154
+ * @param {Map} map The Map this custom layer was just added to.
155
+ * @param {WebGLRenderingContext} gl The gl context for the map.
156
+ */
157
+ onRemove(map: Map, gl: WebGLRenderingContext): void;
158
158
  }
159
159
 
160
160
  export function validateCustomStyleLayer(layerObject: CustomLayerInterface) {
@@ -3,13 +3,13 @@ import StyleLayer from '../style_layer';
3
3
  import FillExtrusionBucket from '../../data/bucket/fill_extrusion_bucket';
4
4
  import {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests';
5
5
  import {translateDistance, translate} from '../query_utils';
6
- import properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties';
6
+ import properties, {FillExtrusionPaintPropsPossiblyEvaluated} from './fill_extrusion_style_layer_properties.g';
7
7
  import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';
8
8
  import {mat4, vec4} from 'gl-matrix';
9
9
  import Point from '@mapbox/point-geometry';
10
10
  import type {FeatureState} from '../../style-spec/expression';
11
11
  import type {BucketParameters} from '../../data/bucket';
12
- import type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties';
12
+ import type {FillExtrusionPaintProps} from './fill_extrusion_style_layer_properties.g';
13
13
  import type Transform from '../../geo/transform';
14
14
  import type {LayerSpecification} from '../../style-spec/types';
15
15
  import type {VectorTileFeature} from '@mapbox/vector-tile';
@@ -40,14 +40,14 @@ class FillExtrusionStyleLayer extends StyleLayer {
40
40
  }
41
41
 
42
42
  queryIntersectsFeature(
43
- queryGeometry: Array<Point>,
44
- feature: VectorTileFeature,
45
- featureState: FeatureState,
46
- geometry: Array<Array<Point>>,
47
- zoom: number,
48
- transform: Transform,
49
- pixelsToTileUnits: number,
50
- pixelPosMatrix: mat4
43
+ queryGeometry: Array<Point>,
44
+ feature: VectorTileFeature,
45
+ featureState: FeatureState,
46
+ geometry: Array<Array<Point>>,
47
+ zoom: number,
48
+ transform: Transform,
49
+ pixelsToTileUnits: number,
50
+ pixelPosMatrix: mat4
51
51
  ): boolean | number {
52
52
 
53
53
  const translatedPolygon = translate(queryGeometry,
@@ -3,13 +3,13 @@ import StyleLayer from '../style_layer';
3
3
  import FillBucket from '../../data/bucket/fill_bucket';
4
4
  import {polygonIntersectsMultiPolygon} from '../../util/intersection_tests';
5
5
  import {translateDistance, translate} from '../query_utils';
6
- import properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties';
6
+ import properties, {FillLayoutPropsPossiblyEvaluated, FillPaintPropsPossiblyEvaluated} from './fill_style_layer_properties.g';
7
7
  import {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties';
8
8
 
9
9
  import type {FeatureState} from '../../style-spec/expression';
10
10
  import type {BucketParameters} from '../../data/bucket';
11
11
  import type Point from '@mapbox/point-geometry';
12
- import type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties';
12
+ import type {FillLayoutProps, FillPaintProps} from './fill_style_layer_properties.g';
13
13
  import type EvaluationParameters from '../evaluation_parameters';
14
14
  import type Transform from '../../geo/transform';
15
15
  import type {LayerSpecification} from '../../style-spec/types';
@@ -45,13 +45,13 @@ class FillStyleLayer extends StyleLayer {
45
45
  }
46
46
 
47
47
  queryIntersectsFeature(
48
- queryGeometry: Array<Point>,
49
- feature: VectorTileFeature,
50
- featureState: FeatureState,
51
- geometry: Array<Array<Point>>,
52
- zoom: number,
53
- transform: Transform,
54
- pixelsToTileUnits: number
48
+ queryGeometry: Array<Point>,
49
+ feature: VectorTileFeature,
50
+ featureState: FeatureState,
51
+ geometry: Array<Array<Point>>,
52
+ zoom: number,
53
+ transform: Transform,
54
+ pixelsToTileUnits: number
55
55
  ): boolean {
56
56
  const translatedPolygon = translate(queryGeometry,
57
57
  this.paint.get('fill-translate'),
@@ -2,13 +2,13 @@ import StyleLayer from '../style_layer';
2
2
 
3
3
  import HeatmapBucket from '../../data/bucket/heatmap_bucket';
4
4
  import {RGBAImage} from '../../util/image';
5
- import properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties';
5
+ import properties, {HeatmapPaintPropsPossiblyEvaluated} from './heatmap_style_layer_properties.g';
6
6
  import {renderColorRamp} from '../../util/color_ramp';
7
7
  import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties';
8
8
 
9
9
  import type Texture from '../../render/texture';
10
10
  import type Framebuffer from '../../gl/framebuffer';
11
- import type {HeatmapPaintProps} from './heatmap_style_layer_properties';
11
+ import type {HeatmapPaintProps} from './heatmap_style_layer_properties.g';
12
12
  import type {LayerSpecification} from '../../style-spec/types';
13
13
 
14
14
  class HeatmapStyleLayer extends StyleLayer {