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.
package/dist/atlas.js CHANGED
@@ -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
  };
@@ -78596,6 +78594,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78596
78594
  var HijackablePromise = /** @class */ (function () {
78597
78595
  function HijackablePromise(origin) {
78598
78596
  var _this = this;
78597
+ this.isHijacked = function () { return _this._hijackedToResolve !== undefined || _this._hijackedToReject !== undefined; };
78599
78598
  this.isResolved = function () { return _this._hijackedToResolve !== undefined || _this._toResolve !== undefined; };
78600
78599
  this.isRejected = function () { return _this._hijackedToReject !== undefined || _this._toReject !== undefined; };
78601
78600
  this.resultIfResolved = function () { return _this._hijackedToResolve || _this._toResolve; };
@@ -78609,39 +78608,28 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78609
78608
  }
78610
78609
  else {
78611
78610
  // we retain the origin, and check if stays the same as resolved
78612
- // to make sure we do nothing if the promise was switched
78613
78611
  var retainedInvocator_1 = _this.origin;
78614
78612
  _this.origin.then(function (result) {
78615
- // origin was switched
78616
- if (retainedInvocator_1 !== _this.origin) {
78613
+ if (_this.isHijacked()) {
78617
78614
  return;
78618
78615
  }
78619
- if (!_this._hijackedToResolve) {
78616
+ // origin was switched during invocation, discard the result and follow the chain
78617
+ if (retainedInvocator_1 !== _this.origin) {
78618
+ _this._thenResolver(resolve, reject);
78619
+ }
78620
+ else {
78620
78621
  _this._toResolve = result;
78621
78622
  resolve(result);
78622
78623
  }
78623
78624
  }).catch(function (error) {
78624
- if (!_this._hijackedToReject) {
78625
- _this._toReject = error;
78626
- reject(error);
78627
- }
78628
- });
78629
- }
78630
- };
78631
- this._catchResolver = function (reject) {
78632
- if (_this._hijackedToReject) {
78633
- reject(_this._hijackedToReject);
78634
- }
78635
- else {
78636
- // we retain the origin, and check if stays the same as resolved
78637
- // to make sure we do nothing if the promise was switched
78638
- var retainedInvocator_2 = _this.origin;
78639
- _this.origin.catch(function (error) {
78640
- // origin was switched
78641
- if (retainedInvocator_2 !== _this.origin) {
78625
+ if (_this.isHijacked()) {
78642
78626
  return;
78643
78627
  }
78644
- if (!_this._hijackedToReject) {
78628
+ // origin was switched during invocation, discard the result and follow the chain
78629
+ if (retainedInvocator_1 !== _this.origin) {
78630
+ _this._thenResolver(resolve, reject);
78631
+ }
78632
+ else {
78645
78633
  _this._toReject = error;
78646
78634
  reject(error);
78647
78635
  }
@@ -78668,14 +78656,20 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78668
78656
  // tslint:disable-next-line: no-reserved-keywords
78669
78657
  HijackablePromise.prototype.catch = function (onrejected) {
78670
78658
  var _this = this;
78671
- return new Promise(function (_, reject) {
78659
+ return new Promise(function (resolve, reject) {
78660
+ _this._resolve = resolve;
78672
78661
  _this._reject = reject;
78673
- _this._catchResolver(reject);
78674
- }).then(onrejected);
78662
+ _this._thenResolver(resolve, reject);
78663
+ }).catch(onrejected);
78675
78664
  };
78676
78665
  // tslint:disable-next-line: no-reserved-keywords
78677
78666
  HijackablePromise.prototype.finally = function (onfinally) {
78678
- return this.origin.finally(onfinally);
78667
+ var _this = this;
78668
+ return new Promise(function (resolve, reject) {
78669
+ _this._resolve = resolve;
78670
+ _this._reject = reject;
78671
+ _this._thenResolver(resolve, reject);
78672
+ }).finally(onfinally);
78679
78673
  };
78680
78674
  HijackablePromise.prototype.hijackAndResolve = function (value) {
78681
78675
  this._hijackedToResolve = value;
@@ -78690,16 +78684,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78690
78684
  }
78691
78685
  };
78692
78686
  HijackablePromise.prototype.switchWith = function (promise) {
78693
- // switching the origin will discard the original in-progress promise result
78687
+ // switching the origin will discard the original in-progress promise result, as well any resolved non-hijacked state
78694
78688
  this.origin = promise;
78695
- // then has been invoked on this promise
78696
- if (this._resolve && this._reject) {
78697
- this._thenResolver(this._resolve, this._reject);
78698
- // catch has been invoked on this promise
78699
- }
78700
- else if (this._reject) {
78701
- this._catchResolver(this._reject);
78702
- }
78689
+ this._toResolve = undefined;
78690
+ this._toReject = undefined;
78703
78691
  };
78704
78692
  return HijackablePromise;
78705
78693
  }());
@@ -78732,7 +78720,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78732
78720
  var _this = this;
78733
78721
  this.definitions = function () { return _this.initPromise ? _this.initPromise : _this.initStyleset(); };
78734
78722
  /**
78735
- * Compatability indoor state used in styleDefinition filtering.
78723
+ * Compatibility indoor state used in styleDefinition filtering.
78724
+ * Legacy indoor module (2.0.6) will not set tilesetId
78736
78725
  */
78737
78726
  this.indoorState = undefined;
78738
78727
  /**
@@ -78789,13 +78778,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78789
78778
  }
78790
78779
  StyleManager.prototype.updateIndoorState = function (theme, tilesetId) {
78791
78780
  var _this = this;
78792
- var styleset = this.map.styles.getStyleSet();
78781
+ var styleset = this.map.styles.getMapConfiguration();
78793
78782
  if (styleset) {
78794
78783
  this.preservedPreindoorStyleset = styleset;
78795
78784
  // tilesetId fallback
78796
78785
  // MAGIC: if we are on a default style set - match existing style to the one in the default indoor style set
78797
- var desiredIndoorStyle = this.map.getStyle().style + "_indoor" + (theme === 'dark' ? '_dark' : '') + "_tileset_" + tilesetId;
78798
- this.map.styles.setStyleSet("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
78786
+ var desiredIndoorStyle = this.map.getStyle().style ? this.map.getStyle().style + "_indoor" + (theme === 'dark' ? '_dark' : '') + "_tileset_" + tilesetId : undefined;
78787
+ this.map.styles.setMapConfiguration("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
78799
78788
  }
78800
78789
  else {
78801
78790
  this.indoorState = {
@@ -78804,9 +78793,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78804
78793
  };
78805
78794
  this.initStyleset();
78806
78795
  this.definitions().then(function (definitions) {
78807
- var currentStyle = _this.map.getStyle().style;
78808
- var targetStyleName = currentStyle + "_indoor" + (_this.indoorState.theme == 'dark' ? '_dark' : '');
78809
- _this.map.setStyle({ style: targetStyleName });
78796
+ var currentStyle = (_this.map.getStyle().style || definitions.defaultStyle)
78797
+ .replace('_indoor_dark', '')
78798
+ .replace('_indoor', '');
78799
+ // we cannot compose the precise style name for auto theme, search for prefix style name match
78800
+ var targetStylePrefix = currentStyle + "_indoor";
78801
+ var candidateStyle = definitions.styles.find(function (style) { return style.name.startsWith(targetStylePrefix); });
78802
+ if (candidateStyle) {
78803
+ _this.map.setStyle({ style: candidateStyle.name });
78804
+ }
78810
78805
  });
78811
78806
  }
78812
78807
  };
@@ -78815,7 +78810,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78815
78810
  var styleset = this.preservedPreindoorStyleset;
78816
78811
  if (styleset) {
78817
78812
  // we need to revert to the styleset that was ap
78818
- this.map.styles.setStyleSet(styleset);
78813
+ this.map.styles.setMapConfiguration(styleset);
78819
78814
  }
78820
78815
  else {
78821
78816
  this.indoorState = undefined;
@@ -78847,7 +78842,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78847
78842
  version: isNaN(definitions.version) ? 0 : parseFloat(definitions.version),
78848
78843
  defaultStyle: definitions.defaultStyle,
78849
78844
  styles: definitions.styles
78850
- .filter(function (style) { return _this.indoorState ? style.name.includes('indoor') && style.name.endsWith(_this.indoorState.theme == 'dark' ? 'dark' : 'indoor') : !style.name.includes('indoor'); })
78845
+ .filter(function (style) {
78846
+ if (!_this.indoorState) {
78847
+ return !style.name.includes('indoor');
78848
+ // NOTE: azure-maps-indoor prior to 2.0.7 will not pass theme auto
78849
+ // the IndoorModule will request getTheme() from StyleManager and will call StyleManager.setStyleSet(theme == 'dark ? 'indoor_dark' : 'indoor') as approperaite
78850
+ }
78851
+ else if (_this.indoorState.theme === 'auto') {
78852
+ return style.name.endsWith(style.theme === 'dark' ? '_indoor_dark' : '_indoor');
78853
+ }
78854
+ else {
78855
+ return style.name.endsWith(_this.indoorState.theme === 'dark' ? '_indoor_dark' : '_indoor');
78856
+ }
78857
+ })
78851
78858
  .map(function (style) { return ({
78852
78859
  copyright: style.copyright.join(' '),
78853
78860
  name: style.name,
@@ -78922,7 +78929,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78922
78929
  StyleManager.prototype.getTheme = function (styleOptions) {
78923
78930
  var style = this._lookUp(styleOptions);
78924
78931
  if (!style) {
78925
- throw Error("Theme is not available.");
78932
+ return undefined;
78926
78933
  }
78927
78934
  return style.theme.toLowerCase();
78928
78935
  };
@@ -78939,7 +78946,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78939
78946
  /**
78940
78947
  * Replaces the style set used. Very costly as it reloads all controls and resources.
78941
78948
  */
78942
- StyleManager.prototype.setStyleSet = function (styleSet, styleName) {
78949
+ StyleManager.prototype.setMapConfiguration = function (styleSet, styleName) {
78943
78950
  var _this = this;
78944
78951
  this.serviceOptions.styleSet = styleSet;
78945
78952
  if (typeof styleSet === 'string') {
@@ -78961,9 +78968,24 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
78961
78968
  _this.map.setStyle({ style: targetStyleName });
78962
78969
  });
78963
78970
  };
78964
- StyleManager.prototype.getStyleSet = function () {
78971
+ StyleManager.prototype.getMapConfiguration = function () {
78965
78972
  return this.serviceOptions.styleSet;
78966
78973
  };
78974
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
78975
+ StyleManager.prototype.setStyleSet = function (styleSet) {
78976
+ this.updateIndoorState(styleSet === 'indoor_dark' ? 'dark' : 'light', null);
78977
+ };
78978
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
78979
+ StyleManager.prototype.getStyleSet = function () {
78980
+ var legacyStyleset = this.indoorState !== undefined
78981
+ ? (this.indoorState.theme === 'dark' ? 'indoor_dark' : 'indoor')
78982
+ : 'base';
78983
+ return legacyStyleset;
78984
+ };
78985
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
78986
+ StyleManager.prototype.clearStyleSet = function () {
78987
+ this.unsetIndoorState();
78988
+ };
78967
78989
  /**
78968
78990
  * Function invoked by mapbox after a style is fetched but before it is committed to the map state.
78969
78991
  *