@itwin/core-frontend 5.16.0-dev.4 → 5.16.0-dev.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.
Files changed (133) hide show
  1. package/lib/cjs/core-frontend.d.ts +1 -1
  2. package/lib/cjs/core-frontend.d.ts.map +1 -1
  3. package/lib/cjs/core-frontend.js +3 -2
  4. package/lib/cjs/core-frontend.js.map +1 -1
  5. package/lib/cjs/internal/cross-package.d.ts +1 -1
  6. package/lib/cjs/internal/cross-package.d.ts.map +1 -1
  7. package/lib/cjs/internal/cross-package.js +4 -1
  8. package/lib/cjs/internal/cross-package.js.map +1 -1
  9. package/lib/cjs/internal/tile/map/ArcGisUtilities.d.ts +15 -2
  10. package/lib/cjs/internal/tile/map/ArcGisUtilities.d.ts.map +1 -1
  11. package/lib/cjs/internal/tile/map/ArcGisUtilities.js +54 -29
  12. package/lib/cjs/internal/tile/map/ArcGisUtilities.js.map +1 -1
  13. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts +14 -0
  14. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
  15. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js +91 -45
  16. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
  17. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  18. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +5 -4
  19. package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  20. package/lib/cjs/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.d.ts.map +1 -1
  21. package/lib/cjs/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js +8 -2
  22. package/lib/cjs/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js.map +1 -1
  23. package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
  24. package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +8 -2
  25. package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
  26. package/lib/cjs/internal/tile/map/MapLayerFetch.d.ts +57 -0
  27. package/lib/cjs/internal/tile/map/MapLayerFetch.d.ts.map +1 -0
  28. package/lib/cjs/internal/tile/map/MapLayerFetch.js +95 -0
  29. package/lib/cjs/internal/tile/map/MapLayerFetch.js.map +1 -0
  30. package/lib/cjs/internal/tile/map/UrlUtils.js +1 -1
  31. package/lib/cjs/internal/tile/map/UrlUtils.js.map +1 -1
  32. package/lib/cjs/internal/tile/map/WmsCapabilities.d.ts +2 -5
  33. package/lib/cjs/internal/tile/map/WmsCapabilities.d.ts.map +1 -1
  34. package/lib/cjs/internal/tile/map/WmsCapabilities.js +16 -9
  35. package/lib/cjs/internal/tile/map/WmsCapabilities.js.map +1 -1
  36. package/lib/cjs/internal/tile/map/WmsUtilities.d.ts +29 -1
  37. package/lib/cjs/internal/tile/map/WmsUtilities.d.ts.map +1 -1
  38. package/lib/cjs/internal/tile/map/WmsUtilities.js +43 -11
  39. package/lib/cjs/internal/tile/map/WmsUtilities.js.map +1 -1
  40. package/lib/cjs/internal/tile/map/WmtsCapabilities.d.ts +2 -5
  41. package/lib/cjs/internal/tile/map/WmtsCapabilities.d.ts.map +1 -1
  42. package/lib/cjs/internal/tile/map/WmtsCapabilities.js +16 -9
  43. package/lib/cjs/internal/tile/map/WmtsCapabilities.js.map +1 -1
  44. package/lib/cjs/tile/internal.d.ts +2 -0
  45. package/lib/cjs/tile/internal.d.ts.map +1 -1
  46. package/lib/cjs/tile/internal.js +2 -0
  47. package/lib/cjs/tile/internal.js.map +1 -1
  48. package/lib/cjs/tile/map/MapLayerFetchHandler.d.ts +94 -0
  49. package/lib/cjs/tile/map/MapLayerFetchHandler.d.ts.map +1 -0
  50. package/lib/cjs/tile/map/MapLayerFetchHandler.js +10 -0
  51. package/lib/cjs/tile/map/MapLayerFetchHandler.js.map +1 -0
  52. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts +27 -1
  53. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  54. package/lib/cjs/tile/map/MapLayerFormatRegistry.js +42 -1
  55. package/lib/cjs/tile/map/MapLayerFormatRegistry.js.map +1 -1
  56. package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
  57. package/lib/cjs/tile/map/MapLayerImageryFormats.js +20 -4
  58. package/lib/cjs/tile/map/MapLayerImageryFormats.js.map +1 -1
  59. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +28 -16
  60. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  61. package/lib/cjs/tile/map/MapLayerImageryProvider.js +134 -66
  62. package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
  63. package/lib/cjs/tile/map/MapLayerSources.d.ts +19 -4
  64. package/lib/cjs/tile/map/MapLayerSources.d.ts.map +1 -1
  65. package/lib/cjs/tile/map/MapLayerSources.js +28 -11
  66. package/lib/cjs/tile/map/MapLayerSources.js.map +1 -1
  67. package/lib/esm/core-frontend.d.ts +1 -1
  68. package/lib/esm/core-frontend.d.ts.map +1 -1
  69. package/lib/esm/core-frontend.js +1 -1
  70. package/lib/esm/core-frontend.js.map +1 -1
  71. package/lib/esm/internal/cross-package.d.ts +1 -1
  72. package/lib/esm/internal/cross-package.d.ts.map +1 -1
  73. package/lib/esm/internal/cross-package.js +1 -1
  74. package/lib/esm/internal/cross-package.js.map +1 -1
  75. package/lib/esm/internal/tile/map/ArcGisUtilities.d.ts +15 -2
  76. package/lib/esm/internal/tile/map/ArcGisUtilities.d.ts.map +1 -1
  77. package/lib/esm/internal/tile/map/ArcGisUtilities.js +55 -30
  78. package/lib/esm/internal/tile/map/ArcGisUtilities.js.map +1 -1
  79. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts +14 -0
  80. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
  81. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js +92 -46
  82. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
  83. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  84. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +5 -4
  85. package/lib/esm/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  86. package/lib/esm/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.d.ts.map +1 -1
  87. package/lib/esm/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js +9 -3
  88. package/lib/esm/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js.map +1 -1
  89. package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
  90. package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +9 -3
  91. package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
  92. package/lib/esm/internal/tile/map/MapLayerFetch.d.ts +57 -0
  93. package/lib/esm/internal/tile/map/MapLayerFetch.d.ts.map +1 -0
  94. package/lib/esm/internal/tile/map/MapLayerFetch.js +91 -0
  95. package/lib/esm/internal/tile/map/MapLayerFetch.js.map +1 -0
  96. package/lib/esm/internal/tile/map/UrlUtils.js +1 -1
  97. package/lib/esm/internal/tile/map/UrlUtils.js.map +1 -1
  98. package/lib/esm/internal/tile/map/WmsCapabilities.d.ts +2 -5
  99. package/lib/esm/internal/tile/map/WmsCapabilities.d.ts.map +1 -1
  100. package/lib/esm/internal/tile/map/WmsCapabilities.js +16 -9
  101. package/lib/esm/internal/tile/map/WmsCapabilities.js.map +1 -1
  102. package/lib/esm/internal/tile/map/WmsUtilities.d.ts +29 -1
  103. package/lib/esm/internal/tile/map/WmsUtilities.d.ts.map +1 -1
  104. package/lib/esm/internal/tile/map/WmsUtilities.js +44 -12
  105. package/lib/esm/internal/tile/map/WmsUtilities.js.map +1 -1
  106. package/lib/esm/internal/tile/map/WmtsCapabilities.d.ts +2 -5
  107. package/lib/esm/internal/tile/map/WmtsCapabilities.d.ts.map +1 -1
  108. package/lib/esm/internal/tile/map/WmtsCapabilities.js +16 -9
  109. package/lib/esm/internal/tile/map/WmtsCapabilities.js.map +1 -1
  110. package/lib/esm/tile/internal.d.ts +2 -0
  111. package/lib/esm/tile/internal.d.ts.map +1 -1
  112. package/lib/esm/tile/internal.js +2 -0
  113. package/lib/esm/tile/internal.js.map +1 -1
  114. package/lib/esm/tile/map/MapLayerFetchHandler.d.ts +94 -0
  115. package/lib/esm/tile/map/MapLayerFetchHandler.d.ts.map +1 -0
  116. package/lib/esm/tile/map/MapLayerFetchHandler.js +9 -0
  117. package/lib/esm/tile/map/MapLayerFetchHandler.js.map +1 -0
  118. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts +27 -1
  119. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  120. package/lib/esm/tile/map/MapLayerFormatRegistry.js +40 -0
  121. package/lib/esm/tile/map/MapLayerFormatRegistry.js.map +1 -1
  122. package/lib/esm/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
  123. package/lib/esm/tile/map/MapLayerImageryFormats.js +21 -5
  124. package/lib/esm/tile/map/MapLayerImageryFormats.js.map +1 -1
  125. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +28 -16
  126. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  127. package/lib/esm/tile/map/MapLayerImageryProvider.js +136 -68
  128. package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
  129. package/lib/esm/tile/map/MapLayerSources.d.ts +19 -4
  130. package/lib/esm/tile/map/MapLayerSources.d.ts.map +1 -1
  131. package/lib/esm/tile/map/MapLayerSources.js +28 -11
  132. package/lib/esm/tile/map/MapLayerSources.js.map +1 -1
  133. package/package.json +20 -20
