maplibre-gl 3.3.0 → 3.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 (50) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +3 -2
  3. package/build/generate-dist-package.js +7 -2
  4. package/build/generate-typings.ts +1 -1
  5. package/dist/LICENSE.txt +116 -0
  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 +243 -100
  11. package/dist/maplibre-gl-dev.js.map +1 -1
  12. package/dist/maplibre-gl.d.ts +28 -15
  13. package/dist/maplibre-gl.js +4 -4
  14. package/dist/maplibre-gl.js.map +1 -1
  15. package/dist/package.json +1 -1
  16. package/package.json +48 -47
  17. package/src/data/dem_data.test.ts +120 -165
  18. package/src/data/dem_data.ts +38 -18
  19. package/src/render/program.ts +15 -0
  20. package/src/source/image_source.test.ts +17 -24
  21. package/src/source/raster_dem_tile_source.ts +15 -2
  22. package/src/source/raster_dem_tile_worker_source.ts +2 -2
  23. package/src/source/raster_tile_source.test.ts +1 -1
  24. package/src/source/raster_tile_source.ts +1 -1
  25. package/src/source/terrain_source_cache.test.ts +1 -1
  26. package/src/source/vector_tile_source.test.ts +1 -1
  27. package/src/source/vector_tile_source.ts +0 -1
  28. package/src/source/vector_tile_worker_source.test.ts +45 -1
  29. package/src/source/vector_tile_worker_source.ts +19 -6
  30. package/src/source/video_source.ts +4 -0
  31. package/src/source/worker_source.ts +6 -2
  32. package/src/style/load_glyph_range.test.ts +6 -8
  33. package/src/style/load_sprite.test.ts +48 -71
  34. package/src/style/style.test.ts +19 -49
  35. package/src/style/style.ts +14 -8
  36. package/src/style/style_layer/line_style_layer.test.ts +50 -0
  37. package/src/style/style_layer/line_style_layer.ts +8 -4
  38. package/src/style/style_layer/variable_text_anchor.ts +1 -1
  39. package/src/ui/control/navigation_control.ts +0 -1
  40. package/src/ui/handler/scroll_zoom.ts +6 -0
  41. package/src/ui/handler_manager.ts +2 -1
  42. package/src/ui/map.test.ts +37 -8
  43. package/src/ui/map.ts +15 -13
  44. package/src/ui/marker.test.ts +25 -0
  45. package/src/ui/marker.ts +9 -2
  46. package/src/ui/popup.ts +1 -1
  47. package/src/util/ajax.test.ts +1 -1
  48. package/src/util/image_request.test.ts +1 -1
  49. package/src/util/test/util.ts +12 -0
  50. package/src/util/throttle.ts +7 -3
@@ -1,4 +1,4 @@
1
- /* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.3.0/LICENSE.txt */
1
+ /* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.4.0/LICENSE.txt */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -1577,10 +1577,28 @@ var source_raster_dem = {
1577
1577
  terrarium: {
1578
1578
  },
1579
1579
  mapbox: {
1580
+ },
1581
+ custom: {
1580
1582
  }
1581
1583
  },
1582
1584
  "default": "mapbox"
1583
1585
  },
1586
+ redFactor: {
1587
+ type: "number",
1588
+ "default": 1
1589
+ },
1590
+ blueFactor: {
1591
+ type: "number",
1592
+ "default": 1
1593
+ },
1594
+ greenFactor: {
1595
+ type: "number",
1596
+ "default": 1
1597
+ },
1598
+ baseShift: {
1599
+ type: "number",
1600
+ "default": 0
1601
+ },
1584
1602
  volatile: {
1585
1603
  type: "boolean",
1586
1604
  "default": false
@@ -8878,6 +8896,9 @@ class ZoomDependentExpression {
8878
8896
  }
8879
8897
  }
8880
8898
  }
