azure-maps-control 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,10 +91,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
91
91
 
92
92
  var azuremapsMaplibreGlDev = {exports: {}};
93
93
 
94
- /* Build timestamp: Tue, 15 Aug 2023 00:27:33 GMT */
94
+ /* Build timestamp: Thu, 16 Nov 2023 20:40:59 GMT */
95
95
 
96
96
  (function (module, exports) {
97
- /* The Azure Maps fork of 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 */
97
+ /* The Azure Maps fork of MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.6.1/LICENSE.txt */
98
98
  (function (global, factory) {
99
99
  module.exports = factory() ;
100
100
  })(commonjsGlobal, (function () {
@@ -121,7 +121,22 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
121
121
  }
122
122
 
123
123
 
124
- define(['exports'], (function (exports) {
124
+ define(['exports'], (function (exports) {
125
+ function __awaiter(thisArg, _arguments, P, generator) {
126
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
127
+ return new (P || (P = Promise))(function (resolve, reject) {
128
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
129
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
130
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
131
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
132
+ });
133
+ }
134
+
135
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
136
+ var e = new Error(message);
137
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
138
+ };
139
+
125
140
  function getDefaultExportFromCjs (x) {
126
141
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
127
142
  }
@@ -518,6 +533,52 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
518
533
 
519
534
  var UnitBezier$1 = /*@__PURE__*/getDefaultExportFromCjs(unitbezier);
520
535
 
536
+ let supportsOffscreenCanvas;
537
+ function offscreenCanvasSupported() {
538
+ if (supportsOffscreenCanvas == null) {
539
+ supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&
540
+ new OffscreenCanvas(1, 1).getContext('2d') &&
541
+ typeof createImageBitmap === 'function';
542
+ }
543
+ return supportsOffscreenCanvas;
544
+ }
545
+
546
+ let offscreenCanvasDistorted;
547
+ /**
548
+ * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185).
549
+ * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false
550
+ * if they don't match.
551
+ *
552
+ * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise.
553
+ */
554
+ function isOffscreenCanvasDistorted() {
555
+ if (offscreenCanvasDistorted == null) {
556
+ offscreenCanvasDistorted = false;
557
+ if (offscreenCanvasSupported()) {
558
+ const size = 5;
559
+ const canvas = new OffscreenCanvas(size, size);
560
+ const context = canvas.getContext('2d', { willReadFrequently: true });
561
+ if (context) {
562
+ // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel):
563
+ // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...]
564
+ for (let i = 0; i < size * size; i++) {
565
+ const base = i * 4;
566
+ context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;
567
+ context.fillRect(i % size, Math.floor(i / size), 1, 1);
568
+ }
569
+ const data = context.getImageData(0, 0, size, size).data;
570
+ for (let i = 0; i < size * size * 4; i++) {
571
+ if (i % 4 !== 3 && data[i] !== i) {
572
+ offscreenCanvasDistorted = true;
573
+ break;
574
+ }
575
+ }
576
+ }
577
+ }
578
+ }
579
+ return offscreenCanvasDistorted || false;
580
+ }
581
+
521
582
  /**
522
583
  * Given a value `t` that varies between 0 and 1, return
523
584
  * an interpolation function that eases between 0 and 1 in a pleasing
@@ -943,6 +1004,143 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
943
1004
  const blob = new Blob([new Uint8Array(data)], { type: 'image/png' });
944
1005
  img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;
945
1006
  }
1007
+ /**
1008
+ * Computes the webcodecs VideoFrame API options to select a rectangle out of
1009
+ * an image and write it into the destination rectangle.
1010
+ *
1011
+ * Rect (x/y/width/height) select the overlapping rectangle from the source image
1012
+ * and layout (offset/stride) write that overlapping rectangle to the correct place
1013
+ * in the destination image.
1014
+ *
1015
+ * Offset is the byte offset in the dest image that the first pixel appears at
1016
+ * and stride is the number of bytes to the start of the next row:
1017
+ * ┌───────────┐
1018
+ * │ dest │
1019
+ * │ ┌───┼───────┐
1020
+ * │offset→│▓▓▓│ source│
1021
+ * │ │▓▓▓│ │
1022
+ * │ └───┼───────┘
1023
+ * │stride ⇠╌╌╌│
1024
+ * │╌╌╌╌╌╌→ │
1025
+ * └───────────┘
1026
+ *
1027
+ * @param image - source image containing a width and height attribute
1028
+ * @param x - top-left x coordinate to read from the image
1029
+ * @param y - top-left y coordinate to read from the image
1030
+ * @param width - width of the rectangle to read from the image
1031
+ * @param height - height of the rectangle to read from the image
1032
+ * @returns the layout and rect options to pass into VideoFrame API
1033
+ */
1034
+ function computeVideoFrameParameters(image, x, y, width, height) {
1035
+ const destRowOffset = Math.max(-x, 0) * 4;
1036
+ const firstSourceRow = Math.max(0, y);
1037
+ const firstDestRow = firstSourceRow - y;
1038
+ const offset = firstDestRow * width * 4 + destRowOffset;
1039
+ const stride = width * 4;
1040
+ const sourceLeft = Math.max(0, x);
1041
+ const sourceTop = Math.max(0, y);
1042
+ const sourceRight = Math.min(image.width, x + width);
1043
+ const sourceBottom = Math.min(image.height, y + height);
1044
+ return {
1045
+ rect: {
1046
+ x: sourceLeft,
1047
+ y: sourceTop,
1048
+ width: sourceRight - sourceLeft,
1049
+ height: sourceBottom - sourceTop
1050
+ },
1051
+ layout: [{ offset, stride }]
1052
+ };
1053
+ }
1054
+ /**
1055
+ * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.
1056
+ *
1057
+ * @param data - image, imagebitmap, or canvas to parse
1058
+ * @param x - top-left x coordinate to read from the image
1059
+ * @param y - top-left y coordinate to read from the image
1060
+ * @param width - width of the rectangle to read from the image
1061
+ * @param height - height of the rectangle to read from the image
1062
+ * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred
1063
+ */
1064
+ function readImageUsingVideoFrame(image, x, y, width, height) {
1065
+ return __awaiter(this, void 0, void 0, function* () {
1066
+ if (typeof VideoFrame === 'undefined') {
1067
+ throw new Error('VideoFrame not supported');
1068
+ }
1069
+ const frame = new VideoFrame(image, { timestamp: 0 });
1070
+ try {
1071
+ const format = frame === null || frame === void 0 ? void 0 : frame.format;
1072
+ if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {
1073
+ throw new Error(`Unrecognized format ${format}`);
1074
+ }
1075
+ const swapBR = format.startsWith('BGR');
1076
+ const result = new Uint8ClampedArray(width * height * 4);
1077
+ yield frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));
1078
+ if (swapBR) {
1079
+ for (let i = 0; i < result.length; i += 4) {
1080
+ const tmp = result[i];
1081
+ result[i] = result[i + 2];
1082
+ result[i + 2] = tmp;
1083
+ }
1084
+ }
1085
+ return result;
1086
+ }
1087
+ finally {
1088
+ frame.close();
1089
+ }
1090
+ });
1091
+ }
1092
+ let offscreenCanvas;
1093
+ let offscreenCanvasContext;
1094
+ /**
1095
+ * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas
1096
+ *
1097
+ * @param data - image, imagebitmap, or canvas to parse
1098
+ * @param x - top-left x coordinate to read from the image
1099
+ * @param y - top-left y coordinate to read from the image
1100
+ * @param width - width of the rectangle to read from the image
1101
+ * @param height - height of the rectangle to read from the image
1102
+ * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred
1103
+ */
1104
+ function readImageDataUsingOffscreenCanvas(imgBitmap, x, y, width, height) {
1105
+ const origWidth = imgBitmap.width;
1106
+ const origHeight = imgBitmap.height;
1107
+ // Lazily initialize OffscreenCanvas
1108
+ if (!offscreenCanvas || !offscreenCanvasContext) {
1109
+ // Dem tiles are typically 256x256
1110
+ offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);
1111
+ offscreenCanvasContext = offscreenCanvas.getContext('2d', { willReadFrequently: true });
1112
+ }
1113
+ offscreenCanvas.width = origWidth;
1114
+ offscreenCanvas.height = origHeight;
1115
+ offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);
1116
+ const imgData = offscreenCanvasContext.getImageData(x, y, width, height);
1117
+ offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);
1118
+ return imgData.data;
1119
+ }
1120
+ /**
1121
+ * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and
1122
+ * the browser is mangling OffscreenCanvas getImageData results.
1123
+ *
1124
+ * @param data - image, imagebitmap, or canvas to parse
1125
+ * @param x - top-left x coordinate to read from the image
1126
+ * @param y - top-left y coordinate to read from the image
1127
+ * @param width - width of the rectangle to read from the image
1128
+ * @param height - height of the rectangle to read from the image
1129
+ * @returns a promise containing the parsed RGBA pixel values of the image
1130
+ */
1131
+ function getImageData(image, x, y, width, height) {
1132
+ return __awaiter(this, void 0, void 0, function* () {
1133
+ if (isOffscreenCanvasDistorted()) {
1134
+ try {
1135
+ return yield readImageUsingVideoFrame(image, x, y, width, height);
1136
+ }
1137
+ catch (e) {
1138
+ // fall back to OffscreenCanvas
1139
+ }
1140
+ }
1141
+ return readImageDataUsingOffscreenCanvas(image, x, y, width, height);
1142
+ });
1143
+ }
946
1144
 
947
1145
  const now = typeof performance !== 'undefined' && performance && performance.now ?
948
1146
  performance.now.bind(performance) :
@@ -1579,10 +1777,28 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
1579
1777
  terrarium: {
1580
1778
  },
1581
1779
  mapbox: {
1780
+ },
1781
+ custom: {
1582
1782
  }
1583
1783
  },
1584
1784
  "default": "mapbox"
1585
1785
  },
1786
+ redFactor: {
1787
+ type: "number",
1788
+ "default": 1
1789
+ },
1790
+ blueFactor: {
1791
+ type: "number",
1792
+ "default": 1
1793
+ },
1794
+ greenFactor: {
1795
+ type: "number",
1796
+ "default": 1
1797
+ },
1798
+ baseShift: {
1799
+ type: "number",
1800
+ "default": 0
1801
+ },
1586
1802
  volatile: {
1587
1803
  type: "boolean",
1588
1804
  "default": false
@@ -8856,6 +9072,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
8856
9072
  }
8857
9073
  }
8858
9074
  }
