maplibre-gl 2.0.5 → 2.1.3

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 (318) 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 +1574 -1022
  15. package/dist/maplibre-gl.js +3 -3
  16. package/dist/maplibre-gl.js.map +1 -1
  17. package/package.json +94 -131
  18. package/src/css/maplibre-gl.css +49 -49
  19. package/src/data/{array_types.ts → array_types.g.ts} +0 -0
  20. package/src/data/bucket/circle_bucket.ts +1 -1
  21. package/src/data/bucket/fill_bucket.test.ts +1 -1
  22. package/src/data/bucket/fill_bucket.ts +4 -4
  23. package/src/data/bucket/fill_extrusion_bucket.ts +1 -1
  24. package/src/data/bucket/line_bucket.test.ts +1 -1
  25. package/src/data/bucket/line_bucket.ts +6 -6
  26. package/src/data/bucket/symbol_bucket.test.ts +16 -16
  27. package/src/data/bucket/symbol_bucket.ts +56 -56
  28. package/src/data/bucket.ts +43 -43
  29. package/src/data/dem_data.ts +12 -12
  30. package/src/data/evaluation_feature.ts +10 -10
  31. package/src/data/feature_index.ts +37 -37
  32. package/src/data/feature_position_map.ts +5 -5
  33. package/src/data/index_array_type.ts +1 -1
  34. package/src/data/load_geometry.test.ts +1 -1
  35. package/src/data/program_configuration.ts +47 -47
  36. package/src/data/segment.ts +14 -14
  37. package/src/geo/edge_insets.ts +2 -2
  38. package/src/geo/lng_lat.ts +4 -4
  39. package/src/geo/lng_lat_bounds.ts +35 -35
  40. package/src/geo/mercator_coordinate.ts +5 -5
  41. package/src/geo/transform.test.ts +1 -1
  42. package/src/geo/transform.ts +14 -14
  43. package/src/gl/context.ts +3 -3
  44. package/src/gl/types.ts +19 -19
  45. package/src/gl/value.ts +6 -6
  46. package/src/gl/vertex_buffer.test.ts +1 -1
  47. package/src/index.ts +24 -9
  48. package/src/render/draw_circle.ts +8 -8
  49. package/src/render/draw_collision_debug.ts +5 -5
  50. package/src/render/draw_debug.ts +1 -1
  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 +34 -33
  56. package/src/render/image_manager.ts +4 -4
  57. package/src/render/painter.ts +16 -14
  58. package/src/render/program/background_program.ts +29 -29
  59. package/src/render/program/circle_program.ts +11 -11
  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 +41 -41
  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 +97 -97
  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_source.test.ts +2 -1
  131. package/src/source/geojson_source.ts +1 -1
  132. package/src/source/geojson_worker_source.ts +23 -23
  133. package/src/source/geojson_wrapper.ts +8 -8
  134. package/src/source/image_source.test.ts +2 -2
  135. package/src/source/image_source.ts +6 -6
  136. package/src/source/pixels_to_tile_units.ts +6 -6
  137. package/src/source/query_features.ts +20 -20
  138. package/src/source/raster_dem_tile_source.test.ts +4 -3
  139. package/src/source/raster_dem_tile_source.ts +1 -1
  140. package/src/source/raster_tile_source.test.ts +4 -3
  141. package/src/source/raster_tile_source.ts +1 -1
  142. package/src/source/rtl_text_plugin.ts +10 -10
  143. package/src/source/source.ts +29 -29
  144. package/src/source/source_cache.test.ts +33 -1
  145. package/src/source/source_cache.ts +7 -5
  146. package/src/source/source_state.ts +1 -1
  147. package/src/source/tile.test.ts +3 -3
  148. package/src/source/tile.ts +15 -15
  149. package/src/source/tile_cache.test.ts +6 -4
  150. package/src/source/tile_cache.ts +6 -6
  151. package/src/source/tile_id.test.ts +10 -13
  152. package/src/source/tile_id.ts +2 -2
  153. package/src/source/vector_tile_source.test.ts +17 -5
  154. package/src/source/vector_tile_source.ts +4 -5
  155. package/src/source/vector_tile_worker_source.test.ts +4 -4
  156. package/src/source/vector_tile_worker_source.ts +5 -5
  157. package/src/source/worker.test.ts +1 -1
  158. package/src/source/worker.ts +22 -22
  159. package/src/source/worker_source.ts +56 -56
  160. package/src/source/worker_tile.ts +4 -4
  161. package/src/style/evaluation_parameters.ts +3 -3
  162. package/src/style/format_section_override.test.ts +1 -1
  163. package/src/style/light.ts +10 -10
  164. package/src/style/load_glyph_range.test.ts +3 -5
  165. package/src/style/load_glyph_range.ts +6 -6
  166. package/src/style/load_sprite.ts +5 -4
  167. package/src/style/pauseable_placement.ts +1 -1
  168. package/src/style/properties.ts +70 -70
  169. package/src/style/query_utils.ts +7 -7
  170. package/src/style/style.test.ts +26 -15
  171. package/src/style/style.ts +30 -30
  172. package/src/style/style_glyph.ts +8 -8
  173. package/src/style/style_image.ts +58 -58
  174. package/src/style/style_layer/background_style_layer.ts +2 -2
  175. package/src/style/style_layer/{background_style_layer_properties.ts → background_style_layer_properties.g.ts} +0 -0
  176. package/src/style/style_layer/circle_style_layer.ts +10 -10
  177. package/src/style/style_layer/{circle_style_layer_properties.ts → circle_style_layer_properties.g.ts} +0 -0
  178. package/src/style/style_layer/custom_style_layer.ts +19 -19
  179. package/src/style/style_layer/fill_extrusion_style_layer.ts +11 -11
  180. package/src/style/style_layer/{fill_extrusion_style_layer_properties.ts → fill_extrusion_style_layer_properties.g.ts} +0 -0
  181. package/src/style/style_layer/fill_style_layer.ts +9 -9
  182. package/src/style/style_layer/{fill_style_layer_properties.ts → fill_style_layer_properties.g.ts} +0 -0
  183. package/src/style/style_layer/heatmap_style_layer.ts +2 -2
  184. package/src/style/style_layer/{heatmap_style_layer_properties.ts → heatmap_style_layer_properties.g.ts} +0 -0
  185. package/src/style/style_layer/hillshade_style_layer.ts +2 -2
  186. package/src/style/style_layer/{hillshade_style_layer_properties.ts → hillshade_style_layer_properties.g.ts} +0 -0
  187. package/src/style/style_layer/line_style_layer.ts +9 -9
  188. package/src/style/style_layer/{line_style_layer_properties.ts → line_style_layer_properties.g.ts} +0 -0
  189. package/src/style/style_layer/raster_style_layer.ts +2 -2
  190. package/src/style/style_layer/{raster_style_layer_properties.ts → raster_style_layer_properties.g.ts} +0 -0
  191. package/src/style/style_layer/symbol_style_layer.ts +26 -7
  192. package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +6 -0
  193. package/src/style/style_layer.ts +10 -10
  194. package/src/style/style_layer_index.ts +3 -3
  195. package/src/style/validate_style.ts +15 -15
  196. package/src/style-spec/CHANGELOG.md +6 -0
  197. package/src/style-spec/error/validation_error.ts +1 -1
  198. package/src/style-spec/expression/compound_expression.ts +3 -3
  199. package/src/style-spec/expression/definitions/format.ts +11 -11
  200. package/src/style-spec/expression/definitions/interpolate.ts +5 -5
  201. package/src/style-spec/expression/definitions/match.ts +2 -2
  202. package/src/style-spec/expression/definitions/number_format.ts +11 -11
  203. package/src/style-spec/expression/expression.ts +8 -8
  204. package/src/style-spec/expression/index.ts +97 -97
  205. package/src/style-spec/expression/parsing_context.ts +11 -11
  206. package/src/style-spec/expression/types/collator.ts +9 -9
  207. package/src/style-spec/expression/types/resolved_image.ts +2 -2
  208. package/src/style-spec/expression/types.ts +14 -14
  209. package/src/style-spec/expression/values.ts +1 -1
  210. package/src/style-spec/feature_filter/index.ts +66 -66
  211. package/src/style-spec/function/convert.ts +3 -3
  212. package/src/style-spec/package.json +1 -1
  213. package/src/style-spec/reference/v8.json +68 -2
  214. package/src/style-spec/style-spec.ts +44 -44
  215. package/src/style-spec/types.ts +2 -0
  216. package/src/style-spec/util/color_spaces.ts +8 -8
  217. package/src/style-spec/util/result.ts +4 -4
  218. package/src/style-spec/validate/validate_filter.ts +58 -58
  219. package/src/style-spec/validate/validate_source.ts +63 -63
  220. package/src/style-spec/visit.ts +11 -11
  221. package/src/symbol/collision_feature.test.ts +1 -1
  222. package/src/symbol/collision_feature.ts +10 -10
  223. package/src/symbol/collision_index.ts +43 -43
  224. package/src/symbol/cross_tile_symbol_index.ts +17 -17
  225. package/src/symbol/get_anchors.ts +16 -16
  226. package/src/symbol/grid_index.test.ts +42 -19
  227. package/src/symbol/grid_index.ts +69 -40
  228. package/src/symbol/placement.ts +124 -95
  229. package/src/symbol/projection.ts +30 -30
  230. package/src/symbol/quads.ts +30 -30
  231. package/src/symbol/shaping.ts +160 -160
  232. package/src/symbol/symbol_layout.ts +119 -119
  233. package/src/symbol/symbol_size.ts +29 -29
  234. package/src/symbol/symbol_style_layer.test.ts +49 -2
  235. package/src/types/cancelable.ts +1 -1
  236. package/src/types/tilejson.ts +13 -13
  237. package/src/ui/anchor.ts +1 -1
  238. package/src/ui/camera.test.ts +9 -9
  239. package/src/ui/camera.ts +18 -18
  240. package/src/ui/control/attribution_control.test.ts +51 -16
  241. package/src/ui/control/attribution_control.ts +35 -16
  242. package/src/ui/control/control.ts +40 -40
  243. package/src/ui/control/fullscreen_control.ts +1 -1
  244. package/src/ui/control/geolocate_control.test.ts +1 -1
  245. package/src/ui/control/geolocate_control.ts +102 -102
  246. package/src/ui/control/logo_control.test.ts +5 -4
  247. package/src/ui/control/navigation_control.ts +3 -3
  248. package/src/ui/control/scale_control.test.ts +2 -2
  249. package/src/ui/control/scale_control.ts +5 -5
  250. package/src/ui/events.ts +289 -200
  251. package/src/ui/handler/box_zoom.test.ts +1 -1
  252. package/src/ui/handler/box_zoom.ts +1 -1
  253. package/src/ui/handler/dblclick_zoom.test.ts +1 -1
  254. package/src/ui/handler/drag_pan.test.ts +1 -1
  255. package/src/ui/handler/drag_rotate.test.ts +1 -1
  256. package/src/ui/handler/keyboard.test.ts +1 -1
  257. package/src/ui/handler/keyboard.ts +51 -51
  258. package/src/ui/handler/map_event.test.ts +1 -1
  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 +1 -1
  262. package/src/ui/handler/scroll_zoom.test.ts +3 -2
  263. package/src/ui/handler/scroll_zoom.ts +9 -9
  264. package/src/ui/handler/shim/drag_pan.ts +4 -4
  265. package/src/ui/handler/shim/drag_rotate.ts +1 -1
  266. package/src/ui/handler/shim/touch_zoom_rotate.ts +1 -1
  267. package/src/ui/handler/tap_recognizer.ts +4 -4
  268. package/src/ui/handler/touch_pan.ts +2 -2
  269. package/src/ui/handler/touch_zoom_rotate.test.ts +1 -1
  270. package/src/ui/handler/touch_zoom_rotate.ts +1 -1
  271. package/src/ui/handler_inertia.ts +6 -6
  272. package/src/ui/handler_manager.ts +44 -44
  273. package/src/ui/map/isMoving.test.ts +1 -1
  274. package/src/ui/map/isRotating.test.ts +1 -1
  275. package/src/ui/map/isZooming.test.ts +1 -1
  276. package/src/ui/map.test.ts +87 -14
  277. package/src/ui/map.ts +136 -106
  278. package/src/ui/map_events.test.ts +1 -1
  279. package/src/ui/marker.test.ts +12 -12
  280. package/src/ui/marker.ts +37 -37
  281. package/src/ui/popup.test.ts +7 -7
  282. package/src/ui/popup.ts +9 -9
  283. package/src/util/actor.test.ts +41 -10
  284. package/src/util/actor.ts +8 -8
  285. package/src/util/ajax.test.ts +29 -21
  286. package/src/util/ajax.ts +51 -30
  287. package/src/util/browser.ts +1 -1
  288. package/src/util/classify_rings.test.ts +1 -1
  289. package/src/util/color_ramp.ts +5 -5
  290. package/src/util/config.ts +2 -2
  291. package/src/util/dispatcher.ts +1 -1
  292. package/src/util/dom.ts +2 -2
  293. package/src/util/evented.ts +1 -1
  294. package/src/util/find_pole_of_inaccessibility.ts +3 -3
  295. package/src/util/image.ts +5 -5
  296. package/src/util/performance.ts +7 -7
  297. package/src/util/request_manager.ts +4 -4
  298. package/src/util/resolve_tokens.ts +4 -4
  299. package/src/util/struct_array.test.ts +1 -1
  300. package/src/util/struct_array.ts +15 -15
  301. package/src/util/task_queue.ts +3 -3
  302. package/src/util/tile_request_cache.ts +3 -3
  303. package/src/util/transferable_grid_index.ts +4 -4
  304. package/src/util/util.ts +8 -8
  305. package/src/util/web_worker.ts +4 -68
  306. package/src/util/web_worker_transfer.test.ts +3 -0
  307. package/src/util/web_worker_transfer.ts +21 -17
  308. package/src/util/worker_pool.ts +1 -1
  309. package/build/.eslintrc +0 -21
  310. package/build/glsl_to_js.js +0 -12
  311. package/build/post-ts-build.js +0 -43
  312. package/build/release-notes.md.ejs +0 -8
  313. package/build/test/build-tape.js +0 -17
  314. package/build/web_worker_replacement.js +0 -5
  315. package/dist/package.json +0 -1
  316. package/src/style-spec/validate_spec.test.ts +0 -29
  317. package/src/symbol/shaping.test.ts +0 -392
  318. package/src/types/glsl.d.ts +0 -4
