azure-maps-control 2.1.11 → 2.1.14

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.
@@ -43487,7 +43487,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
43487
43487
  return Url;
43488
43488
  }());
43489
43489
 
43490
- var version = "2.1.11";
43490
+ var version = "2.1.14";
43491
43491
 
43492
43492
  /**
43493
43493
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -47443,11 +47443,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
47443
47443
  * Default `true`
47444
47444
  */
47445
47445
  _this.autoSelectionMode = true;
47446
- /**
47447
- * theme
47448
- * when unset - all styles are selectable
47449
- */
47450
- _this.theme = undefined;
47451
47446
  return _this;
47452
47447
  }
47453
47448
  return StyleControlOptions;
@@ -47483,6 +47478,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
47483
47478
  return;
47484
47479
  }
47485
47480
  Array.from(_this.styleOpsGrid.children).forEach(function (element) { return element.remove(); });
47481
+ _this.styleButtons.clear();
47486
47482
  _this.populateOpsGridFromDefinitions(definitions);
47487
47483
  };
47488
47484
  _this.mapToFriendlyStyleName = function (name, styleset) {
@@ -47597,6 +47593,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
47597
47593
  if (image_1.src !== newSrc) {
47598
47594
  image_1.src = newSrc;
47599
47595
  }
47596
+ Object.entries(this.styleButtons).forEach(function (_a) {
47597
+ var _b = __read(_a, 2), buttonStyleName = _b[0], button = _b[1];
47598
+ return button.setAttribute('aria-current', buttonStyleName === styleName ? 'true' : 'false');
47599
+ });
47600
47600
  this.map.styles.definitions().then(function (styleset) {
47601
47601
  var newAlt = _this.mapToFriendlyStyleName(styleName, styleset);
47602
47602
  if (image_1.alt !== newAlt) {
@@ -47736,9 +47736,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
47736
47736
  if (Array.isArray(this.options.mapStyles)) {
47737
47737
  styles = styles.filter(function (style) { return _this.options.mapStyles.includes(style.name.split("_indoor")[0]); });
47738
47738
  }
47739
- if (this.options.theme) {
47740
- styles = styles.filter(function (style) { return style.theme === _this.options.theme; });
47741
- }
47742
47739
  styles.forEach(function (style) {
47743
47740
  // Create fetch thumbnail request
47744
47741
  var requestParams = {
@@ -47761,9 +47758,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
47761
47758
  positionTooltip(tooltip, styleOptionButton);
47762
47759
  }
47763
47760
  });
47761
+ var targetStyleName = this.map.getStyle().style;
47764
47762
  Object.entries(this.styleButtons).forEach(function (_a) {
47765
47763
  var _b = __read(_a, 2), styleName = _b[0], button = _b[1];
47766
- return button.setAttribute('aria-current', styleName === _this.map.getStyle().style ? 'true' : 'false');
47764
+ return button.setAttribute('aria-current', styleName === targetStyleName ? 'true' : 'false');
47767
47765
  });
47768
47766
  };
47769
47767
  StyleControl.InvertOrderPositions = [exports.ControlPosition.TopRight, exports.ControlPosition.BottomRight];
@@ -47929,13 +47927,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
47929
47927
  * This is invoked on init in constructTrafficButton and on each Map.setTraffic()
47930
47928
  */
47931
47929
  TrafficControl.prototype.updateButtonState = function () {
47932
- if (this.isActive) {
47933
- this.container.classList.add("in-use");
47934
- }
47935
- else {
47936
- this.container.classList.remove("in-use");
47937
- }
47938
47930
  if (this.trafficButton) {
47931
+ if (this.isActive) {
47932
+ this.container.classList.add("in-use");
47933
+ }
47934
+ else {
47935
+ this.container.classList.remove("in-use");
47936
+ }
47939
47937
  this.trafficButton.setAttribute("aria-pressed", this.isActive ? "true" : "false");
47940
47938
  }
47941
47939
  };
@@ -68415,6 +68413,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68415
68413
  var HijackablePromise = /** @class */ (function () {
68416
68414
  function HijackablePromise(origin) {
68417
68415
  var _this = this;
68416
+ this.isHijacked = function () { return _this._hijackedToResolve !== undefined || _this._hijackedToReject !== undefined; };
68418
68417
  this.isResolved = function () { return _this._hijackedToResolve !== undefined || _this._toResolve !== undefined; };
68419
68418
  this.isRejected = function () { return _this._hijackedToReject !== undefined || _this._toReject !== undefined; };
68420
68419
  this.resultIfResolved = function () { return _this._hijackedToResolve || _this._toResolve; };
@@ -68428,39 +68427,28 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68428
68427
  }
68429
68428
  else {
68430
68429
  // we retain the origin, and check if stays the same as resolved
68431
- // to make sure we do nothing if the promise was switched
68432
68430
  var retainedInvocator_1 = _this.origin;
68433
68431
  _this.origin.then(function (result) {
68434
- // origin was switched
68435
- if (retainedInvocator_1 !== _this.origin) {
68432
+ if (_this.isHijacked()) {
68436
68433
  return;
68437
68434
  }
68438
- if (!_this._hijackedToResolve) {
68435
+ // origin was switched during invocation, discard the result and follow the chain
68436
+ if (retainedInvocator_1 !== _this.origin) {
68437
+ _this._thenResolver(resolve, reject);
68438
+ }
68439
+ else {
68439
68440
  _this._toResolve = result;
68440
68441
  resolve(result);
68441
68442
  }
68442
68443
  }).catch(function (error) {
68443
- if (!_this._hijackedToReject) {
68444
- _this._toReject = error;
68445
- reject(error);
68446
- }
68447
- });
68448
- }
68449
- };
68450
- this._catchResolver = function (reject) {
68451
- if (_this._hijackedToReject) {
68452
- reject(_this._hijackedToReject);
68453
- }
68454
- else {
68455
- // we retain the origin, and check if stays the same as resolved
68456
- // to make sure we do nothing if the promise was switched
68457
- var retainedInvocator_2 = _this.origin;
68458
- _this.origin.catch(function (error) {
68459
- // origin was switched
68460
- if (retainedInvocator_2 !== _this.origin) {
68444
+ if (_this.isHijacked()) {
68461
68445
  return;
68462
68446
  }
68463
- if (!_this._hijackedToReject) {
68447
+ // origin was switched during invocation, discard the result and follow the chain
68448
+ if (retainedInvocator_1 !== _this.origin) {
68449
+ _this._thenResolver(resolve, reject);
68450
+ }
68451
+ else {
68464
68452
  _this._toReject = error;
68465
68453
  reject(error);
68466
68454
  }
@@ -68487,14 +68475,20 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68487
68475
  // tslint:disable-next-line: no-reserved-keywords
68488
68476
  HijackablePromise.prototype.catch = function (onrejected) {
68489
68477
  var _this = this;
68490
- return new Promise(function (_, reject) {
68478
+ return new Promise(function (resolve, reject) {
68479
+ _this._resolve = resolve;
68491
68480
  _this._reject = reject;
68492
- _this._catchResolver(reject);
68493
- }).then(onrejected);
68481
+ _this._thenResolver(resolve, reject);
68482
+ }).catch(onrejected);
68494
68483
  };
68495
68484
  // tslint:disable-next-line: no-reserved-keywords
68496
68485
  HijackablePromise.prototype.finally = function (onfinally) {
68497
- return this.origin.finally(onfinally);
68486
+ var _this = this;
68487
+ return new Promise(function (resolve, reject) {
68488
+ _this._resolve = resolve;
68489
+ _this._reject = reject;
68490
+ _this._thenResolver(resolve, reject);
68491
+ }).finally(onfinally);
68498
68492
  };
68499
68493
  HijackablePromise.prototype.hijackAndResolve = function (value) {
68500
68494
  this._hijackedToResolve = value;
@@ -68509,16 +68503,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68509
68503
  }
68510
68504
  };
68511
68505
  HijackablePromise.prototype.switchWith = function (promise) {
68512
- // switching the origin will discard the original in-progress promise result
68506
+ // switching the origin will discard the original in-progress promise result, as well any resolved non-hijacked state
68513
68507
  this.origin = promise;
68514
- // then has been invoked on this promise
68515
- if (this._resolve && this._reject) {
68516
- this._thenResolver(this._resolve, this._reject);
68517
- // catch has been invoked on this promise
68518
- }
68519
- else if (this._reject) {
68520
- this._catchResolver(this._reject);
68521
- }
68508
+ this._toResolve = undefined;
68509
+ this._toReject = undefined;
68522
68510
  };
68523
68511
  return HijackablePromise;
68524
68512
  }());
@@ -68551,7 +68539,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68551
68539
  var _this = this;
68552
68540
  this.definitions = function () { return _this.initPromise ? _this.initPromise : _this.initStyleset(); };
68553
68541
  /**
68554
- * Compatability indoor state used in styleDefinition filtering.
68542
+ * Compatibility indoor state used in styleDefinition filtering.
68543
+ * Legacy indoor module (2.0.6) will not set tilesetId
68555
68544
  */
68556
68545
  this.indoorState = undefined;
68557
68546
  /**
@@ -68608,13 +68597,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68608
68597
  }
68609
68598
  StyleManager.prototype.updateIndoorState = function (theme, tilesetId) {
68610
68599
  var _this = this;
68611
- var styleset = this.map.styles.getStyleSet();
68600
+ var styleset = this.map.styles.getMapConfiguration();
68612
68601
  if (styleset) {
68613
68602
  this.preservedPreindoorStyleset = styleset;
68614
68603
  // tilesetId fallback
68615
68604
  // MAGIC: if we are on a default style set - match existing style to the one in the default indoor style set
68616
- var desiredIndoorStyle = this.map.getStyle().style + "_indoor" + (theme === 'dark' ? '_dark' : '') + "_tileset_" + tilesetId;
68617
- this.map.styles.setStyleSet("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
68605
+ var desiredIndoorStyle = this.map.getStyle().style ? this.map.getStyle().style + "_indoor" + (theme === 'dark' ? '_dark' : '') + "_tileset_" + tilesetId : undefined;
68606
+ this.map.styles.setMapConfiguration("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
68618
68607
  }
68619
68608
  else {
68620
68609
  this.indoorState = {
@@ -68623,9 +68612,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68623
68612
  };
68624
68613
  this.initStyleset();
68625
68614
  this.definitions().then(function (definitions) {
68626
- var currentStyle = _this.map.getStyle().style;
68627
- var targetStyleName = currentStyle + "_indoor" + (_this.indoorState.theme == 'dark' ? '_dark' : '');
68628
- _this.map.setStyle({ style: targetStyleName });
68615
+ var currentStyle = (_this.map.getStyle().style || definitions.defaultStyle)
68616
+ .replace('_indoor_dark', '')
68617
+ .replace('_indoor', '');
68618
+ // we cannot compose the precise style name for auto theme, search for prefix style name match
68619
+ var targetStylePrefix = currentStyle + "_indoor";
68620
+ var candidateStyle = definitions.styles.find(function (style) { return style.name.startsWith(targetStylePrefix); });
68621
+ if (candidateStyle) {
68622
+ _this.map.setStyle({ style: candidateStyle.name });
68623
+ }
68629
68624
  });
68630
68625
  }
68631
68626
  };
@@ -68634,7 +68629,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68634
68629
  var styleset = this.preservedPreindoorStyleset;
68635
68630
  if (styleset) {
68636
68631
  // we need to revert to the styleset that was ap
68637
- this.map.styles.setStyleSet(styleset);
68632
+ this.map.styles.setMapConfiguration(styleset);
68638
68633
  }
68639
68634
  else {
68640
68635
  this.indoorState = undefined;
@@ -68666,7 +68661,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68666
68661
  version: isNaN(definitions.version) ? 0 : parseFloat(definitions.version),
68667
68662
  defaultStyle: definitions.defaultStyle,
68668
68663
  styles: definitions.styles
68669
- .filter(function (style) { return _this.indoorState ? style.name.includes('indoor') && style.name.endsWith(_this.indoorState.theme == 'dark' ? 'dark' : 'indoor') : !style.name.includes('indoor'); })
68664
+ .filter(function (style) {
68665
+ if (!_this.indoorState) {
68666
+ return !style.name.includes('indoor');
68667
+ // NOTE: azure-maps-indoor prior to 2.0.7 will not pass theme auto
68668
+ // the IndoorModule will request getTheme() from StyleManager and will call StyleManager.setStyleSet(theme == 'dark ? 'indoor_dark' : 'indoor') as approperaite
68669
+ }
68670
+ else if (_this.indoorState.theme === 'auto') {
68671
+ return style.name.endsWith(style.theme === 'dark' ? '_indoor_dark' : '_indoor');
68672
+ }
68673
+ else {
68674
+ return style.name.endsWith(_this.indoorState.theme === 'dark' ? '_indoor_dark' : '_indoor');
68675
+ }
68676
+ })
68670
68677
  .map(function (style) { return ({
68671
68678
  copyright: style.copyright.join(' '),
68672
68679
  name: style.name,
@@ -68741,7 +68748,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68741
68748
  StyleManager.prototype.getTheme = function (styleOptions) {
68742
68749
  var style = this._lookUp(styleOptions);
68743
68750
  if (!style) {
68744
- throw Error("Theme is not available.");
68751
+ return undefined;
68745
68752
  }
68746
68753
  return style.theme.toLowerCase();
68747
68754
  };
@@ -68758,7 +68765,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68758
68765
  /**
68759
68766
  * Replaces the style set used. Very costly as it reloads all controls and resources.
68760
68767
  */
68761
- StyleManager.prototype.setStyleSet = function (styleSet, styleName) {
68768
+ StyleManager.prototype.setMapConfiguration = function (styleSet, styleName) {
68762
68769
  var _this = this;
68763
68770
  this.serviceOptions.styleSet = styleSet;
68764
68771
  if (typeof styleSet === 'string') {
@@ -68780,9 +68787,24 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
68780
68787
  _this.map.setStyle({ style: targetStyleName });
68781
68788
  });
68782
68789
  };
68783
- StyleManager.prototype.getStyleSet = function () {
68790
+ StyleManager.prototype.getMapConfiguration = function () {
68784
68791
  return this.serviceOptions.styleSet;
68785
68792
  };
68793
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
68794
+ StyleManager.prototype.setStyleSet = function (styleSet) {
68795
+ this.updateIndoorState(styleSet === 'indoor_dark' ? 'dark' : 'light', null);
68796
+ };
68797
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
68798
+ StyleManager.prototype.getStyleSet = function () {
68799
+ var legacyStyleset = this.indoorState !== undefined
68800
+ ? (this.indoorState.theme === 'dark' ? 'indoor_dark' : 'indoor')
68801
+ : 'base';
68802
+ return legacyStyleset;
68803
+ };
68804
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
68805
+ StyleManager.prototype.clearStyleSet = function () {
68806
+ this.unsetIndoorState();
68807
+ };
68786
68808
  /**
68787
68809
  * Function invoked by mapbox after a style is fetched but before it is committed to the map state.
68788
68810
  *