9075
+ function isZoomExpression(expression) {
9076
+ return expression._styleExpression !== undefined;
9077
+ }
8859
9078
  function createPropertyExpression(expressionInput, propertySpec) {
8860
9079
  const expression = createExpression(expressionInput, propertySpec);
8861
9080
  if (expression.result === 'error') {
@@ -9871,6 +10090,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9871
10090
  else if (sourceType === 'vector' && type === 'raster') {
9872
10091
  errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster source`));
9873
10092
  }
10093
+ else if (sourceType !== 'raster-dem' && type === 'hillshade') {
10094
+ errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster-dem source`));
10095
+ }
9874
10096
  else if (sourceType === 'raster' && type !== 'raster') {
9875
10097
  errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a vector source`));
9876
10098
  }
@@ -9957,6 +10179,47 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9957
10179
  return [];
9958
10180
  }
9959
10181
 
10182
+ function validateRasterDEMSource(options) {
10183
+ var _a;
10184
+ const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';
10185
+ const rasterDEM = options.value;
10186
+ const styleSpec = options.styleSpec;
10187
+ const rasterDEMSpec = styleSpec.source_raster_dem;
10188
+ const style = options.style;
10189
+ let errors = [];
10190
+ const rootType = getType(rasterDEM);
10191
+ if (rasterDEM === undefined) {
10192
+ return errors;
10193
+ }
10194
+ else if (rootType !== 'object') {
10195
+ errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));
10196
+ return errors;
10197
+ }
10198
+ const encoding = unbundle(rasterDEM.encoding);
10199
+ const isCustomEncoding = encoding === 'custom';
10200
+ const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];
10201
+ const encodingName = options.value.encoding ? `"${options.value.encoding}"` : 'Default';
10202
+ for (const key in rasterDEM) {
10203
+ if (!isCustomEncoding && customEncodingKeys.includes(key)) {
10204
+ errors.push(new ValidationError(key, rasterDEM[key], `In "${sourceName}": "${key}" is only valid when "encoding" is set to "custom". ${encodingName} encoding found`));
10205
+ }
10206
+ else if (rasterDEMSpec[key]) {
10207
+ errors = errors.concat(options.validateSpec({
10208
+ key,
10209
+ value: rasterDEM[key],
10210
+ valueSpec: rasterDEMSpec[key],
10211
+ validateSpec: options.validateSpec,
10212
+ style,
10213
+ styleSpec
10214
+ }));
10215
+ }
10216
+ else {
10217
+ errors.push(new ValidationError(key, rasterDEM[key], `unknown property "${key}"`));
10218
+ }
10219
+ }
10220
+ return errors;
10221
+ }
10222
+
9960
10223
  const objectElementValidators = {
9961
10224
  promoteId: validatePromoteId
9962
10225
  };
@@ -9974,7 +10237,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9974
10237
  switch (type) {
9975
10238
  case 'vector':
9976
10239
  case 'raster':
9977
- case 'raster-dem':
9978
10240
  errors = validateObject({
9979
10241
  key,
9980
10242
  value,
@@ -9985,6 +10247,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9985
10247
  validateSpec,
9986
10248
  });
9987
10249
  return errors;
10250
+ case 'raster-dem':
10251
+ errors = validateRasterDEMSource({
10252
+ sourceName: key,
10253
+ value,
10254
+ style: options.style,
10255
+ styleSpec,
10256
+ validateSpec,
10257
+ });
10258
+ return errors;
9988
10259
  case 'geojson':
9989
10260
  errors = validateObject({
9990
10261
  key,
@@ -10698,7 +10969,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10698
10969
  klass.serialize(input, transferables) : {};
10699
10970
  if (!klass.serialize) {
10700
10971
  for (const key in input) {
10701
- // any cast due to https://github.com/facebook/flow/issues/5393
10702
10972
  if (!input.hasOwnProperty(key))
10703
10973
  continue; // eslint-disable-line no-prototype-builtins
10704
10974
  if (registry[name].omit.indexOf(key) >= 0)
@@ -18641,8 +18911,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
18641
18911
  }
18642
18912
  _handleSpecialPaintPropertyUpdate(name) {
18643
18913
  if (name === 'line-gradient') {
18644
- const expression = this._transitionablePaint._values['line-gradient'].value.expression;
18645
- this.stepInterpolant = expression._styleExpression.expression instanceof Step;
18914
+ const expression = this.gradientExpression();
18915
+ if (isZoomExpression(expression)) {
18916
+ this.stepInterpolant = expression._styleExpression.expression instanceof Step;
18917
+ }
18918
+ else {
18919
+ this.stepInterpolant = false;
18920
+ }
18646
18921
  this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
18647
18922
  }
18648
18923
  }
@@ -20492,7 +20767,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
20492
20767
  /**
20493
20768
  * Called when shapedIcon.image.contentMatch is set.
20494
20769
  * Determines the dimensions of a content rectangle using the value in contentMatch.
20495
- * @param shapedIcon The icon that will be resized.
20770
+ *
20771
+ * @param shapedIcon - The icon that will be resized.
20496
20772
  * @returns Extents of the shapedIcon with contentMatch adjustments if necessary.
20497
20773
  */
20498
20774
  function applyContentMatch(shapedIcon) {
@@ -21275,7 +21551,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21275
21551
  */
21276
21552
  function resolveTokens(properties, text) {
21277
21553
  return text.replace(/{([^{}]+)}/g, (match, key) => {
21278
- return key in properties ? String(properties[key]) : '';
21554
+ return properties && key in properties ? String(properties[key]) : '';
21279
21555
  });
21280
21556
  }
21281
21557
 
@@ -21769,8 +22045,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21769
22045
  if (callback) {
21770
22046
  this.callbacks[id] = callback;
21771
22047
  }
21772
- const buffers = isSafari(this.globalScope) ? undefined : [];
21773
- this.target.postMessage({
22048
+ const buffers = [];
22049
+ const message = {
21774
22050
  id,
21775
22051
  type,
21776
22052
  hasCallback: !!callback,
@@ -21778,19 +22054,21 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21778
22054
  mustQueue,
21779
22055
  sourceMapId: this.mapId,
21780
22056
  data: serialize(data, buffers)
21781
- }, buffers);
22057
+ };
22058
+ this.target.postMessage(message, { transfer: buffers });
21782
22059
  return {
21783
22060
  cancel: () => {
21784
22061
  if (callback) {
21785
22062
  // Set the callback to null so that it never fires after the request is aborted.
21786
22063
  delete this.callbacks[id];
21787
22064
  }
21788
- this.target.postMessage({
22065
+ const cancelMessage = {
21789
22066
  id,
21790
22067
  type: '<cancel>',
21791
22068
  targetMapId,
21792
22069
  sourceMapId: this.mapId
21793
- });
22070
+ };
22071
+ this.target.postMessage(cancelMessage);
21794
22072
  }
21795
22073
  };
21796
22074
  }
@@ -21812,17 +22090,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21812
22090
  }
21813
22091
  else {
21814
22092
  let completed = false;
21815
- const buffers = isSafari(this.globalScope) ? undefined : [];
22093
+ const buffers = [];
21816
22094
  const done = task.hasCallback ? (err, data) => {
21817
22095
  completed = true;
21818
22096
  delete this.cancelCallbacks[id];
21819
- this.target.postMessage({
22097
+ const responseMessage = {
21820
22098
  id,
21821
22099
  type: '<response>',
21822
22100
  sourceMapId: this.mapId,
21823
22101
  error: err ? serialize(err) : null,
21824
22102
  data: serialize(data, buffers)
21825
- }, buffers);
22103
+ };
22104
+ this.target.postMessage(responseMessage, { transfer: buffers });
21826
22105
  } : (_) => {
21827
22106
  completed = true;
21828
22107
  };
@@ -21832,7 +22111,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21832
22111
  // task.type == 'loadTile', 'removeTile', etc.
21833
22112
  callback = this.parent[task.type](task.sourceMapId, params, done);
21834
22113
  }
21835
- else if (this.parent.getWorkerSource) {
22114
+ else if ('getWorkerSource' in this.parent) {
21836
22115
  // task.type == sourcetype.method
21837
22116
  const keys = task.type.split('.');
21838
22117
  const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], params.source);
@@ -22332,29 +22611,45 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22332
22611
  register('CanonicalTileID', CanonicalTileID);
22333
22612
  register('OverscaledTileID', OverscaledTileID, { omit: ['posMatrix'] });
22334
22613
 
22335
- // DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders
22336
- // data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially
22337
- // loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the
22338
- // elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of
22339
- // integer overflow when creating the texture used in the hillshadePrepare step.
22340
- // DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8
22341
- // surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a
22342
- // tile's edge without backfilling from neighboring tiles.
22343
22614
  class DEMData {
22344
22615
  // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride
22345
22616
  // and dim is calculated as stride - 2.
22346
- constructor(uid, data, encoding) {
22617
+ constructor(uid, data, encoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {
22347
22618
  this.uid = uid;
22348
22619
  if (data.height !== data.width)
22349
22620
  throw new RangeError('DEM tiles must be square');
22350
- if (encoding && encoding !== 'mapbox' && encoding !== 'terrarium') {
22351
- warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);
22621
+ if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {
22622
+ warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);
22352
22623
  return;
22353
22624
  }
22354
22625
  this.stride = data.height;
22355
22626
  const dim = this.dim = data.height - 2;
22356
22627
  this.data = new Uint32Array(data.data.buffer);
22357
- this.encoding = encoding || 'mapbox';
22628
+ switch (encoding) {
22629
+ case 'terrarium':
22630
+ // unpacking formula for mapzen terrarium:
22631
+ // https://aws.amazon.com/public-datasets/terrain/
22632
+ this.redFactor = 256.0;
22633
+ this.greenFactor = 1.0;
22634
+ this.blueFactor = 1.0 / 256.0;
22635
+ this.baseShift = 32768.0;
22636
+ break;
22637
+ case 'custom':
22638
+ this.redFactor = redFactor;
22639
+ this.greenFactor = greenFactor;
22640
+ this.blueFactor = blueFactor;
22641
+ this.baseShift = baseShift;
22642
+ break;
22643
+ case 'mapbox':
22644
+ default:
22645
+ // unpacking formula for mapbox.terrain-rgb:
22646
+ // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
22647
+ this.redFactor = 6553.6;
22648
+ this.greenFactor = 25.6;
22649
+ this.blueFactor = 0.1;
22650
+ this.baseShift = 10000.0;
22651
+ break;
22652
+ }
22358
22653
  // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image
22359
22654
  // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring
22360
22655
  // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder
@@ -22389,26 +22684,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22389
22684
  get(x, y) {
22390
22685
  const pixels = new Uint8Array(this.data.buffer);
22391
22686
  const index = this._idx(x, y) * 4;
22392
- const unpack = this.encoding === 'terrarium' ? this._unpackTerrarium : this._unpackMapbox;
22393
- return unpack(pixels[index], pixels[index + 1], pixels[index + 2]);
22687
+ return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);
22394
22688
  }
22395
22689
  getUnpackVector() {
22396
- return this.encoding === 'terrarium' ? [256.0, 1.0, 1.0 / 256.0, 32768.0] : [6553.6, 25.6, 0.1, 10000.0];
22690
+ return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];
22397
22691
  }
22398
22692
  _idx(x, y) {
22399
22693
  if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1)
22400
22694
  throw new RangeError('out of range source coordinates for DEM data');
22401
22695
  return (y + 1) * this.stride + (x + 1);
22402
22696
  }
22403
- _unpackMapbox(r, g, b) {
22404
- // unpacking formula for mapbox.terrain-rgb:
22405
- // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
22406
- return ((r * 256 * 256 + g * 256.0 + b) / 10.0 - 10000.0);
22407
- }
22408
- _unpackTerrarium(r, g, b) {
22409
- // unpacking formula for mapzen terrarium:
22410
- // https://aws.amazon.com/public-datasets/terrain/
22411
- return ((r * 256 + g + b / 256) - 32768.0);
22697
+ unpack(r, g, b) {
22698
+ return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);
22412
22699
  }
22413
22700
  getPixels() {
22414
22701
  return new RGBAImage({ width: this.stride, height: this.stride }, new Uint8Array(this.data.buffer));
@@ -23107,10 +23394,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23107
23394
  verticalizedLabelOffset = builtInOffset;
23108
23395
  builtInOffset = [0, 0];
23109
23396
  }
23397
+ const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1;
23110
23398
  const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];
23111
23399
  const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1];
23112
- const x2 = x1 + textureRect.w * positionedGlyph.scale / pixelRatio;
23113
- const y2 = y1 + textureRect.h * positionedGlyph.scale / pixelRatio;
23400
+ const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio;
23401
+ const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio;
23114
23402
  const tl = new Point$2(x1, y1);
23115
23403
  const tr = new Point$2(x2, y1);
23116
23404
  const bl = new Point$2(x1, y2);
@@ -23454,7 +23742,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23454
23742
  if (radialOffset < 0)
23455
23743
  radialOffset = 0; // Ignore negative offset.
23456
23744
  // solve for r where r^2 + r^2 = radialOffset^2
23457
- const hypotenuse = radialOffset / Math.sqrt(2);
23745
+ const hypotenuse = radialOffset / Math.SQRT2;
23458
23746
  switch (anchor) {
23459
23747
  case 'top-right':
23460
23748
  case 'top-left':
@@ -24475,6 +24763,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24475
24763
  exports.UnwrappedTileID = UnwrappedTileID;
24476
24764
  exports.ValidationError = ValidationError;
24477
24765
  exports.ZoomHistory = ZoomHistory;
24766
+ exports.__awaiter = __awaiter;
24478
24767
  exports.add = add$4;
24479
24768
  exports.addDynamicAttributes = addDynamicAttributes;
24480
24769
  exports.arrayBufferToImage = arrayBufferToImage;
@@ -24520,6 +24809,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24520
24809
  exports.getAnchorJustification = getAnchorJustification;
24521
24810
  exports.getArrayBuffer = getArrayBuffer;
24522
24811
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
24812
+ exports.getImageData = getImageData;
24523
24813
  exports.getJSON = getJSON;
24524
24814
  exports.getOverlapMode = getOverlapMode;
24525
24815
  exports.getProtocolAction = getProtocolAction;
@@ -24531,6 +24821,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24531
24821
  exports.interpolate = interpolate;
24532
24822
  exports.invert = invert$2;
24533
24823
  exports.isImageBitmap = isImageBitmap;
24824
+ exports.isOffscreenCanvasDistorted = isOffscreenCanvasDistorted;
24534
24825
  exports.isSafari = isSafari;
24535
24826
  exports.isWorker = isWorker;
24536
24827
  exports.keysDifference = keysDifference;
@@ -24545,6 +24836,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24545
24836
  exports.multiply = multiply$5;
24546
24837
  exports.nextPowerOfTwo = nextPowerOfTwo;
24547
24838
  exports.normalize = normalize$4;
24839
+ exports.offscreenCanvasSupported = offscreenCanvasSupported;
24548
24840
  exports.operations = operations;
24549
24841
  exports.ortho = ortho;
24550
24842
  exports.parseCacheControl = parseCacheControl;
@@ -24557,6 +24849,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24557
24849
  exports.pointGeometry = pointGeometry;
24558
24850
  exports.polygonIntersectsPolygon = polygonIntersectsPolygon;
24559
24851
  exports.potpack = potpack;
24852
+ exports.readImageUsingVideoFrame = readImageUsingVideoFrame;
24560
24853
  exports.register = register;
24561
24854
  exports.registerForPluginStateChange = registerForPluginStateChange;
24562
24855
  exports.renderColorRamp = renderColorRamp;
@@ -24871,12 +25164,27 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24871
25164
  callback(err);
24872
25165
  }
24873
25166
  else if (data) {
24874
- callback(null, {
24875
- vectorTile: new performance.vectorTile.VectorTile(new performance.Protobuf(data)),
24876
- rawData: data,
24877
- cacheControl,
24878
- expires
24879
- });
25167
+ try {
25168
+ const vectorTile = new performance.vectorTile.VectorTile(new performance.Protobuf(data));
25169
+ callback(null, {
25170
+ vectorTile,
25171
+ rawData: data,
25172
+ cacheControl,
25173
+ expires
25174
+ });
25175
+ }
25176
+ catch (ex) {
25177
+ const bytes = new Uint8Array(data);
25178
+ const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;
25179
+ let errorMessage = `Unable to parse the tile at ${params.request.url}, `;
25180
+ if (isGzipped) {
25181
+ errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';
25182
+ }
25183
+ else {
25184
+ errorMessage += `got error: ${ex.messge}`;
25185
+ }
25186
+ callback(new Error(errorMessage));
25187
+ }
24880
25188
  }
24881
25189
  });
24882
25190
  return () => {
@@ -25025,28 +25333,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25025
25333
  this.loaded = {};
25026
25334
  }
25027
25335
  loadTile(params, callback) {
25028
- const { uid, encoding, rawImageData } = params;
25029
- // Main thread will transfer ImageBitmap if offscreen decode with OffscreenCanvas is supported, else it will transfer an already decoded image.
25030
- const imagePixels = performance.isImageBitmap(rawImageData) ? this.getImageData(rawImageData) : rawImageData;
25031
- const dem = new performance.DEMData(uid, imagePixels, encoding);
25032
- this.loaded = this.loaded || {};
25033
- this.loaded[uid] = dem;
25034
- callback(null, dem);
25035
- }
25036
- getImageData(imgBitmap) {
25037
- // Lazily initialize OffscreenCanvas
25038
- if (!this.offscreenCanvas || !this.offscreenCanvasContext) {
25039
- // Dem tiles are typically 256x256
25040
- this.offscreenCanvas = new OffscreenCanvas(imgBitmap.width, imgBitmap.height);
25041
- this.offscreenCanvasContext = this.offscreenCanvas.getContext('2d', { willReadFrequently: true });
25042
- }
25043
- this.offscreenCanvas.width = imgBitmap.width;
25044
- this.offscreenCanvas.height = imgBitmap.height;
25045
- this.offscreenCanvasContext.drawImage(imgBitmap, 0, 0, imgBitmap.width, imgBitmap.height);
25046
- // Insert an additional 1px padding around the image to allow backfilling for neighboring data.
25047
- const imgData = this.offscreenCanvasContext.getImageData(-1, -1, imgBitmap.width + 2, imgBitmap.height + 2);
25048
- this.offscreenCanvasContext.clearRect(0, 0, this.offscreenCanvas.width, this.offscreenCanvas.height);
25049
- return new performance.RGBAImage({ width: imgData.width, height: imgData.height }, imgData.data);
25336
+ return performance.__awaiter(this, void 0, void 0, function* () {
25337
+ const { uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift } = params;
25338
+ const width = rawImageData.width + 2;
25339
+ const height = rawImageData.height + 2;
25340
+ const imagePixels = performance.isImageBitmap(rawImageData) ?
25341
+ new performance.RGBAImage({ width, height }, yield performance.getImageData(rawImageData, -1, -1, width, height)) :
25342
+ rawImageData;
25343
+ const dem = new performance.DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);
25344
+ this.loaded = this.loaded || {};
25345
+ this.loaded[uid] = dem;
25346
+ callback(null, dem);
25347
+ });
25050
25348
  }
25051
25349
  removeTile(params) {
25052
25350
  const loaded = this.loaded, uid = params.uid;
@@ -26787,10 +27085,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26787
27085
  // note: removeAllProperties gives us a new properties object, so we can skip the clone step
26788
27086
  const cloneProperties = !update.removeAllProperties && (((_a = update.removeProperties) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = update.addOrUpdateProperties) === null || _b === void 0 ? void 0 : _b.length) > 0);
26789
27087
  if (cloneFeature || cloneProperties) {
26790
- feature = { ...feature };
27088
+ feature = Object.assign({}, feature);
26791
27089
  updateable.set(update.id, feature);
26792
27090
  if (cloneProperties) {
26793
- feature.properties = { ...feature.properties };
27091
+ feature.properties = Object.assign({}, feature.properties);
26794
27092
  }
26795
27093
  }
26796
27094
  if (update.newGeometry) {
@@ -26815,34 +27113,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26815
27113
  }
26816
27114
  }
26817
27115
 
26818
- function loadGeoJSONTile(params, callback) {
26819
- const canonical = params.tileID.canonical;
26820
- if (!this._geoJSONIndex) {
26821
- return callback(null, null); // we couldn't load the file
26822
- }
26823
- const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);
26824
- if (!geoJSONTile) {
26825
- return callback(null, null); // nothing in the given tile
26826
- }
26827
- const geojsonWrapper = new GeoJSONWrapper$2(geoJSONTile.features);
26828
- // Encode the geojson-vt tile into binary vector tile form. This
26829
- // is a convenience that allows `FeatureIndex` to operate the same way
26830
- // across `VectorTileSource` and `GeoJSONSource` data.
26831
- let pbf = vtpbf(geojsonWrapper);
26832
- if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {
26833
- // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)
26834
- pbf = new Uint8Array(pbf);
26835
- }
26836
- callback(null, {
26837
- vectorTile: geojsonWrapper,
26838
- rawData: pbf.buffer
26839
- });
26840
- }
26841
27116
  /**
26842
27117
  * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.
26843
27118
  * This class is designed to be easily reused to support custom source types
26844
27119
  * for data formats that can be parsed/converted into an in-memory GeoJSON
26845
- * representation. To do so, create it with
27120
+ * representation. To do so, create it with
26846
27121
  * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.
26847
27122
  * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).
26848
27123
  */
@@ -26853,7 +27128,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26853
27128
  * See {@link GeoJSONWorkerSource#loadGeoJSON}.
26854
27129
  */
26855
27130
  constructor(actor, layerIndex, availableImages, loadGeoJSON) {
26856
- super(actor, layerIndex, availableImages, loadGeoJSONTile);
27131
+ super(actor, layerIndex, availableImages);
26857
27132
  this._dataUpdateable = new Map();
26858
27133
  /**
26859
27134
  * Fetch and parse GeoJSON according to the given params. Calls `callback`
@@ -26902,10 +27177,34 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26902
27177
  }
26903
27178
  return { cancel: () => { } };
26904
27179
  };
27180
+ this.loadVectorData = this.loadGeoJSONTile;
26905
27181
  if (loadGeoJSON) {
26906
27182
  this.loadGeoJSON = loadGeoJSON;
26907
27183
  }
26908
27184
  }
27185
+ loadGeoJSONTile(params, callback) {
27186
+ const canonical = params.tileID.canonical;
27187
+ if (!this._geoJSONIndex) {
27188
+ return callback(null, null); // we couldn't load the file
27189
+ }
27190
+ const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);
27191
+ if (!geoJSONTile) {
27192
+ return callback(null, null); // nothing in the given tile
27193
+ }
27194
+ const geojsonWrapper = new GeoJSONWrapper$2(geoJSONTile.features);
27195
+ // Encode the geojson-vt tile into binary vector tile form. This
27196
+ // is a convenience that allows `FeatureIndex` to operate the same way
27197
+ // across `VectorTileSource` and `GeoJSONSource` data.
27198
+ let pbf = vtpbf(geojsonWrapper);
27199
+ if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {
27200
+ // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)
27201
+ pbf = new Uint8Array(pbf);
27202
+ }
27203
+ callback(null, {
27204
+ vectorTile: geojsonWrapper,
27205
+ rawData: pbf.buffer
27206
+ });
27207
+ }
26909
27208
  /**
26910
27209
  * Fetches (if appropriate), parses, and index geojson data into tiles. This
26911
27210
  * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}
@@ -27187,12 +27486,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27187
27486
  }
27188
27487
  return layerIndexes;
27189
27488
  }
27190
- getWorkerSource(mapId, type, source) {
27489
+ getWorkerSource(mapId, sourceType, sourceName) {
27191
27490
  if (!this.workerSources[mapId])
27192
27491
  this.workerSources[mapId] = {};
27193
- if (!this.workerSources[mapId][type])
27194
- this.workerSources[mapId][type] = {};
27195
- if (!this.workerSources[mapId][type][source]) {
27492
+ if (!this.workerSources[mapId][sourceType])
27493
+ this.workerSources[mapId][sourceType] = {};
27494
+ if (!this.workerSources[mapId][sourceType][sourceName]) {
27196
27495
  // use a wrapped actor so that we can attach a target mapId param
27197
27496
  // to any messages invoked by the WorkerSource
27198
27497
  const actor = {
@@ -27200,9 +27499,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27200
27499
  this.actor.send(type, data, callback, mapId);
27201
27500
  }
27202
27501
  };
27203
- this.workerSources[mapId][type][source] = new this.workerSourceTypes[type](actor, this.getLayerIndex(mapId), this.getAvailableImages(mapId));
27502
+ this.workerSources[mapId][sourceType][sourceName] = new this.workerSourceTypes[sourceType](actor, this.getLayerIndex(mapId), this.getAvailableImages(mapId));
27204
27503
  }
27205
- return this.workerSources[mapId][type][source];
27504
+ return this.workerSources[mapId][sourceType][sourceName];
27206
27505
  }
27207
27506
  getDEMWorkerSource(mapId, source) {
27208
27507
  if (!this.demWorkerSources[mapId])
@@ -27224,7 +27523,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27224
27523
  define(['./shared'], (function (performance) {
27225
27524
  var name = "azuremaps-maplibre-gl";
27226
27525
  var description = "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library";
27227
- var version$2 = "3.3.0";
27526
+ var version$2 = "3.6.1";
27228
27527
  var main = "dist/azuremaps-maplibre-gl.js";
27229
27528
  var style = "dist/azuremaps-maplibre-gl.css";
27230
27529
  var license = "BSD-3-Clause";
@@ -27243,12 +27542,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27243
27542
  "@mapbox/unitbezier": "^0.0.1",
27244
27543
  "@mapbox/vector-tile": "^1.3.1",
27245
27544
  "@mapbox/whoots-js": "^3.1.0",
27246
- "@maplibre/maplibre-gl-style-spec": "^19.3.0",
27247
- "@types/geojson": "^7946.0.10",
27248
- "@types/mapbox__point-geometry": "^0.1.2",
27249
- "@types/mapbox__vector-tile": "^1.3.0",
27250
- "@types/pbf": "^3.0.2",
27251
- "@types/supercluster": "^7.1.0",
27545
+ "@maplibre/maplibre-gl-style-spec": "^19.3.3",
27546
+ "@types/geojson": "^7946.0.13",
27547
+ "@types/mapbox__point-geometry": "^0.1.4",
27548
+ "@types/mapbox__vector-tile": "^1.3.3",
27549
+ "@types/pbf": "^3.0.4",
27550
+ "@types/supercluster": "^7.1.3",
27252
27551
  earcut: "^2.2.4",
27253
27552
  "geojson-vt": "^3.2.1",
27254
27553
  "gl-matrix": "^3.4.3",
@@ -27265,94 +27564,94 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27265
27564
  var devDependencies = {
27266
27565
  "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
27267
27566
  "@mapbox/mvt-fixtures": "^3.10.0",
27268
- "@rollup/plugin-commonjs": "^25.0.3",
27269
- "@rollup/plugin-json": "^6.0.0",
27270
- "@rollup/plugin-node-resolve": "^15.1.0",
27271
- "@rollup/plugin-replace": "^5.0.2",
27272
- "@rollup/plugin-strip": "^3.0.2",
27273
- "@rollup/plugin-terser": "^0.4.3",
27274
- "@rollup/plugin-typescript": "^11.1.2",
27275
- "@types/benchmark": "^2.1.2",
27567
+ "@rollup/plugin-commonjs": "^25.0.7",
27568
+ "@rollup/plugin-json": "^6.0.1",
27569
+ "@rollup/plugin-node-resolve": "^15.2.3",
27570
+ "@rollup/plugin-replace": "^5.0.5",
27571
+ "@rollup/plugin-strip": "^3.0.4",
27572
+ "@rollup/plugin-terser": "^0.4.4",
27573
+ "@rollup/plugin-typescript": "^11.1.5",
27574
+ "@types/benchmark": "^2.1.5",
27276
27575
  "@types/cssnano": "^5.0.0",
27277
- "@types/d3": "^7.4.0",
27278
- "@types/diff": "^5.0.3",
27279
- "@types/earcut": "^2.1.1",
27280
- "@types/eslint": "^8.44.2",
27281
- "@types/gl": "^6.0.2",
27576
+ "@types/d3": "^7.4.2",
27577
+ "@types/diff": "^5.0.8",
27578
+ "@types/earcut": "^2.1.4",
27579
+ "@types/eslint": "^8.44.7",
27580
+ "@types/geojson-vt": "3.2.4",
27581
+ "@types/gl": "^6.0.4",
27282
27582
  "@types/glob": "^8.1.0",
27283
- "@types/jest": "^29.5.3",
27284
- "@types/jsdom": "^21.1.1",
27285
- "@types/minimist": "^1.2.2",
27286
- "@types/murmurhash-js": "^1.0.4",
27287
- "@types/nise": "^1.4.1",
27288
- "@types/node": "^20.4.8",
27289
- "@types/offscreencanvas": "^2019.7.0",
27290
- "@types/pixelmatch": "^5.2.4",
27291
- "@types/pngjs": "^6.0.1",
27292
- "@types/react": "^18.2.18",
27293
- "@types/react-dom": "^18.2.7",
27294
- "@types/request": "^2.48.8",
27295
- "@types/shuffle-seed": "^1.1.0",
27296
- "@types/window-or-global": "^1.0.4",
27297
- "@typescript-eslint/eslint-plugin": "^6.2.1",
27298
- "@typescript-eslint/parser": "^6.2.1",
27299
- address: "^1.2.2",
27583
+ "@types/jest": "^29.5.8",
27584
+ "@types/jsdom": "^21.1.5",
27585
+ "@types/minimist": "^1.2.5",
27586
+ "@types/murmurhash-js": "^1.0.5",
27587
+ "@types/nise": "^1.4.4",
27588
+ "@types/node": "^20.9.0",
27589
+ "@types/offscreencanvas": "^2019.7.3",
27590
+ "@types/pixelmatch": "^5.2.5",
27591
+ "@types/pngjs": "^6.0.4",
27592
+ "@types/react": "^18.2.35",
27593
+ "@types/react-dom": "^18.2.14",
27594
+ "@types/request": "^2.48.12",
27595
+ "@types/shuffle-seed": "^1.1.2",
27596
+ "@types/window-or-global": "^1.0.6",
27597
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
27598
+ "@typescript-eslint/parser": "^6.10.0",
27599
+ address: "^2.0.1",
27300
27600
  benchmark: "^2.1.4",
27301
27601
  canvas: "^2.11.2",
27302
27602
  cssnano: "^6.0.1",
27303
27603
  d3: "^7.8.5",
27304
27604
  "d3-queue": "^3.0.7",
27305
- "devtools-protocol": "^0.0.1179426",
27605
+ "devtools-protocol": "^0.0.1219864",
27306
27606
  diff: "^5.1.0",
27307
- "dts-bundle-generator": "^8.0.1",
27308
- eslint: "^8.46.0",
27607
+ "dts-bundle-generator": "^8.1.2",
27608
+ eslint: "^8.53.0",
27309
27609
  "eslint-config-mourner": "^3.0.0",
27310
27610
  "eslint-plugin-html": "^7.1.0",
27311
- "eslint-plugin-import": "^2.28.0",
27312
- "eslint-plugin-jest": "^27.2.3",
27313
- "eslint-plugin-react": "^7.33.1",
27611
+ "eslint-plugin-import": "^2.29.0",
27612
+ "eslint-plugin-jest": "^27.6.0",
27613
+ "eslint-plugin-react": "^7.33.2",
27314
27614
  "eslint-plugin-tsdoc": "0.2.17",
27315
- expect: "^29.6.2",
27615
+ expect: "^29.7.0",
27316
27616
  gl: "^6.0.2",
27317
- glob: "^10.3.3",
27617
+ glob: "^10.3.10",
27318
27618
  "is-builtin-module": "^3.2.1",
27319
- jest: "^29.6.2",
27619
+ jest: "^29.7.0",
27320
27620
  "jest-canvas-mock": "^2.5.2",
27321
- "jest-environment-jsdom": "^29.6.2",
27621
+ "jest-environment-jsdom": "^29.7.0",
27322
27622
  jsdom: "^22.1.0",
27323
27623
  "json-stringify-pretty-compact": "^4.0.0",
27324
27624
  minimist: "^1.2.8",
27325
27625
  "mock-geolocation": "^1.0.11",
27326
- nise: "^5.1.4",
27327
- "node-plantuml": "^0.9.0",
27626
+ nise: "^5.1.5",
27328
27627
  "npm-font-open-sans": "^1.1.0",
27329
27628
  "npm-run-all": "^4.1.5",
27330
27629
  "pdf-merger-js": "^4.3.0",
27331
27630
  pixelmatch: "^5.3.0",
27332
27631
  pngjs: "^7.0.0",
27333
- postcss: "^8.4.27",
27632
+ postcss: "^8.4.31",
27334
27633
  "postcss-cli": "^10.1.0",
27335
27634
  "postcss-inline-svg": "^6.0.0",
27336
27635
  "pretty-bytes": "^6.1.1",
27337
- puppeteer: "^21.0.1",
27636
+ puppeteer: "^21.5.1",
27338
27637
  react: "^18.2.0",
27339
27638
  "react-dom": "^18.2.0",
27340
- rollup: "^3.27.2",
27639
+ rollup: "^4.4.0",
27341
27640
  "rollup-plugin-sourcemaps": "^0.6.3",
27342
27641
  rw: "^1.3.3",
27343
27642
  semver: "^7.5.4",
27344
27643
  "shuffle-seed": "^1.1.6",
27345
27644
  "source-map-explorer": "^2.5.3",
27346
27645
  st: "^3.0.0",
27347
- stylelint: "^15.10.2",
27646
+ stylelint: "^15.11.0",
27348
27647
  "stylelint-config-standard": "^34.0.0",
27349
27648
  "ts-jest": "^29.1.1",
27350
27649
  "ts-node": "^10.9.1",
27351
- tslib: "^2.6.1",
27352
- typedoc: "^0.24.8",
27353
- "typedoc-plugin-markdown": "^3.15.4",
27354
- "typedoc-plugin-missing-exports": "^2.0.1",
27355
- typescript: "^5.1.6"
27650
+ tslib: "^2.6.2",
27651
+ typedoc: "^0.25.3",
27652
+ "typedoc-plugin-markdown": "^3.17.1",
27653
+ "typedoc-plugin-missing-exports": "^2.1.0",
27654
+ typescript: "^5.2.2"
27356
27655
  };
27357
27656
  var overrides = {
27358
27657
  "postcss-inline-svg": {
@@ -27378,11 +27677,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27378
27677
  "build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts",
27379
27678
  "build-csp-dev": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev",
27380
27679
  "build-css": "postcss -o dist/azuremaps-maplibre-gl.css src/css/azuremaps-maplibre-gl.css",
27381
- "build-diagrams": "cd docs/diagrams; ls *.plantuml | xargs -I {} puml generate --svg {} -o {}.svg",
27382
27680
  "watch-css": "postcss --watch -o dist/azuremaps-maplibre-gl.css src/css/azuremaps-maplibre-gl.css",
27383
27681
  "build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts",
27384
27682
  "watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch",
27385
27683
  "start-server": "st --no-cache -H 0.0.0.0 --port 9966 .",
27684
+ "start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material",
27386
27685
  start: "run-p watch-css watch-dev start-server",
27387
27686
  "start-bench": "run-p watch-css watch-benchmarks start-server",
27388
27687
  lint: "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .",
@@ -28554,6 +28853,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28554
28853
  if (!this._doesCharSupportLocalGlyph(id)) {
28555
28854
  return;
28556
28855
  }
28856
+ // Client-generated glyphs are rendered at 2x texture scale,
28857
+ // because CJK glyphs are more detailed than others.
28858
+ const textureScale = 2;
28557
28859
  let tinySDF = entry.tinySDF;
28558
28860
  if (!tinySDF) {
28559
28861
  let fontWeight = '400';
@@ -28567,9 +28869,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28567
28869
  fontWeight = '200';
28568
28870
  }
28569
28871
  tinySDF = entry.tinySDF = new GlyphManager.TinySDF({
28570
- fontSize: 24,
28571
- buffer: 3,
28572
- radius: 8,
28872
+ fontSize: 24 * textureScale,
28873
+ buffer: 3 * textureScale,
28874
+ radius: 8 * textureScale,
28573
28875
  cutoff: 0.25,
28574
28876
  fontFamily,
28575
28877
  fontWeight
@@ -28589,16 +28891,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28589
28891
  * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment
28590
28892
  * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode)
28591
28893
  */
28592
- const topAdjustment = 27;
28894
+ const topAdjustment = 27.5;
28895
+ const leftAdjustment = 0.5;
28593
28896
  return {
28594
28897
  id,
28595
- bitmap: new performance.AlphaImage({ width: char.width || 30, height: char.height || 30 }, char.data),
28898
+ bitmap: new performance.AlphaImage({ width: char.width || 30 * textureScale, height: char.height || 30 * textureScale }, char.data),
28596
28899
  metrics: {
28597
- width: char.glyphWidth || 24,
28598
- height: char.glyphHeight || 24,
28599
- left: char.glyphLeft || 0,
28600
- top: char.glyphTop - topAdjustment || -8,
28601
- advance: char.glyphAdvance || 24
28900
+ width: char.glyphWidth / textureScale || 24,
28901
+ height: char.glyphHeight / textureScale || 24,
28902
+ left: (char.glyphLeft / textureScale + leftAdjustment) || 0,
28903
+ top: char.glyphTop / textureScale - topAdjustment || -8,
28904
+ advance: char.glyphAdvance / textureScale || 24,
28905
+ isDoubleResolution: true
28602
28906
  }
28603
28907
  };
28604
28908
  }
@@ -28856,7 +29160,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28856
29160
  const workers = this.workerPool.acquire(mapId);
28857
29161
  for (let i = 0; i < workers.length; i++) {
28858
29162
  const worker = workers[i];
28859
- const actor = new Dispatcher.Actor(worker, parent, mapId);
29163
+ const actor = new performance.Actor(worker, parent, mapId);
28860
29164
  actor.name = `Worker ${i}`;
28861
29165
  this.actors.push(actor);
28862
29166
  }
@@ -28887,7 +29191,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28887
29191
  this.workerPool.release(this.id);
28888
29192
  }
28889
29193
  }
28890
- Dispatcher.Actor = performance.Actor;
28891
29194
 
28892
29195
  function loadTileJson(options, requestManager, callback) {
28893
29196
  const loaded = function (err, tileJSON) {
@@ -29258,7 +29561,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29258
29561
  * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);
29259
29562
  * ```
29260
29563
  * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)