@@ -4,21 +4,21 @@ import {ErrorEvent} from '../util/evented';
4
4
  import type {Evented} from '../util/evented';
5
5
 
6
6
  type ValidationError = {
7
- message: string;
8
- line: number;
9
- identifier?: string;
7
+ message: string;
8
+ line: number;
9
+ identifier?: string;
10
10
  };
11
11
 
12
12
  export type Validator = (a: any) => ReadonlyArray<ValidationError>;
13
13
 
14
14
  type ValidateStyle = {
15
- source: Validator;
16
- layer: Validator;
17
- light: Validator;
18
- filter: Validator;
19
- paintProperty: Validator;
20
- layoutProperty: Validator;
21
- (b: any, a?: any | null): ReadonlyArray<ValidationError>;
15
+ source: Validator;
16
+ layer: Validator;
17
+ light: Validator;
18
+ filter: Validator;
19
+ paintProperty: Validator;
20
+ layoutProperty: Validator;
21
+ (b: any, a?: any | null): ReadonlyArray<ValidationError>;
22
22
  };
23
23
 
24
24
  export const validateStyle = (validateStyleMin as ValidateStyle);
@@ -30,11 +30,11 @@ export const validatePaintProperty = validateStyle.paintProperty;
30
30
  export const validateLayoutProperty = validateStyle.layoutProperty;
