@esri/solutions-components 0.8.4 → 0.8.5

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.
@@ -1571,6 +1571,38 @@ const LayerTable = class {
1571
1571
  };
1572
1572
  LayerTable.style = layerTableCss;
1573
1573
 
1574
+ function joinAppProxies(map, config, appProxies) {
1575
+ if (appProxies) {
1576
+ appProxies.forEach((proxy) => {
1577
+ map.allLayers.forEach((layer) => {
1578
+ if (layer && layer.url === proxy.sourceUrl) {
1579
+ // directly change the layer url to the proxy url
1580
+ layer.url = proxy.proxyUrl;
1581
+ // Replace the layer's portalItem's url with the proxy url too, otherwise anonymous viewers get a sign-in prompt.
1582
+ if (layer.portalItem) {
1583
+ layer.portalItem.when(() => {
1584
+ // layer.portalItem exists, see above. Not sure why typescript thinks it could be undefined here.
1585
+ layer.portalItem.url = proxy.proxyUrl;
1586
+ });
1587
+ }
1588
+ // also add a request interceptor in case we missed any requests to the original url, or the jsapi team adds new requests in the future.
1589
+ config.request?.interceptors?.push({
1590
+ // this interceptor only applies to requests made to this proxy's sourceUrl (the layer's original url).
1591
+ urls: proxy.sourceUrl,
1592
+ before: (params) => {
1593
+ // change requests from the original url to the proxy url
1594
+ if (params.url && params.url === proxy.sourceUrl) {
1595
+ params.url = proxy.proxyUrl;
1596
+ }
1597
+ },
1598
+ });
1599
+ }
1600
+ });
1601
+ });
1602
+ }
1603
+ return map;
1604
+ }
1605
+
1574
1606
  const mapCardCss = ":host{display:block;--calcite-label-margin-bottom:0;--calcite-block-padding:0}.map-height{height:calc(100% - 51px)}.height-full{height:100%}.box-shadow{box-shadow:none !important}.visibility-hidden-1{visibility:hidden;height:1px;}.display-none{display:none}";
1575
1607
 
1576
1608
  const MapCard = class {
@@ -1586,6 +1618,7 @@ const MapCard = class {
1586
1618
  * string: the id of map currently displayed
1587
1619
  */
1588
1620
  this._loadedId = "";
1621
+ this.appProxies = undefined;
1589
1622
  this.defaultWebmapId = "";
1590
1623
  this.enableHome = undefined;
1591
1624
  this.enableLegend = undefined;
@@ -1662,14 +1695,16 @@ const MapCard = class {
1662
1695
  * @protected
1663
1696
  */
1664
1697
  async _initModules() {
1665
- const [WebMap, MapView, Home] = await locale.loadModules([
1698
+ const [WebMap, MapView, Home, esriConfig] = await locale.loadModules([
1666
1699
  "esri/WebMap",
1667
1700
  "esri/views/MapView",
1668
- "esri/widgets/Home"
1701
+ "esri/widgets/Home",
1702
+ "esri/config"
1669
1703
  ]);
1670
1704
  this.WebMap = WebMap;
1671
1705
  this.MapView = MapView;
1672
1706
  this.Home = Home;
1707
+ this.esriConfig = esriConfig;
1673
1708
  }
1674
1709
  /**
1675
1710
  * Load the webmap for the provided webMapInfo
@@ -1690,6 +1725,10 @@ const MapCard = class {
1690
1725
  const webMap = new this.WebMap({
1691
1726
  portalItem: { id }
1692
1727
  });
1728
+ if (this.appProxies) {
1729
+ await webMap.load();
1730
+ await joinAppProxies(webMap, this.esriConfig, this.appProxies);
1731
+ }
1693
1732
  this.mapView = new this.MapView({
1694
1733
  container: this._mapDiv,
1695
1734
  map: webMap,
@@ -39,6 +39,7 @@ const CrowdsourceManager = class {
39
39
  * MapView.when is not fired when mapView is not currently visible
40
40
  */
41
41
  this._shouldSetMapView = false;
42
+ this.appProxies = undefined;
42
43
  this.defaultCenter = "";
43
44
  this.defaultGlobalId = "";
44
45
  this.defaultLayer = "";
@@ -326,7 +327,7 @@ const CrowdsourceManager = class {
326
327
  _getMapNode(panelOpen) {
327
328
  var _a;
328
329
  const mapContainerClass = this._layoutMode === interfaces.ELayoutMode.HORIZONTAL && (!this._isMobile || panelOpen) ? "" : "adjusted-height-50";
329
- return (index.h("div", { class: `${mapContainerClass} overflow-hidden` }, index.h("map-card", { basemapConfig: this.basemapConfig, class: "width-full", defaultWebmapId: this.defaultWebmap, enableBasemap: this.enableBasemap, enableFloorFilter: this.enableFloorFilter, enableFullscreen: this.enableFullscreen, enableHome: this.enableHome, enableLegend: this.enableLegend, enableSearch: this.enableSearch, enableSingleExpand: true, hidden: this._expandPopup && !this._isMobile, homeZoomIndex: 3, homeZoomPosition: "top-left", homeZoomToolsSize: "s", mapInfos: (_a = this.mapInfos) === null || _a === void 0 ? void 0 : _a.filter(mapInfo => mapInfo.visible !== false), mapWidgetsIndex: 0, mapWidgetsPosition: "top-right", mapWidgetsSize: "m", stackTools: true, theme: this.theme, toolOrder: ["legend", "search", "fullscreen", "basemap", "floorfilter"] })));
330
+ return (index.h("div", { class: `${mapContainerClass} overflow-hidden` }, index.h("map-card", { appProxies: this.appProxies, basemapConfig: this.basemapConfig, class: "width-full", defaultWebmapId: this.defaultWebmap, enableBasemap: this.enableBasemap, enableFloorFilter: this.enableFloorFilter, enableFullscreen: this.enableFullscreen, enableHome: this.enableHome, enableLegend: this.enableLegend, enableSearch: this.enableSearch, enableSingleExpand: true, hidden: this._expandPopup && !this._isMobile, homeZoomIndex: 3, homeZoomPosition: "top-left", homeZoomToolsSize: "s", mapInfos: (_a = this.mapInfos) === null || _a === void 0 ? void 0 : _a.filter(mapInfo => mapInfo.visible !== false), mapWidgetsIndex: 0, mapWidgetsPosition: "top-right", mapWidgetsSize: "m", stackTools: true, theme: this.theme, toolOrder: ["legend", "search", "fullscreen", "basemap", "floorfilter"] })));
330
331
  }
331
332
  /**
332
333
  * Get the expand node for the popup information