29261
- * @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
29262
29564
  */
29263
29565
  class VectorTileSource extends performance.Evented {
29264
29566
  constructor(id, options, dispatcher, eventedParent) {
@@ -29428,7 +29730,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29428
29730
  * ```ts
29429
29731
  * map.addSource('raster-source', {
29430
29732
  * 'type': 'raster',
29431
- * 'tiles': ['https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg'],
29733
+ * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'],
29432
29734
  * 'tileSize': 256,
29433
29735
  * });
29434
29736
  * ```
@@ -29498,6 +29800,25 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29498
29800
  this._tileJSONRequest = null;
29499
29801
  }
29500
29802
  }
29803
+ setSourceProperty(callback) {
29804
+ if (this._tileJSONRequest) {
29805
+ this._tileJSONRequest.cancel();
29806
+ }
29807
+ callback();
29808
+ this.load();
29809
+ }
29810
+ /**
29811
+ * Sets the source `tiles` property and re-renders the map.
29812
+ *
29813
+ * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/)
29814
+ * @returns `this`
29815
+ */
29816
+ setTiles(tiles) {
29817
+ this.setSourceProperty(() => {
29818
+ this._options.tiles = tiles;
29819
+ });
29820
+ return this;
29821
+ }
29501
29822
  serialize() {
29502
29823
  return performance.extend({}, this._options);
29503
29824
  }