31
31
 
32
32
  export function emitValidationErrors(
33
- emitter: Evented,
34
- errors?: ReadonlyArray<{
35
- message: string;
36
- identifier?: string;
37
- }> | null
33
+ emitter: Evented,
34
+ errors?: ReadonlyArray<{
35
+ message: string;
36
+ identifier?: string;
37
+ }> | null
38
38
  ): boolean {
39
39
  let hasErrors = false;
40
40
  if (errors && errors.length) {
@@ -1,3 +1,9 @@
1
+ ## 15.1.0
2
+
3
+ ### ✨ Features and improvements
4
+ * Add `icon-overlap` and `text-overlap` symbol layout properties [#347](https://github.com/maplibre/maplibre-gl-js/pull/347)
5
+ * Deprecate `icon-allow-overlap` and `text-allow-overlap` symbol layout properties. `icon-overlap` and `text-overlap` are their replacements.
6
+
1
7
  ## 15.0.0
2
8
 
3
9
  ### Breaking changes
@@ -6,7 +6,7 @@ export default class ValidationError {
6
6
  line: number;
7
7
 
8
8
  constructor(key: string, value: {
9
- __line__: number;
9
+ __line__: number;
10
10
  }, message: string, identifier?: string | null) {
11
11
  this.message = (key ? `${key}: ` : '') + message;
12
12
  if (identifier) this.identifier = identifier;
@@ -9,14 +9,14 @@ import type {Type} from './types';
9
9
  import type {Value} from './values';
10
10
 
11
11
  export type Varargs = {
12
- type: Type;
12
+ type: Type;
13
13
  };
14
14
  type Signature = Array<Type> | Varargs;
15
15
  type Evaluate = (b: EvaluationContext, a: Array<Expression>) => Value;
16
16
 
17
17
  type Definition = [Type, Signature, Evaluate] | {
18
- type: Type;
19
- overloads: Array<[Signature, Evaluate]>;
18
+ type: Type;
19
+ overloads: Array<[Signature, Evaluate]>;
20
20
  };
21
21
 
22
22
  class CompoundExpression implements Expression {
@@ -16,12 +16,12 @@ import type ParsingContext from '../parsing_context';
16
16
  import type {Type} from '../types';
17
17
 
18
18
  type FormattedSectionExpression = {
19
- // Content of a section may be Image expression or other
20
- // type of expression that is coercable to 'string'.
21
- content: Expression;
22
- scale: Expression | null;
23
- font: Expression | null;
24
- textColor: Expression | null;
19
+ // Content of a section may be Image expression or other
20
+ // type of expression that is coercable to 'string'.
21
+ content: Expression;
22
+ scale: Expression | null;
23
+ font: Expression | null;
24
+ textColor: Expression | null;
25
25
  };
26
26
 
27
27
  export default class FormatExpression implements Expression {
@@ -97,11 +97,11 @@ export default class FormatExpression implements Expression {
97
97
  }
98
98
 
99
99
  return new FormattedSection(
100
- toString(evaluatedContent),
101
- null,
102
- section.scale ? section.scale.evaluate(ctx) : null,
103
- section.font ? section.font.evaluate(ctx).join(',') : null,
104
- section.textColor ? section.textColor.evaluate(ctx) : null
100
+ toString(evaluatedContent),
101
+ null,
102
+ section.scale ? section.scale.evaluate(ctx) : null,
103
+ section.font ? section.font.evaluate(ctx).join(',') : null,
104
+ section.textColor ? section.textColor.evaluate(ctx) : null
105
105
  );
106
106
  };
107
107
 
@@ -12,13 +12,13 @@ import type EvaluationContext from '../evaluation_context';
12
12
  import type {Type} from '../types';
13
13
 
14
14
  export type InterpolationType = {
15
- name: 'linear';
15
+ name: 'linear';
16
16
  } | {
17
- name: 'exponential';
18
- base: number;
17
+ name: 'exponential';
18
+ base: number;
19
19
  } | {
20
- name: 'cubic-bezier';
21
- controlPoints: [number, number, number, number];
20
+ name: 'cubic-bezier';
21
+ controlPoints: [number, number, number, number];
22
22
  };
23
23
 
24
24
  class Interpolate implements Expression {
@@ -11,7 +11,7 @@ import type EvaluationContext from '../evaluation_context';
11
11
 
12
12
  // Map input label values to output expression index
13
13
  type Cases = {
14
- [k in number | string]: number;
14
+ [k in number | string]: number;
15
15
  };
16
16
 
17
17
  class Match implements Expression {
@@ -128,7 +128,7 @@ class Match implements Expression {
128
128
  // serializations of the form [case1, case2, ...] -> matchExpression
129
129
  const groupedByOutput: Array<[number, Array<number | string>]> = [];
130
130
  const outputLookup: {
131
- [index: number]: number;
131
+ [index: number]: number;
132
132
  } = {}; // lookup index into groupedByOutput for a given output expression
133
133
  for (const label of sortedLabels) {
134
134
  const outputIndex = outputLookup[this.cases[label]];
@@ -6,9 +6,9 @@ import type ParsingContext from '../parsing_context';
6
6
  import type {Type} from '../types';
7
7
 
8
8
  declare let Intl: {
9
- NumberFormat: {
10
- new (...args: any): Intl$NumberFormat;
11
- };
9
+ NumberFormat: {
10
+ new (...args: any): Intl$NumberFormat;
11
+ };
12
12
  };
13
13
 
14
14
  declare class Intl$NumberFormat {
@@ -18,10 +18,10 @@ declare class Intl$NumberFormat {
18
18
  }
19
19
 
20
20
  type NumberFormatOptions = {
21
- style?: 'decimal' | 'currency' | 'percent';
22
- currency?: null | string;
23
- minimumFractionDigits?: null | string;
24
- maximumFractionDigits?: null | string;
21
+ style?: 'decimal' | 'currency' | 'percent';
22
+ currency?: null | string;
23
+ minimumFractionDigits?: null | string;
24
+ maximumFractionDigits?: null | string;
25
25
  };
26
26
 
27
27
  export default class NumberFormat implements Expression {
@@ -33,10 +33,10 @@ export default class NumberFormat implements Expression {
33
33
  maxFractionDigits: Expression | null; // Default 3
34
34
 
35
35
  constructor(number: Expression,
36
- locale: Expression | null,
37
- currency: Expression | null,
38
- minFractionDigits: Expression | null,
39
- maxFractionDigits: Expression | null) {
36
+ locale: Expression | null,
37
+ currency: Expression | null,
38
+ minFractionDigits: Expression | null,
39
+ maxFractionDigits: Expression | null) {
40
40
  this.type = StringType;
41
41
  this.number = number;
42
42
  this.locale = locale;
@@ -5,21 +5,21 @@ import type EvaluationContext from './evaluation_context';
5
5
  type SerializedExpression = Array<unknown> | string | number | boolean | null;
6
6
 
7
7
  export interface Expression {
8
- readonly type: Type;
9
- evaluate(ctx: EvaluationContext): any;
10
- eachChild(fn: (a: Expression) => void): void;
11
- /**
8
+ readonly type: Type;
9
+ evaluate(ctx: EvaluationContext): any;
10
+ eachChild(fn: (a: Expression) => void): void;
11
+ /**
12
12
  * Statically analyze the expression, attempting to enumerate possible outputs. Returns
13
13
  * false if the complete set of outputs is statically undecidable, otherwise true.
14
14
  */
15
- outputDefined(): boolean;
16
- serialize(): SerializedExpression;
15
+ outputDefined(): boolean;
16
+ serialize(): SerializedExpression;
17
17
  }
18
18
 
19
19
  export type ExpressionParser = (args: ReadonlyArray<unknown>, context: ParsingContext) => Expression;
20
20
  export type ExpressionRegistration = {
21
- new (...args: any): Expression;
21
+ new (...args: any): Expression;
22
22
  } & {
23
- readonly parse: ExpressionParser;
23
+ readonly parse: ExpressionParser;
24
24
  };
25
25
  export type ExpressionRegistry = {[_: string]: ExpressionRegistration};
@@ -27,27 +27,27 @@ import type Point from '@mapbox/point-geometry';
27
27
  import type {CanonicalTileID} from '../../source/tile_id';
28
28
 
29
29
  export type Feature = {
30
- readonly type: 1 | 2 | 3 | 'Unknown' | 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon';
31
- readonly id?: any;
32
- readonly properties: {[_: string]: any};
33
- readonly patterns?: {
34
- [_: string]: {
35
- 'min': string;
36
- 'mid': string;
37
- 'max': string;
30
+ readonly type: 1 | 2 | 3 | 'Unknown' | 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon';
31
+ readonly id?: any;
32
+ readonly properties: {[_: string]: any};
33
+ readonly patterns?: {
34
+ [_: string]: {
35
+ 'min': string;
36
+ 'mid': string;
37
+ 'max': string;
38
+ };
38
39
  };
39
- };
40
- readonly geometry?: Array<Array<Point>>;
40
+ readonly geometry?: Array<Array<Point>>;
41
41
  };
42
42
 
43
43
  export type FeatureState = {[_: string]: any};
44
44
 
45
45
  export type GlobalProperties = Readonly<{
46
- zoom: number;
47
- heatmapDensity?: number;
48
- lineProgress?: number;
49
- isSupportedScript?: (_: string) => boolean;
50
- accumulated?: Value;
46
+ zoom: number;
47
+ heatmapDensity?: number;
48
+ lineProgress?: number;
49
+ isSupportedScript?: (_: string) => boolean;
50
+ accumulated?: Value;
51
51
  }>;
52
52
 
53
53
  export class StyleExpression {
@@ -67,12 +67,12 @@ export class StyleExpression {
67
67
  }
68
68
 
69
69
  evaluateWithoutErrorHandling(
70
- globals: GlobalProperties,
71
- feature?: Feature,
72
- featureState?: FeatureState,
73
- canonical?: CanonicalTileID,
74
- availableImages?: Array<string>,
75
- formattedSection?: FormattedSection
70
+ globals: GlobalProperties,
71
+ feature?: Feature,
72
+ featureState?: FeatureState,
73
+ canonical?: CanonicalTileID,
74
+ availableImages?: Array<string>,
75
+ formattedSection?: FormattedSection
76
76
  ): any {
77
77
  this._evaluator.globals = globals;
78
78
  this._evaluator.feature = feature;
@@ -85,12 +85,12 @@ export class StyleExpression {
85
85
  }
86
86
 
87
87
  evaluate(
88
- globals: GlobalProperties,
89
- feature?: Feature,
90
- featureState?: FeatureState,
91
- canonical?: CanonicalTileID,
92
- availableImages?: Array<string>,
93
- formattedSection?: FormattedSection
88
+ globals: GlobalProperties,
89
+ feature?: Feature,
90
+ featureState?: FeatureState,
91
+ canonical?: CanonicalTileID,
92
+ availableImages?: Array<string>,
93
+ formattedSection?: FormattedSection
94
94
  ): any {
95
95
  this._evaluator.globals = globals;
96
96
  this._evaluator.feature = feature || null;
@@ -162,23 +162,23 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
162
162
  }
163
163
 
164
164
  evaluateWithoutErrorHandling(
165
- globals: GlobalProperties,
166
- feature?: Feature,
167
- featureState?: FeatureState,
168
- canonical?: CanonicalTileID,
169
- availableImages?: Array<string>,
170
- formattedSection?: FormattedSection
165
+ globals: GlobalProperties,
166
+ feature?: Feature,
167
+ featureState?: FeatureState,
168
+ canonical?: CanonicalTileID,
169
+ availableImages?: Array<string>,
170
+ formattedSection?: FormattedSection
171
171
  ): any {
172
172
  return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
173
173
  }
174
174
 
175
175
  evaluate(
176
- globals: GlobalProperties,
177
- feature?: Feature,
178
- featureState?: FeatureState,
179
- canonical?: CanonicalTileID,
180
- availableImages?: Array<string>,
181
- formattedSection?: FormattedSection
176
+ globals: GlobalProperties,
177
+ feature?: Feature,
178
+ featureState?: FeatureState,
179
+ canonical?: CanonicalTileID,
180
+ availableImages?: Array<string>,
181
+ formattedSection?: FormattedSection
182
182
  ): any {
183
183
  return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
184
184
  }
@@ -201,23 +201,23 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
201
201
  }
202
202
 
203
203
  evaluateWithoutErrorHandling(
204
- globals: GlobalProperties,
205
- feature?: Feature,
206
- featureState?: FeatureState,
207
- canonical?: CanonicalTileID,
208
- availableImages?: Array<string>,
209
- formattedSection?: FormattedSection
204
+ globals: GlobalProperties,
205
+ feature?: Feature,
206
+ featureState?: FeatureState,
207
+ canonical?: CanonicalTileID,
208
+ availableImages?: Array<string>,
209
+ formattedSection?: FormattedSection
210
210
  ): any {
211
211
  return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
212
212
  }
213
213
 
214
214
  evaluate(
215
- globals: GlobalProperties,
216
- feature?: Feature,
217
- featureState?: FeatureState,
218
- canonical?: CanonicalTileID,
219
- availableImages?: Array<string>,
220
- formattedSection?: FormattedSection
215
+ globals: GlobalProperties,
216
+ feature?: Feature,
217
+ featureState?: FeatureState,
218
+ canonical?: CanonicalTileID,
219
+ availableImages?: Array<string>,
220
+ formattedSection?: FormattedSection
221
221
  ): any {
222
222
  return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
223
223
  }
@@ -232,57 +232,57 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
232
232
  }
233
233
 
234
234
  export type ConstantExpression = {
235
- kind: 'constant';
236
- readonly evaluate: (
237
- globals: GlobalProperties,
238
- feature?: Feature,
239
- featureState?: FeatureState,
240
- canonical?: CanonicalTileID,
241
- availableImages?: Array<string>
242
- ) => any;
235
+ kind: 'constant';
236
+ readonly evaluate: (
237
+ globals: GlobalProperties,
238
+ feature?: Feature,
239
+ featureState?: FeatureState,
240
+ canonical?: CanonicalTileID,
241
+ availableImages?: Array<string>
242
+ ) => any;
243
243
  };
244
244
 
245
245
  export type SourceExpression = {
246
- kind: 'source';
247
- isStateDependent: boolean;
248
- readonly evaluate: (
249
- globals: GlobalProperties,
250
- feature?: Feature,
251
- featureState?: FeatureState,
252
- canonical?: CanonicalTileID,
253
- availableImages?: Array<string>,
254
- formattedSection?: FormattedSection
255
- ) => any;
246
+ kind: 'source';
247
+ isStateDependent: boolean;
248
+ readonly evaluate: (
249
+ globals: GlobalProperties,
250
+ feature?: Feature,
251
+ featureState?: FeatureState,
252
+ canonical?: CanonicalTileID,
253
+ availableImages?: Array<string>,
254
+ formattedSection?: FormattedSection
255
+ ) => any;
256
256
  };
257
257
 
258
258
  export type CameraExpression = {
259
- kind: 'camera';
260
- readonly evaluate: (
261
- globals: GlobalProperties,
262
- feature?: Feature,
263
- featureState?: FeatureState,
264
- canonical?: CanonicalTileID,
265
- availableImages?: Array<string>
266
- ) => any;
267
- readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
268
- zoomStops: Array<number>;
269
- interpolationType: InterpolationType;
259
+ kind: 'camera';
260
+ readonly evaluate: (
261
+ globals: GlobalProperties,
262
+ feature?: Feature,
263
+ featureState?: FeatureState,
264
+ canonical?: CanonicalTileID,
265
+ availableImages?: Array<string>
266
+ ) => any;
267
+ readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
268
+ zoomStops: Array<number>;
269
+ interpolationType: InterpolationType;
270
270
  };
271
271
 
272
272
  export type CompositeExpression = {
273
- kind: 'composite';
274
- isStateDependent: boolean;
275
- readonly evaluate: (
276
- globals: GlobalProperties,
277
- feature?: Feature,
278
- featureState?: FeatureState,
279
- canonical?: CanonicalTileID,
280
- availableImages?: Array<string>,
281
- formattedSection?: FormattedSection
282
- ) => any;
283
- readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
284
- zoomStops: Array<number>;
285
- interpolationType: InterpolationType;
273
+ kind: 'composite';
274
+ isStateDependent: boolean;
275
+ readonly evaluate: (
276
+ globals: GlobalProperties,
277
+ feature?: Feature,
278
+ featureState?: FeatureState,
279
+ canonical?: CanonicalTileID,
280
+ availableImages?: Array<string>,
281
+ formattedSection?: FormattedSection
282
+ ) => any;
283
+ readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
284
+ zoomStops: Array<number>;
285
+ interpolationType: InterpolationType;
286
286
  };
287
287
 
288
288
  export type StylePropertyExpression = ConstantExpression | SourceExpression | CameraExpression | CompositeExpression;
@@ -348,8 +348,8 @@ export class StylePropertyFunction<T> {
348
348
  }
349
349
 
350
350
  static deserialize<T>(serialized: {
351
- _parameters: PropertyValueSpecification<T>;
352
- _specification: StylePropertySpecification;
351
+ _parameters: PropertyValueSpecification<T>;
352
+ _specification: StylePropertySpecification;
353
353
  }) {
354
354
  return new StylePropertyFunction(serialized._parameters, serialized._specification) as StylePropertyFunction<T>;
355
355
  }
@@ -363,8 +363,8 @@ export class StylePropertyFunction<T> {
363
363
  }
364
364
 
365
365
  export function normalizePropertyExpression<T>(
366
- value: PropertyValueSpecification<T>,
367
- specification: StylePropertySpecification
366
+ value: PropertyValueSpecification<T>,
367
+ specification: StylePropertySpecification
368
368
  ): StylePropertyExpression {
369
369
  if (isFunction(value)) {
370
370
  return new StylePropertyFunction(value, specification) as any;
@@ -54,13 +54,13 @@ class ParsingContext {
54
54
  * @private
55
55
  */
56
56
  parse(
57
- expr: unknown,
58
- index?: number,
59
- expectedType?: Type | null,
60
- bindings?: Array<[string, Expression]>,
61
- options: {
62
- typeAnnotation?: 'assert' | 'coerce' | 'omit';
63
- } = {}
57
+ expr: unknown,
58
+ index?: number,
59
+ expectedType?: Type | null,
60
+ bindings?: Array<[string, Expression]>,
61
+ options: {
62
+ typeAnnotation?: 'assert' | 'coerce' | 'omit';
63
+ } = {}
64
64
  ): Expression {
65
65
  if (index) {
66
66
  return this.concat(index, expectedType, bindings)._parse(expr, options);
@@ -69,10 +69,10 @@ class ParsingContext {
69
69
  }
70
70
 
71
71
  _parse(
72
- expr: unknown,
73
- options: {
74
- typeAnnotation?: 'assert' | 'coerce' | 'omit';
75
- }
72
+ expr: unknown,
73
+ options: {
74
+ typeAnnotation?: 'assert' | 'coerce' | 'omit';
75
+ }
76
76
  ): Expression {
77
77
  if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {
78
78
  expr = ['literal', expr];
@@ -2,9 +2,9 @@
2
2
  // https://github.com/facebook/flow/issues/1270
3
3
 
4
4
  declare let Intl: {
5
- Collator: {
6
- new (...args: any): Intl$Collator;
7
- };
5
+ Collator: {
6
+ new (...args: any): Intl$Collator;
7
+ };
8
8
  };
9
9
 
10
10
  declare class Intl$Collator {
@@ -14,12 +14,12 @@ declare class Intl$Collator {
14
14
  }
15
15
 
16
16
  type CollatorOptions = {
17
- localeMatcher?: 'lookup' | 'best fit';
18
- usage?: 'sort' | 'search';
19
- sensitivity?: 'base' | 'accent' | 'case' | 'variant';
20
- ignorePunctuation?: boolean;
21
- numeric?: boolean;
22
- caseFirst?: 'upper' | 'lower' | 'false';
17
+ localeMatcher?: 'lookup' | 'best fit';
18
+ usage?: 'sort' | 'search';
19
+ sensitivity?: 'base' | 'accent' | 'case' | 'variant';
20
+ ignorePunctuation?: boolean;
21
+ numeric?: boolean;
22
+ caseFirst?: 'upper' | 'lower' | 'false';
23
23
  };
24
24
 
25
25
  export default class Collator {
@@ -1,6 +1,6 @@
1
1
  export type ResolvedImageOptions = {
2
- name: string;
3
- available: boolean;
2
+ name: string;
3
+ available: boolean;
4
4
  };
5
5
 
6
6
  export default class ResolvedImage {
@@ -1,35 +1,35 @@
1
1
  export type NullTypeT = {
2
- kind: 'null';
2
+ kind: 'null';
3
3
  };
4
4
  export type NumberTypeT = {
5
- kind: 'number';
5
+ kind: 'number';
6
6
  };
7
7
  export type StringTypeT = {
8
- kind: 'string';
8
+ kind: 'string';
9
9
  };
10
10
  export type BooleanTypeT = {
11
- kind: 'boolean';
11
+ kind: 'boolean';
12
12
  };
13
13
  export type ColorTypeT = {
14
- kind: 'color';
14
+ kind: 'color';
15
15
  };
16
16
  export type ObjectTypeT = {
17
- kind: 'object';
17
+ kind: 'object';
18
18
  };
19
19
  export type ValueTypeT = {
20
- kind: 'value';
20
+ kind: 'value';
21
21
  };
22
22
  export type ErrorTypeT = {
23
- kind: 'error';
23
+ kind: 'error';
24
24
  };
25
25
  export type CollatorTypeT = {
26
- kind: 'collator';
26
+ kind: 'collator';
27
27
  };
28
28
  export type FormattedTypeT = {
29
- kind: 'formatted';
29
+ kind: 'formatted';
30
30
  };
31
31
  export type ResolvedImageTypeT = {
32
- kind: 'resolvedImage';
32
+ kind: 'resolvedImage';
33
33
  };
34
34
 
35
35
  export type EvaluationKind = 'constant' | 'source' | 'camera' | 'composite';
@@ -38,9 +38,9 @@ export type Type = NullTypeT | NumberTypeT | StringTypeT | BooleanTypeT | ColorT
38
38
  ArrayType | ErrorTypeT | CollatorTypeT | FormattedTypeT | ResolvedImageTypeT;
39
39
 
40
40
  export type ArrayType = {
41
- kind: 'array';
42
- itemType: Type;
43
- N: number;
41
+ kind: 'array';
42
+ itemType: Type;
43
+ N: number;
44
44
  };
45
45
 
46
46
  export type NativeType = 'number' | 'string' | 'boolean' | 'null' | 'array' | 'object';
@@ -28,7 +28,7 @@ export function validateRGBA(r: unknown, g: unknown, b: unknown, a?: unknown): s
28
28
  }
29
29
 
30
30
  export type Value = null | string | boolean | number | Color | Collator | Formatted | ResolvedImage | ReadonlyArray<Value> | {
31
- readonly [x: string]: Value;
31
+ readonly [x: string]: Value;
32
32
  };
33
33
 
34
34
  export function isValue(mixed: unknown): boolean {