@itwin/map-layers 5.0.0-dev.3 → 5.1.0

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 (105) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/lib/cjs/MapLayerPreferences.js +1 -1
  3. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  4. package/lib/cjs/MapLayersPrefBrowserStorage.d.ts +5 -0
  5. package/lib/cjs/MapLayersPrefBrowserStorage.d.ts.map +1 -0
  6. package/lib/cjs/MapLayersPrefBrowserStorage.js +16 -0
  7. package/lib/cjs/MapLayersPrefBrowserStorage.js.map +1 -0
  8. package/lib/cjs/PreferencesBrowserStorage.d.ts +36 -0
  9. package/lib/cjs/PreferencesBrowserStorage.d.ts.map +1 -0
  10. package/lib/cjs/PreferencesBrowserStorage.js +92 -0
  11. package/lib/cjs/PreferencesBrowserStorage.js.map +1 -0
  12. package/lib/cjs/map-layers.d.ts +1 -0
  13. package/lib/cjs/map-layers.d.ts.map +1 -1
  14. package/lib/cjs/map-layers.js +1 -0
  15. package/lib/cjs/map-layers.js.map +1 -1
  16. package/lib/cjs/public/locales/en/mapLayers.json +7 -2
  17. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  18. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +144 -64
  19. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  20. package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
  21. package/lib/cjs/ui/widget/BasemapPanel.js +44 -15
  22. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  23. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  24. package/lib/cjs/ui/widget/MapLayerDroppable.js +31 -3
  25. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  26. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
  27. package/lib/cjs/ui/widget/MapLayerManager.js +35 -57
  28. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  29. package/lib/cjs/ui/widget/MapLayerManager.scss +2 -8
  30. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.d.ts +11 -0
  31. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.d.ts.map +1 -0
  32. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js +58 -0
  33. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js.map +1 -0
  34. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.scss +17 -0
  35. package/lib/cjs/ui/widget/MapUrlDialog.d.ts +7 -2
  36. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
  37. package/lib/cjs/ui/widget/MapUrlDialog.js +38 -134
  38. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  39. package/lib/cjs/ui/widget/MapUrlDialog.scss +10 -10
  40. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts +3 -3
  41. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
  42. package/lib/cjs/ui/widget/SubLayersDataProvider.js +4 -5
  43. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  44. package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts +3 -7
  45. package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts.map +1 -1
  46. package/lib/cjs/ui/widget/SubLayersPopupButton.js +2 -2
  47. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
  48. package/lib/cjs/ui/widget/SubLayersTree.d.ts +17 -9
  49. package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
  50. package/lib/cjs/ui/widget/SubLayersTree.js +59 -112
  51. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  52. package/lib/cjs/ui/widget/SubLayersTree.scss +12 -3
  53. package/lib/esm/MapLayerPreferences.js +1 -1
  54. package/lib/esm/MapLayerPreferences.js.map +1 -1
  55. package/lib/esm/MapLayersPrefBrowserStorage.d.ts +5 -0
  56. package/lib/esm/MapLayersPrefBrowserStorage.d.ts.map +1 -0
  57. package/lib/esm/MapLayersPrefBrowserStorage.js +12 -0
  58. package/lib/esm/MapLayersPrefBrowserStorage.js.map +1 -0
  59. package/lib/esm/PreferencesBrowserStorage.d.ts +36 -0
  60. package/lib/esm/PreferencesBrowserStorage.d.ts.map +1 -0
  61. package/lib/esm/PreferencesBrowserStorage.js +88 -0
  62. package/lib/esm/PreferencesBrowserStorage.js.map +1 -0
  63. package/lib/esm/map-layers.d.ts +1 -0
  64. package/lib/esm/map-layers.d.ts.map +1 -1
  65. package/lib/esm/map-layers.js +1 -0
  66. package/lib/esm/map-layers.js.map +1 -1
  67. package/lib/esm/public/locales/en/mapLayers.json +7 -2
  68. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  69. package/lib/esm/ui/widget/AttachLayerPopupButton.js +145 -65
  70. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  71. package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
  72. package/lib/esm/ui/widget/BasemapPanel.js +44 -15
  73. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  74. package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  75. package/lib/esm/ui/widget/MapLayerDroppable.js +32 -4
  76. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  77. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
  78. package/lib/esm/ui/widget/MapLayerManager.js +36 -58
  79. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  80. package/lib/esm/ui/widget/MapLayerManager.scss +2 -8
  81. package/lib/esm/ui/widget/MapSelectFeaturesDialog.d.ts +11 -0
  82. package/lib/esm/ui/widget/MapSelectFeaturesDialog.d.ts.map +1 -0
  83. package/lib/esm/ui/widget/MapSelectFeaturesDialog.js +54 -0
  84. package/lib/esm/ui/widget/MapSelectFeaturesDialog.js.map +1 -0
  85. package/lib/esm/ui/widget/MapSelectFeaturesDialog.scss +17 -0
  86. package/lib/esm/ui/widget/MapUrlDialog.d.ts +7 -2
  87. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
  88. package/lib/esm/ui/widget/MapUrlDialog.js +38 -134
  89. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  90. package/lib/esm/ui/widget/MapUrlDialog.scss +10 -10
  91. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts +3 -3
  92. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
  93. package/lib/esm/ui/widget/SubLayersDataProvider.js +4 -5
  94. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  95. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts +3 -7
  96. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts.map +1 -1
  97. package/lib/esm/ui/widget/SubLayersPopupButton.js +2 -2
  98. package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
  99. package/lib/esm/ui/widget/SubLayersTree.d.ts +17 -9
  100. package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
  101. package/lib/esm/ui/widget/SubLayersTree.js +60 -113
  102. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  103. package/lib/esm/ui/widget/SubLayersTree.scss +12 -3
  104. package/lib/public/locales/en/mapLayers.json +7 -2
  105. package/package.json +26 -25