@@ -29554,16 +29875,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29554
29875
  }
29555
29876
  }
29556
29877
 
29557
- let supportsOffscreenCanvas;
29558
- function offscreenCanvasSupported() {
29559
- if (supportsOffscreenCanvas == null) {
29560
- supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&
29561
- new OffscreenCanvas(1, 1).getContext('2d') &&
29562
- typeof createImageBitmap === 'function';
29563
- }
29564
- return supportsOffscreenCanvas;
29565
- }
29566
-
29567
29878
  /**
29568
29879
  * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)
29569
29880
  * This source can be used to show hillshading and 3D terrain
@@ -29587,12 +29898,16 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29587
29898
  this.maxzoom = 22;
29588
29899
  this._options = performance.extend({ type: 'raster-dem' }, options);
29589
29900
  this.encoding = options.encoding || 'mapbox';
29901
+ this.redFactor = options.redFactor;
29902
+ this.greenFactor = options.greenFactor;
29903
+ this.blueFactor = options.blueFactor;
29904
+ this.baseShift = options.baseShift;
29590
29905
  }
29591
29906
  loadTile(tile, callback) {
29592
29907
  const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);
29593
- tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), imageLoaded.bind(this), this.map._refreshExpiredTiles);
29908
+ const request = this.map._requestManager.transformRequest(url, ResourceType.Tile);
29594
29909
  tile.neighboringTiles = this._getNeighboringTiles(tile.tileID);
29595
- function imageLoaded(err, img) {
29910
+ tile.request = ImageRequest.getImage(request, (err, img, expiry) => performance.__awaiter(this, void 0, void 0, function* () {
29596
29911
  delete tile.request;
29597
29912
  if (tile.aborted) {
29598
29913
  tile.state = 'unloaded';
@@ -29604,23 +29919,40 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29604
29919
  }
29605
29920
  else if (img) {
29606
29921
  if (this.map._refreshExpiredTiles)
29607
- tile.setExpiryData(img);
29608
- delete img.cacheControl;
29609
- delete img.expires;
29610
- const transfer = performance.isImageBitmap(img) && offscreenCanvasSupported();
29611
- const rawImageData = transfer ? img : performance.browser.getImageData(img, 1);
29922
+ tile.setExpiryData(expiry);
29923
+ const transfer = performance.isImageBitmap(img) && performance.offscreenCanvasSupported();
29924
+ const rawImageData = transfer ? img : yield readImageNow(img);
29612
29925
  const params = {
29613
29926
  uid: tile.uid,
29614
29927
  coord: tile.tileID,
29615
29928
  source: this.id,
29616
29929
  rawImageData,
29617
- encoding: this.encoding
29930
+ encoding: this.encoding,
29931
+ redFactor: this.redFactor,
29932
+ greenFactor: this.greenFactor,
29933
+ blueFactor: this.blueFactor,
29934
+ baseShift: this.baseShift
29618
29935
  };
29619
29936
  if (!tile.actor || tile.state === 'expired') {
29620
29937
  tile.actor = this.dispatcher.getActor();
29621
- tile.actor.send('loadDEMTile', params, done.bind(this));
29938
+ tile.actor.send('loadDEMTile', params, done);
29622
29939
  }
29623
29940
  }
29941
+ }), this.map._refreshExpiredTiles);
29942
+ function readImageNow(img) {
29943
+ return performance.__awaiter(this, void 0, void 0, function* () {
29944
+ if (typeof VideoFrame !== 'undefined' && performance.isOffscreenCanvasDistorted()) {
29945
+ const width = img.width + 2;
29946
+ const height = img.height + 2;
29947
+ try {
29948
+ return new performance.RGBAImage({ width, height }, yield performance.readImageUsingVideoFrame(img, -1, -1, width, height));
29949
+ }
29950
+ catch (e) {
29951
+ // fall-back to browser canvas decoding
29952
+ }
29953
+ }
29954
+ return performance.browser.getImageData(img, 1);
29955
+ });
29624
29956
  }
29625
29957
  function done(err, data) {
29626
29958
  if (err) {
@@ -29954,8 +30286,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29954
30286
  performance.extend(data, { resourceTiming });
29955
30287
  // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache
29956
30288
  // know its ok to start requesting tiles.
29957
- this.fire(new performance.Event('data', { ...data, sourceDataType: 'metadata' }));
29958
- this.fire(new performance.Event('data', { ...data, sourceDataType: 'content' }));
30289
+ this.fire(new performance.Event('data', Object.assign(Object.assign({}, data), { sourceDataType: 'metadata' })));
30290
+ this.fire(new performance.Event('data', Object.assign(Object.assign({}, data), { sourceDataType: 'content' })));
29959
30291
  });
29960
30292
  }
29961
30293
  loaded() {
@@ -30288,6 +30620,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
30288
30620
  * map.removeSource('some id'); // remove
30289
30621
  * ```
30290
30622
  * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)
30623
+ *
30624
+ * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.
30625
+ * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,
30626
+ * set the layer's `raster-fade-duration` property to `0`.
30291
30627
  */