8899
+ function isZoomExpression(expression) {
8900
+ return expression._styleExpression !== undefined;
8901
+ }
8881
8902
  function createPropertyExpression(expressionInput, propertySpec) {
8882
8903
  const expression = createExpression(expressionInput, propertySpec);
8883
8904
  if (expression.result === 'error') {
@@ -10392,6 +10413,9 @@ function validateLayer(options) {
10392
10413
  else if (sourceType === 'vector' && type === 'raster') {
10393
10414
  errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster source`));
10394
10415
  }
10416
+ else if (sourceType !== 'raster-dem' && type === 'hillshade') {
10417
+ errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster-dem source`));
10418
+ }
10395
10419
  else if (sourceType === 'raster' && type !== 'raster') {
10396
10420
  errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a vector source`));
10397
10421
  }
@@ -10478,6 +10502,47 @@ function validateString(options) {
10478
10502
  return [];
10479
10503
  }
10480
10504
 
10505
+ function validateRasterDEMSource(options) {
10506
+ var _a;
10507
+ const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';
10508
+ const rasterDEM = options.value;
10509
+ const styleSpec = options.styleSpec;
10510
+ const rasterDEMSpec = styleSpec.source_raster_dem;
10511
+ const style = options.style;
10512
+ let errors = [];
10513
+ const rootType = getType(rasterDEM);
10514
+ if (rasterDEM === undefined) {
10515
+ return errors;
10516
+ }
10517
+ else if (rootType !== 'object') {
10518
+ errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));
10519
+ return errors;
10520
+ }
10521
+ const encoding = unbundle(rasterDEM.encoding);
10522
+ const isCustomEncoding = encoding === 'custom';
10523
+ const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];
10524
+ const encodingName = options.value.encoding ? `"${options.value.encoding}"` : 'Default';
10525
+ for (const key in rasterDEM) {
10526
+ if (!isCustomEncoding && customEncodingKeys.includes(key)) {
10527
+ errors.push(new ValidationError(key, rasterDEM[key], `In "${sourceName}": "${key}" is only valid when "encoding" is set to "custom". ${encodingName} encoding found`));
10528
+ }
10529
+ else if (rasterDEMSpec[key]) {
10530
+ errors = errors.concat(options.validateSpec({
10531
+ key,
10532
+ value: rasterDEM[key],
10533
+ valueSpec: rasterDEMSpec[key],
10534
+ validateSpec: options.validateSpec,
10535
+ style,
10536
+ styleSpec
10537
+ }));
10538
+ }
10539
+ else {
10540
+ errors.push(new ValidationError(key, rasterDEM[key], `unknown property "${key}"`));
10541
+ }
10542
+ }
10543
+ return errors;
10544
+ }
10545
+
10481
10546
  const objectElementValidators = {
10482
10547
  promoteId: validatePromoteId
10483
10548
  };
@@ -10495,7 +10560,6 @@ function validateSource$1(options) {
10495
10560
  switch (type) {
10496
10561
  case 'vector':
10497
10562
  case 'raster':
10498
- case 'raster-dem':
10499
10563
  errors = validateObject({
10500
10564
  key,
10501
10565
  value,
@@ -10506,6 +10570,15 @@ function validateSource$1(options) {
10506
10570
  validateSpec,
10507
10571
  });
10508
10572
  return errors;
10573
+ case 'raster-dem':
10574
+ errors = validateRasterDEMSource({
10575
+ sourceName: key,
10576
+ value,
10577
+ style: options.style,
10578
+ styleSpec,
10579
+ validateSpec,
10580
+ });
10581
+ return errors;
10509
10582
  case 'geojson':
10510
10583
  errors = validateObject({
10511
10584
  key,
@@ -10922,6 +10995,7 @@ const expression = {
10922
10995
  createPropertyExpression,
10923
10996
  isExpression,
10924
10997
  isExpressionFilter,
10998
+ isZoomExpression,
10925
10999
  normalizePropertyExpression,
10926
11000
  };
10927
11001
  const styleFunction = {
@@ -25473,8 +25547,13 @@ class LineStyleLayer extends StyleLayer {
25473
25547
  }
25474
25548
  _handleSpecialPaintPropertyUpdate(name) {
25475
25549
  if (name === 'line-gradient') {
25476
- const expression = this._transitionablePaint._values['line-gradient'].value.expression;
25477
- this.stepInterpolant = expression._styleExpression.expression instanceof Step;
25550
+ const expression = this.gradientExpression();
25551
+ if (isZoomExpression(expression)) {
25552
+ this.stepInterpolant = expression._styleExpression.expression instanceof Step;
25553
+ }
25554
+ else {
25555
+ this.stepInterpolant = false;
25556
+ }
25478
25557
  this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
25479
25558
  }
25480
25559
  }
@@ -29150,29 +29229,45 @@ function getQuadkey(z, x, y) {
29150
29229
  register('CanonicalTileID', CanonicalTileID);
29151
29230
  register('OverscaledTileID', OverscaledTileID, { omit: ['posMatrix'] });
29152
29231
 
29153
- // DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders
29154
- // data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially
29155
- // loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the
29156
- // elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of
29157
- // integer overflow when creating the texture used in the hillshadePrepare step.
29158
- // DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8
29159
- // surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a
29160
- // tile's edge without backfilling from neighboring tiles.
29161
29232
  class DEMData {
29162
29233
  // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride
29163
29234
  // and dim is calculated as stride - 2.
29164
- constructor(uid, data, encoding) {
29235
+ constructor(uid, data, encoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {
29165
29236
  this.uid = uid;
29166
29237
  if (data.height !== data.width)
29167
29238
  throw new RangeError('DEM tiles must be square');
29168
- if (encoding && encoding !== 'mapbox' && encoding !== 'terrarium') {
29169
- warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);
29239
+ if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {
29240
+ warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);
29170
29241
  return;
29171
29242
  }
29172
29243
  this.stride = data.height;
29173
29244
  const dim = this.dim = data.height - 2;
29174
29245
  this.data = new Uint32Array(data.data.buffer);
29175
- this.encoding = encoding || 'mapbox';
29246
+ switch (encoding) {
29247
+ case 'terrarium':
29248
+ // unpacking formula for mapzen terrarium:
29249
+ // https://aws.amazon.com/public-datasets/terrain/
29250
+ this.redFactor = 256.0;
29251
+ this.greenFactor = 1.0;
29252
+ this.blueFactor = 1.0 / 256.0;
29253
+ this.baseShift = 32768.0;
29254
+ break;
29255
+ case 'custom':
29256
+ this.redFactor = redFactor;
29257
+ this.greenFactor = greenFactor;
29258
+ this.blueFactor = blueFactor;
29259
+ this.baseShift = baseShift;
29260
+ break;
29261
+ case 'mapbox':
29262
+ default:
29263
+ // unpacking formula for mapbox.terrain-rgb:
29264
+ // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
29265
+ this.redFactor = 6553.6;
29266
+ this.greenFactor = 25.6;
29267
+ this.blueFactor = 0.1;
29268
+ this.baseShift = 10000.0;
29269
+ break;
29270
+ }
29176
29271
  // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image
29177
29272
  // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring
29178
29273
  // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder
@@ -29207,26 +29302,18 @@ class DEMData {
29207
29302
  get(x, y) {
29208
29303
  const pixels = new Uint8Array(this.data.buffer);
29209
29304
  const index = this._idx(x, y) * 4;
29210
- const unpack = this.encoding === 'terrarium' ? this._unpackTerrarium : this._unpackMapbox;
29211
- return unpack(pixels[index], pixels[index + 1], pixels[index + 2]);
29305
+ return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);
29212
29306
  }
29213
29307
  getUnpackVector() {
29214
- return this.encoding === 'terrarium' ? [256.0, 1.0, 1.0 / 256.0, 32768.0] : [6553.6, 25.6, 0.1, 10000.0];
29308
+ return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];
29215
29309
  }
29216
29310
  _idx(x, y) {
29217
29311
  if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1)
29218
29312
  throw new RangeError('out of range source coordinates for DEM data');
29219
29313
  return (y + 1) * this.stride + (x + 1);
29220
29314
  }
29221
- _unpackMapbox(r, g, b) {
29222
- // unpacking formula for mapbox.terrain-rgb:
29223
- // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
29224
- return ((r * 256 * 256 + g * 256.0 + b) / 10.0 - 10000.0);
29225
- }
29226
- _unpackTerrarium(r, g, b) {
29227
- // unpacking formula for mapzen terrarium:
29228
- // https://aws.amazon.com/public-datasets/terrain/
29229
- return ((r * 256 + g + b / 256) - 32768.0);
29315
+ unpack(r, g, b) {
29316
+ return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);
29230
29317
  }
29231
29318
  getPixels() {
29232
29319
  return new RGBAImage({ width: this.stride, height: this.stride }, new Uint8Array(this.data.buffer));
@@ -30249,7 +30336,7 @@ function evaluateVariableOffset(anchor, offset) {
30249
30336
  if (radialOffset < 0)
30250
30337
  radialOffset = 0; // Ignore negative offset.
30251
30338
  // solve for r where r^2 + r^2 = radialOffset^2
30252
- const hypotenuse = radialOffset / Math.sqrt(2);
30339
+ const hypotenuse = radialOffset / Math.SQRT2;
30253
30340
  switch (anchor) {
30254
30341
  case 'top-right':
30255
30342
  case 'top-left':
@@ -31667,12 +31754,27 @@ function loadVectorTile(params, callback) {
31667
31754
  callback(err);
31668
31755
  }
31669
31756
  else if (data) {
31670
- callback(null, {
31671
- vectorTile: new performance.vectorTile.VectorTile(new performance.Protobuf(data)),
31672
- rawData: data,
31673
- cacheControl,
31674
- expires
31675
- });
31757
+ try {
31758
+ const vectorTile = new performance.vectorTile.VectorTile(new performance.Protobuf(data));
31759
+ callback(null, {
31760
+ vectorTile,
31761
+ rawData: data,
31762
+ cacheControl,
31763
+ expires
31764
+ });
31765
+ }
31766
+ catch (ex) {
31767
+ const bytes = new Uint8Array(data);
31768
+ const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;
31769
+ let errorMessage = `Unable to parse the tile at ${params.request.url}, `;
31770
+ if (isGzipped) {
31771
+ errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';
31772
+ }
31773
+ else {
31774
+ errorMessage += `got error: ${ex.messge}`;
31775
+ }
31776
+ callback(new Error(errorMessage));
31777
+ }
31676
31778
  }
31677
31779
  });
31678
31780
  return () => {
@@ -31821,10 +31923,10 @@ class RasterDEMTileWorkerSource {
31821
31923
  this.loaded = {};
31822
31924
  }
31823
31925
  loadTile(params, callback) {
31824
- const { uid, encoding, rawImageData } = params;
31926
+ const { uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift } = params;
31825
31927
  // Main thread will transfer ImageBitmap if offscreen decode with OffscreenCanvas is supported, else it will transfer an already decoded image.
31826
31928
  const imagePixels = performance.isImageBitmap(rawImageData) ? this.getImageData(rawImageData) : rawImageData;
31827
- const dem = new performance.DEMData(uid, imagePixels, encoding);
31929
+ const dem = new performance.DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);
31828
31930
  this.loaded = this.loaded || {};
31829
31931
  this.loaded[uid] = dem;
31830
31932
  callback(null, dem);
@@ -34029,7 +34131,7 @@ define(['./shared'], (function (performance) { 'use strict';
34029
34131
 
34030
34132
  var name = "maplibre-gl";
34031
34133
  var description = "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library";
34032
- var version$2 = "3.3.0";
34134
+ var version$2 = "3.4.0";
34033
34135
  var main = "dist/maplibre-gl.js";
34034
34136
  var style = "dist/maplibre-gl.css";
34035
34137
  var license = "BSD-3-Clause";
@@ -34048,12 +34150,12 @@ var dependencies = {
34048
34150
  "@mapbox/unitbezier": "^0.0.1",
34049
34151
  "@mapbox/vector-tile": "^1.3.1",
34050
34152
  "@mapbox/whoots-js": "^3.1.0",
34051
- "@maplibre/maplibre-gl-style-spec": "^19.3.0",
34052
- "@types/geojson": "^7946.0.10",
34153
+ "@maplibre/maplibre-gl-style-spec": "^19.3.2",
34154
+ "@types/geojson": "^7946.0.11",
34053
34155
  "@types/mapbox__point-geometry": "^0.1.2",
34054
- "@types/mapbox__vector-tile": "^1.3.0",
34055
- "@types/pbf": "^3.0.2",
34056
- "@types/supercluster": "^7.1.0",
34156
+ "@types/mapbox__vector-tile": "^1.3.1",
34157
+ "@types/pbf": "^3.0.3",
34158
+ "@types/supercluster": "^7.1.1",
34057
34159
  earcut: "^2.2.4",
34058
34160
  "geojson-vt": "^3.2.1",
34059
34161
  "gl-matrix": "^3.4.3",
@@ -34070,56 +34172,56 @@ var dependencies = {
34070
34172
  var devDependencies = {
34071
34173
  "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
34072
34174
  "@mapbox/mvt-fixtures": "^3.10.0",
34073
- "@rollup/plugin-commonjs": "^25.0.3",
34074
- "@rollup/plugin-json": "^6.0.0",
34075
- "@rollup/plugin-node-resolve": "^15.1.0",
34076
- "@rollup/plugin-replace": "^5.0.2",
34077
- "@rollup/plugin-strip": "^3.0.2",
34078
- "@rollup/plugin-terser": "^0.4.3",
34079
- "@rollup/plugin-typescript": "^11.1.2",
34080
- "@types/benchmark": "^2.1.2",
34175
+ "@rollup/plugin-commonjs": "^25.0.5",
34176
+ "@rollup/plugin-json": "^6.0.1",
34177
+ "@rollup/plugin-node-resolve": "^15.2.2",
34178
+ "@rollup/plugin-replace": "^5.0.3",
34179
+ "@rollup/plugin-strip": "^3.0.3",
34180
+ "@rollup/plugin-terser": "^0.4.4",
34181
+ "@rollup/plugin-typescript": "^11.1.5",
34182
+ "@types/benchmark": "^2.1.3",
34081
34183
  "@types/cssnano": "^5.0.0",
34082
- "@types/d3": "^7.4.0",
34083
- "@types/diff": "^5.0.3",
34084
- "@types/earcut": "^2.1.1",
34085
- "@types/eslint": "^8.44.2",
34086
- "@types/gl": "^6.0.2",
34184
+ "@types/d3": "^7.4.1",
34185
+ "@types/diff": "^5.0.5",
34186
+ "@types/earcut": "^2.1.2",
34187
+ "@types/eslint": "^8.44.3",
34188
+ "@types/gl": "^6.0.3",
34087
34189
  "@types/glob": "^8.1.0",
34088
34190
  "@types/jest": "^29.5.3",
34089
- "@types/jsdom": "^21.1.1",
34090
- "@types/minimist": "^1.2.2",
34191
+ "@types/jsdom": "^21.1.3",
34192
+ "@types/minimist": "^1.2.3",
34091
34193
  "@types/murmurhash-js": "^1.0.4",
34092
- "@types/nise": "^1.4.1",
34093
- "@types/node": "^20.4.8",
34094
- "@types/offscreencanvas": "^2019.7.0",
34194
+ "@types/nise": "^1.4.2",
34195
+ "@types/node": "^20.8.2",
34196
+ "@types/offscreencanvas": "^2019.7.1",
34095
34197
  "@types/pixelmatch": "^5.2.4",
34096
- "@types/pngjs": "^6.0.1",
34097
- "@types/react": "^18.2.18",
34098
- "@types/react-dom": "^18.2.7",
34099
- "@types/request": "^2.48.8",
34198
+ "@types/pngjs": "^6.0.2",
34199
+ "@types/react": "^18.2.25",
34200
+ "@types/react-dom": "^18.2.10",
34201
+ "@types/request": "^2.48.9",
34100
34202
  "@types/shuffle-seed": "^1.1.0",
34101
34203
  "@types/window-or-global": "^1.0.4",
34102
- "@typescript-eslint/eslint-plugin": "^6.2.1",
34103
- "@typescript-eslint/parser": "^6.2.1",
34104
- address: "^1.2.2",
34204
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
34205
+ "@typescript-eslint/parser": "^6.7.4",
34206
+ address: "^2.0.1",
34105
34207
  benchmark: "^2.1.4",
34106
34208
  canvas: "^2.11.2",
34107
34209
  cssnano: "^6.0.1",
34108
34210
  d3: "^7.8.5",
34109
34211
  "d3-queue": "^3.0.7",
34110
- "devtools-protocol": "^0.0.1179426",
34212
+ "devtools-protocol": "^0.0.1205644",
34111
34213
  diff: "^5.1.0",
34112
34214
  "dts-bundle-generator": "^8.0.1",
34113
- eslint: "^8.46.0",
34215
+ eslint: "^8.50.0",
34114
34216
  "eslint-config-mourner": "^3.0.0",
34115
34217
  "eslint-plugin-html": "^7.1.0",
34116
- "eslint-plugin-import": "^2.28.0",
34117
- "eslint-plugin-jest": "^27.2.3",
34118
- "eslint-plugin-react": "^7.33.1",
34218
+ "eslint-plugin-import": "^2.28.1",
34219
+ "eslint-plugin-jest": "^27.4.2",
34220
+ "eslint-plugin-react": "^7.33.2",
34119
34221
  "eslint-plugin-tsdoc": "0.2.17",
34120
- expect: "^29.6.2",
34222
+ expect: "^29.7.0",
34121
34223
  gl: "^6.0.2",
34122
- glob: "^10.3.3",
34224
+ glob: "^10.3.10",
34123
34225
  "is-builtin-module": "^3.2.1",
34124
34226
  jest: "^29.6.2",
34125
34227
  "jest-canvas-mock": "^2.5.2",
@@ -34135,29 +34237,29 @@ var devDependencies = {
34135
34237
  "pdf-merger-js": "^4.3.0",
34136
34238
  pixelmatch: "^5.3.0",
34137
34239
  pngjs: "^7.0.0",
34138
- postcss: "^8.4.27",
34240
+ postcss: "^8.4.31",
34139
34241
  "postcss-cli": "^10.1.0",
34140
34242
  "postcss-inline-svg": "^6.0.0",
34141
34243
  "pretty-bytes": "^6.1.1",
34142
- puppeteer: "^21.0.1",
34244
+ puppeteer: "^21.3.6",
34143
34245
  react: "^18.2.0",
34144
34246
  "react-dom": "^18.2.0",
34145
- rollup: "^3.27.2",
34247
+ rollup: "^3.29.4",
34146
34248
  "rollup-plugin-sourcemaps": "^0.6.3",
34147
34249
  rw: "^1.3.3",
34148
34250
  semver: "^7.5.4",
34149
34251
  "shuffle-seed": "^1.1.6",
34150
34252
  "source-map-explorer": "^2.5.3",
34151
34253
  st: "^3.0.0",
34152
- stylelint: "^15.10.2",
34254
+ stylelint: "^15.10.3",
34153
34255
  "stylelint-config-standard": "^34.0.0",
34154
34256
  "ts-jest": "^29.1.1",
34155
34257
  "ts-node": "^10.9.1",
34156
- tslib: "^2.6.1",
34157
- typedoc: "^0.24.8",
34158
- "typedoc-plugin-markdown": "^3.15.4",
34159
- "typedoc-plugin-missing-exports": "^2.0.1",
34160
- typescript: "^5.1.6"
34258
+ tslib: "^2.6.2",
34259
+ typedoc: "^0.25.1",
34260
+ "typedoc-plugin-markdown": "^3.16.0",
34261
+ "typedoc-plugin-missing-exports": "^2.1.0",
34262
+ typescript: "^5.2.2"
34161
34263
  };
34162
34264
  var overrides = {
34163
34265
  "postcss-inline-svg": {
@@ -34187,6 +34289,7 @@ var scripts = {
34187
34289
  "build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts",
34188
34290
  "watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch",
34189
34291
  "start-server": "st --no-cache -H 0.0.0.0 --port 9966 .",
34292
+ "start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material",
34190
34293
  start: "run-p watch-css watch-dev start-server",
34191
34294
  "start-bench": "run-p watch-css watch-benchmarks start-server",
34192
34295
  lint: "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .",
@@ -36059,7 +36162,6 @@ class TileBounds {
36059
36162
  * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);
36060
36163
  * ```
36061
36164
  * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)
36062
- * @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
36063
36165
  */
36064
36166
  class VectorTileSource extends performance.Evented {
36065
36167
  constructor(id, options, dispatcher, eventedParent) {
@@ -36229,7 +36331,7 @@ class VectorTileSource extends performance.Evented {
36229
36331
  * ```ts
36230
36332
  * map.addSource('raster-source', {
36231
36333
  * 'type': 'raster',
36232
- * 'tiles': ['https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg'],
36334
+ * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'],
36233
36335
  * 'tileSize': 256,
36234
36336
  * });
36235
36337
  * ```
@@ -36388,6 +36490,10 @@ class RasterDEMTileSource extends RasterTileSource {
36388
36490
  this.maxzoom = 22;
36389
36491
  this._options = performance.extend({ type: 'raster-dem' }, options);
36390
36492
  this.encoding = options.encoding || 'mapbox';
36493
+ this.redFactor = options.redFactor;
36494
+ this.greenFactor = options.greenFactor;
36495
+ this.blueFactor = options.blueFactor;
36496
+ this.baseShift = options.baseShift;
36391
36497
  }
36392
36498
  loadTile(tile, callback) {
36393
36499
  const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);
@@ -36415,7 +36521,11 @@ class RasterDEMTileSource extends RasterTileSource {
36415
36521
  coord: tile.tileID,
36416
36522
  source: this.id,
36417
36523
  rawImageData,
36418
- encoding: this.encoding
36524
+ encoding: this.encoding,
36525
+ redFactor: this.redFactor,
36526
+ greenFactor: this.greenFactor,
36527
+ blueFactor: this.blueFactor,
36528
+ baseShift: this.baseShift
36419
36529
  };
36420
36530
  if (!tile.actor || tile.state === 'expired') {
36421
36531
  tile.actor = this.dispatcher.getActor();
@@ -37089,6 +37199,10 @@ function getCoordinatesCenterTileID(coords) {
37089
37199
  * map.removeSource('some id'); // remove
37090
37200
  * ```
37091
37201
  * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)
37202
+ *
37203
+ * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.
37204
+ * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,
37205
+ * set the layer's `raster-fade-duration` property to `0`.
37092
37206
  */
37093
37207
  class VideoSource extends ImageSource {
37094
37208
  constructor(id, options, dispatcher, eventedParent) {
@@ -41640,6 +41754,7 @@ class Style extends performance.Evented {
41640
41754
  this._load(empty, { validate: false });
41641
41755
  }
41642
41756
  _load(json, options, previousStyle) {
41757
+ var _a;
41643
41758
  const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json;
41644
41759
  if (options.validate && emitValidationErrors(this, performance.validateStyle(nextState))) {
41645
41760
  return;
@@ -41658,7 +41773,7 @@ class Style extends performance.Evented {
41658
41773
  this.glyphManager.setURL(nextState.glyphs);
41659
41774
  this._createLayers();
41660
41775
  this.light = new Light(this.stylesheet.light);
41661
- this.map.setTerrain(this.stylesheet.terrain);
41776
+ this.map.setTerrain((_a = this.stylesheet.terrain) !== null && _a !== void 0 ? _a : null);
41662
41777
  this.fire(new performance.Event('data', { dataType: 'style' }));
41663
41778
  this.fire(new performance.Event('style.load'));
41664
41779
  }
@@ -42076,7 +42191,7 @@ class Style extends performance.Evented {
42076
42191
  layer = performance.createStyleLayer(layerObject);
42077
42192
  }
42078
42193
  else {
42079
- if (typeof layerObject.source === 'object') {
42194
+ if ('source' in layerObject && typeof layerObject.source === 'object') {
42080
42195
  this.addSource(id, layerObject.source);
42081
42196
  layerObject = performance.clone$1(layerObject);
42082
42197
  layerObject = performance.extend(layerObject, { source: id });
@@ -43277,6 +43392,9 @@ class Program {
43277
43392
  }
43278
43393
  gl.shaderSource(fragmentShader, fragmentSource);
43279
43394
  gl.compileShader(fragmentShader);
43395
+ if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
43396
+ throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);
43397
+ }
43280
43398
  gl.attachShader(this.program, fragmentShader);
43281
43399
  const vertexShader = gl.createShader(gl.VERTEX_SHADER);
43282
43400
  if (gl.isContextLost()) {
@@ -43285,6 +43403,9 @@ class Program {
43285
43403
  }
43286
43404
  gl.shaderSource(vertexShader, vertexSource);
43287
43405
  gl.compileShader(vertexShader);
43406
+ if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
43407
+ throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);
43408
+ }
43288
43409
  gl.attachShader(this.program, vertexShader);
43289
43410
  this.attributes = {};
43290
43411
  const uniformLocations = {};
@@ -43296,6 +43417,9 @@ class Program {
43296
43417
  }
43297
43418
  }
43298
43419
  gl.linkProgram(this.program);
43420
+ if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {
43421
+ throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);
43422
+ }
43299
43423
  gl.deleteShader(vertexShader);
43300
43424
  gl.deleteShader(fragmentShader);
43301
43425
  for (let it = 0; it < allUniformsInfo.length; it++) {
@@ -47535,16 +47659,20 @@ class Transform {
47535
47659
  function throttle(fn, time) {
47536
47660
  let pending = false;
47537
47661
  let timerId = null;
47662
+ let lastCallContext = null;
47663
+ let lastCallArgs;
47538
47664
  const later = () => {
47539
47665
  timerId = null;
47540
47666
  if (pending) {
47541
- fn();
47667
+ fn.apply(lastCallContext, lastCallArgs);
47542
47668
  timerId = setTimeout(later, time);
47543
47669
  pending = false;
47544
47670
  }
47545
47671
  };
47546
- return () => {
47672
+ return (...args) => {
47547
47673
  pending = true;
47674
+ lastCallContext = this;
47675
+ lastCallArgs = args;
47548
47676
  if (!timerId) {
47549
47677
  later();
47550
47678
  }
@@ -49351,6 +49479,12 @@ class ScrollZoomHandler {
49351
49479
  }
49352
49480
  reset() {
49353
49481
  this._active = false;
49482
+ this._zooming = false;
49483
+ delete this._targetZoom;
49484
+ if (this._finishTimeout) {
49485
+ clearTimeout(this._finishTimeout);
49486
+ delete this._finishTimeout;
49487
+ }
49354
49488
  }
49355
49489
  }
49356
49490
 
@@ -50130,7 +50264,7 @@ class HandlerManager {
50130
50264
  this._updatingCamera = true;
50131
50265
  const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);
50132
50266
  const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;
50133
- if (inertialEase) {
50267
+ if (inertialEase && (inertialEase.essential || !performance.browser.prefersReducedMotion)) {
50134
50268
  if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {
50135
50269
  inertialEase.bearing = 0;
50136
50270
  }
@@ -52356,14 +52490,17 @@ let Map$1 = class Map extends Camera {
52356
52490
  if (typeof window !== 'undefined') {
52357
52491
  addEventListener('online', this._onWindowOnline, false);
52358
52492
  let initialResizeEventCaptured = false;
52493
+ const throttledResizeCallback = throttle((entries) => {
52494
+ if (this._trackResize && !this._removed) {
52495
+ this.resize(entries)._update();
52496
+ }
52497
+ }, 50);
52359
52498
  this._resizeObserver = new ResizeObserver((entries) => {
52360
52499
  if (!initialResizeEventCaptured) {
52361
52500
  initialResizeEventCaptured = true;
52362
52501
  return;
52363
52502
  }
52364
- if (this._trackResize) {
52365
- this.resize(entries)._update();
52366
- }
52503
+ throttledResizeCallback(entries);
52367
52504
  });
52368
52505
  this._resizeObserver.observe(this._container);
52369
52506
  }
@@ -53455,7 +53592,8 @@ let Map$1 = class Map extends Camera {
53455
53592
  * ```
53456
53593
  */
53457
53594
  getTerrain() {
53458
- return this.terrain && this.terrain.options;
53595
+ var _a, _b;
53596
+ return (_b = (_a = this.terrain) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null;
53459
53597
  }
53460
53598
  /**
53461
53599
  * Returns a Boolean indicating whether all tiles in the viewport from all sources on
@@ -53744,7 +53882,7 @@ let Map$1 = class Map extends Camera {
53744
53882
  *
53745
53883
  * @param layer - The layer to add,
53746
53884
  * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,
53747
- * less commonly, the {@link CustomLayerInterface} specification.
53885
+ * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition.
53748
53886
  * The MapLibre Style Specification's layer definition is appropriate for most layers.
53749
53887
  *
53750
53888
  * @param beforeId - The ID of an existing layer to insert the new layer before,
@@ -53952,6 +54090,7 @@ let Map$1 = class Map extends Camera {
53952
54090
  * @param name - The name of the paint property to set.
53953
54091
  * @param value - The value of the paint property to set.
53954
54092
  * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).
54093
+ * Pass `null` to unset the existing value.
53955
54094
  * @param options - Options object.
53956
54095
  * @returns `this`
53957
54096
  * @example
@@ -54748,7 +54887,6 @@ const defaultOptions$3 = {
54748
54887
  * map.addControl(nav, 'top-left');
54749
54888
  * ```
54750
54889
  * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)
54751
- * @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
54752
54890
  */
54753
54891
  class NavigationControl {
54754
54892
  /**
@@ -55110,6 +55248,10 @@ class Marker extends performance.Evented {
55110
55248
  this._update = (e) => {
55111
55249
  if (!this._map)
55112
55250
  return;
55251
+ const isFullyLoaded = this._map.loaded() && !this._map.isMoving();
55252
+ if ((e === null || e === void 0 ? void 0 : e.type) === 'terrain' || ((e === null || e === void 0 ? void 0 : e.type) === 'render' && !isFullyLoaded)) {
55253
+ this._map.once('render', this._update);
55254
+ }
55113
55255
  if (this._map.transform.renderWorldCopies) {
55114
55256
  this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);
55115
55257
  }
@@ -55333,6 +55475,7 @@ class Marker extends performance.Evented {
55333
55475
  map.getCanvasContainer().appendChild(this._element);
55334
55476
  map.on('move', this._update);
55335
55477
  map.on('moveend', this._update);
55478
+ map.on('terrain', this._update);
55336
55479
  this.setDraggable(this._draggable);
55337
55480
  this._update();
55338
55481
  // If we attached the `click` listener to the marker element, the popup
@@ -55448,7 +55591,7 @@ class Marker extends performance.Evented {
55448
55591
  if (!('offset' in popup.options)) {
55449
55592
  const markerHeight = 41 - (5.8 / 2);
55450
55593
  const markerRadius = 13.5;
55451
- const linearOffset = Math.sqrt(Math.pow(markerRadius, 2) / 2);
55594
+ const linearOffset = Math.abs(markerRadius) / Math.SQRT2;
55452
55595
  popup.options.offset = this._defaultMarker ? {
55453
55596
  'top': [0, 0],
55454
55597
  'top-left': [0, 0],
@@ -57021,7 +57164,7 @@ function normalizeOffset(offset) {
57021
57164
  }
57022
57165
  else if (typeof offset === 'number') {
57023
57166
  // input specifies a radius from which to calculate offsets at all positions
57024
- const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
57167
+ const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);
57025
57168
  return {
57026
57169
  'center': new performance.Point(0, 0),
57027
57170
  'top': new performance.Point(0, offset),