maplibre-gl 2.2.0-pre.3 → 2.2.1

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 (121) hide show
  1. package/README.md +73 -14
  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/generate-typings.ts +1 -1
  6. package/build/rollup_plugins.ts +4 -1
  7. package/dist/maplibre-gl-csp-worker.js +1 -1
  8. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  9. package/dist/maplibre-gl-csp.js +1 -1
  10. package/dist/maplibre-gl-csp.js.map +1 -1
  11. package/dist/maplibre-gl-dev.js +364 -3124
  12. package/dist/maplibre-gl.css +1 -1
  13. package/dist/maplibre-gl.d.ts +439 -151
  14. package/dist/maplibre-gl.js +4 -4
  15. package/dist/maplibre-gl.js.map +1 -1
  16. package/package.json +68 -65
  17. package/src/css/maplibre-gl.css +39 -32
  18. package/src/data/bucket/fill_bucket.test.ts +1 -0
  19. package/src/data/bucket/symbol_bucket.test.ts +2 -0
  20. package/src/data/evaluation_feature.ts +1 -1
  21. package/src/data/program_configuration.ts +2 -2
  22. package/src/geo/transform.ts +4 -4
  23. package/src/gl/vertex_buffer.ts +4 -4
  24. package/src/index.ts +1 -1
  25. package/src/render/image_atlas.ts +1 -0
  26. package/src/render/image_manager.ts +1 -0
  27. package/src/render/program/debug_program.ts +1 -1
  28. package/src/render/render_to_texture.ts +3 -0
  29. package/src/render/terrain.ts +21 -21
  30. package/src/shaders/README.md +2 -2
  31. package/src/source/geojson_worker_source.test.ts +2 -2
  32. package/src/source/geojson_wrapper.test.ts +1 -1
  33. package/src/source/image_source.test.ts +8 -8
  34. package/src/source/image_source.ts +1 -1
  35. package/src/source/raster_tile_source.test.ts +1 -1
  36. package/src/source/source_cache.test.ts +12 -12
  37. package/src/source/source_cache.ts +1 -1
  38. package/src/source/terrain_source_cache.ts +3 -3
  39. package/src/source/vector_tile_source.test.ts +1 -1
  40. package/src/source/vector_tile_worker_source.test.ts +1 -1
  41. package/src/source/video_source.test.ts +2 -2
  42. package/src/source/worker.ts +2 -4
  43. package/src/style/light.test.ts +1 -1
  44. package/src/style/style.test.ts +3 -3
  45. package/src/style/style.ts +2 -2
  46. package/src/style/style_layer/background_style_layer_properties.g.ts +1 -0
  47. package/src/style/style_layer/circle_style_layer_properties.g.ts +1 -0
  48. package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +1 -0
  49. package/src/style/style_layer/fill_style_layer_properties.g.ts +1 -0
  50. package/src/style/style_layer/heatmap_style_layer_properties.g.ts +1 -0
  51. package/src/style/style_layer/hillshade_style_layer_properties.g.ts +1 -0
  52. package/src/style/style_layer/line_style_layer_properties.g.ts +1 -0
  53. package/src/style/style_layer/raster_style_layer_properties.g.ts +1 -0
  54. package/src/style/style_layer/symbol_style_layer.ts +16 -1
  55. package/src/style/style_layer/symbol_style_layer_properties.g.ts +4 -3
  56. package/src/style-spec/CHANGELOG.md +5 -0
  57. package/src/style-spec/composite.test.ts +2 -0
  58. package/src/style-spec/diff.test.ts +3 -3
  59. package/src/style-spec/empty.ts +3 -2
  60. package/src/style-spec/expression/definitions/coercion.ts +13 -2
  61. package/src/style-spec/expression/definitions/interpolate.ts +1 -0
  62. package/src/style-spec/expression/expression.test.ts +1 -1
  63. package/src/style-spec/expression/expression.ts +3 -0
  64. package/src/style-spec/expression/index.ts +8 -2
  65. package/src/style-spec/expression/parsing_context.ts +2 -0
  66. package/src/style-spec/expression/types.ts +6 -1
  67. package/src/style-spec/expression/values.ts +9 -4
  68. package/src/style-spec/feature_filter/convert.ts +65 -65
  69. package/src/style-spec/feature_filter/feature_filter.test.ts +45 -4
  70. package/src/style-spec/feature_filter/index.ts +2 -1
  71. package/src/style-spec/function/index.test.ts +117 -1
  72. package/src/style-spec/function/index.ts +24 -12
  73. package/src/style-spec/migrate/expressions.ts +1 -1
  74. package/src/style-spec/migrate/v8.test.ts +2 -0
  75. package/src/style-spec/migrate/v9.test.ts +6 -4
  76. package/src/style-spec/migrate.test.ts +3 -1
  77. package/src/style-spec/package.json +1 -1
  78. package/src/style-spec/reference/latest.ts +2 -2
  79. package/src/style-spec/reference/v8.json +9 -6
  80. package/src/style-spec/style-spec.test.ts +2 -1
  81. package/src/style-spec/style-spec.ts +18 -9
  82. package/src/style-spec/types.g.ts +152 -36
  83. package/src/style-spec/util/interpolate.test.ts +5 -0
  84. package/src/style-spec/util/interpolate.ts +12 -0
  85. package/src/style-spec/util/padding.test.ts +27 -0
  86. package/src/style-spec/util/padding.ts +64 -0
  87. package/src/style-spec/validate/validate.ts +3 -1
  88. package/src/style-spec/validate/validate_padding.test.ts +82 -0
  89. package/src/style-spec/validate/validate_padding.ts +36 -0
  90. package/src/style-spec/validate_style.ts +1 -1
  91. package/src/symbol/check_max_angle.test.ts +5 -5
  92. package/src/symbol/collision_feature.test.ts +22 -5
  93. package/src/symbol/collision_feature.ts +7 -5
  94. package/src/symbol/collision_index.ts +1 -1
  95. package/src/symbol/get_anchors.test.ts +4 -4
  96. package/src/symbol/projection.ts +1 -1
  97. package/src/symbol/quads.test.ts +1 -1
  98. package/src/symbol/shaping.ts +10 -10
  99. package/src/symbol/symbol_layout.ts +5 -4
  100. package/src/symbol/symbol_style_layer.test.ts +1 -1
  101. package/src/ui/camera.test.ts +11 -11
  102. package/src/ui/control/geolocate_control.ts +1 -1
  103. package/src/ui/control/terrain_control.ts +4 -4
  104. package/src/ui/handler/cooperative_gestures.test.ts +167 -0
  105. package/src/ui/handler/drag_pan.test.ts +2 -1
  106. package/src/ui/handler/scroll_zoom.ts +7 -0
  107. package/src/ui/handler/touch_pan.ts +22 -2
  108. package/src/ui/handler/touch_zoom_rotate.ts +18 -1
  109. package/src/ui/handler_manager.ts +2 -2
  110. package/src/ui/map.test.ts +16 -16
  111. package/src/ui/map.ts +76 -8
  112. package/src/ui/map_events.test.ts +33 -32
  113. package/src/ui/popup.test.ts +2 -2
  114. package/src/util/ajax.test.ts +5 -5
  115. package/src/util/ajax.ts +1 -1
  116. package/src/util/classify_rings.test.ts +27 -27
  117. package/src/util/primitives.ts +4 -4
  118. package/src/util/resolve_tokens.test.ts +1 -1
  119. package/src/util/tile_request_cache.test.ts +5 -5
  120. package/src/util/util.test.ts +5 -5
  121. package/src/util/util.ts +2 -3
@@ -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();
@@ -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');
@@ -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 => {
package/src/util/util.ts CHANGED
@@ -384,7 +384,6 @@ export function sphericalToCartesian([r, azimuthal, polar]: [number, number, num
384
384
  };
385
385
  }
386
386
 
387
- /* global self, WorkerGlobalScope */
388
387
  /**
389
388
  * Returns true if the when run in the web-worker context.
390
389
  *
@@ -392,8 +391,8 @@ export function sphericalToCartesian([r, azimuthal, polar]: [number, number, num
392
391
  * @returns {boolean}
393
392
  */
394
393
  export function isWorker(): boolean {
395
- return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' &&
396
- self instanceof WorkerGlobalScope;
394
+ // @ts-ignore
395
+ return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
397
396
  }
398
397
 
399
398
  /**