30292
30628
  class VideoSource extends ImageSource {
30293
30629
  constructor(id, options, dispatcher, eventedParent) {
@@ -34837,6 +35173,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
34837
35173
  this._load(empty, { validate: false });
34838
35174
  }
34839
35175
  _load(json, options, previousStyle) {
35176
+ var _a;
34840
35177
  const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json;
34841
35178
  if (options.validate && emitValidationErrors(this, performance.validateStyle(nextState))) {
34842
35179
  return;
@@ -34855,7 +35192,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
34855
35192
  this.glyphManager.setURL(nextState.glyphs);
34856
35193
  this._createLayers();
34857
35194
  this.light = new Light(this.stylesheet.light);
34858
- this.map.setTerrain(this.stylesheet.terrain);
35195
+ this.map.setTerrain((_a = this.stylesheet.terrain) !== null && _a !== void 0 ? _a : null);
34859
35196
  this.fire(new performance.Event('data', { dataType: 'style' }));
34860
35197
  this.fire(new performance.Event('style.load'));
34861
35198
  }
@@ -35147,6 +35484,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35147
35484
  this[op.command].apply(this, op.args);
35148
35485
  }
35149
35486
  this.stylesheet = nextState;
35487
+ // reset serialization field, to be populated only when needed
35488
+ this._serializedLayers = null;
35150
35489
  return true;
35151
35490
  }