@@ -51,21 +51,33 @@ export class MapLayerSource {
51
51
  transparentBackground;
52
52
  userName;
53
53
  password;
54
- /** List of query parameters that will get appended to the source URL that should be be persisted part of the JSON representation.
54
+ /** Former name of [[queryParams]], which stores the value; retained as the backing field so existing subclasses
55
+ * and `delete` keep working.
56
+ * @deprecated in 5.16. Use [[queryParams]].
55
57
  * @beta
56
58
  */
57
59
  savedQueryParams;
60
+ /** Non-secret query parameters appended to every request made for the source, persisted as part of the JSON
61
+ * representation ([[MapLayerSourceProps.queryParams]]). Secrets must never be placed here; the hosting application
62
+ * injects them per session through a [[MapLayerFetchHandler]].
63
+ * @beta
64
+ */
65
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- the deprecated field is the storage until its removal.
66
+ get queryParams() { return this.savedQueryParams; }
67
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
68
+ set queryParams(value) { this.savedQueryParams = value; }
58
69
  /** List of query parameters that will get appended to the source URL that should *not* be be persisted part of the JSON representation.
70
+ * @deprecated in 5.16. Register a [[MapLayerFetchHandler]] ([[MapLayerFormatRegistry.addMapLayerFetchHandler]]) to inject secret or per-session parameters, which unlike this field are protected against leaking through redirects; use [[queryParams]] for non-secret parameters.
59
71
  * @beta
60
72
  */
61
73
  unsavedQueryParams;
62
- constructor(formatId = "WMS", name, url, baseMap = false, transparentBackground = true, savedQueryParams) {
74
+ constructor(formatId = "WMS", name, url, baseMap = false, transparentBackground = true, queryParams) {
63
75
  this.formatId = formatId;
64
76
  this.name = name;
65
77
  this.url = url;
66
78
  this.baseMap = baseMap;
67
79
  this.transparentBackground = transparentBackground;
68
- this.savedQueryParams = savedQueryParams;
80
+ this.queryParams = queryParams;
69
81
  }
70
82
  static fromJSON(json) {
71
83
  if (json === undefined)
@@ -89,7 +101,7 @@ export class MapLayerSource {
89
101
  return undefined;
90
102
  }
91
103
  toJSON() {
92
- return { url: this.url, name: this.name, formatId: this.formatId, transparentBackground: this.transparentBackground, queryParams: this.savedQueryParams };
104
+ return { url: this.url, name: this.name, formatId: this.formatId, transparentBackground: this.transparentBackground, queryParams: this.queryParams };
93
105
  }
94
106
  toLayerSettings(subLayers) {
95
107
  // When MapLayerSetting is created from a MapLayerSource, sub-layers and credentials need to be set separately.
@@ -97,10 +109,12 @@ export class MapLayerSource {
97
109
  if (this.userName !== undefined || this.password !== undefined) {
98
110
  layerSettings?.setCredentials(this.userName, this.password);
99
111
  }
100
- if (this.savedQueryParams) {
101
- layerSettings.savedQueryParams = { ...this.savedQueryParams };
112
+ if (this.queryParams) {
113
+ layerSettings.queryParams = { ...this.queryParams };
102
114
  }
115
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- kept for backward compatibility until removal.
103
116
  if (this.unsavedQueryParams) {
117
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
104
118
  layerSettings.unsavedQueryParams = { ...this.unsavedQueryParams };
105
119
  }
106
120
  return layerSettings;
@@ -108,14 +122,17 @@ export class MapLayerSource {
108
122
  getCredentials() {
109
123
  return this.userName && this.password ? { user: this.userName, password: this.password } : undefined;
110
124
  }
111
- /** Collect all query parameters
112
- * @beta
113
- */
125
+ /** The query parameters actually sent with requests: [[queryParams]] overlaid with the deprecated `unsavedQueryParams`
126
+ * (a key present in both takes the latter's value). Equals a copy of [[queryParams]] once `unsavedQueryParams` is removed.
127
+ * @beta
128
+ */
114
129
  collectQueryParams() {
115
130
  let queryParams = {};
116
- if (this.savedQueryParams)
117
- queryParams = { ...this.savedQueryParams };
131
+ if (this.queryParams)
132
+ queryParams = { ...this.queryParams };
133
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- kept for backward compatibility until removal.
118
134
  if (this.unsavedQueryParams)
135
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
119
136
  queryParams = { ...queryParams, ...this.unsavedQueryParams };
120
137
  return queryParams;
121
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerSources.js","sourceRoot":"","sources":["../../../../src/tile/map/MapLayerSources.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EACL,qBAAqB,EAAE,iBAAiB,EAAE,oBAAoB,EAAgC,qBAAqB,GACpH,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAA2B,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAA4B,MAAM,aAAa,CAAC;AAE3F;;GAEG;AACH,MAAM,CAAN,IAAY,oBAwBX;AAxBD,WAAY,oBAAoB;IAC9B,4BAA4B;IAC5B,iEAAK,CAAA;IACL,iEAAiE;IACjE,2FAAkB,CAAA;IAClB,6EAA6E;IAC7E,iFAAa,CAAA;IACb,uDAAuD;IACvD,qFAAe,CAAA;IACf,oEAAoE;IACpE,2EAAU,CAAA;IACV,iEAAiE;IACjE,6EAAW,CAAA;IACX,mDAAmD;IACnD,qGAAuB,CAAA;IACvB;OACG;IACH,2FAAkB,CAAA;IAClB;;;;OAIG;IACH,qFAAe,CAAA;AACjB,CAAC,EAxBW,oBAAoB,KAApB,oBAAoB,QAwB/B;AAwBD;;GAEG;AACH,MAAM,OAAO,cAAc;IAClB,QAAQ,CAAS;IACjB,IAAI,CAAS;IACb,GAAG,CAAS;IACZ,OAAO,GAAG,KAAK,CAAC;IAChB,qBAAqB,CAAW;IAChC,QAAQ,CAAU;IAClB,QAAQ,CAAU;IAEzB;;MAEE;IACK,gBAAgB,CAA6B;IAEpD;;MAEE;IACK,kBAAkB,CAA6B;IAEtD,YAAoB,QAAQ,GAAG,KAAK,EAAE,IA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AC;QAED,mCAAmC;QACnC,MAAM,kBAAkB,GAAG,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrE,eAAe,CAAC,SAAS,CAAC,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YACxF,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,kBAAkB,KAAK,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayers\r\n */\r\n\r\nimport { compareStrings, expectDefined } from \"@itwin/core-bentley\";\r\nimport {\r\n BackgroundMapProvider, BackgroundMapType, BaseMapLayerSettings, DeprecatedBackgroundMapProps, ImageMapLayerSettings, MapSubLayerProps,\r\n} from \"@itwin/core-common\";\r\nimport { Point2d } from \"@itwin/core-geometry\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { request, RequestBasicCredentials } from \"../../request/Request\";\r\nimport { ArcGisUtilities, MapCartoRectangle, MapLayerSourceValidation } from \"../internal\";\r\n\r\n/** Values for return codes from [[MapLayerSource.validateSource]]\r\n * @public\r\n */\r\nexport enum MapLayerSourceStatus {\r\n /** Layer source is valid */\r\n Valid,\r\n /** Authorization has failed when accessing this layer source. */\r\n InvalidCredentials,\r\n /** Provided format id could not be resolved in [[MapLayerFormatRegistry]] */\r\n InvalidFormat,\r\n /** The tiling schema of the source is not supported */\r\n InvalidTileTree,\r\n /** Could not not connect to remote server using the provided URL.*/\r\n InvalidUrl,\r\n /** Authorization is required to access this map layer source. */\r\n RequireAuth,\r\n /** Map-layer coordinate system is not supported */\r\n InvalidCoordinateSystem,\r\n /** Format is not compatible with the URL provided.\r\n */\r\n IncompatibleFormat,\r\n /** Authentication could not be attempted because the source's origin is not trusted\r\n * (see [MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]($frontend)). Add the origin to\r\n * [MapLayerFormatRegistry.trustedCredentialsOrigins]($frontend) rather than prompting for credentials.\r\n * @beta\r\n */\r\n UntrustedOrigin,\r\n}\r\n\r\n/** JSON representation of a map layer source.\r\n * @see [ImageryMapLayerFormatId]($common)\r\n * @public\r\n */\r\nexport interface MapLayerSourceProps {\r\n /** Identifies the map layers source. Defaults to 'WMS'. */\r\n formatId?: string;\r\n /** Name */\r\n name: string;\r\n /** URL of the source's endpoint. */\r\n url: string;\r\n /** True to indicate background is transparent. Defaults to 'true'. */\r\n transparentBackground?: boolean;\r\n /** Indicate if this source definition should be used as a base map. Defaults to false. */\r\n baseMap?: boolean;\r\n\r\n /** List of query parameters that will get appended to the source.\r\n * @beta\r\n */\r\n queryParams?: { [key: string]: string };\r\n}\r\n\r\n/** A source for map layers. These may be catalogued for convenient use by users or applications.\r\n * @public\r\n */\r\nexport class MapLayerSource {\r\n public formatId: string;\r\n public name: string;\r\n public url: string;\r\n public baseMap = false;\r\n public transparentBackground?: boolean;\r\n public userName?: string;\r\n public password?: string;\r\n\r\n /** List of query parameters that will get appended to the source URL that should be be persisted part of the JSON representation.\r\n * @beta\r\n */\r\n public savedQueryParams?: { [key: string]: string };\r\n\r\n /** List of query parameters that will get appended to the source URL that should *not* be be persisted part of the JSON representation.\r\n * @beta\r\n */\r\n public unsavedQueryParams?: { [key: string]: string };\r\n\r\n private constructor(formatId = \"WMS\", name: string, url: string, baseMap = false, transparentBackground = true, savedQueryParams?: { [key: string]: string}) {\r\n this.formatId = formatId;\r\n this.name = name;\r\n this.url = url;\r\n this.baseMap = baseMap;\r\n this.transparentBackground = transparentBackground;\r\n this.savedQueryParams = savedQueryParams;\r\n }\r\n\r\n public static fromJSON(json: MapLayerSourceProps): MapLayerSource | undefined {\r\n if (json === undefined)\r\n return undefined;\r\n\r\n return new MapLayerSource(json.formatId, json.name, json.url, json.baseMap, json.transparentBackground, json.queryParams);\r\n }\r\n\r\n public async validateSource(ignoreCache?: boolean): Promise<MapLayerSourceValidation> {\r\n return IModelApp.mapLayerFormatRegistry.validateSource({source: this, ignoreCache});\r\n }\r\n\r\n /** @internal*/\r\n public static fromBackgroundMapProps(props: DeprecatedBackgroundMapProps) {\r\n const provider = BackgroundMapProvider.fromBackgroundMapProps(props);\r\n const layerSettings = BaseMapLayerSettings.fromProvider(provider);\r\n if (undefined !== layerSettings) {\r\n const source = MapLayerSource.fromJSON(layerSettings);\r\n if (source) {\r\n source.baseMap = true;\r\n return source;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n public toJSON(): Omit<MapLayerSourceProps, \"formatId\"> & {formatId: string} {\r\n return { url: this.url, name: this.name, formatId: this.formatId, transparentBackground: this.transparentBackground, queryParams: this.savedQueryParams };\r\n }\r\n\r\n public toLayerSettings(subLayers?: MapSubLayerProps[]): ImageMapLayerSettings | undefined {\r\n // When MapLayerSetting is created from a MapLayerSource, sub-layers and credentials need to be set separately.\r\n const layerSettings = ImageMapLayerSettings.fromJSON({ ...this, subLayers });\r\n if (this.userName !== undefined || this.password !== undefined) {\r\n layerSettings?.setCredentials(this.userName, this.password);\r\n }\r\n\r\n if (this.savedQueryParams) {\r\n layerSettings.savedQueryParams = {...this.savedQueryParams};\r\n }\r\n\r\n if (this.unsavedQueryParams) {\r\n layerSettings.unsavedQueryParams = {...this.unsavedQueryParams};\r\n }\r\n return layerSettings;\r\n }\r\n\r\n private getCredentials(): RequestBasicCredentials | undefined {\r\n return this.userName && this.password ? { user: this.userName, password: this.password } : undefined;\r\n }\r\n\r\n /** Collect all query parameters\r\n * @beta\r\n */\r\n public collectQueryParams() {\r\n let queryParams: {[key: string]: string} = {};\r\n\r\n if (this.savedQueryParams)\r\n queryParams = {...this.savedQueryParams};\r\n if (this.unsavedQueryParams)\r\n queryParams = {...queryParams, ...this.unsavedQueryParams};\r\n return queryParams;\r\n }\r\n\r\n}\r\n\r\n/** A collection of [[MapLayerSource]] objects.\r\n * @beta\r\n */\r\nexport class MapLayerSources {\r\n private static _instance?: MapLayerSources;\r\n private constructor(private _sources: MapLayerSource[]) { }\r\n\r\n public static getInstance() { return MapLayerSources._instance; }\r\n\r\n public findByName(name: string, baseMap: boolean = false): MapLayerSource | undefined {\r\n const nameTest = name.toLowerCase();\r\n for (const source of this._sources)\r\n if (source.baseMap === baseMap && source.name.toLowerCase().indexOf(nameTest) !== -1)\r\n return source;\r\n\r\n return undefined;\r\n }\r\n public get layers(): MapLayerSource[] {\r\n const layers = new Array<MapLayerSource>();\r\n this._sources.forEach((source) => {\r\n if (!source.baseMap)\r\n layers.push(source);\r\n });\r\n\r\n return layers;\r\n }\r\n public get allSource() { return this._sources; }\r\n public get bases(): MapLayerSource[] {\r\n const layers = new Array<MapLayerSource>();\r\n this._sources.forEach((source) => {\r\n if (source.baseMap)\r\n layers.push(source);\r\n });\r\n\r\n return layers;\r\n }\r\n\r\n private static getBingMapLayerSource(): MapLayerSource[] {\r\n const mapLayerSources: MapLayerSource[] = [];\r\n // We know these hard-coded sources are valid, so ! is okay here.\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"BingProvider\", providerData: { mapType: BackgroundMapType.Street } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"BingProvider\", providerData: { mapType: BackgroundMapType.Aerial } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"BingProvider\", providerData: { mapType: BackgroundMapType.Hybrid } })!);\r\n return mapLayerSources;\r\n }\r\n\r\n private static getMapBoxLayerSource(): MapLayerSource[] {\r\n const mapLayerSources: MapLayerSource[] = [];\r\n // We know these hard-coded sources are valid, so ! is okay here.\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"MapBoxProvider\", providerData: { mapType: BackgroundMapType.Street } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"MapBoxProvider\", providerData: { mapType: BackgroundMapType.Aerial } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"MapBoxProvider\", providerData: { mapType: BackgroundMapType.Hybrid } })!);\r\n return mapLayerSources;\r\n }\r\n\r\n public static async create(iModel?: IModelConnection, queryForPublicSources = false, addMapBoxSources = false): Promise<MapLayerSources> {\r\n if (!queryForPublicSources && MapLayerSources._instance)\r\n return MapLayerSources._instance;\r\n\r\n if (!iModel)\r\n iModel = IModelApp.viewManager.selectedView ? IModelApp.viewManager.selectedView.iModel : undefined;\r\n\r\n let sourceRange = MapCartoRectangle.createMaximum();\r\n if (iModel) {\r\n const projectCenter = expectDefined(iModel.projectExtents.localXYZToWorld(.5, .5, .5));\r\n const cartoCenter = iModel.spatialToCartographicFromEcef(projectCenter);\r\n const globeRange = MapCartoRectangle.createMaximum();\r\n const nearDelta = Point2d.create(globeRange.xLength() / 100, globeRange.yLength() / 100);\r\n sourceRange = MapCartoRectangle.fromRadians(cartoCenter.longitude - nearDelta.x, cartoCenter.latitude - nearDelta.y, cartoCenter.longitude + nearDelta.x, cartoCenter.latitude + nearDelta.y);\r\n }\r\n\r\n const sources = new Array<MapLayerSource>();\r\n const urlSet = new Set<string>();\r\n const addSource = ((source: MapLayerSource) => {\r\n if (!urlSet.has(source.url)) {\r\n sources.push(source);\r\n urlSet.add(source.url);\r\n }\r\n });\r\n\r\n this.getBingMapLayerSource().forEach((source) => {\r\n addSource(source);\r\n });\r\n\r\n if (addMapBoxSources) {\r\n this.getMapBoxLayerSource().forEach((source) => {\r\n addSource(source);\r\n });\r\n }\r\n\r\n if (queryForPublicSources) {\r\n const sourcesJson = await request(`${IModelApp.publicPath}assets/MapLayerSources.json`, \"json\");\r\n\r\n for (const sourceJson of sourcesJson) {\r\n const source = MapLayerSource.fromJSON(sourceJson);\r\n if (source)\r\n addSource(source);\r\n }\r\n\r\n (await ArcGisUtilities.getSourcesFromQuery(sourceRange)).forEach((queriedSource) => addSource(queriedSource));\r\n }\r\n\r\n sources.sort((a: MapLayerSource, b: MapLayerSource) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));\r\n\r\n const mapLayerSources = new MapLayerSources(sources);\r\n MapLayerSources._instance = mapLayerSources;\r\n\r\n return mapLayerSources;\r\n }\r\n public static async addSourceToMapLayerSources(mapLayerSource?: MapLayerSource): Promise<MapLayerSources | undefined> {\r\n if (!MapLayerSources._instance || !mapLayerSource) {\r\n return undefined;\r\n }\r\n MapLayerSources._instance._sources = MapLayerSources._instance._sources.filter((source) => {\r\n return !(source.name === mapLayerSource.name || source.url === mapLayerSource.url);\r\n });\r\n\r\n MapLayerSources._instance._sources.push(mapLayerSource);\r\n MapLayerSources._instance._sources.sort((a: MapLayerSource, b: MapLayerSource) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));\r\n return MapLayerSources._instance;\r\n }\r\n\r\n public static removeLayerByName(name: string): boolean {\r\n if (!MapLayerSources._instance) {\r\n return false;\r\n }\r\n\r\n // For now we only rely on the name\r\n const lengthBeforeRemove = MapLayerSources._instance._sources.length;\r\n MapLayerSources._instance._sources = MapLayerSources._instance._sources.filter((source) => {\r\n return (source.name !== name);\r\n });\r\n return (lengthBeforeRemove !== MapLayerSources._instance._sources.length);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MapLayerSources.js","sourceRoot":"","sources":["../../../../src/tile/map/MapLayerSources.ts"],"names":[],"mappings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AC;IACnC,CAAC;IAEM,MAAM,CAAC,iBAAiB,CAAC,IAAY;QAC1C,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,mCAAmC;QACnC,MAAM,kBAAkB,GAAG,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrE,eAAe,CAAC,SAAS,CAAC,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YACxF,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,kBAAkB,KAAK,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayers\r\n */\r\n\r\nimport { compareStrings, expectDefined } from \"@itwin/core-bentley\";\r\nimport {\r\n BackgroundMapProvider, BackgroundMapType, BaseMapLayerSettings, DeprecatedBackgroundMapProps, ImageMapLayerSettings, MapSubLayerProps,\r\n} from \"@itwin/core-common\";\r\nimport { Point2d } from \"@itwin/core-geometry\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { request, RequestBasicCredentials } from \"../../request/Request\";\r\nimport { ArcGisUtilities, MapCartoRectangle, MapLayerSourceValidation } from \"../internal\";\r\n\r\n/** Values for return codes from [[MapLayerSource.validateSource]]\r\n * @public\r\n */\r\nexport enum MapLayerSourceStatus {\r\n /** Layer source is valid */\r\n Valid,\r\n /** Authorization has failed when accessing this layer source. */\r\n InvalidCredentials,\r\n /** Provided format id could not be resolved in [[MapLayerFormatRegistry]] */\r\n InvalidFormat,\r\n /** The tiling schema of the source is not supported */\r\n InvalidTileTree,\r\n /** Could not not connect to remote server using the provided URL.*/\r\n InvalidUrl,\r\n /** Authorization is required to access this map layer source. */\r\n RequireAuth,\r\n /** Map-layer coordinate system is not supported */\r\n InvalidCoordinateSystem,\r\n /** Format is not compatible with the URL provided.\r\n */\r\n IncompatibleFormat,\r\n /** Authentication could not be attempted because the source's origin is not trusted\r\n * (see [MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]($frontend)). Add the origin to\r\n * [MapLayerFormatRegistry.trustedCredentialsOrigins]($frontend) rather than prompting for credentials.\r\n * @beta\r\n */\r\n UntrustedOrigin,\r\n}\r\n\r\n/** JSON representation of a map layer source.\r\n * @see [ImageryMapLayerFormatId]($common)\r\n * @public\r\n */\r\nexport interface MapLayerSourceProps {\r\n /** Identifies the map layers source. Defaults to 'WMS'. */\r\n formatId?: string;\r\n /** Name */\r\n name: string;\r\n /** URL of the source's endpoint. */\r\n url: string;\r\n /** True to indicate background is transparent. Defaults to 'true'. */\r\n transparentBackground?: boolean;\r\n /** Indicate if this source definition should be used as a base map. Defaults to false. */\r\n baseMap?: boolean;\r\n\r\n /** List of query parameters that will get appended to the source.\r\n * @beta\r\n */\r\n queryParams?: { [key: string]: string };\r\n}\r\n\r\n/** A source for map layers. These may be catalogued for convenient use by users or applications.\r\n * @public\r\n */\r\nexport class MapLayerSource {\r\n public formatId: string;\r\n public name: string;\r\n public url: string;\r\n public baseMap = false;\r\n public transparentBackground?: boolean;\r\n public userName?: string;\r\n public password?: string;\r\n\r\n /** Former name of [[queryParams]], which stores the value; retained as the backing field so existing subclasses\r\n * and `delete` keep working.\r\n * @deprecated in 5.16. Use [[queryParams]].\r\n * @beta\r\n */\r\n public savedQueryParams?: { [key: string]: string };\r\n\r\n /** Non-secret query parameters appended to every request made for the source, persisted as part of the JSON\r\n * representation ([[MapLayerSourceProps.queryParams]]). Secrets must never be placed here; the hosting application\r\n * injects them per session through a [[MapLayerFetchHandler]].\r\n * @beta\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- the deprecated field is the storage until its removal.\r\n public get queryParams(): { [key: string]: string } | undefined { return this.savedQueryParams; }\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public set queryParams(value: { [key: string]: string } | undefined) { this.savedQueryParams = value; }\r\n\r\n /** List of query parameters that will get appended to the source URL that should *not* be be persisted part of the JSON representation.\r\n * @deprecated in 5.16. Register a [[MapLayerFetchHandler]] ([[MapLayerFormatRegistry.addMapLayerFetchHandler]]) to inject secret or per-session parameters, which unlike this field are protected against leaking through redirects; use [[queryParams]] for non-secret parameters.\r\n * @beta\r\n */\r\n public unsavedQueryParams?: { [key: string]: string };\r\n\r\n private constructor(formatId = \"WMS\", name: string, url: string, baseMap = false, transparentBackground = true, queryParams?: { [key: string]: string}) {\r\n this.formatId = formatId;\r\n this.name = name;\r\n this.url = url;\r\n this.baseMap = baseMap;\r\n this.transparentBackground = transparentBackground;\r\n this.queryParams = queryParams;\r\n }\r\n\r\n public static fromJSON(json: MapLayerSourceProps): MapLayerSource | undefined {\r\n if (json === undefined)\r\n return undefined;\r\n\r\n return new MapLayerSource(json.formatId, json.name, json.url, json.baseMap, json.transparentBackground, json.queryParams);\r\n }\r\n\r\n public async validateSource(ignoreCache?: boolean): Promise<MapLayerSourceValidation> {\r\n return IModelApp.mapLayerFormatRegistry.validateSource({source: this, ignoreCache});\r\n }\r\n\r\n /** @internal*/\r\n public static fromBackgroundMapProps(props: DeprecatedBackgroundMapProps) {\r\n const provider = BackgroundMapProvider.fromBackgroundMapProps(props);\r\n const layerSettings = BaseMapLayerSettings.fromProvider(provider);\r\n if (undefined !== layerSettings) {\r\n const source = MapLayerSource.fromJSON(layerSettings);\r\n if (source) {\r\n source.baseMap = true;\r\n return source;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n public toJSON(): Omit<MapLayerSourceProps, \"formatId\"> & {formatId: string} {\r\n return { url: this.url, name: this.name, formatId: this.formatId, transparentBackground: this.transparentBackground, queryParams: this.queryParams };\r\n }\r\n\r\n public toLayerSettings(subLayers?: MapSubLayerProps[]): ImageMapLayerSettings | undefined {\r\n // When MapLayerSetting is created from a MapLayerSource, sub-layers and credentials need to be set separately.\r\n const layerSettings = ImageMapLayerSettings.fromJSON({ ...this, subLayers });\r\n if (this.userName !== undefined || this.password !== undefined) {\r\n layerSettings?.setCredentials(this.userName, this.password);\r\n }\r\n\r\n if (this.queryParams) {\r\n layerSettings.queryParams = {...this.queryParams};\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- kept for backward compatibility until removal.\r\n if (this.unsavedQueryParams) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n layerSettings.unsavedQueryParams = {...this.unsavedQueryParams};\r\n }\r\n return layerSettings;\r\n }\r\n\r\n private getCredentials(): RequestBasicCredentials | undefined {\r\n return this.userName && this.password ? { user: this.userName, password: this.password } : undefined;\r\n }\r\n\r\n /** The query parameters actually sent with requests: [[queryParams]] overlaid with the deprecated `unsavedQueryParams`\r\n * (a key present in both takes the latter's value). Equals a copy of [[queryParams]] once `unsavedQueryParams` is removed.\r\n * @beta\r\n */\r\n public collectQueryParams() {\r\n let queryParams: {[key: string]: string} = {};\r\n\r\n if (this.queryParams)\r\n queryParams = {...this.queryParams};\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- kept for backward compatibility until removal.\r\n if (this.unsavedQueryParams)\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n queryParams = {...queryParams, ...this.unsavedQueryParams};\r\n return queryParams;\r\n }\r\n\r\n}\r\n\r\n/** A collection of [[MapLayerSource]] objects.\r\n * @beta\r\n */\r\nexport class MapLayerSources {\r\n private static _instance?: MapLayerSources;\r\n private constructor(private _sources: MapLayerSource[]) { }\r\n\r\n public static getInstance() { return MapLayerSources._instance; }\r\n\r\n public findByName(name: string, baseMap: boolean = false): MapLayerSource | undefined {\r\n const nameTest = name.toLowerCase();\r\n for (const source of this._sources)\r\n if (source.baseMap === baseMap && source.name.toLowerCase().indexOf(nameTest) !== -1)\r\n return source;\r\n\r\n return undefined;\r\n }\r\n public get layers(): MapLayerSource[] {\r\n const layers = new Array<MapLayerSource>();\r\n this._sources.forEach((source) => {\r\n if (!source.baseMap)\r\n layers.push(source);\r\n });\r\n\r\n return layers;\r\n }\r\n public get allSource() { return this._sources; }\r\n public get bases(): MapLayerSource[] {\r\n const layers = new Array<MapLayerSource>();\r\n this._sources.forEach((source) => {\r\n if (source.baseMap)\r\n layers.push(source);\r\n });\r\n\r\n return layers;\r\n }\r\n\r\n private static getBingMapLayerSource(): MapLayerSource[] {\r\n const mapLayerSources: MapLayerSource[] = [];\r\n // We know these hard-coded sources are valid, so ! is okay here.\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"BingProvider\", providerData: { mapType: BackgroundMapType.Street } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"BingProvider\", providerData: { mapType: BackgroundMapType.Aerial } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"BingProvider\", providerData: { mapType: BackgroundMapType.Hybrid } })!);\r\n return mapLayerSources;\r\n }\r\n\r\n private static getMapBoxLayerSource(): MapLayerSource[] {\r\n const mapLayerSources: MapLayerSource[] = [];\r\n // We know these hard-coded sources are valid, so ! is okay here.\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"MapBoxProvider\", providerData: { mapType: BackgroundMapType.Street } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"MapBoxProvider\", providerData: { mapType: BackgroundMapType.Aerial } })!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n mapLayerSources.push(MapLayerSource.fromBackgroundMapProps({ providerName: \"MapBoxProvider\", providerData: { mapType: BackgroundMapType.Hybrid } })!);\r\n return mapLayerSources;\r\n }\r\n\r\n public static async create(iModel?: IModelConnection, queryForPublicSources = false, addMapBoxSources = false): Promise<MapLayerSources> {\r\n if (!queryForPublicSources && MapLayerSources._instance)\r\n return MapLayerSources._instance;\r\n\r\n if (!iModel)\r\n iModel = IModelApp.viewManager.selectedView ? IModelApp.viewManager.selectedView.iModel : undefined;\r\n\r\n let sourceRange = MapCartoRectangle.createMaximum();\r\n if (iModel) {\r\n const projectCenter = expectDefined(iModel.projectExtents.localXYZToWorld(.5, .5, .5));\r\n const cartoCenter = iModel.spatialToCartographicFromEcef(projectCenter);\r\n const globeRange = MapCartoRectangle.createMaximum();\r\n const nearDelta = Point2d.create(globeRange.xLength() / 100, globeRange.yLength() / 100);\r\n sourceRange = MapCartoRectangle.fromRadians(cartoCenter.longitude - nearDelta.x, cartoCenter.latitude - nearDelta.y, cartoCenter.longitude + nearDelta.x, cartoCenter.latitude + nearDelta.y);\r\n }\r\n\r\n const sources = new Array<MapLayerSource>();\r\n const urlSet = new Set<string>();\r\n const addSource = ((source: MapLayerSource) => {\r\n if (!urlSet.has(source.url)) {\r\n sources.push(source);\r\n urlSet.add(source.url);\r\n }\r\n });\r\n\r\n this.getBingMapLayerSource().forEach((source) => {\r\n addSource(source);\r\n });\r\n\r\n if (addMapBoxSources) {\r\n this.getMapBoxLayerSource().forEach((source) => {\r\n addSource(source);\r\n });\r\n }\r\n\r\n if (queryForPublicSources) {\r\n const sourcesJson = await request(`${IModelApp.publicPath}assets/MapLayerSources.json`, \"json\");\r\n\r\n for (const sourceJson of sourcesJson) {\r\n const source = MapLayerSource.fromJSON(sourceJson);\r\n if (source)\r\n addSource(source);\r\n }\r\n\r\n (await ArcGisUtilities.getSourcesFromQuery(sourceRange)).forEach((queriedSource) => addSource(queriedSource));\r\n }\r\n\r\n sources.sort((a: MapLayerSource, b: MapLayerSource) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));\r\n\r\n const mapLayerSources = new MapLayerSources(sources);\r\n MapLayerSources._instance = mapLayerSources;\r\n\r\n return mapLayerSources;\r\n }\r\n public static async addSourceToMapLayerSources(mapLayerSource?: MapLayerSource): Promise<MapLayerSources | undefined> {\r\n if (!MapLayerSources._instance || !mapLayerSource) {\r\n return undefined;\r\n }\r\n MapLayerSources._instance._sources = MapLayerSources._instance._sources.filter((source) => {\r\n return !(source.name === mapLayerSource.name || source.url === mapLayerSource.url);\r\n });\r\n\r\n MapLayerSources._instance._sources.push(mapLayerSource);\r\n MapLayerSources._instance._sources.sort((a: MapLayerSource, b: MapLayerSource) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));\r\n return MapLayerSources._instance;\r\n }\r\n\r\n public static removeLayerByName(name: string): boolean {\r\n if (!MapLayerSources._instance) {\r\n return false;\r\n }\r\n\r\n // For now we only rely on the name\r\n const lengthBeforeRemove = MapLayerSources._instance._sources.length;\r\n MapLayerSources._instance._sources = MapLayerSources._instance._sources.filter((source) => {\r\n return (source.name !== name);\r\n });\r\n return (lengthBeforeRemove !== MapLayerSources._instance._sources.length);\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-frontend",
3
- "version": "5.16.0-dev.4",
3
+ "version": "5.16.0-dev.5",
4
4
  "description": "iTwin.js frontend components",
5
5
  "main": "lib/cjs/core-frontend.js",
6
6
  "module": "lib/esm/core-frontend.js",
@@ -23,14 +23,14 @@
23
23
  "url": "http://www.bentley.com"
24
24
  },
25
25
  "peerDependencies": {
26
- "@itwin/appui-abstract": "5.16.0-dev.4",
27
- "@itwin/core-geometry": "5.16.0-dev.4",
28
- "@itwin/core-quantity": "5.16.0-dev.4",
29
- "@itwin/core-common": "5.16.0-dev.4",
30
- "@itwin/ecschema-metadata": "5.16.0-dev.4",
31
- "@itwin/core-orbitgt": "5.16.0-dev.4",
32
- "@itwin/core-bentley": "5.16.0-dev.4",
33
- "@itwin/ecschema-rpcinterface-common": "5.16.0-dev.4"
26
+ "@itwin/appui-abstract": "5.16.0-dev.5",
27
+ "@itwin/core-orbitgt": "5.16.0-dev.5",
28
+ "@itwin/core-bentley": "5.16.0-dev.5",
29
+ "@itwin/core-geometry": "5.16.0-dev.5",
30
+ "@itwin/core-quantity": "5.16.0-dev.5",
31
+ "@itwin/core-common": "5.16.0-dev.5",
32
+ "@itwin/ecschema-rpcinterface-common": "5.16.0-dev.5",
33
+ "@itwin/ecschema-metadata": "5.16.0-dev.5"
34
34
  },
35
35
  "//devDependencies": [
36
36
  "NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
@@ -54,15 +54,15 @@
54
54
  "typescript": "~5.6.2",
55
55
  "vite": "^6.4.4",
56
56
  "vitest": "^4.1.10",
57
- "@itwin/appui-abstract": "5.16.0-dev.4",
58
- "@itwin/build-tools": "5.16.0-dev.4",
59
- "@itwin/core-geometry": "5.16.0-dev.4",
60
- "@itwin/core-common": "5.16.0-dev.4",
61
- "@itwin/core-orbitgt": "5.16.0-dev.4",
62
- "@itwin/core-quantity": "5.16.0-dev.4",
63
- "@itwin/core-bentley": "5.16.0-dev.4",
64
- "@itwin/ecschema-rpcinterface-common": "5.16.0-dev.4",
65
- "@itwin/ecschema-metadata": "5.16.0-dev.4"
57
+ "@itwin/core-bentley": "5.16.0-dev.5",
58
+ "@itwin/appui-abstract": "5.16.0-dev.5",
59
+ "@itwin/core-geometry": "5.16.0-dev.5",
60
+ "@itwin/build-tools": "5.16.0-dev.5",
61
+ "@itwin/core-common": "5.16.0-dev.5",
62
+ "@itwin/ecschema-metadata": "5.16.0-dev.5",
63
+ "@itwin/core-orbitgt": "5.16.0-dev.5",
64
+ "@itwin/ecschema-rpcinterface-common": "5.16.0-dev.5",
65
+ "@itwin/core-quantity": "5.16.0-dev.5"
66
66
  },
67
67
  "//dependencies": [
68
68
  "NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
@@ -73,8 +73,8 @@
73
73
  "@loaders.gl/draco": "^4.4.5",
74
74
  "fuse.js": "^3.3.0",
75
75
  "wms-capabilities": "0.6.0",
76
- "@itwin/core-i18n": "5.16.0-dev.4",
77
- "@itwin/webgl-compatibility": "5.16.0-dev.4"
76
+ "@itwin/webgl-compatibility": "5.16.0-dev.5",
77
+ "@itwin/core-i18n": "5.16.0-dev.5"
78
78
  },
79
79
  "scripts": {
80
80
  "build": "npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s build:workers && npm run -s copy:draco",