maplibre-gl 2.3.0 → 2.4.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 (79) hide show
  1. package/build/generate-query-test-fixtures.ts +3 -2
  2. package/build/generate-struct-arrays.ts +0 -2
  3. package/build/generate-style-spec.ts +12 -17
  4. package/build/rollup_plugins.ts +0 -4
  5. package/dist/maplibre-gl-csp-worker.js +1 -1
  6. package/dist/maplibre-gl-csp.js +1 -1
  7. package/dist/maplibre-gl-dev.js +179 -1369
  8. package/dist/maplibre-gl.d.ts +15 -16
  9. package/dist/maplibre-gl.js +4 -4
  10. package/dist/style-spec/index.d.ts +3 -16
  11. package/package.json +20 -21
  12. package/src/data/array_types.g.ts +0 -5
  13. package/src/data/bucket/fill_bucket.ts +0 -2
  14. package/src/data/bucket/fill_extrusion_bucket.ts +0 -2
  15. package/src/data/feature_position_map.ts +1 -2
  16. package/src/gl/framebuffer.ts +3 -2
  17. package/src/gl/index_buffer.ts +1 -2
  18. package/src/gl/vertex_buffer.ts +1 -2
  19. package/src/index.ts +1 -3
  20. package/src/render/draw_debug.ts +1 -1
  21. package/src/render/draw_fill.ts +9 -1
  22. package/src/render/draw_fill_extrusion.ts +8 -1
  23. package/src/render/draw_heatmap.ts +5 -3
  24. package/src/render/draw_hillshade.ts +17 -2
  25. package/src/render/image_manager.ts +5 -7
  26. package/src/render/program/line_program.ts +1 -1
  27. package/src/render/program/pattern.ts +0 -2
  28. package/src/render/program.ts +12 -9
  29. package/src/render/vertex_array_object.ts +1 -3
  30. package/src/source/geojson_worker_source.ts +0 -4
  31. package/src/source/query_features.ts +0 -3
  32. package/src/source/rtl_text_plugin.ts +3 -4
  33. package/src/source/source_cache.ts +0 -2
  34. package/src/source/tile_id.ts +8 -8
  35. package/src/source/worker.ts +0 -7
  36. package/src/source/worker_tile.ts +3 -2
  37. package/src/style/format_section_override.ts +1 -2
  38. package/src/style/properties.ts +1 -3
  39. package/src/style/style.ts +6 -5
  40. package/src/style/style_layer/custom_style_layer.ts +1 -2
  41. package/src/style/style_layer/symbol_style_layer.ts +5 -8
  42. package/src/style-spec/CHANGELOG.md +2 -2
  43. package/src/style-spec/expression/compound_expression.ts +0 -4
  44. package/src/style-spec/expression/definitions/assertion.ts +2 -4
  45. package/src/style-spec/expression/definitions/case.ts +1 -2
  46. package/src/style-spec/expression/definitions/coalesce.ts +1 -3
  47. package/src/style-spec/expression/definitions/coercion.ts +2 -4
  48. package/src/style-spec/expression/definitions/match.ts +0 -3
  49. package/src/style-spec/expression/index.ts +0 -2
  50. package/src/style-spec/expression/values.ts +0 -2
  51. package/src/style-spec/feature_filter/feature_filter.test.ts +39 -2
  52. package/src/style-spec/function/convert.ts +1 -3
  53. package/src/style-spec/types.g.ts +12 -17
  54. package/src/symbol/collision_index.ts +0 -3
  55. package/src/symbol/path_interpolator.ts +0 -2
  56. package/src/symbol/placement.ts +14 -9
  57. package/src/symbol/shaping.ts +0 -4
  58. package/src/ui/camera.test.ts +64 -1
  59. package/src/ui/camera.ts +36 -10
  60. package/src/ui/control/attribution_control.test.ts +62 -0
  61. package/src/ui/control/attribution_control.ts +4 -2
  62. package/src/ui/control/geolocate_control.ts +4 -6
  63. package/src/ui/control/terrain_control.test.ts +60 -0
  64. package/src/ui/handler/handler_util.ts +1 -2
  65. package/src/ui/handler/map_event.test.ts +65 -1
  66. package/src/ui/handler/map_event.ts +4 -1
  67. package/src/ui/handler/scroll_zoom.ts +0 -2
  68. package/src/ui/handler_manager.ts +0 -2
  69. package/src/ui/map.test.ts +105 -0
  70. package/src/ui/map.ts +8 -1
  71. package/src/util/ajax.ts +1 -2
  72. package/src/util/color_ramp.ts +1 -2
  73. package/src/util/dictionary_coder.ts +1 -3
  74. package/src/util/dispatcher.ts +1 -4
  75. package/src/util/dom.ts +0 -3
  76. package/src/util/image.ts +1 -3
  77. package/src/util/struct_array.ts +0 -5
  78. package/src/util/task_queue.ts +1 -3
  79. package/src/util/web_worker_transfer.ts +5 -6
