maplibre-gl 2.2.0-pre.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +73 -8
  2. package/build/generate-debug-index-file.ts +19 -0
  3. package/build/generate-style-code.ts +6 -1
  4. package/build/generate-style-spec.ts +151 -35
  5. package/build/rollup_plugins.ts +4 -1
  6. package/dist/maplibre-gl-csp-worker.js +1 -1
  7. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  8. package/dist/maplibre-gl-csp.js +1 -1
  9. package/dist/maplibre-gl-csp.js.map +1 -1
  10. package/dist/maplibre-gl-dev.js +1317 -4304
  11. package/dist/maplibre-gl.css +1 -1
  12. package/dist/maplibre-gl.d.ts +443 -145
  13. package/dist/maplibre-gl.js +4 -4
  14. package/dist/maplibre-gl.js.map +1 -1
  15. package/package.json +70 -67
  16. package/src/css/maplibre-gl.css +48 -32
  17. package/src/data/bucket/fill_bucket.test.ts +1 -0
  18. package/src/data/bucket/symbol_bucket.test.ts +2 -0
  19. package/src/data/bucket/symbol_bucket.ts +1 -1
  20. package/src/data/evaluation_feature.ts +1 -1
  21. package/src/data/program_configuration.ts +2 -2
  22. package/src/geo/transform.test.ts +34 -1
  23. package/src/geo/transform.ts +25 -15
  24. package/src/gl/vertex_buffer.ts +4 -4
  25. package/src/index.ts +1 -1
  26. package/src/render/draw_debug.ts +1 -1
  27. package/src/render/draw_symbol.test.ts +2 -23
  28. package/src/render/draw_terrain.ts +1 -1
  29. package/src/render/image_atlas.ts +1 -0
  30. package/src/render/image_manager.ts +1 -0
  31. package/src/render/program/debug_program.ts +1 -1
  32. package/src/render/render_to_texture.ts +3 -0
  33. package/src/render/terrain.test.ts +119 -17
  34. package/src/render/terrain.ts +39 -21
  35. package/src/shaders/README.md +2 -2
  36. package/src/shaders/shaders.ts +3 -1
  37. package/src/source/geojson_worker_source.test.ts +2 -2
  38. package/src/source/geojson_wrapper.test.ts +1 -1
  39. package/src/source/image_source.test.ts +8 -8
  40. package/src/source/image_source.ts +1 -1
  41. package/src/source/load_tilejson.ts +6 -1
  42. package/src/source/pixels_to_tile_units.ts +1 -1
  43. package/src/source/raster_tile_source.test.ts +1 -1
  44. package/src/source/source_cache.test.ts +12 -12
  45. package/src/source/source_cache.ts +1 -1
  46. package/src/source/terrain_source_cache.test.ts +17 -2
  47. package/src/source/terrain_source_cache.ts +16 -12
  48. package/src/source/vector_tile_source.test.ts +1 -1
  49. package/src/source/vector_tile_worker_source.test.ts +1 -1
  50. package/src/source/video_source.test.ts +2 -2
  51. package/src/style/light.test.ts +1 -1
  52. package/src/style/load_sprite.ts +1 -1
  53. package/src/style/parse_glyph_pbf.ts +1 -1
  54. package/src/style/style.test.ts +3 -3
  55. package/src/style/style.ts +2 -2
  56. package/src/style/style_layer/background_style_layer_properties.g.ts +1 -0
  57. package/src/style/style_layer/circle_style_layer_properties.g.ts +1 -0
  58. package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +1 -0
  59. package/src/style/style_layer/fill_style_layer_properties.g.ts +1 -0
  60. package/src/style/style_layer/heatmap_style_layer_properties.g.ts +1 -0
  61. package/src/style/style_layer/hillshade_style_layer_properties.g.ts +1 -0
  62. package/src/style/style_layer/line_style_layer_properties.g.ts +1 -0
  63. package/src/style/style_layer/raster_style_layer_properties.g.ts +1 -0
  64. package/src/style/style_layer/symbol_style_layer.ts +16 -1
  65. package/src/style/style_layer/symbol_style_layer_properties.g.ts +4 -3
  66. package/src/style-spec/CHANGELOG.md +5 -0
  67. package/src/style-spec/composite.test.ts +2 -0
  68. package/src/style-spec/composite.ts +3 -2
  69. package/src/style-spec/diff.test.ts +3 -3
  70. package/src/style-spec/empty.ts +3 -2
  71. package/src/style-spec/expression/compound_expression.ts +0 -4
  72. package/src/style-spec/expression/definitions/assertion.ts +0 -18
  73. package/src/style-spec/expression/definitions/at.ts +0 -4
  74. package/src/style-spec/expression/definitions/case.ts +0 -6
  75. package/src/style-spec/expression/definitions/coalesce.ts +0 -6
  76. package/src/style-spec/expression/definitions/coercion.ts +13 -18
  77. package/src/style-spec/expression/definitions/collator.ts +0 -10
  78. package/src/style-spec/expression/definitions/comparison.ts +0 -6
  79. package/src/style-spec/expression/definitions/format.ts +0 -19
  80. package/src/style-spec/expression/definitions/image.ts +0 -4
  81. package/src/style-spec/expression/definitions/in.ts +0 -4
  82. package/src/style-spec/expression/definitions/index_of.ts +0 -8
  83. package/src/style-spec/expression/definitions/interpolate.ts +1 -25
  84. package/src/style-spec/expression/definitions/length.ts +0 -6
  85. package/src/style-spec/expression/definitions/let.ts +0 -9
  86. package/src/style-spec/expression/definitions/literal.ts +1 -23
  87. package/src/style-spec/expression/definitions/match.ts +0 -41
  88. package/src/style-spec/expression/definitions/number_format.ts +0 -17
  89. package/src/style-spec/expression/definitions/slice.ts +0 -8
  90. package/src/style-spec/expression/definitions/step.ts +0 -11
  91. package/src/style-spec/expression/definitions/var.ts +0 -4
  92. package/src/style-spec/expression/definitions/within.ts +0 -5
  93. package/src/style-spec/expression/expression.test.ts +1 -1
  94. package/src/style-spec/expression/expression.ts +3 -3
  95. package/src/style-spec/expression/index.ts +8 -2
  96. package/src/style-spec/expression/parsing_context.ts +2 -0
  97. package/src/style-spec/expression/types/formatted.ts +0 -23
  98. package/src/style-spec/expression/types/resolved_image.ts +0 -4
  99. package/src/style-spec/expression/types.ts +6 -1
  100. package/src/style-spec/expression/values.ts +9 -4
  101. package/src/style-spec/feature_filter/convert.ts +65 -65
  102. package/src/style-spec/feature_filter/feature_filter.test.ts +45 -4
  103. package/src/style-spec/feature_filter/index.ts +2 -1
  104. package/src/style-spec/function/index.test.ts +117 -1
  105. package/src/style-spec/function/index.ts +24 -12
  106. package/src/style-spec/migrate/expressions.ts +2 -2
  107. package/src/style-spec/migrate/v8.test.ts +2 -0
  108. package/src/style-spec/migrate/v8.ts +8 -7
  109. package/src/style-spec/migrate/v9.test.ts +6 -4
  110. package/src/style-spec/migrate/v9.ts +3 -2
  111. package/src/style-spec/migrate.test.ts +3 -1
  112. package/src/style-spec/migrate.ts +5 -4
  113. package/src/style-spec/package.json +1 -1
  114. package/src/style-spec/read_style.ts +2 -1
  115. package/src/style-spec/reference/latest.ts +1 -1
  116. package/src/style-spec/reference/v8.json +9 -6
  117. package/src/style-spec/style-spec.test.ts +2 -1
  118. package/src/style-spec/style-spec.ts +8 -0
  119. package/src/style-spec/types.g.ts +152 -36
  120. package/src/style-spec/util/extend.ts +1 -1
  121. package/src/style-spec/util/interpolate.test.ts +5 -0
  122. package/src/style-spec/util/interpolate.ts +12 -0
  123. package/src/style-spec/util/padding.test.ts +27 -0
  124. package/src/style-spec/util/padding.ts +64 -0
  125. package/src/style-spec/util/ref_properties.ts +2 -1
  126. package/src/style-spec/validate/validate.ts +3 -1
  127. package/src/style-spec/validate/validate_expression.ts +2 -1
  128. package/src/style-spec/validate/validate_function.ts +2 -2
  129. package/src/style-spec/validate/validate_glyphs_url.ts +1 -1
  130. package/src/style-spec/validate/validate_object.ts +2 -2
  131. package/src/style-spec/validate/validate_padding.test.ts +82 -0
  132. package/src/style-spec/validate/validate_padding.ts +36 -0
  133. package/src/style-spec/validate_style.min.ts +4 -3
  134. package/src/style-spec/validate_style.ts +4 -3
  135. package/src/symbol/check_max_angle.test.ts +5 -5
  136. package/src/symbol/collision_feature.test.ts +22 -5
  137. package/src/symbol/collision_feature.ts +7 -5
  138. package/src/symbol/collision_index.ts +1 -1
  139. package/src/symbol/get_anchors.test.ts +4 -4
  140. package/src/symbol/{mergelines.test.ts → merge_lines.test.ts} +1 -1
  141. package/src/symbol/{mergelines.ts → merge_lines.ts} +1 -1
  142. package/src/symbol/projection.ts +1 -1
  143. package/src/symbol/quads.test.ts +1 -1
  144. package/src/symbol/shaping.ts +10 -10
  145. package/src/symbol/symbol_layout.ts +5 -4
  146. package/src/symbol/symbol_style_layer.test.ts +1 -1
  147. package/src/symbol/transform_text.ts +3 -3
  148. package/src/ui/camera.test.ts +11 -11
  149. package/src/ui/control/geolocate_control.ts +1 -1
  150. package/src/ui/control/terrain_control.ts +4 -4
  151. package/src/ui/handler/cooperative_gestures.test.ts +167 -0
  152. package/src/ui/handler/drag_pan.test.ts +2 -1
  153. package/src/ui/handler/scroll_zoom.ts +7 -0
  154. package/src/ui/handler/touch_pan.ts +22 -2
  155. package/src/ui/handler/touch_zoom_rotate.ts +18 -1
  156. package/src/ui/handler_manager.ts +2 -2
  157. package/src/ui/map.test.ts +17 -17
  158. package/src/ui/map.ts +76 -8
  159. package/src/ui/map_events.test.ts +33 -32
  160. package/src/ui/popup.test.ts +2 -2
  161. package/src/util/ajax.test.ts +5 -5
  162. package/src/util/ajax.ts +1 -1
  163. package/src/util/classify_rings.test.ts +27 -27
  164. package/src/util/find_pole_of_inaccessibility.ts +1 -1
  165. package/src/util/primitives.ts +4 -4
  166. package/src/util/resolve_tokens.test.ts +1 -1
  167. package/src/util/smart_wrap.ts +1 -1
  168. package/src/util/tile_request_cache.test.ts +5 -5
  169. package/src/util/util.test.ts +5 -5