package/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Change Log - @itwin/map-layers
2
2
 
3
- This log was last generated on Thu, 04 May 2023 23:59:19 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 26 Jul 2023 21:49:07 GMT and should not be manually modified.
4
+
5
+ ## 5.1.0
6
+ Wed, 26 Jul 2023 21:49:07 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - New UI that allow creating multiple layers from sources supporting single layer per request.
11
+
12
+ ### Patches
13
+
14
+ - Fixvarious display issues with MapLayer widget
15
+
16
+ ## 5.0.0
17
+ Tue, 06 Jun 2023 10:57:06 GMT
18
+
19
+ ### Patches
20
+
21
+ - Fix an issue with MapLayerPreferences that would not save with the proper key with replacing an existing source. Also also added MapLayersPrefBrowserStorage as a simple/testing implementation of UserPreferencesAccess.
22
+ - Refactored SubLayers tree panel and made it independent from viewport
4
23
 
5
24
  ## 4.0.0
6
25
  Thu, 04 May 2023 23:59:19 GMT
@@ -98,7 +98,7 @@ class MapLayerPreferences {
98
98
  await mapLayers_1.MapLayersUI.iTwinConfig.save({
99
99
  accessToken,
100
100
  namespace: MapLayerPreferences._preferenceNamespace,
101
- key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,
101
+ key: newSource.name,
102
102
  iTwinId,
103
103
  iModelId: storeOnIModel ? iModelId : undefined,
104
104
  content: mapLayerSetting,
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,IAAI,CAAC,uBAAW,CAAC,WAAW;YAC1B,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAErI,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,C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AkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAjTH,kDAkTC;AAjTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
1
+ {"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,IAAI,CAAC,uBAAW,CAAC,WAAW;YAC1B,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAErI,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,eAAe,GAA+B;YAClD,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,qBAAqB,EAAE,UAAU,CAAC,qBAAqB;SACxD,CAAC;QAEF,MAAM,MAAM,GAAY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AY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAjTH,kDAkTC;AAjTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { PreferencesBrowserStorage } from "./PreferencesBrowserStorage";
2
+ export declare class MapLayersPrefBrowserStorage extends PreferencesBrowserStorage {
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=MapLayersPrefBrowserStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayersPrefBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/MapLayersPrefBrowserStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,2BAA4B,SAAQ,yBAAyB;;CAMzE"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MapLayersPrefBrowserStorage = void 0;
8
+ const PreferencesBrowserStorage_1 = require("./PreferencesBrowserStorage");
9
+ class MapLayersPrefBrowserStorage extends PreferencesBrowserStorage_1.PreferencesBrowserStorage {
10
+ constructor() {
11
+ super("itwinjs.mapLayers", { throwOnDeleteMissingKey: true } // 'MapLayerPreferences.replaceSource' expect 'delete' to throw when there is no match for the provided key.
12
+ );
13
+ }
14
+ }
15
+ exports.MapLayersPrefBrowserStorage = MapLayersPrefBrowserStorage;
16
+ //# sourceMappingURL=MapLayersPrefBrowserStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayersPrefBrowserStorage.js","sourceRoot":"","sources":["../../src/MapLayersPrefBrowserStorage.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2EAAwE;AAExE,MAAa,2BAA4B,SAAQ,qDAAyB;IACxE;QACE,KAAK,CAAC,mBAAmB,EACvB,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAG,4GAA4G;SACjJ,CAAC;IACJ,CAAC;CACF;AAND,kEAMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PreferencesBrowserStorage } from \"./PreferencesBrowserStorage\";\n\nexport class MapLayersPrefBrowserStorage extends PreferencesBrowserStorage {\n constructor() {\n super(\"itwinjs.mapLayers\",\n { throwOnDeleteMissingKey: true } // 'MapLayerPreferences.replaceSource' expect 'delete' to throw when there is no match for the provided key.\n );\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from "@itwin/core-frontend";
2
+ /**
3
+ * @beta
4
+ */
5
+ export interface PreferencesBrowserStorageOptions {
6
+ /** indicate whether or not delete function should throw an error if the provided key cannot be found. */
7
+ throwOnDeleteMissingKey?: boolean;
8
+ }
9
+ /** User preferences implementation using browser's local storage.
10
+ * It creates storage item key in the form of:
11
+ * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>
12
+ *
13
+ * <itwin_guid> and <imodel_guid> being optional.
14
+ *
15
+ * Each entry in the storage is a serialized JSON of the following index signature:
16
+ * {
17
+ * "<preference_namespace?>.<preference_key>": {
18
+ * ...
19
+ * <preferences_json_content>
20
+ * },
21
+ * ...
22
+ * }
23
+ * @beta
24
+ */
25
+ export declare class PreferencesBrowserStorage implements UserPreferencesAccess {
26
+ private readonly _options;
27
+ private readonly _storageItemKeyPrefix;
28
+ constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions);
29
+ private getStorageItemKey;
30
+ private static getPreferenceKey;
31
+ private loadFromStorage;
32
+ get(arg: PreferenceKeyArg & ITwinIdArg): Promise<any[] | undefined>;
33
+ delete(arg: PreferenceKeyArg & ITwinIdArg): Promise<void>;
34
+ save(arg: PreferenceArg & ITwinIdArg): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=PreferencesBrowserStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreferencesBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAU1G;;EAEE;AACF,MAAM,WAAW,gCAAgC;IAC/C,yGAAyG;IACzG,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;;;;;;;EAeE;AACF,qBAAa,yBAA0B,YAAW,qBAAqB;IAErE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+C;IACxE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;gBAEnC,oBAAoB,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gCAAgC;IAKjF,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAK/B,OAAO,CAAC,eAAe;IAeV,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAoBtC,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAoBzC,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU;CAUlD"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreferencesBrowserStorage = void 0;
4
+ /** User preferences implementation using browser's local storage.
5
+ * It creates storage item key in the form of:
6
+ * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>
7
+ *
8
+ * <itwin_guid> and <imodel_guid> being optional.
9
+ *
10
+ * Each entry in the storage is a serialized JSON of the following index signature:
11
+ * {
12
+ * "<preference_namespace?>.<preference_key>": {
13
+ * ...
14
+ * <preferences_json_content>
15
+ * },
16
+ * ...
17
+ * }
18
+ * @beta
19
+ */
20
+ class PreferencesBrowserStorage {
21
+ constructor(storageItemKeyPrefix, opts) {
22
+ this._options = opts;
23
+ this._storageItemKeyPrefix = storageItemKeyPrefix;
24
+ }
25
+ getStorageItemKey(arg) {
26
+ const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : "";
27
+ const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : "";
28
+ return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;
29
+ }
30
+ static getPreferenceKey(arg) {
31
+ const nsStr = arg.namespace ? `${arg.namespace}.` : "";
32
+ return `${nsStr}${arg.key}`;
33
+ }
34
+ loadFromStorage(arg) {
35
+ const storage = window.localStorage;
36
+ let map = {};
37
+ const itemStr = storage.getItem(this.getStorageItemKey(arg));
38
+ if (itemStr === null) {
39
+ return undefined;
40
+ }
41
+ if (!itemStr || itemStr === "{}")
42
+ return map;
43
+ map = JSON.parse(itemStr);
44
+ return map;
45
+ }
46
+ async get(arg) {
47
+ const map = this.loadFromStorage(arg);
48
+ if (map === undefined)
49
+ return undefined;
50
+ if (arg.key) {
51
+ if (!Object.keys(map).includes(arg.key))
52
+ return undefined;
53
+ const nsStr = arg.namespace ? `${arg.namespace}.` : "";
54
+ const prefKey = `${nsStr}${arg.key}`;
55
+ return [map[prefKey]];
56
+ }
57
+ else { // No key provided, return all objects
58
+ const values = [];
59
+ for (const [_key, value] of Object.entries(map))
60
+ values.push(value);
61
+ return values;
62
+ }
63
+ }
64
+ async delete(arg) {
65
+ const map = this.loadFromStorage(arg);
66
+ if (map === undefined) {
67
+ if (this._options?.throwOnDeleteMissingKey)
68
+ throw new Error("Could not find key from storage.");
69
+ else
70
+ return;
71
+ }
72
+ const prefKey = PreferencesBrowserStorage.getPreferenceKey(arg);
73
+ if (!Object.keys(map).includes(prefKey)) {
74
+ if (this._options?.throwOnDeleteMissingKey)
75
+ throw Error("Could not find key from storage.");
76
+ else
77
+ return;
78
+ }
79
+ delete map[prefKey];
80
+ window.localStorage.setItem(this.getStorageItemKey(arg), JSON.stringify(map));
81
+ }
82
+ async save(arg) {
83
+ let map = this.loadFromStorage(arg);
84
+ if (map === undefined)
85
+ map = {};
86
+ map[PreferencesBrowserStorage.getPreferenceKey(arg)] = arg.content;
87
+ const itemValue = JSON.stringify(map);
88
+ window.localStorage.setItem(this.getStorageItemKey(arg), itemValue);
89
+ }
90
+ }
91
+ exports.PreferencesBrowserStorage = PreferencesBrowserStorage;
92
+ //# sourceMappingURL=PreferencesBrowserStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreferencesBrowserStorage.js","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":";;;AAsBA;;;;;;;;;;;;;;;EAeE;AACF,MAAa,yBAAyB;IAKpC,YAAY,oBAA4B,EAAE,IAAuC;QAC/E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;IACpD,CAAC;IAEO,iBAAiB,CAAC,GAAe;QACvC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,GAAG,IAAI,CAAC,qBAAqB,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC;IACpE,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,GAAqB;QACnD,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,OAAO,GAAG,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAEO,eAAe,CAAC,GAAkC;QACxD,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC;QAEpC,IAAI,GAAG,GAAoB,EAAE,CAAC;QA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,CAAC,CAAC;QACtC,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,IAAI,IAAI,CAAC,QAAQ,EAAE,uBAAuB;gBACxC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;;gBAEpD,OAAO;SACV;QAED,MAAM,OAAO,GAAG,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACvC,IAAI,IAAI,CAAC,QAAQ,EAAE,uBAAuB;gBACxC,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;;gBAEhD,OAAO;SACV;QACD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QACpB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,GAA+B;QAC/C,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,GAAG,KAAK,SAAS;YACnB,GAAG,GAAG,EAAE,CAAC;QAEX,GAAG,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;QAEnE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IACtE,CAAC;CACF;AAtFD,8DAsFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from \"@itwin/core-frontend\";\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps {\n [preferenceKey: string]: any;\n}\n\n/**\n* @beta\n*/\nexport interface PreferencesBrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n}\n\n/** User preferences implementation using browser's local storage.\n * It creates storage item key in the form of:\n * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>\n *\n * <itwin_guid> and <imodel_guid> being optional.\n *\n * Each entry in the storage is a serialized JSON of the following index signature:\n * {\n * \"<preference_namespace?>.<preference_key>\": {\n * ...\n * <preferences_json_content>\n * },\n * ...\n * }\n * @beta\n*/\nexport class PreferencesBrowserStorage implements UserPreferencesAccess {\n\n private readonly _options: PreferencesBrowserStorageOptions | undefined;\n private readonly _storageItemKeyPrefix: string;\n\n constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions) {\n this._options = opts;\n this._storageItemKeyPrefix = storageItemKeyPrefix;\n }\n\n private getStorageItemKey(arg: ITwinIdArg) {\n const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : \"\";\n const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : \"\";\n return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;\n }\n\n private static getPreferenceKey(arg: PreferenceKeyArg) {\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n return `${nsStr}${arg.key}`;\n }\n\n private loadFromStorage(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = window.localStorage;\n\n let map: KeyContentProps = {};\n const itemStr = storage.getItem(this.getStorageItemKey(arg));\n if (itemStr === null) {\n return undefined;\n }\n if (!itemStr || itemStr === \"{}\")\n return map;\n\n map = JSON.parse(itemStr);\n return map;\n }\n\n public async get(arg: PreferenceKeyArg & ITwinIdArg) {\n const map = this.loadFromStorage(arg);\n if (map === undefined)\n return undefined;\n\n if (arg.key) {\n if (!Object.keys(map).includes(arg.key))\n return undefined;\n\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n const prefKey = `${nsStr}${arg.key}`;\n return [map[prefKey]];\n } else { // No key provided, return all objects\n const values = [];\n for (const [_key, value] of Object.entries(map))\n values.push(value);\n return values;\n }\n }\n\n public async delete(arg: PreferenceKeyArg & ITwinIdArg) {\n const map = this.loadFromStorage(arg);\n if (map === undefined) {\n if (this._options?.throwOnDeleteMissingKey)\n throw new Error(\"Could not find key from storage.\");\n else\n return;\n }\n\n const prefKey = PreferencesBrowserStorage.getPreferenceKey(arg);\n if (!Object.keys(map).includes(prefKey)) {\n if (this._options?.throwOnDeleteMissingKey)\n throw Error(\"Could not find key from storage.\");\n else\n return;\n }\n delete map[prefKey];\n window.localStorage.setItem(this.getStorageItemKey(arg), JSON.stringify(map));\n }\n\n public async save(arg: PreferenceArg & ITwinIdArg) {\n let map = this.loadFromStorage(arg);\n if (map === undefined)\n map = {};\n\n map[PreferencesBrowserStorage.getPreferenceKey(arg)] = arg.content;\n\n const itemValue = JSON.stringify(map);\n window.localStorage.setItem(this.getStorageItemKey(arg), itemValue);\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from "./mapLayers";
2
+ export * from "./MapLayersPrefBrowserStorage";
2
3
  export * from "./ui/Interfaces";
3
4
  export * from "./ui/MapLayersUiItemsProvider";
4
5
  export * from "./ui/FeatureInfoUiItemsProvider";
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers.d.ts","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"map-layers.d.ts","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC"}
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  * See LICENSE.md in the project root for license terms and full copyright notice.
16
16
  *--------------------------------------------------------------------------------------------*/
17
17
  __exportStar(require("./mapLayers"), exports);
18
+ __exportStar(require("./MapLayersPrefBrowserStorage"), exports);
18
19
  __exportStar(require("./ui/Interfaces"), exports);
19
20
  __exportStar(require("./ui/MapLayersUiItemsProvider"), exports);
20
21
  __exportStar(require("./ui/FeatureInfoUiItemsProvider"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers.js","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,kDAAgC;AAChC,gEAA8C;AAC9C,kEAAgD;AAChD,0DAAwC;AACxC,8DAA4C","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\nexport * from \"./mapLayers\";\r\nexport * from \"./ui/Interfaces\";\r\nexport * from \"./ui/MapLayersUiItemsProvider\";\r\nexport * from \"./ui/FeatureInfoUiItemsProvider\";\r\nexport * from \"./ui/MapFeatureInfoTool\";\r\nexport * from \"./ui/widget/MapLayersWidget\";\r\n"]}
1
+ {"version":3,"file":"map-layers.js","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,gEAA8C;AAC9C,kDAAgC;AAChC,gEAA8C;AAC9C,kEAAgD;AAChD,0DAAwC;AACxC,8DAA4C","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\nexport * from \"./mapLayers\";\r\nexport * from \"./MapLayersPrefBrowserStorage\";\r\nexport * from \"./ui/Interfaces\";\r\nexport * from \"./ui/MapLayersUiItemsProvider\";\r\nexport * from \"./ui/FeatureInfoUiItemsProvider\";\r\nexport * from \"./ui/MapFeatureInfoTool\";\r\nexport * from \"./ui/widget/MapLayersWidget\";\r\n"]}
@@ -39,15 +39,18 @@
39
39
  "MissingCredentials": "This layer requires credentials to be provided",
40
40
  "Name": "Name",
41
41
  "NameInputPlaceHolder": "Enter Map Name",
42
+ "NoLayersSelected": "Please select at least one layer",
42
43
  "RemoveLayerDefButtonTitle": "Delete layer definition",
43
44
  "RemoveLayerDefDialogMessage": "Are you sure you want to delete {{layerName}} ?",
44
45
  "RemoveLayerDefDialogTitle": "Delete layer definition",
45
46
  "RemoveLayerDefError": "Could not delete map layer definition: {{layerName}}",
46
47
  "RemoveLayerDefSuccess": "Successfully deleted map layer definition: {{layerName}}",
47
48
  "SearchPlaceholder": "Search...",
49
+ "SelectLayersToCreate": "Select layers to be created",
48
50
  "StoreOnModelSettings": "Store on Model Settings",
49
51
  "StoreOnITwinSettings": "Store on iTwin Settings",
50
52
  "TechPreviewBadgeTooltip": "Technology preview",
53
+ "TooManyLayersSelected": "There are currently {{layerCount}} layers selected; Adding too many layers may impact performance.",
51
54
  "Type": "Type",
52
55
  "URL": "URL",
53
56
  "UrlInputPlaceHolder": "Enter Map Source URL",
@@ -64,9 +67,10 @@
64
67
  "NotSupported": "No active viewport or geo-located iModel available.",
65
68
  "NoRangeDefined": "No range is defined for Map Layer",
66
69
  "Start": "Map Layers Extension Loaded",
67
- "MapLayerAttached": "Map layer {{sourceName}} attached from URL: {{sourceUrl}}",
70
+ "MapLayerAttached": "Map layer {{layerNames}} attached",
71
+ "MapLayersAttached": "Map layers ({{sourceName}}) attached",
68
72
  "MapLayerAttachedRequiresAuth": "Map layer {{sourceName}} attached, but requires credentials to be provided",
69
- "MapLayerAttachError": "Error '{{error}}' occurred attaching MapLayer from URL: {{sourceUrl}}",
73
+ "MapLayerAttachError": "Error '{{error}}' occurred attaching MapLayer '{{sourceName}}'",
70
74
  "MapLayerAttachMissingViewOrSource": "Missing view or source",
71
75
  "MapLayerEditError": "Failed to edit '{{layerName}}'",
72
76
  "MapLayerLayerSettingsConversionError": "Conversion to layer settings failed",
@@ -119,6 +123,7 @@
119
123
  "AllOn": "Turn on all Sub-layers",
120
124
  "AllOff": "Turn off all Sub-layers",
121
125
  "Hide": "Hide Sub-layers",
126
+ "NoResults": "No Results",
122
127
  "NoSubLayers": "No Sub-layers Available",
123
128
  "SearchPlaceholder": "Search...",
124
129
  "Show": "Show Sub-layers"
@@ -1 +1 @@
1
- {"version":3,"file":"AttachLayerPopupButton.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/AttachLayerPopupButton.tsx"],"names":[],"mappings":"AAyWA,gBAAgB;AAChB,oBAAY,qBAAqB;IAC/B,OAAO,IAAA;IACP,IAAI,IAAA;IACJ,IAAI,IAAA;CACL;AACD,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,eAiHxE"}
1
+ {"version":3,"file":"AttachLayerPopupButton.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/AttachLayerPopupButton.tsx"],"names":[],"mappings":"AAocA,gBAAgB;AAChB,oBAAY,qBAAqB;IAC/B,OAAO,IAAA;IACP,IAAI,IAAA;IACJ,IAAI,IAAA;CACL;AACD,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,eAkHxE"}