@@ -207,8 +207,6 @@ export declare type ExpressionSpecification = [
207
207
  ExpressionInputType | ExpressionSpecification
208
208
  ] | [
209
209
  "coalesce",
210
- ExpressionInputType | ExpressionSpecification,
211
- ExpressionInputType | ExpressionSpecification,
212
210
  ...(ExpressionInputType | ExpressionSpecification)[]
213
211
  ] | [
214
212
  "match",
@@ -224,27 +222,20 @@ export declare type ExpressionSpecification = [
224
222
  "interpolate",
225
223
  InterpolationSpecification,
226
224
  number | ExpressionSpecification,
227
- number | ExpressionSpecification,
228
- ExpressionInputType | ExpressionSpecification,
229
- ...(number | ExpressionInputType | ExpressionSpecification)[]
225
+ ...(number | number[] | ColorSpecification)[]
230
226
  ] | [
231
227
  "interpolate-hcl",
232
228
  InterpolationSpecification,
233
229
  number | ExpressionSpecification,
234
- number | ExpressionSpecification,
235
- ExpressionInputType | ExpressionSpecification,
236
- ...(number | ColorSpecification | ExpressionSpecification)[]
230
+ ...(number | ColorSpecification)[]
237
231
  ] | [
238
232
  "interpolate-lab",
239
233
  InterpolationSpecification,
240
234
  number | ExpressionSpecification,
241
- number | ExpressionSpecification,
242
- ExpressionInputType | ExpressionSpecification,
243
- ...(number | ColorSpecification | ExpressionSpecification)[]
235
+ ...(number | ColorSpecification)[]
244
236
  ] | [
245
237
  "step",
246
238
  number | ExpressionSpecification,
247
- number | ExpressionSpecification,
248
239
  ExpressionInputType | ExpressionSpecification,
249
240
  ...(number | ExpressionInputType | ExpressionSpecification)[]
250
241
  ] | [
@@ -257,8 +248,6 @@ export declare type ExpressionSpecification = [
257
248
  string
258
249
  ] | [
259
250
  "concat",
260
- ExpressionInputType | ExpressionSpecification,
261
- ExpressionInputType | ExpressionSpecification,
262
251
  ...(ExpressionInputType | ExpressionSpecification)[]
263
252
  ] | [
264
253
  "downcase",
@@ -309,8 +298,6 @@ export declare type ExpressionSpecification = [
309
298
  number | ExpressionSpecification
310
299
  ] | [
311
300
  "+",
312
- number | ExpressionSpecification,
313
- number | ExpressionSpecification,
314
301
  ...(number | ExpressionSpecification)[]
315
302
  ] | [
316
303
  "abs",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maplibre-gl",
3
3
  "description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",
4
- "version": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "main": "dist/maplibre-gl.js",
6
6
  "style": "dist/maplibre-gl.css",
7
7
  "license": "BSD-3-Clause",
@@ -28,6 +28,7 @@
28
28
  "earcut": "^2.2.4",
29
29
  "geojson-vt": "^3.2.1",
30
30
  "gl-matrix": "^3.4.3",
31
+ "global-prefix": "^3.0.0",
31
32
  "murmurhash-js": "^1.0.0",
32
33
  "pbf": "^3.2.1",
33
34
  "potpack": "^1.0.2",
@@ -39,7 +40,7 @@
39
40
  "devDependencies": {
40
41
  "@mapbox/gazetteer": "^5.1.0",
41
42
  "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
42
- "@mapbox/mvt-fixtures": "^3.9.0",
43
+ "@mapbox/mvt-fixtures": "^3.10.0",
43
44
  "@rollup/plugin-commonjs": "^22.0.2",
44
45
  "@rollup/plugin-json": "^4.1.0",
45
46
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -47,15 +48,14 @@
47
48
  "@rollup/plugin-strip": "^2.1.0",
48
49
  "@rollup/plugin-typescript": "^8.3.4",
49
50
  "@types/benchmark": "^2.1.1",
50
- "@types/browserify": "^12.0.37",
51
51
  "@types/cssnano": "^5.0.0",
52
52
  "@types/d3": "^7.4.0",
53
53
  "@types/diff": "^5.0.2",
54
54
  "@types/earcut": "^2.1.1",
55
- "@types/eslint": "^8.4.5",
55
+ "@types/eslint": "^8.4.6",
56
56
  "@types/gl": "^4.1.1",
57
57
  "@types/glob": "^7.2.0",
58
- "@types/jest": "^28.1.6",
58
+ "@types/jest": "^28.1.7",
59
59
  "@types/jsdom": "^20.0.0",
60
60
  "@types/minimist": "^1.2.2",
61
61
  "@types/murmurhash-js": "^1.0.3",
@@ -63,31 +63,30 @@
63
63
  "@types/offscreencanvas": "^2019.7.0",
64
64
  "@types/pixelmatch": "^5.2.4",
65
65
  "@types/pngjs": "^6.0.1",
66
- "@types/react": "^18.0.15",
66
+ "@types/react": "^18.0.17",
67
67
  "@types/react-dom": "^18.0.6",
68
68
  "@types/request": "^2.48.8",
69
69
  "@types/rollup-plugin-json": "^3.0.3",
70
70
  "@types/shuffle-seed": "^1.1.0",
71
71
  "@types/supercluster": "^7.1.0",
72
72
  "@types/window-or-global": "^1.0.4",
73
- "@typescript-eslint/eslint-plugin": "^5.32.0",
74
- "@typescript-eslint/parser": "^5.32.0",
73
+ "@typescript-eslint/eslint-plugin": "^5.34.0",
74
+ "@typescript-eslint/parser": "^5.33.1",
75
75
  "acorn-import-assertions": "^1.8.0",
76
76
  "address": "^1.2.0",
77
77
  "benchmark": "^2.1.4",
78
- "browserify": "^17.0.0",
79
78
  "canvas": "^2.9.3",
80
- "cssnano": "^5.1.12",
79
+ "cssnano": "^5.1.13",
81
80
  "d3": "^7.6.1",
82
81
  "d3-queue": "^3.0.7",
83
82
  "diff": "^5.1.0",
84
- "documentation": "14.0.0-alpha.1",
83
+ "documentation": "14.0.0",
85
84
  "dts-bundle-generator": "^6.12.0",
86
- "eslint": "^8.21.0",
85
+ "eslint": "^8.22.0",
87
86
  "eslint-config-mourner": "^3.0.0",
88
87
  "eslint-plugin-html": "^7.1.0",
89
88
  "eslint-plugin-import": "^2.26.0",
90
- "eslint-plugin-jest": "^26.7.0",
89
+ "eslint-plugin-jest": "^26.8.7",
91
90
  "eslint-plugin-jsdoc": "^39.3.4",
92
91
  "eslint-plugin-react": "^7.30.1",
93
92
  "gl": "^5.0.3",
@@ -106,9 +105,9 @@
106
105
  "node-plantuml": "^0.9.0",
107
106
  "npm-font-open-sans": "^1.1.0",
108
107
  "npm-run-all": "^4.1.5",
109
- "pdf-merger-js": "^3.4.0",
108
+ "pdf-merger-js": "^4.0.0",
110
109
  "pixelmatch": "^5.3.0",
111
- "playwright": "^1.24.2",
110
+ "playwright": "^1.25.0",
112
111
  "pngjs": "^6.0.0",
113
112
  "postcss": "^8.4.14",
114
113
  "postcss-cli": "^10.0.0",
@@ -117,7 +116,7 @@
117
116
  "react": "^18.2.0",
118
117
  "react-dom": "^18.2.0",
119
118
  "request": "^2.88.0",
120
- "rollup": "^2.77.2",
119
+ "rollup": "^2.78.1",
121
120
  "rollup-plugin-import-assert": "^2.1.0",
122
121
  "rollup-plugin-sourcemaps": "^0.6.3",
123
122
  "rollup-plugin-terser": "^7.0.2",
@@ -126,12 +125,11 @@
126
125
  "shuffle-seed": "^1.1.6",
127
126
  "source-map-explorer": "^2.5.2",
128
127
  "st": "^3.0.0",
129
- "stylelint": "^14.9.1",
130
- "stylelint-config-standard": "^26.0.0",
131
- "ts-jest": "^28.0.7",
128
+ "stylelint": "^14.11.0",
129
+ "stylelint-config-standard": "^28.0.0",
130
+ "ts-jest": "^28.0.8",
132
131
  "ts-node": "^10.9.1",
133
- "typescript": "^4.7.4",
134
- "unassert-rollup-plugin": "^2.0.0"
132
+ "typescript": "^4.7.4"
135
133
  },
136
134
  "scripts": {
137
135
  "generate-shaders": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-shaders.ts",
@@ -141,6 +139,7 @@
141
139
  "generate-typings": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-typings.ts",
142
140
  "generate-query-test-fixtures": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-query-test-fixtures.ts",
143
141
  "generate-debug-index-file": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-debug-index-file.ts",
142
+ "build-dist": "npm run generate-typings && npm run build-dev && npm run build-prod && npm run build-csp && npm run build-css",
144
143
  "build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev",
145
144
  "watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch",
146
145
  "build-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production",
@@ -1,6 +1,5 @@
1
1
  // This file is generated. Edit build/generate-struct-arrays.ts, then run `npm run codegen`.
2
2
 
3
- import assert from 'assert';
4
3
  import {Struct, StructArray} from '../util/struct_array';
5
4
  import {register} from '../util/web_worker_transfer';
6
5
  import Point from '@mapbox/point-geometry';
@@ -877,7 +876,6 @@ export class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {
877
876
  * @private
878
877
  */
879
878
  get(index: number): CollisionBoxStruct {
880
- assert(!this.isTransferred);
881
879
  return new CollisionBoxStruct(this, index);
882
880
  }
883
881
  }
@@ -922,7 +920,6 @@ export class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48
922
920
  * @private
923
921
  */
924
922
  get(index: number): PlacedSymbolStruct {
925
- assert(!this.isTransferred);
926
923
  return new PlacedSymbolStruct(this, index);
927
924
  }
928
925
  }
@@ -976,7 +973,6 @@ export class SymbolInstanceArray extends StructArrayLayout8i15ui1ul4f68 {
976
973
  * @private
977
974
  */
978
975
  get(index: number): SymbolInstanceStruct {
979
- assert(!this.isTransferred);
980
976
  return new SymbolInstanceStruct(this, index);
981
977
  }
982
978
  }
@@ -1024,7 +1020,6 @@ export class FeatureIndexArray extends StructArrayLayout1ul2ui8 {
1024
1020
  * @private
1025
1021
  */
1026
1022
  get(index: number): FeatureIndexStruct {
1027
- assert(!this.isTransferred);
1028
1023
  return new FeatureIndexStruct(this, index);
1029
1024
  }
1030
1025
  }
@@ -6,7 +6,6 @@ import {ProgramConfigurationSet} from '../program_configuration';
6
6
  import {LineIndexArray, TriangleIndexArray} from '../index_array_type';
7
7
  import earcut from 'earcut';
8
8
  import classifyRings from '../../util/classify_rings';
9
- import assert from 'assert';
10
9
  const EARCUT_MAX_RINGS = 500;
11
10
  import {register} from '../../util/web_worker_transfer';
12
11
  import {hasPattern, addPatternDependencies} from './pattern_bucket_features';
@@ -211,7 +210,6 @@ class FillBucket implements Bucket {
211
210
  }
212
211
 
213
212
  const indices = earcut(flattened, holeIndices);
214
- assert(indices.length % 3 === 0);
215
213
 
216
214
  for (let i = 0; i < indices.length; i += 3) {
217
215
  this.indexArray.emplaceBack(
@@ -9,7 +9,6 @@ import earcut from 'earcut';
9
9
  import mvt from '@mapbox/vector-tile';
10
10
  const vectorTileFeatureTypes = mvt.VectorTileFeature.types;
11
11
  import classifyRings from '../../util/classify_rings';
12
- import assert from 'assert';
13
12
  const EARCUT_MAX_RINGS = 500;
14
13
  import {register} from '../../util/web_worker_transfer';
15
14
  import {hasPattern, addPatternDependencies} from './pattern_bucket_features';
@@ -264,7 +263,6 @@ class FillExtrusionBucket implements Bucket {
264
263
  }
265
264
 
266
265
  const indices = earcut(flattened, holeIndices);
267
- assert(indices.length % 3 === 0);
268
266
 
269
267
  for (let j = 0; j < indices.length; j += 3) {
270
268
  // Counter-clockwise winding order.
@@ -1,6 +1,5 @@
1
1
  import murmur3 from 'murmurhash-js';
2
2
  import {register} from '../util/web_worker_transfer';
3
- import assert from 'assert';
4
3
 
5
4
  type SerializedFeaturePositionMap = {
6
5
  ids: Float64Array;
@@ -31,7 +30,7 @@ export default class FeaturePositionMap {
31
30
  }
32
31
 
33
32
  getPositions(id: unknown): Array<FeaturePosition> {
34
- assert(this.indexed);
33
+ if (!this.indexed) throw new Error('Trying to get index, but feature positions are not indexed');
35
34
 
36
35
  const intId = getNumericId(id);
37
36
 
@@ -1,5 +1,4 @@
1
1
  import {ColorAttachment, DepthAttachment} from './value';
2
- import assert from 'assert';
3
2
 
4
3
  import type Context from './context';
5
4
 
@@ -22,7 +21,9 @@ class Framebuffer {
22
21
  if (hasDepth) {
23
22
  this.depthAttachment = new DepthAttachment(context, fbo);
24
23
  }
25
- assert(gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE);
24
+ if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) {
25
+ throw new Error('Framebuffer is not complete');
26
+ }
26
27
  }
27
28
 
28
29
  destroy() {
@@ -1,4 +1,3 @@
1
- import assert from 'assert';
2
1
 
3
2
  import type {StructArray} from '../util/struct_array';
4
3
  import type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type';
@@ -34,7 +33,7 @@ class IndexBuffer {
34
33
 
35
34
  updateData(array: StructArray) {
36
35
  const gl = this.context.gl;
37
- assert(this.dynamicDraw);
36
+ if (!this.dynamicDraw) throw new Error('Attempted to update data while not in dynamic mode.');
38
37
  // The right VAO will get this buffer re-bound later in VertexArrayObject#bind
39
38
  // See https://github.com/mapbox/mapbox-gl-js/issues/5620
40
39
  this.context.unbindVAO();
@@ -1,4 +1,3 @@
1
- import assert from 'assert';
2
1
 
3
2
  import type {
4
3
  StructArray,
@@ -62,7 +61,7 @@ class VertexBuffer {
62
61
  }
63
62
 
64
63
  updateData(array: StructArray) {
65
- assert(array.length === this.length);
64
+ if (array.length !== this.length) throw new Error(`Length of new data is ${array.length}, which doesn't match current length of ${this.length}`);
66
65
  const gl = this.context.gl;
67
66
  this.bind();
68
67
  gl.bufferSubData(gl.ARRAY_BUFFER, 0, array.arrayBuffer);
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import assert from 'assert';
2
1
  import {supported} from '@mapbox/mapbox-gl-supported';
3
2
  import packageJSON from '../package.json' assert {type: 'json'};
4
3
  import Map from './ui/map';
@@ -262,5 +261,4 @@ Debug.extend(exported, {isSafari, getPerformanceMetrics: PerformanceUtils.getPer
262
261
  */
263
262
 
264
263
  export default exported;
265
- // canary assert: used to confirm that asserts have been removed from production build
266
- assert(true, 'canary assert');
264
+
@@ -66,7 +66,7 @@ function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array<Ove
66
66
  }
67
67
  }
68
68
 
69
- function drawDebugTile(painter, sourceCache, coord: OverscaledTileID) {
69
+ function drawDebugTile(painter: Painter, sourceCache: SourceCache, coord: OverscaledTileID) {
70
70
  const context = painter.context;
71
71
  const gl = context.gl;
72
72
 
@@ -1,6 +1,7 @@
1
1
  import Color from '../style-spec/util/color';
2
2
  import DepthMode from '../gl/depth_mode';
3
3
  import CullFaceMode from '../gl/cull_face_mode';
4
+ import ColorMode from '../gl/color_mode';
4
5
  import {
5
6
  fillUniformValues,
6
7
  fillPatternUniformValues,
@@ -56,7 +57,14 @@ function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLa
56
57
  }
57
58
  }
58
59
 
59
- function drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, isOutline) {
60
+ function drawFillTiles(
61
+ painter: Painter,
62
+ sourceCache: SourceCache,
63
+ layer: FillStyleLayer,
64
+ coords: Array<OverscaledTileID>,
65
+ depthMode: Readonly<DepthMode>,
66
+ colorMode: Readonly<ColorMode>,
67
+ isOutline: boolean) {
60
68
  const gl = painter.context.gl;
61
69
 
62
70
  const patternProperty = layer.paint.get('fill-pattern');
@@ -45,7 +45,14 @@ function draw(painter: Painter, source: SourceCache, layer: FillExtrusionStyleLa
45
45
  }
46
46
  }
47
47
 
48
- function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMode, colorMode) {
48
+ function drawExtrusionTiles(
49
+ painter: Painter,
50
+ source: SourceCache,
51
+ layer: FillExtrusionStyleLayer,
52
+ coords: OverscaledTileID[],
53
+ depthMode: DepthMode,
54
+ stencilMode: Readonly<StencilMode>,
55
+ colorMode: Readonly<ColorMode>) {
49
56
  const context = painter.context;
50
57
  const gl = context.gl;
51
58
  const patternProperty = layer.paint.get('fill-extrusion-pattern');
@@ -4,6 +4,8 @@ import DepthMode from '../gl/depth_mode';
4
4
  import StencilMode from '../gl/stencil_mode';
5
5
  import ColorMode from '../gl/color_mode';
6
6
  import CullFaceMode from '../gl/cull_face_mode';
7
+ import Context from '../gl/context';
8
+ import Framebuffer from '../gl/framebuffer';
7
9
  import {
8
10
  heatmapUniformValues,
9
11
  heatmapTextureUniformValues
@@ -67,7 +69,7 @@ function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapS
67
69
  }
68
70
  }
69
71
 
70
- function bindFramebuffer(context, painter, layer) {
72
+ function bindFramebuffer(context: Context, painter: Painter, layer: HeatmapStyleLayer) {
71
73
  const gl = context.gl;
72
74
  context.activeTexture.set(gl.TEXTURE1);
73
75
 
@@ -94,7 +96,7 @@ function bindFramebuffer(context, painter, layer) {
94
96
  }
95
97
  }
96
98
 
97
- function bindTextureToFramebuffer(context, painter, texture, fbo) {
99
+ function bindTextureToFramebuffer(context: Context, painter: Painter, texture: WebGLTexture, fbo: Framebuffer) {
98
100
  const gl = context.gl;
99
101
  // Use the higher precision half-float texture where available (producing much smoother looking heatmaps);
100
102
  // Otherwise, fall back to a low precision texture
@@ -103,7 +105,7 @@ function bindTextureToFramebuffer(context, painter, texture, fbo) {
103
105
  fbo.colorAttachment.set(texture);
104
106
  }
105
107
 
106
- function renderTextureToMap(painter, layer) {
108
+ function renderTextureToMap(painter: Painter, layer: HeatmapStyleLayer) {
107
109
  const context = painter.context;
108
110
  const gl = context.gl;
109
111
 
@@ -2,6 +2,8 @@ import Texture from './texture';
2
2
  import StencilMode from '../gl/stencil_mode';
3
3
  import DepthMode from '../gl/depth_mode';
4
4
  import CullFaceMode from '../gl/cull_face_mode';
5
+ import ColorMode from '../gl/color_mode';
6
+ import Tile from '../source/tile';
5
7
  import {
6
8
  hillshadeUniformValues,
7
9
  hillshadeUniformPrepareValues
@@ -37,7 +39,14 @@ function drawHillshade(painter: Painter, sourceCache: SourceCache, layer: Hillsh
37
39
  context.viewport.set([0, 0, painter.width, painter.height]);
38
40
  }
39
41
 
40
- function renderHillshade(painter, coord, tile, layer, depthMode, stencilMode, colorMode) {
42
+ function renderHillshade(
43
+ painter: Painter,
44
+ coord: OverscaledTileID,
45
+ tile: Tile,
46
+ layer: HillshadeStyleLayer,
47
+ depthMode: Readonly<DepthMode>,
48
+ stencilMode: Readonly<StencilMode>,
49
+ colorMode: Readonly<ColorMode>) {
41
50
  const context = painter.context;
42
51
  const gl = context.gl;
43
52
  const fbo = tile.fbo;
@@ -58,7 +67,13 @@ function renderHillshade(painter, coord, tile, layer, depthMode, stencilMode, co
58
67
 
59
68
  // hillshade rendering is done in two steps. the prepare step first calculates the slope of the terrain in the x and y
60
69
  // directions for each pixel, and saves those values to a framebuffer texture in the r and g channels.
61
- function prepareHillshade(painter, tile, layer, depthMode, stencilMode, colorMode) {
70
+ function prepareHillshade(
71
+ painter: Painter,
72
+ tile: Tile,
73
+ layer: HillshadeStyleLayer,
74
+ depthMode: Readonly<DepthMode>,
75
+ stencilMode: Readonly<StencilMode>,
76
+ colorMode: Readonly<ColorMode>) {
62
77
  const context = painter.context;
63
78
  const gl = context.gl;
64
79
  const dem = tile.dem;
@@ -5,7 +5,6 @@ import {Event, ErrorEvent, Evented} from '../util/evented';
5
5
  import {RGBAImage} from '../util/image';
6
6
  import {ImagePosition} from './image_atlas';
7
7
  import Texture from './texture';
8
- import assert from 'assert';
9
8
  import {renderStyleImage} from '../style/style_image';
10
9
  import {warnOnce} from '../util/util';
11
10
 
@@ -88,7 +87,7 @@ class ImageManager extends Evented {
88
87
  }
89
88
 
90
89
  addImage(id: string, image: StyleImage) {
91
- assert(!this.images[id]);
90
+ if (this.images[id]) throw new Error(`Image id ${id} already exist, use updateImage instead`);
92
91
  if (this._validate(id, image)) {
93
92
  this.images[id] = image;
94
93
  }
@@ -135,16 +134,15 @@ class ImageManager extends Evented {
135
134
 
136
135
  updateImage(id: string, image: StyleImage) {
137
136
  const oldImage = this.images[id];
138
- assert(oldImage);
139
- assert(oldImage.data.width === image.data.width);
140
- assert(oldImage.data.height === image.data.height);
137
+ if (oldImage.data.width !== image.data.width || oldImage.data.height !== image.data.height) {
138
+ throw new Error(`size mismatch between old image (${oldImage.data.width}x${oldImage.data.height}) and new image (${image.data.width}x${image.data.height}).`);
139
+ }
141
140
  image.version = oldImage.version + 1;
142
141
  this.images[id] = image;
143
142
  this.updatedImages[id] = true;
144
143
  }
145
144
 
146
145
  removeImage(id: string) {
147
- assert(this.images[id]);
148
146
  const image = this.images[id];
149
147
  delete this.images[id];
150
148
  delete this.patterns[id];
@@ -295,7 +293,7 @@ class ImageManager extends Evented {
295
293
  this.callbackDispatchedThisFrame[id] = true;
296
294
 
297
295
  const image = this.images[id];
298
- assert(image);
296
+ if (!image) warnOnce(`Image with ID: "${id}" was not found`);
299
297
 
300
298
  const updated = renderStyleImage(image);
301
299
  if (updated) {
@@ -186,7 +186,7 @@ function calculateTileRatio(tile: Tile, transform: Transform) {
186
186
  return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom);
187
187
  }
188
188
 
189
- function calculateMatrix(painter, tile, layer, coord) {
189
+ function calculateMatrix(painter: Painter, tile: Tile, layer: LineStyleLayer, coord: OverscaledTileID) {
190
190
  return painter.translatePosMatrix(
191
191
  coord ? coord.posMatrix : tile.tileID.posMatrix,
192
192
  tile,
@@ -1,4 +1,3 @@
1
- import assert from 'assert';
2
1
  import {
3
2
  Uniform1i,
4
3
  Uniform1f,
@@ -74,7 +73,6 @@ function bgPatternUniformValues(
74
73
  ): UniformValues<BackgroundPatternUniformsType> {
75
74
  const imagePosA = painter.imageManager.getPattern(image.from.toString());
76
75
  const imagePosB = painter.imageManager.getPattern(image.to.toString());
77
- assert(imagePosA && imagePosB);
78
76
  const {width, height} = painter.imageManager.getPixelSize();
79
77
 
80
78
  const numTiles = Math.pow(2, tile.tileID.overscaledZ);
@@ -1,5 +1,4 @@
1
1
  import shaders from '../shaders/shaders';
2
- import assert from 'assert';
3
2
  import ProgramConfiguration from '../data/program_configuration';
4
3
  import VertexArrayObject from './vertex_array_object';
5
4
  import Context from '../gl/context';
@@ -84,7 +83,6 @@ class Program<Us extends UniformBindings> {
84
83
  }
85
84
  gl.shaderSource(fragmentShader, fragmentSource);
86
85
  gl.compileShader(fragmentShader);
87
- assert(gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS), (gl.getShaderInfoLog(fragmentShader) as any));
88
86
  gl.attachShader(this.program, fragmentShader);
89
87
 
90
88
  const vertexShader = gl.createShader(gl.VERTEX_SHADER);
@@ -94,7 +92,6 @@ class Program<Us extends UniformBindings> {
94
92
  }
95
93
  gl.shaderSource(vertexShader, vertexSource);
96
94
  gl.compileShader(vertexShader);
97
- assert(gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS), (gl.getShaderInfoLog(vertexShader) as any));
98
95
  gl.attachShader(this.program, vertexShader);
99
96
 
100
97
  this.attributes = {};
@@ -110,7 +107,6 @@ class Program<Us extends UniformBindings> {
110
107
  }
111
108
 
112
109
  gl.linkProgram(this.program);
113
- assert(gl.getProgramParameter(this.program, gl.LINK_STATUS), (gl.getProgramInfoLog(this.program) as any));
114
110
 
115
111
  gl.deleteShader(vertexShader);
116
112
  gl.deleteShader(fragmentShader);
@@ -178,11 +174,18 @@ class Program<Us extends UniformBindings> {
178
174
  configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom as any)});
179
175
  }
180
176
 
181
- const primitiveSize = {
182
- [gl.LINES]: 2,
183
- [gl.TRIANGLES]: 3,
184
- [gl.LINE_STRIP]: 1
185
- }[drawMode];
177
+ let primitiveSize = 0;
178
+ switch (drawMode) {
179
+ case gl.LINES:
180
+ primitiveSize = 2;
181
+ break;
182
+ case gl.TRIANGLES:
183
+ primitiveSize = 3;
184
+ break;
185
+ case gl.LINE_STRIP:
186
+ primitiveSize = 1;
187
+ break;
188
+ }
186
189
 
187
190
  for (const segment of segments.get()) {
188
191
  const vaos = segment.vaos || (segment.vaos = {});
@@ -1,4 +1,3 @@
1
- import assert from 'assert';
2
1
 
3
2
  import type Program from './program';
4
3
  import type VertexBuffer from '../gl/vertex_buffer';
@@ -119,9 +118,8 @@ class VertexArrayObject {
119
118
  // Disable all attributes from the previous program that aren't used in
120
119
  // the new program. Note: attribute indices are *not* program specific!
121
120
  for (let i = numNextAttributes; i < numPrevAttributes; i++) {
122
- // WebGL breaks if you disable attribute 0.
121
+ // WebGL breaks if you disable attribute 0, so if i == 0.
123
122
  // http://stackoverflow.com/questions/20305231
124
- assert(i !== 0);
125
123
  gl.disableVertexAttribArray(i);
126
124
  }
127
125
  }
@@ -6,7 +6,6 @@ import GeoJSONWrapper from './geojson_wrapper';
6
6
  import vtpbf from 'vt-pbf';
7
7
  import Supercluster from 'supercluster';
8
8
  import geojsonvt from 'geojson-vt';
9
- import assert from 'assert';
10
9
  import VectorTileWorkerSource from './vector_tile_worker_source';
11
10
  import {createExpression} from '../style-spec/expression';
12
11
 
@@ -292,9 +291,6 @@ function getSuperclusterOptions({superclusterOptions, clusterProperties}: { supe
292
291
  const reduceExpressionParsed = createExpression(
293
292
  typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator);
294
293
 
295
- assert(mapExpressionParsed.result === 'success');
296
- assert(reduceExpressionParsed.result === 'success');
297
-
298
294
  mapExpressions[key] = mapExpressionParsed.value;
299
295
  reduceExpressions[key] = reduceExpressionParsed.value;
300
296
  }
@@ -6,7 +6,6 @@ import type {RetainedQueryData} from '../symbol/placement';
6
6
  import type {FilterSpecification} from '../style-spec/types.g';
7
7
  import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';
8
8
  import type Point from '@mapbox/point-geometry';
9
- import assert from 'assert';
10
9
  import {mat4} from 'gl-matrix';
11
10
 
12
11
  /*
@@ -137,8 +136,6 @@ export function queryRenderedSymbols(styleLayers: {[_: string]: StyleLayer},
137
136
  // we sort each feature based on the first matching symbol instance.
138
137
  const sortedA = featureSortOrder.indexOf(a.featureIndex);
139
138
  const sortedB = featureSortOrder.indexOf(b.featureIndex);
140
- assert(sortedA >= 0);
141
- assert(sortedB >= 0);
142
139
  return sortedB - sortedA;
143
140
  } else {
144
141
  // Bucket hasn't been re-sorted based on angle, so use the