@@ -1,6 +1,7 @@
1
1
  import simulate, {window} from '../../test/unit/lib/simulate_interaction';
2
2
  import StyleLayer from '../style/style_layer';
3
3
  import {createMap, setPerformance, setWebGlContext} from '../util/test/util';
4
+ import {MapGeoJSONFeature} from '../util/vectortile_to_geojson';
4
5
  import {MapLayerEventType} from './events';
5
6
 
6
7
  beforeEach(() => {
@@ -37,10 +38,10 @@ describe('map events', () => {
37
38
 
38
39
  test('Map#on adds a listener for an event on a given layer', () => {
39
40
  const map = createMap();
40
- const features = [{}];
41
+ const features = [{} as MapGeoJSONFeature];
41
42
 
42
43
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
43
- jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => {
44
+ jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => {
44
45
  expect(options).toEqual({layers: ['layer']});
45
46
  return features;
46
47
  });
@@ -79,7 +80,7 @@ describe('map events', () => {
79
80
  test('Map#on adds a listener not triggered when the specified layer does not exiist', () => {
80
81
  const map = createMap();
81
82
 
82
- jest.spyOn(map, 'getLayer').mockReturnValue(null);
83
+ jest.spyOn(map, 'getLayer').mockReturnValue(null as unknown as StyleLayer);
83
84
 
84
85
  const spy = jest.fn();
85
86
 
@@ -94,7 +95,7 @@ describe('map events', () => {
94
95
  const map = createMap();
95
96
 
96
97
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
97
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
98
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
98
99
 
99
100
  const spyDown = jest.fn((e) => {
100
101
  expect(e.type).toBe('mousedown');
@@ -114,11 +115,11 @@ describe('map events', () => {
114
115
 
115
116
  test('Map#on distinguishes distinct layers', () => {
116
117
  const map = createMap();
117
- const featuresA = [{}];
118
- const featuresB = [{}];
118
+ const featuresA = [{} as MapGeoJSONFeature];
119
+ const featuresB = [{} as MapGeoJSONFeature];
119
120
 
120
121
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
121
- jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => {
122
+ jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => {
122
123
  return (options as any).layers[0] === 'A' ? featuresA : featuresB;
123
124
  });
124
125
 
@@ -142,7 +143,7 @@ describe('map events', () => {
142
143
  const map = createMap();
143
144
 
144
145
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
145
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
146
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
146
147
 
147
148
  const spyA = jest.fn();
148
149
  const spyB = jest.fn();
@@ -159,7 +160,7 @@ describe('map events', () => {
159
160
  const map = createMap();
160
161
 
161
162
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
162
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
163
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
163
164
 
164
165
  const spy = jest.fn();
165
166
 
@@ -175,7 +176,7 @@ describe('map events', () => {
175
176
  const map = createMap();
176
177
 
177
178
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
178
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
179
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
179
180
 
180
181
  const spy = jest.fn((e) => {
181
182
  expect(e.type).toBe('mousedown');
@@ -191,7 +192,7 @@ describe('map events', () => {
191
192
 
192
193
  test('Map#off distinguishes distinct layers', () => {
193
194
  const map = createMap();
194
- const featuresA = [{}];
195
+ const featuresA = [{} as MapGeoJSONFeature];
195
196
 
196
197
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
197
198
  jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => {
@@ -215,7 +216,7 @@ describe('map events', () => {
215
216
  const map = createMap();
216
217
 
217
218
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
218
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
219
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
219
220
 
220
221
  const spyA = jest.fn();
221
222
  const spyB = jest.fn();
@@ -233,7 +234,7 @@ describe('map events', () => {
233
234
  test(`Map#on ${event} does not fire if the specified layer does not exist`, () => {
234
235
  const map = createMap();
235
236
 
236
- jest.spyOn(map, 'getLayer').mockReturnValue(null);
237
+ jest.spyOn(map, 'getLayer').mockReturnValue(null as unknown as StyleLayer);
237
238
 
238
239
  const spy = jest.fn();
239
240
 
@@ -247,10 +248,10 @@ describe('map events', () => {
247
248
 
248
249
  test(`Map#on ${event} fires when entering the specified layer`, () => {
249
250
  const map = createMap();
250
- const features = [{}];
251
+ const features = [{} as MapGeoJSONFeature];
251
252
 
252
253
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
253
- jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => {
254
+ jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => {
254
255
  expect(options).toEqual({layers: ['layer']});
255
256
  return features;
256
257
  });
@@ -272,7 +273,7 @@ describe('map events', () => {
272
273
  const map = createMap();
273
274
 
274
275
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
275
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
276
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
276
277
 
277
278
  const spy = jest.fn();
278
279
 
@@ -288,9 +289,9 @@ describe('map events', () => {
288
289
 
289
290
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
290
291
  jest.spyOn(map, 'queryRenderedFeatures')
291
- .mockReturnValueOnce([{}])
292
+ .mockReturnValueOnce([{} as MapGeoJSONFeature])
292
293
  .mockReturnValueOnce([])
293
- .mockReturnValueOnce([{}]);
294
+ .mockReturnValueOnce([{} as MapGeoJSONFeature]);
294
295
 
295
296
  const spy = jest.fn();
296
297
 
@@ -306,7 +307,7 @@ describe('map events', () => {
306
307
  const map = createMap();
307
308
 
308
309
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
309
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
310
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
310
311
 
311
312
  const spy = jest.fn();
312
313
 
@@ -320,11 +321,11 @@ describe('map events', () => {
320
321
 
321
322
  test(`Map#on ${event} distinguishes distinct layers`, () => {
322
323
  const map = createMap();
323
- const featuresA = [{}];
324
- const featuresB = [{}];
324
+ const featuresA = [{} as MapGeoJSONFeature];
325
+ const featuresB = [{} as MapGeoJSONFeature];
325
326
 
326
327
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
327
- jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => {
328
+ jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => {
328
329
  return (options as any).layers[0] === 'A' ? featuresA : featuresB;
329
330
  });
330
331
 
@@ -350,7 +351,7 @@ describe('map events', () => {
350
351
  const map = createMap();
351
352
 
352
353
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
353
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
354
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
354
355
 
355
356
  const spyA = jest.fn();
356
357
  const spyB = jest.fn();
@@ -367,7 +368,7 @@ describe('map events', () => {
367
368
  const map = createMap();
368
369
 
369
370
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
370
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
371
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
371
372
 
372
373
  const spy = jest.fn();
373
374
 
@@ -381,10 +382,10 @@ describe('map events', () => {
381
382
 
382
383
  test(`Map#off ${event} distinguishes distinct layers`, () => {
383
384
  const map = createMap();
384
- const featuresA = [{}];
385
+ const featuresA = [{} as MapGeoJSONFeature];
385
386
 
386
387
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
387
- jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((point, options) => {
388
+ jest.spyOn(map, 'queryRenderedFeatures').mockImplementation((_point, options) => {
388
389
  expect(options).toEqual({layers: ['A']});
389
390
  return featuresA;
390
391
  });
@@ -405,7 +406,7 @@ describe('map events', () => {
405
406
  const map = createMap();
406
407
 
407
408
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
408
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
409
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
409
410
 
410
411
  const spyA = jest.fn();
411
412
  const spyB = jest.fn();
@@ -424,7 +425,7 @@ describe('map events', () => {
424
425
  test(`Map#on ${event} does not fire if the specified layer does not exiist`, () => {
425
426
  const map = createMap();
426
427
 
427
- jest.spyOn(map, 'getLayer').mockReturnValue(null);
428
+ jest.spyOn(map, 'getLayer').mockReturnValue(null as unknown as StyleLayer);
428
429
 
429
430
  const spy = jest.fn();
430
431
 
@@ -440,7 +441,7 @@ describe('map events', () => {
440
441
  const map = createMap();
441
442
 
442
443
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
443
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
444
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
444
445
 
445
446
  const spy = jest.fn();
446
447
 
@@ -457,7 +458,7 @@ describe('map events', () => {
457
458
 
458
459
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
459
460
  jest.spyOn(map, 'queryRenderedFeatures')
460
- .mockReturnValueOnce([{}])
461
+ .mockReturnValueOnce([{} as MapGeoJSONFeature])
461
462
  .mockReturnValueOnce([]);
462
463
 
463
464
  const spy = jest.fn(function (e) {
@@ -477,7 +478,7 @@ describe('map events', () => {
477
478
  const map = createMap();
478
479
 
479
480
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
480
- jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{}]);
481
+ jest.spyOn(map, 'queryRenderedFeatures').mockReturnValue([{} as MapGeoJSONFeature]);
481
482
 
482
483
  const spy = jest.fn(function (e) {
483
484
  expect(this).toBe(map);
@@ -497,7 +498,7 @@ describe('map events', () => {
497
498
 
498
499
  jest.spyOn(map, 'getLayer').mockReturnValue({} as StyleLayer);
499
500
  jest.spyOn(map, 'queryRenderedFeatures')
500
- .mockReturnValueOnce([{}])
501
+ .mockReturnValueOnce([{} as MapGeoJSONFeature])
501
502
  .mockReturnValueOnce([]);
502
503
 
503
504
  const spy = jest.fn();
@@ -625,8 +625,8 @@ describe('popup', () => {
625
625
  .trackPointer()
626
626
  .addTo(map);
627
627
 
628
- simulate.mousemove(map.getCanvas(), {screenX:0, screenY:0});
629
- expect(popup._pos).toEqual({x:0, y:0});
628
+ simulate.mousemove(map.getCanvas(), {screenX: 0, screenY: 0});
629
+ expect(popup._pos).toEqual({x: 0, y: 0});
630
630
  });
631
631
 
632
632
  test('Popup closes on Map#remove', () => {
@@ -34,7 +34,7 @@ describe('ajax', () => {
34
34
  server.respondWith(request => {
35
35
  request.respond(404, undefined, '404 Not Found');
36
36
  });
37
- getArrayBuffer({url:'http://example.com/test.bin'}, async (error) => {
37
+ getArrayBuffer({url: 'http://example.com/test.bin'}, async (error) => {
38
38
  const ajaxError = error as AJAXError;
39
39
  const body = await readAsText(ajaxError.body);
40
40
  expect(ajaxError.status).toBe(404);
@@ -50,7 +50,7 @@ describe('ajax', () => {
50
50
  server.respondWith(request => {
51
51
  request.respond(200, {'Content-Type': 'application/json'}, '{"foo": "bar"}');
52
52
  });
53
- getJSON({url:''}, (error, body) => {
53
+ getJSON({url: ''}, (error, body) => {
54
54
  expect(error).toBeFalsy();
55
55
  expect(body).toEqual({foo: 'bar'});
56
56
  done();
@@ -62,7 +62,7 @@ describe('ajax', () => {
62
62
  server.respondWith(request => {
63
63
  request.respond(200, {'Content-Type': 'application/json'}, 'how do i even');
64
64
  });
65
- getJSON({url:''}, (error) => {
65
+ getJSON({url: ''}, (error) => {
66
66
  expect(error).toBeTruthy();
67
67
  done();
68
68
  });
@@ -73,7 +73,7 @@ describe('ajax', () => {
73
73
  server.respondWith(request => {
74
74
  request.respond(404, undefined, '404 Not Found');
75
75
  });
76
- getJSON({url:'http://example.com/test.json'}, async (error) => {
76
+ getJSON({url: 'http://example.com/test.json'}, async (error) => {
77
77
  const ajaxError = error as AJAXError;
78
78
  const body = await readAsText(ajaxError.body);
79
79
  expect(ajaxError.status).toBe(404);
@@ -89,7 +89,7 @@ describe('ajax', () => {
89
89
  server.respondWith(request => {
90
90
  request.respond(204, undefined, undefined);
91
91
  });
92
- postData({url:'api.mapbox.com'}, (error) => {
92
+ postData({url: 'api.mapbox.com'}, (error) => {
93
93
  expect(error).toBeNull();
94
94
  done();
95
95
  });
package/src/util/ajax.ts CHANGED
@@ -341,7 +341,7 @@ function arrayBufferToImageBitmap(data: ArrayBuffer, callback: (err?: Error | nu
341
341
  });
342
342
  }
343
343
 
344
- export type ExpiryData = {cacheControl?: string | null; expires?: string | null};
344
+ export type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null};
345
345
 
346
346
  function arrayBufferToCanvasImageSource(data: ArrayBuffer, callback: Callback<CanvasImageSource>) {
347
347
  const imageBitmapSupported = typeof createImageBitmap === 'function';
@@ -16,11 +16,11 @@ describe('classifyRings', () => {
16
16
 
17
17
  geometry = [
18
18
  [
19
- {x:0, y:0},
20
- {x:0, y:40},
21
- {x:40, y:40},
22
- {x:40, y:0},
23
- {x:0, y:0}
19
+ {x: 0, y: 0},
20
+ {x: 0, y: 40},
21
+ {x: 40, y: 40},
22
+ {x: 40, y: 0},
23
+ {x: 0, y: 0}
24
24
  ]
25
25
  ];
26
26
  classified = classifyRings(geometry, undefined);
@@ -29,18 +29,18 @@ describe('classifyRings', () => {
29
29
 
30
30
  geometry = [
31
31
  [
32
- {x:0, y:0},
33
- {x:0, y:40},
34
- {x:40, y:40},
35
- {x:40, y:0},
36
- {x:0, y:0}
32
+ {x: 0, y: 0},
33
+ {x: 0, y: 40},
34
+ {x: 40, y: 40},
35
+ {x: 40, y: 0},
36
+ {x: 0, y: 0}
37
37
  ],
38
38
  [
39
- {x:60, y:0},
40
- {x:60, y:40},
41
- {x:100, y:40},
42
- {x:100, y:0},
43
- {x:60, y:0}
39
+ {x: 60, y: 0},
40
+ {x: 60, y: 40},
41
+ {x: 100, y: 40},
42
+ {x: 100, y: 0},
43
+ {x: 60, y: 0}
44
44
  ]
45
45
  ];
46
46
  classified = classifyRings(geometry, undefined);
@@ -50,17 +50,17 @@ describe('classifyRings', () => {
50
50
 
51
51
  geometry = [
52
52
  [
53
- {x:0, y:0},
54
- {x:0, y:40},
55
- {x:40, y:40},
56
- {x:40, y:0},
57
- {x:0, y:0}
53
+ {x: 0, y: 0},
54
+ {x: 0, y: 40},
55
+ {x: 40, y: 40},
56
+ {x: 40, y: 0},
57
+ {x: 0, y: 0}
58
58
  ],
59
59
  [
60
- {x:10, y:10},
61
- {x:20, y:10},
62
- {x:20, y:20},
63
- {x:10, y:10}
60
+ {x: 10, y: 10},
61
+ {x: 20, y: 10},
62
+ {x: 20, y: 20},
63
+ {x: 10, y: 10}
64
64
  ]
65
65
  ];
66
66
  classified = classifyRings(geometry, undefined);
@@ -80,11 +80,11 @@ describe('classifyRings + maxRings', () => {
80
80
  function createGeometry(options?) {
81
81
  const geometry = [
82
82
  // Outer ring, area = 3200
83
- [ {x:0, y:0}, {x:0, y:40}, {x:40, y:40}, {x:40, y:0}, {x:0, y:0} ],
83
+ [{x: 0, y: 0}, {x: 0, y: 40}, {x: 40, y: 40}, {x: 40, y: 0}, {x: 0, y: 0}],
84
84
  // Inner ring, area = 100
85
- [ {x:30, y:30}, {x:32, y:30}, {x:32, y:32}, {x:30, y:30} ],
85
+ [{x: 30, y: 30}, {x: 32, y: 30}, {x: 32, y: 32}, {x: 30, y: 30}],
86
86
  // Inner ring, area = 4
87
- [ {x:10, y:10}, {x:20, y:10}, {x:20, y:20}, {x:10, y:10} ]
87
+ [{x: 10, y: 10}, {x: 20, y: 10}, {x: 20, y: 20}, {x: 10, y: 10}]
88
88
  ] as Point[][];
89
89
  if (options && options.reverse) {
90
90
  geometry[0].reverse();
@@ -13,7 +13,7 @@ import {distToSegmentSquared} from './intersection_tests';
13
13
  * @returns Pole of Inaccessibiliy.
14
14
  * @private
15
15
  */
16
- export default function(
16
+ export default function findPoleOfInaccessibility(
17
17
  polygonRings: Array<Array<Point>>,
18
18
  precision: number = 1,
19
19
  debug: boolean = false
@@ -7,12 +7,12 @@ class Frustum {
7
7
  public static fromInvProjectionMatrix(invProj: mat4, worldSize: number, zoom: number): Frustum {
8
8
  const clipSpaceCorners = [
9
9
  [-1, 1, -1, 1],
10
- [ 1, 1, -1, 1],
11
- [ 1, -1, -1, 1],
10
+ [1, 1, -1, 1],
11
+ [1, -1, -1, 1],
12
12
  [-1, -1, -1, 1],
13
13
  [-1, 1, 1, 1],
14
- [ 1, 1, 1, 1],
15
- [ 1, -1, 1, 1],
14
+ [1, 1, 1, 1],
15
+ [1, -1, 1, 1],
16
16
  [-1, -1, 1, 1]
17
17
  ];
18
18
 
@@ -1,7 +1,7 @@
1
1
  import resolveTokens from './resolve_tokens';
2
2
 
3
3
  test('resolveToken', () => {
4
- expect('3 Fine Fields').toBe(resolveTokens({a:3, b:'Fine', c:'Fields'}, '{a} {b} {c}'));
4
+ expect('3 Fine Fields').toBe(resolveTokens({a: 3, b: 'Fine', c: 'Fields'}, '{a} {b} {c}'));
5
5
 
6
6
  // No tokens.
7
7
  expect(resolveTokens({}, 'Test')).toBe('Test');
@@ -18,7 +18,7 @@ import type Transform from '../geo/transform';
18
18
  *
19
19
  * @private
20
20
  */
21
- export default function(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {
21
+ export default function smartWrap(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {
22
22
  lngLat = new LngLat(lngLat.lng, lngLat.lat);
23
23
 
24
24
  // First, try shifting one world in either direction, and see if either is closer to the
@@ -21,7 +21,7 @@ describe('tile_request_cache', () => {
21
21
 
22
22
  let result;
23
23
  try {
24
- result = cachePut({url:''} as Request, undefined, undefined);
24
+ result = cachePut({url: ''} as Request, undefined, undefined);
25
25
  expect(result).toBeFalsy();
26
26
  } catch (e) {
27
27
  expect(e).toBeFalsy();
@@ -32,7 +32,7 @@ describe('tile_request_cache', () => {
32
32
  test('cacheGet, no caches', done => {
33
33
  delete global.caches;
34
34
 
35
- cacheGet({url:''} as Request, (result) => {
35
+ cacheGet({url: ''} as Request, (result) => {
36
36
  expect(result).toBeFalsy();
37
37
  expect(result).toBeNull();
38
38
  done();
@@ -42,7 +42,7 @@ describe('tile_request_cache', () => {
42
42
  test('cacheGet, cache open error', done => {
43
43
  global.caches.open = jest.fn().mockRejectedValue(new Error('The operation is insecure'));
44
44
 
45
- cacheGet({url:''} as Request, (error) => {
45
+ cacheGet({url: ''} as Request, (error) => {
46
46
  expect(error).toBeTruthy();
47
47
  expect(error.message).toBe('The operation is insecure');
48
48
  done();
@@ -55,7 +55,7 @@ describe('tile_request_cache', () => {
55
55
  };
56
56
  global.caches.open = jest.fn().mockResolvedValue(fakeCache);
57
57
 
58
- cacheGet({url:'someurl'} as Request, (error) => {
58
+ cacheGet({url: 'someurl'} as Request, (error) => {
59
59
  expect(error).toBeTruthy();
60
60
  expect(error.message).toBe('ohno');
61
61
  done();
@@ -86,7 +86,7 @@ describe('tile_request_cache', () => {
86
86
  };
87
87
  global.caches.open = jest.fn().mockResolvedValue(fakeCache);
88
88
 
89
- cacheGet({url:'someurl'} as Request, (error, response, fresh) => {
89
+ cacheGet({url: 'someurl'} as Request, (error, response, fresh) => {
90
90
  expect(error).toBeFalsy();
91
91
  expect(fakeCache.match).toHaveBeenCalledWith('someurl');
92
92
  expect(fakeCache.delete).toHaveBeenCalledWith('someurl');
@@ -6,11 +6,11 @@ describe('util', () => {
6
6
  expect(easeCubicInOut(0.2)).toBe(0.03200000000000001);
7
7
  expect(easeCubicInOut(0.5)).toBe(0.5);
8
8
  expect(easeCubicInOut(1)).toBe(1);
9
- expect(keysDifference({a:1}, {})).toEqual(['a']);
10
- expect(keysDifference({a:1}, {a:1})).toEqual([]);
11
- expect(extend({a:1}, {b:2})).toEqual({a:1, b:2});
12
- expect(pick({a:1, b:2, c:3}, ['a', 'c'])).toEqual({a:1, c:3});
13
- expect(pick({a:1, b:2, c:3}, ['a', 'c', 'd'])).toEqual({a:1, c:3});
9
+ expect(keysDifference({a: 1}, {})).toEqual(['a']);
10
+ expect(keysDifference({a: 1}, {a: 1})).toEqual([]);
11
+ expect(extend({a: 1}, {b: 2})).toEqual({a: 1, b: 2});
12
+ expect(pick({a: 1, b: 2, c: 3}, ['a', 'c'])).toEqual({a: 1, c: 3});
13
+ expect(pick({a: 1, b: 2, c: 3}, ['a', 'c', 'd'])).toEqual({a: 1, c: 3});
14
14
  expect(typeof uniqueId() === 'number').toBeTruthy();
15
15
 
16
16
  test('bindAll', done => {