35152
35491
  addImage(id, image) {
@@ -35273,7 +35612,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35273
35612
  layer = performance.createStyleLayer(layerObject);
35274
35613
  }
35275
35614
  else {
35276
- if (typeof layerObject.source === 'object') {
35615
+ if ('source' in layerObject && typeof layerObject.source === 'object') {
35277
35616
  this.addSource(id, layerObject.source);
35278
35617
  layerObject = performance.clone$1(layerObject);
35279
35618
  layerObject = performance.extend(layerObject, { source: id });
@@ -35384,7 +35723,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35384
35723
  return this._layers[id];
35385
35724
  }
35386
35725
  /**
35387
- * checks if a specific layer is present within the style.
35726
+ * Return the ids of all layers currently in the style, including custom layers, in order.
35727
+ *
35728
+ * @returns ids of layers, in order
35729
+ */
35730
+ getLayersOrder() {
35731
+ return [...this._order];
35732
+ }
35733
+ /**
35734
+ * Checks if a specific layer is present within the style.
35388
35735
  *
35389
35736
  * @param id - the id of the desired layer
35390
35737
  * @returns a boolean specifying if the given layer is present
@@ -35557,6 +35904,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35557
35904
  return;
35558
35905
  const sources = performance.mapObject(this.sourceCaches, (source) => source.serialize());
35559
35906
  const layers = this._serializeByIds(this._order);
35907
+ const terrain = this.map.getTerrain() || undefined;
35560
35908
  const myStyleSheet = this.stylesheet;
35561
35909
  return performance.filterObject({
35562
35910
  version: myStyleSheet.version,
@@ -35571,7 +35919,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35571
35919
  glyphs: myStyleSheet.glyphs,
35572
35920
  transition: myStyleSheet.transition,
35573
35921
  sources,
35574
- layers
35922
+ layers,
35923
+ terrain
35575
35924
  }, (value) => { return value !== undefined; });
35576
35925
  }
35577
35926
  _updateLayer(layer) {
@@ -36474,6 +36823,9 @@ uniform ${precision} ${type} u_${name};
36474
36823
  }
36475
36824
  gl.shaderSource(fragmentShader, fragmentSource);
36476
36825
  gl.compileShader(fragmentShader);
36826
+ if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
36827
+ throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);
36828
+ }
36477
36829
  gl.attachShader(this.program, fragmentShader);
36478
36830
  const vertexShader = gl.createShader(gl.VERTEX_SHADER);
36479
36831
  if (gl.isContextLost()) {
@@ -36482,6 +36834,9 @@ uniform ${precision} ${type} u_${name};
36482
36834
  }
36483
36835
  gl.shaderSource(vertexShader, vertexSource);
36484
36836
  gl.compileShader(vertexShader);
36837
+ if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
36838
+ throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);
36839
+ }
36485
36840
  gl.attachShader(this.program, vertexShader);
36486
36841
  this.attributes = {};
36487
36842
  const uniformLocations = {};
@@ -36493,6 +36848,9 @@ uniform ${precision} ${type} u_${name};
36493
36848
  }
36494
36849
  }
36495
36850
  gl.linkProgram(this.program);
36851
+ if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {
36852
+ throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);
36853
+ }
36496
36854
  gl.deleteShader(vertexShader);
36497
36855
  gl.deleteShader(fragmentShader);
36498
36856
  for (let it = 0; it < allUniformsInfo.length; it++) {
@@ -37296,11 +37654,12 @@ uniform ${precision} ${type} u_${name};
37296
37654
 
37297
37655
  const cache = new WeakMap();
37298
37656
  function isWebGL2(gl) {
37657
+ var _a;
37299
37658
  if (cache.has(gl)) {
37300
37659
  return cache.get(gl);
37301
37660
  }
37302
37661
  else {
37303
- const value = gl.getParameter(gl.VERSION).startsWith('WebGL 2.0');
37662
+ const value = (_a = gl.getParameter(gl.VERSION)) === null || _a === void 0 ? void 0 : _a.startsWith('WebGL 2.0');
37304
37663
  cache.set(gl, value);
37305
37664
  return value;
37306
37665
  }
@@ -40732,16 +41091,20 @@ uniform ${precision} ${type} u_${name};
40732
41091
  function throttle(fn, time) {
40733
41092
  let pending = false;
40734
41093
  let timerId = null;
41094
+ let lastCallContext = null;
41095
+ let lastCallArgs;
40735
41096
  const later = () => {
40736
41097
  timerId = null;
40737
41098
  if (pending) {
40738
- fn();
41099
+ fn.apply(lastCallContext, lastCallArgs);
40739
41100
  timerId = setTimeout(later, time);
40740
41101
  pending = false;
40741
41102
  }
40742
41103
  };
40743
- return () => {
41104
+ return (...args) => {
40744
41105
  pending = true;
41106
+ lastCallContext = this;
41107
+ lastCallArgs = args;
40745
41108
  if (!timerId) {
40746
41109
  later();
40747
41110
  }
@@ -42548,6 +42911,12 @@ uniform ${precision} ${type} u_${name};
42548
42911
  }
42549
42912
  reset() {
42550
42913
  this._active = false;
42914
+ this._zooming = false;
42915
+ delete this._targetZoom;
42916
+ if (this._finishTimeout) {
42917
+ clearTimeout(this._finishTimeout);
42918
+ delete this._finishTimeout;
42919
+ }
42551
42920
  }
42552
42921
  }
42553
42922
 
@@ -43327,7 +43696,7 @@ uniform ${precision} ${type} u_${name};
43327
43696
  this._updatingCamera = true;
43328
43697
  const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);
43329
43698
  const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;
43330
- if (inertialEase) {
43699
+ if (inertialEase && (inertialEase.essential || !performance.browser.prefersReducedMotion)) {
43331
43700
  if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {
43332
43701
  inertialEase.bearing = 0;
43333
43702
  }
@@ -43368,7 +43737,8 @@ uniform ${precision} ${type} u_${name};
43368
43737
  this._renderFrameCallback = () => {
43369
43738
  const t = Math.min((performance.browser.now() - this._easeStart) / this._easeOptions.duration, 1);
43370
43739
  this._onEaseFrame(this._easeOptions.easing(t));
43371
- if (t < 1) {
43740
+ // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted
43741
+ if (t < 1 && this._easeFrameId) {
43372
43742
  this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);
43373
43743
  }
43374
43744
  else {
@@ -45555,14 +45925,17 @@ uniform ${precision} ${type} u_${name};
45555
45925
  if (typeof window !== 'undefined') {
45556
45926
  addEventListener('online', this._onWindowOnline, false);
45557
45927
  let initialResizeEventCaptured = false;
45928
+ const throttledResizeCallback = throttle((entries) => {
45929
+ if (this._trackResize && !this._removed) {
45930
+ this.resize(entries)._update();
45931
+ }
45932
+ }, 50);
45558
45933
  this._resizeObserver = new ResizeObserver((entries) => {
45559
45934
  if (!initialResizeEventCaptured) {
45560
45935
  initialResizeEventCaptured = true;
45561
45936
  return;
45562
45937
  }
45563
- if (this._trackResize) {
45564
- this.resize(entries)._update();
45565
- }
45938
+ throttledResizeCallback(entries);
45566
45939
  });
45567
45940
  this._resizeObserver.observe(this._container);
45568
45941
  }
@@ -45764,7 +46137,6 @@ uniform ${precision} ${type} u_${name};
45764
46137
  * @internal
45765
46138
  * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize.
45766
46139
  * Internally you should use this and not getPixelRatio().
45767
- * @hidden
45768
46140
  */
45769
46141
  _getClampedPixelRatio(width, height) {
45770
46142
  const { 0: maxCanvasWidth, 1: maxCanvasHeight } = this._maxCanvasSize;
@@ -46655,7 +47027,8 @@ uniform ${precision} ${type} u_${name};
46655
47027
  * ```
46656
47028
  */
46657
47029
  getTerrain() {
46658
- return this.terrain && this.terrain.options;
47030
+ var _a, _b;
47031
+ return (_b = (_a = this.terrain) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null;
46659
47032
  }
46660
47033
  /**
46661
47034
  * Returns a Boolean indicating whether all tiles in the viewport from all sources on
@@ -46945,7 +47318,7 @@ uniform ${precision} ${type} u_${name};
46945
47318
  *
46946
47319
  * @param layer - The layer to add,
46947
47320
  * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,
46948
- * less commonly, the {@link CustomLayerInterface} specification.
47321
+ * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition.
46949
47322
  * The MapLibre Style Specification's layer definition is appropriate for most layers.
46950
47323
  *
46951
47324
  * @param beforeId - The ID of an existing layer to insert the new layer before,
@@ -47074,6 +47447,19 @@ uniform ${precision} ${type} u_${name};
47074
47447
  getLayer(id) {
47075
47448
  return this.style.getLayer(id);
47076
47449
  }
47450
+ /**
47451
+ * Return the ids of all layers currently in the style, including custom layers, in order.
47452
+ *
47453
+ * @returns ids of layers, in order
47454
+ *
47455
+ * @example
47456
+ * ```ts
47457
+ * const orderedLayerIds = map.getLayersOrder();
47458
+ * ```
47459
+ */
47460
+ getLayersOrder() {
47461
+ return this.style.getLayersOrder();
47462
+ }
47077
47463
  /**
47078
47464
  * Sets the zoom extent for the specified style layer. The zoom extent includes the
47079
47465
  * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)
@@ -47153,6 +47539,7 @@ uniform ${precision} ${type} u_${name};
47153
47539
  * @param name - The name of the paint property to set.
47154
47540
  * @param value - The value of the paint property to set.
47155
47541
  * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).
47542
+ * Pass `null` to unset the existing value.
47156
47543
  * @param options - Options object.
47157
47544
  * @returns `this`
47158
47545
  * @example
@@ -47949,7 +48336,6 @@ uniform ${precision} ${type} u_${name};
47949
48336
  * map.addControl(nav, 'top-left');
47950
48337
  * ```
47951
48338
  * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)
47952
- * @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
47953
48339
  */
47954
48340
  class NavigationControl {
47955
48341
  /**
@@ -48311,6 +48697,10 @@ uniform ${precision} ${type} u_${name};
48311
48697
  this._update = (e) => {
48312
48698
  if (!this._map)
48313
48699
  return;
48700
+ const isFullyLoaded = this._map.loaded() && !this._map.isMoving();
48701
+ if ((e === null || e === void 0 ? void 0 : e.type) === 'terrain' || ((e === null || e === void 0 ? void 0 : e.type) === 'render' && !isFullyLoaded)) {
48702
+ this._map.once('render', this._update);
48703
+ }
48314
48704
  if (this._map.transform.renderWorldCopies) {
48315
48705
  this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);
48316
48706
  }
@@ -48534,6 +48924,7 @@ uniform ${precision} ${type} u_${name};
48534
48924
  map.getCanvasContainer().appendChild(this._element);
48535
48925
  map.on('move', this._update);
48536
48926
  map.on('moveend', this._update);
48927
+ map.on('terrain', this._update);
48537
48928
  this.setDraggable(this._draggable);
48538
48929
  this._update();
48539
48930
  // If we attached the `click` listener to the marker element, the popup
@@ -48649,7 +49040,7 @@ uniform ${precision} ${type} u_${name};
48649
49040
  if (!('offset' in popup.options)) {
48650
49041
  const markerHeight = 41 - (5.8 / 2);
48651
49042
  const markerRadius = 13.5;
48652
- const linearOffset = Math.sqrt(Math.pow(markerRadius, 2) / 2);
49043
+ const linearOffset = Math.abs(markerRadius) / Math.SQRT2;
48653
49044
  popup.options.offset = this._defaultMarker ? {
48654
49045
  'top': [0, 0],
48655
49046
  'top-left': [0, 0],
@@ -50222,7 +50613,7 @@ uniform ${precision} ${type} u_${name};
50222
50613
  }
50223
50614
  else if (typeof offset === 'number') {
50224
50615
  // input specifies a radius from which to calculate offsets at all positions
50225
- const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
50616
+ const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);
50226
50617
  return {
50227
50618
  'center': new performance.Point(0, 0),
50228
50619
  'top': new performance.Point(0, offset),
@@ -50705,7 +51096,7 @@ uniform ${precision} ${type} u_${name};
50705
51096
  return Url;
50706
51097
  }());
50707
51098
 
50708
- var version$2 = "3.0.2";
51099
+ var version$2 = "3.0.3";
50709
51100
 
50710
51101
  /**
50711
51102
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -51257,6 +51648,16 @@ uniform ${precision} ${type} u_${name};
51257
51648
  grid.classList.add("hidden-accessible-element");
51258
51649
  }
51259
51650
  });
51651
+ // Dismiss the grid when esc key is pressed on the reset button and the tooltip is not visible
51652
+ rotationButton.addEventListener("keydown", function (event) {
51653
+ if ((event.key === "Escape" || event.key === "Esc") &&
51654
+ (container === null || container === void 0 ? void 0 : container.classList.contains("in-use")) &&
51655
+ (tooltip === null || tooltip === void 0 ? void 0 : tooltip.style.display) === "none") {
51656
+ event.stopPropagation();
51657
+ container.classList.remove("in-use");
51658
+ grid.classList.add("hidden-accessible-element");
51659
+ }
51660
+ });
51260
51661
  // If the control's position will require inverting the element order
51261
51662
  // add them in the opposite order to preserve tabindex.
51262
51663
  if (options && CompassControl.InvertOrderPositions.includes(options.position)) {
@@ -51518,6 +51919,16 @@ uniform ${precision} ${type} u_${name};
51518
51919
  grid.classList.add("hidden-accessible-element");
51519
51920
  }
51520
51921
  });
51922
+ // Dismiss the grid when esc key is pressed on the reset button and the tooltip is not visible
51923
+ pitchButton.addEventListener("keydown", function (event) {
51924
+ if ((event.key === "Escape" || event.key === "Esc") &&
51925
+ (container === null || container === void 0 ? void 0 : container.classList.contains("in-use")) &&
51926
+ (tooltip === null || tooltip === void 0 ? void 0 : tooltip.style.display) === "none") {
51927
+ event.stopPropagation();
51928
+ container.classList.remove("in-use");
51929
+ grid.classList.add("hidden-accessible-element");
51930
+ }
51931
+ });
51521
51932
  // If the control's position will require inverting the element order
51522
51933
  // add them in the opposite order to preserve tabindex.
51523
51934
  if (options && PitchControl.INVERT_ORDER_POSITIONS.includes(options.position)) {
@@ -68020,8 +68431,11 @@ uniform ${precision} ${type} u_${name};
68020
68431
  var domain = this.map.getServiceOptions().domain;
68021
68432
  var urlOptions = {
68022
68433
  domain: domain,
68023
- path: "search/address/reverse/json",
68024
- queryParams: __assign$6({ "api-version": "1.0", "language": options.style.language, "limit": 1, "query": "".concat(normalizeLatitude(options.position[1]), ",").concat(normalizeLongitude(options.position[0])) }, (options.style.view && { view: options.style.view }))
68434
+ path: "reverseGeocode",
68435
+ queryParams: __assign$6({ "api-version": "2023-06-01", "coordinates": "".concat(normalizeLongitude(options.position[0]), ",").concat(normalizeLatitude(options.position[1])) }, (options.style.view && { view: options.style.view })),
68436
+ headers: {
68437
+ "Accept-Language": options.style.language
68438
+ }
68025
68439
  };
68026
68440
  return new Url(((_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.signRequest(urlOptions)) || urlOptions).get();
68027
68441
  };
@@ -69227,12 +69641,13 @@ uniform ${precision} ${type} u_${name};
69227
69641
  position: cam.center,
69228
69642
  style: style
69229
69643
  }).then(function (r) {
69644
+ var _a, _b, _c;
69230
69645
  var info = {};
69231
- if (r && r.addresses && r.addresses.length > 0) {
69232
- if (r.addresses[0].address) {
69233
- var a = r.addresses[0].address;
69234
- if (a.country) {
69235
- info.country = a.country;
69646
+ if (r && r.features && r.features.length > 0) {
69647
+ if ((_b = (_a = r.features[0]) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.address) {
69648
+ var a = r.features[0].properties.address;
69649
+ if (a.countryRegion) {
69650
+ info.country = a.countryRegion.name;
69236
69651
  MapViewDescriptor._labelCache.cache(info.country, {
69237
69652
  source: [],
69238
69653
  labelType: "country",
@@ -69240,8 +69655,8 @@ uniform ${precision} ${type} u_${name};
69240
69655
  minZoom: 0
69241
69656
  }, cam.center, style.language);
69242
69657
  }
69243
- if (a.countrySubdivision) {
69244
- info.state = a.countrySubdivision;
69658
+ if (a.adminDistricts) {
69659
+ info.state = (_c = a.adminDistricts[0]) === null || _c === void 0 ? void 0 : _c.shortName;
69245
69660
  MapViewDescriptor._labelCache.cache(info.state, {
69246
69661
  source: [],
69247
69662
  labelType: "state",
@@ -69249,20 +69664,17 @@ uniform ${precision} ${type} u_${name};
69249
69664
  minZoom: 4
69250
69665
  }, cam.center, style.language);
69251
69666
  }
69252
- if (a.municipality) {
69253
- info.city = a.municipality;
69254
- MapViewDescriptor._labelCache.cache(info.state, {
69667
+ if (a.locality) {
69668
+ info.city = a.locality;
69669
+ MapViewDescriptor._labelCache.cache(info.city, {
69255
69670
  source: [],
69256
69671
  labelType: "city",
69257
69672
  radius: 1000,
69258
69673
  minZoom: 10
69259
69674
  }, cam.center, style.language);
69260
69675
  }
69261
- if (a.streetNameAndNumber) {
69262
- info.road = a.streetNameAndNumber;
69263
- }
69264
- else if (a.street) {
69265
- info.road = a.street;
69676
+ if (a.addressLine) {
69677
+ info.road = a.addressLine;
69266
69678
  }
69267
69679
  }
69268
69680
  }
@@ -95313,8 +95725,8 @@ uniform ${precision} ${type} u_${name};
95313
95725
  */
95314
95726
  _this.styleSet = undefined;
95315
95727
  /**
95316
- * Enable accessibility
95317
- * default: true
95728
+ * Enable the accessibility feature to provide screen reader support for users who have difficulty visualizing the web application.
95729
+ * This property is set to true by default.
95318
95730
  * @default true
95319
95731
  */
95320
95732
  _this.enableAccessibility = true;