@itwin/core-frontend 5.11.0-dev.8 → 5.12.0-dev.1

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 (283) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/AccuDraw.d.ts +2 -0
  3. package/lib/cjs/AccuDraw.d.ts.map +1 -1
  4. package/lib/cjs/AccuDraw.js +9 -1
  5. package/lib/cjs/AccuDraw.js.map +1 -1
  6. package/lib/cjs/BingLocation.d.ts +4 -0
  7. package/lib/cjs/BingLocation.d.ts.map +1 -1
  8. package/lib/cjs/BingLocation.js +6 -1
  9. package/lib/cjs/BingLocation.js.map +1 -1
  10. package/lib/cjs/CesiumAccessClient.d.ts +52 -0
  11. package/lib/cjs/CesiumAccessClient.d.ts.map +1 -0
  12. package/lib/cjs/CesiumAccessClient.js +10 -0
  13. package/lib/cjs/CesiumAccessClient.js.map +1 -0
  14. package/lib/cjs/DisplayStyleState.js +2 -2
  15. package/lib/cjs/DisplayStyleState.js.map +1 -1
  16. package/lib/cjs/GeoProviders.d.ts +45 -0
  17. package/lib/cjs/GeoProviders.d.ts.map +1 -0
  18. package/lib/cjs/GeoProviders.js +49 -0
  19. package/lib/cjs/GeoProviders.js.map +1 -0
  20. package/lib/cjs/GraphicalEditingScope.d.ts +21 -0
  21. package/lib/cjs/GraphicalEditingScope.d.ts.map +1 -1
  22. package/lib/cjs/GraphicalEditingScope.js +26 -0
  23. package/lib/cjs/GraphicalEditingScope.js.map +1 -1
  24. package/lib/cjs/HitDetail.d.ts.map +1 -1
  25. package/lib/cjs/HitDetail.js +10 -7
  26. package/lib/cjs/HitDetail.js.map +1 -1
  27. package/lib/cjs/IModelApp.d.ts +33 -0
  28. package/lib/cjs/IModelApp.d.ts.map +1 -1
  29. package/lib/cjs/IModelApp.js +33 -0
  30. package/lib/cjs/IModelApp.js.map +1 -1
  31. package/lib/cjs/IModelConnection.d.ts +3 -3
  32. package/lib/cjs/IModelConnection.d.ts.map +1 -1
  33. package/lib/cjs/IModelConnection.js +15 -8
  34. package/lib/cjs/IModelConnection.js.map +1 -1
  35. package/lib/cjs/NativeApp.d.ts.map +1 -1
  36. package/lib/cjs/NativeApp.js +1 -3
  37. package/lib/cjs/NativeApp.js.map +1 -1
  38. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.d.ts +1 -1
  39. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.d.ts.map +1 -1
  40. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.js +23 -5
  41. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.js.map +1 -1
  42. package/lib/cjs/SubCategoriesCache.d.ts +15 -3
  43. package/lib/cjs/SubCategoriesCache.d.ts.map +1 -1
  44. package/lib/cjs/SubCategoriesCache.js +98 -26
  45. package/lib/cjs/SubCategoriesCache.js.map +1 -1
  46. package/lib/cjs/ViewGlobalLocation.d.ts +1 -1
  47. package/lib/cjs/ViewGlobalLocation.d.ts.map +1 -1
  48. package/lib/cjs/ViewGlobalLocation.js +3 -6
  49. package/lib/cjs/ViewGlobalLocation.js.map +1 -1
  50. package/lib/cjs/Viewport.d.ts +1 -0
  51. package/lib/cjs/Viewport.d.ts.map +1 -1
  52. package/lib/cjs/Viewport.js +13 -1
  53. package/lib/cjs/Viewport.js.map +1 -1
  54. package/lib/cjs/core-frontend.d.ts +3 -0
  55. package/lib/cjs/core-frontend.d.ts.map +1 -1
  56. package/lib/cjs/core-frontend.js +4 -0
  57. package/lib/cjs/core-frontend.js.map +1 -1
  58. package/lib/cjs/internal/tile/DynamicIModelTile.d.ts +3 -3
  59. package/lib/cjs/internal/tile/DynamicIModelTile.d.ts.map +1 -1
  60. package/lib/cjs/internal/tile/DynamicIModelTile.js +26 -6
  61. package/lib/cjs/internal/tile/DynamicIModelTile.js.map +1 -1
  62. package/lib/cjs/internal/tile/IModelTileTree.d.ts.map +1 -1
  63. package/lib/cjs/internal/tile/IModelTileTree.js +4 -2
  64. package/lib/cjs/internal/tile/IModelTileTree.js.map +1 -1
  65. package/lib/cjs/internal/tile/RealityModelTileTree.d.ts.map +1 -1
  66. package/lib/cjs/internal/tile/RealityModelTileTree.js +6 -2
  67. package/lib/cjs/internal/tile/RealityModelTileTree.js.map +1 -1
  68. package/lib/cjs/internal/tile/RealityTileLoader.d.ts +22 -0
  69. package/lib/cjs/internal/tile/RealityTileLoader.d.ts.map +1 -1
  70. package/lib/cjs/internal/tile/RealityTileLoader.js +53 -5
  71. package/lib/cjs/internal/tile/RealityTileLoader.js.map +1 -1
  72. package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.d.ts +1 -0
  73. package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.d.ts.map +1 -1
  74. package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.js +1 -0
  75. package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
  76. package/lib/cjs/properties/AngleDescription.d.ts +1 -0
  77. package/lib/cjs/properties/AngleDescription.d.ts.map +1 -1
  78. package/lib/cjs/properties/AngleDescription.js +3 -0
  79. package/lib/cjs/properties/AngleDescription.js.map +1 -1
  80. package/lib/cjs/properties/FormattedQuantityDescription.d.ts +29 -1
  81. package/lib/cjs/properties/FormattedQuantityDescription.d.ts.map +1 -1
  82. package/lib/cjs/properties/FormattedQuantityDescription.js +35 -0
  83. package/lib/cjs/properties/FormattedQuantityDescription.js.map +1 -1
  84. package/lib/cjs/properties/LengthDescription.d.ts +3 -0
  85. package/lib/cjs/properties/LengthDescription.d.ts.map +1 -1
  86. package/lib/cjs/properties/LengthDescription.js +9 -0
  87. package/lib/cjs/properties/LengthDescription.js.map +1 -1
  88. package/lib/cjs/render/RenderSystem.d.ts +1 -1
  89. package/lib/cjs/render/RenderSystem.d.ts.map +1 -1
  90. package/lib/cjs/render/RenderSystem.js +1 -1
  91. package/lib/cjs/render/RenderSystem.js.map +1 -1
  92. package/lib/cjs/tile/RealityTile.d.ts +5 -0
  93. package/lib/cjs/tile/RealityTile.d.ts.map +1 -1
  94. package/lib/cjs/tile/RealityTile.js +4 -0
  95. package/lib/cjs/tile/RealityTile.js.map +1 -1
  96. package/lib/cjs/tile/TileAdmin.d.ts +23 -1
  97. package/lib/cjs/tile/TileAdmin.d.ts.map +1 -1
  98. package/lib/cjs/tile/TileAdmin.js +17 -1
  99. package/lib/cjs/tile/TileAdmin.js.map +1 -1
  100. package/lib/cjs/tile/map/BingElevation.d.ts +16 -4
  101. package/lib/cjs/tile/map/BingElevation.d.ts.map +1 -1
  102. package/lib/cjs/tile/map/BingElevation.js +18 -8
  103. package/lib/cjs/tile/map/BingElevation.js.map +1 -1
  104. package/lib/cjs/tile/map/CesiumTerrainProvider.d.ts +16 -1
  105. package/lib/cjs/tile/map/CesiumTerrainProvider.d.ts.map +1 -1
  106. package/lib/cjs/tile/map/CesiumTerrainProvider.js +57 -17
  107. package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
  108. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts +6 -1
  109. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  110. package/lib/cjs/tile/map/MapLayerFormatRegistry.js.map +1 -1
  111. package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts +1 -0
  112. package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
  113. package/lib/cjs/tile/map/MapLayerImageryFormats.js +3 -0
  114. package/lib/cjs/tile/map/MapLayerImageryFormats.js.map +1 -1
  115. package/lib/cjs/tile/map/MapTileTree.d.ts.map +1 -1
  116. package/lib/cjs/tile/map/MapTileTree.js +19 -8
  117. package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
  118. package/lib/cjs/tile/map/TerrainMeshProvider.d.ts +6 -0
  119. package/lib/cjs/tile/map/TerrainMeshProvider.d.ts.map +1 -1
  120. package/lib/cjs/tile/map/TerrainMeshProvider.js.map +1 -1
  121. package/lib/cjs/tools/AccuDrawShortcutTool.d.ts +29 -0
  122. package/lib/cjs/tools/AccuDrawShortcutTool.d.ts.map +1 -0
  123. package/lib/cjs/tools/AccuDrawShortcutTool.js +139 -0
  124. package/lib/cjs/tools/AccuDrawShortcutTool.js.map +1 -0
  125. package/lib/cjs/tools/AccuDrawTool.d.ts +13 -68
  126. package/lib/cjs/tools/AccuDrawTool.d.ts.map +1 -1
  127. package/lib/cjs/tools/AccuDrawTool.js +103 -129
  128. package/lib/cjs/tools/AccuDrawTool.js.map +1 -1
  129. package/lib/cjs/tools/SetupCameraTools.d.ts +89 -0
  130. package/lib/cjs/tools/SetupCameraTools.d.ts.map +1 -0
  131. package/lib/cjs/tools/SetupCameraTools.js +444 -0
  132. package/lib/cjs/tools/SetupCameraTools.js.map +1 -0
  133. package/lib/cjs/tools/ToolAdmin.d.ts +5 -2
  134. package/lib/cjs/tools/ToolAdmin.d.ts.map +1 -1
  135. package/lib/cjs/tools/ToolAdmin.js +30 -7
  136. package/lib/cjs/tools/ToolAdmin.js.map +1 -1
  137. package/lib/cjs/tools/ViewTool.d.ts +1 -81
  138. package/lib/cjs/tools/ViewTool.d.ts.map +1 -1
  139. package/lib/cjs/tools/ViewTool.js +13 -410
  140. package/lib/cjs/tools/ViewTool.js.map +1 -1
  141. package/lib/esm/AccuDraw.d.ts +2 -0
  142. package/lib/esm/AccuDraw.d.ts.map +1 -1
  143. package/lib/esm/AccuDraw.js +9 -1
  144. package/lib/esm/AccuDraw.js.map +1 -1
  145. package/lib/esm/BingLocation.d.ts +4 -0
  146. package/lib/esm/BingLocation.d.ts.map +1 -1
  147. package/lib/esm/BingLocation.js +6 -1
  148. package/lib/esm/BingLocation.js.map +1 -1
  149. package/lib/esm/CesiumAccessClient.d.ts +52 -0
  150. package/lib/esm/CesiumAccessClient.d.ts.map +1 -0
  151. package/lib/esm/CesiumAccessClient.js +9 -0
  152. package/lib/esm/CesiumAccessClient.js.map +1 -0
  153. package/lib/esm/DisplayStyleState.js +2 -2
  154. package/lib/esm/DisplayStyleState.js.map +1 -1
  155. package/lib/esm/GeoProviders.d.ts +45 -0
  156. package/lib/esm/GeoProviders.d.ts.map +1 -0
  157. package/lib/esm/GeoProviders.js +45 -0
  158. package/lib/esm/GeoProviders.js.map +1 -0
  159. package/lib/esm/GraphicalEditingScope.d.ts +21 -0
  160. package/lib/esm/GraphicalEditingScope.d.ts.map +1 -1
  161. package/lib/esm/GraphicalEditingScope.js +26 -0
  162. package/lib/esm/GraphicalEditingScope.js.map +1 -1
  163. package/lib/esm/HitDetail.d.ts.map +1 -1
  164. package/lib/esm/HitDetail.js +11 -8
  165. package/lib/esm/HitDetail.js.map +1 -1
  166. package/lib/esm/IModelApp.d.ts +33 -0
  167. package/lib/esm/IModelApp.d.ts.map +1 -1
  168. package/lib/esm/IModelApp.js +34 -1
  169. package/lib/esm/IModelApp.js.map +1 -1
  170. package/lib/esm/IModelConnection.d.ts +3 -3
  171. package/lib/esm/IModelConnection.d.ts.map +1 -1
  172. package/lib/esm/IModelConnection.js +15 -8
  173. package/lib/esm/IModelConnection.js.map +1 -1
  174. package/lib/esm/NativeApp.d.ts.map +1 -1
  175. package/lib/esm/NativeApp.js +1 -3
  176. package/lib/esm/NativeApp.js.map +1 -1
  177. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.d.ts +1 -1
  178. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.d.ts.map +1 -1
  179. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.js +24 -6
  180. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.js.map +1 -1
  181. package/lib/esm/SubCategoriesCache.d.ts +15 -3
  182. package/lib/esm/SubCategoriesCache.d.ts.map +1 -1
  183. package/lib/esm/SubCategoriesCache.js +99 -27
  184. package/lib/esm/SubCategoriesCache.js.map +1 -1
  185. package/lib/esm/ViewGlobalLocation.d.ts +1 -1
  186. package/lib/esm/ViewGlobalLocation.d.ts.map +1 -1
  187. package/lib/esm/ViewGlobalLocation.js +3 -6
  188. package/lib/esm/ViewGlobalLocation.js.map +1 -1
  189. package/lib/esm/Viewport.d.ts +1 -0
  190. package/lib/esm/Viewport.d.ts.map +1 -1
  191. package/lib/esm/Viewport.js +13 -1
  192. package/lib/esm/Viewport.js.map +1 -1
  193. package/lib/esm/core-frontend.d.ts +3 -0
  194. package/lib/esm/core-frontend.d.ts.map +1 -1
  195. package/lib/esm/core-frontend.js +6 -1
  196. package/lib/esm/core-frontend.js.map +1 -1
  197. package/lib/esm/internal/tile/DynamicIModelTile.d.ts +3 -3
  198. package/lib/esm/internal/tile/DynamicIModelTile.d.ts.map +1 -1
  199. package/lib/esm/internal/tile/DynamicIModelTile.js +26 -6
  200. package/lib/esm/internal/tile/DynamicIModelTile.js.map +1 -1
  201. package/lib/esm/internal/tile/IModelTileTree.d.ts.map +1 -1
  202. package/lib/esm/internal/tile/IModelTileTree.js +4 -2
  203. package/lib/esm/internal/tile/IModelTileTree.js.map +1 -1
  204. package/lib/esm/internal/tile/RealityModelTileTree.d.ts.map +1 -1
  205. package/lib/esm/internal/tile/RealityModelTileTree.js +6 -2
  206. package/lib/esm/internal/tile/RealityModelTileTree.js.map +1 -1
  207. package/lib/esm/internal/tile/RealityTileLoader.d.ts +22 -0
  208. package/lib/esm/internal/tile/RealityTileLoader.d.ts.map +1 -1
  209. package/lib/esm/internal/tile/RealityTileLoader.js +54 -6
  210. package/lib/esm/internal/tile/RealityTileLoader.js.map +1 -1
  211. package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.d.ts +1 -0
  212. package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.d.ts.map +1 -1
  213. package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.js +1 -0
  214. package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
  215. package/lib/esm/properties/AngleDescription.d.ts +1 -0
  216. package/lib/esm/properties/AngleDescription.d.ts.map +1 -1
  217. package/lib/esm/properties/AngleDescription.js +3 -0
  218. package/lib/esm/properties/AngleDescription.js.map +1 -1
  219. package/lib/esm/properties/FormattedQuantityDescription.d.ts +29 -1
  220. package/lib/esm/properties/FormattedQuantityDescription.d.ts.map +1 -1
  221. package/lib/esm/properties/FormattedQuantityDescription.js +35 -1
  222. package/lib/esm/properties/FormattedQuantityDescription.js.map +1 -1
  223. package/lib/esm/properties/LengthDescription.d.ts +3 -0
  224. package/lib/esm/properties/LengthDescription.d.ts.map +1 -1
  225. package/lib/esm/properties/LengthDescription.js +9 -0
  226. package/lib/esm/properties/LengthDescription.js.map +1 -1
  227. package/lib/esm/render/RenderSystem.d.ts +1 -1
  228. package/lib/esm/render/RenderSystem.d.ts.map +1 -1
  229. package/lib/esm/render/RenderSystem.js +1 -1
  230. package/lib/esm/render/RenderSystem.js.map +1 -1
  231. package/lib/esm/tile/RealityTile.d.ts +5 -0
  232. package/lib/esm/tile/RealityTile.d.ts.map +1 -1
  233. package/lib/esm/tile/RealityTile.js +4 -0
  234. package/lib/esm/tile/RealityTile.js.map +1 -1
  235. package/lib/esm/tile/TileAdmin.d.ts +23 -1
  236. package/lib/esm/tile/TileAdmin.d.ts.map +1 -1
  237. package/lib/esm/tile/TileAdmin.js +17 -1
  238. package/lib/esm/tile/TileAdmin.js.map +1 -1
  239. package/lib/esm/tile/map/BingElevation.d.ts +16 -4
  240. package/lib/esm/tile/map/BingElevation.d.ts.map +1 -1
  241. package/lib/esm/tile/map/BingElevation.js +18 -8
  242. package/lib/esm/tile/map/BingElevation.js.map +1 -1
  243. package/lib/esm/tile/map/CesiumTerrainProvider.d.ts +16 -1
  244. package/lib/esm/tile/map/CesiumTerrainProvider.d.ts.map +1 -1
  245. package/lib/esm/tile/map/CesiumTerrainProvider.js +55 -17
  246. package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
  247. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts +6 -1
  248. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  249. package/lib/esm/tile/map/MapLayerFormatRegistry.js.map +1 -1
  250. package/lib/esm/tile/map/MapLayerImageryFormats.d.ts +1 -0
  251. package/lib/esm/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
  252. package/lib/esm/tile/map/MapLayerImageryFormats.js +3 -0
  253. package/lib/esm/tile/map/MapLayerImageryFormats.js.map +1 -1
  254. package/lib/esm/tile/map/MapTileTree.d.ts.map +1 -1
  255. package/lib/esm/tile/map/MapTileTree.js +20 -9
  256. package/lib/esm/tile/map/MapTileTree.js.map +1 -1
  257. package/lib/esm/tile/map/TerrainMeshProvider.d.ts +6 -0
  258. package/lib/esm/tile/map/TerrainMeshProvider.d.ts.map +1 -1
  259. package/lib/esm/tile/map/TerrainMeshProvider.js.map +1 -1
  260. package/lib/esm/tools/AccuDrawShortcutTool.d.ts +29 -0
  261. package/lib/esm/tools/AccuDrawShortcutTool.d.ts.map +1 -0
  262. package/lib/esm/tools/AccuDrawShortcutTool.js +134 -0
  263. package/lib/esm/tools/AccuDrawShortcutTool.js.map +1 -0
  264. package/lib/esm/tools/AccuDrawTool.d.ts +13 -68
  265. package/lib/esm/tools/AccuDrawTool.d.ts.map +1 -1
  266. package/lib/esm/tools/AccuDrawTool.js +102 -128
  267. package/lib/esm/tools/AccuDrawTool.js.map +1 -1
  268. package/lib/esm/tools/SetupCameraTools.d.ts +89 -0
  269. package/lib/esm/tools/SetupCameraTools.d.ts.map +1 -0
  270. package/lib/esm/tools/SetupCameraTools.js +439 -0
  271. package/lib/esm/tools/SetupCameraTools.js.map +1 -0
  272. package/lib/esm/tools/ToolAdmin.d.ts +5 -2
  273. package/lib/esm/tools/ToolAdmin.d.ts.map +1 -1
  274. package/lib/esm/tools/ToolAdmin.js +30 -7
  275. package/lib/esm/tools/ToolAdmin.js.map +1 -1
  276. package/lib/esm/tools/ViewTool.d.ts +1 -81
  277. package/lib/esm/tools/ViewTool.d.ts.map +1 -1
  278. package/lib/esm/tools/ViewTool.js +14 -409
  279. package/lib/esm/tools/ViewTool.js.map +1 -1
  280. package/lib/public/locales/en/iModelJs.json +2 -1
  281. package/lib/public/scripts/parse-imdl-worker.js +1 -1
  282. package/lib/workers/webpack/parse-imdl-worker.js +1 -1
  283. package/package.json +24 -23
@@ -1 +1 @@
1
- {"version":3,"file":"NativeApp.d.ts","sourceRoot":"","sources":["../../src/NativeApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAU,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,mBAAmB,EACrI,kBAAkB,EACwB,YAAY,EAAE,QAAQ,EACjE,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAU,aAAa,EAAuB,MAAM,UAAU,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC7B;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,GAC5C;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE5C;;;EAGE;AACF,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,GAAG;IAC3D,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAWF;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAiB;IAEjD,kFAAkF;IAClF,OAAc,YAAY,qEAA4E;IACtG,OAAc,UAAU,2EAAgG;IAExH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AAC;IAInD,sCAAsC;IACzB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -74,9 +74,7 @@ export class NativeApp {
74
74
  this._removeAppNotify = NativeAppNotifyHandler.register(); // receives notifications from backend
75
75
  NativeApp.hookBrowserConnectivityEvents();
76
76
  // initialize current online state.
77
- if (window.navigator.onLine) {
78
- await this.setConnectivity(OverriddenBy.Browser, window.navigator.onLine ? InternetConnectivityStatus.Online : InternetConnectivityStatus.Offline);
79
- }
77
+ await this.setConnectivity(OverriddenBy.Browser, window.navigator.onLine ? InternetConnectivityStatus.Online : InternetConnectivityStatus.Offline);
80
78
  }
81
79
  /** @internal */
82
80
  static async shutdown() {
@@ -1 +1 @@
1
- {"version":3,"file":"NativeApp.js","sourceRoot":"","sources":["../../src/NativeApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAC+C,aAAa,EAAE,0BAA0B,EACzE,mBAAmB,EAA0B,YAAY,EACrB,QAAQ,GACjE,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAyBpD,2CAA2C;AAC3C,MAAM,sBAAuB,SAAQ,mBAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/D,iCAAiC,CAAC,MAAkC;QACzE,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC;QAClF,SAAS,CAAC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACF;AAUD;;;;GAIG;AACH,MAAM,OAAO,SAAS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nB,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAmB;QACnD,OAAO,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iCAAiC;IAC1B,KAAK,CAAC,UAAU,CAAC,GAAW;QACjC,OAAO,SAAS,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED,sCAAsC;IAC/B,KAAK,CAAC,SAAS;QACpB,OAAO,SAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1D,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 NativeApp\r\n */\r\n\r\nimport { BeEvent, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseDownloader, BriefcaseProps, CatalogIModel, IModelVersion, InternetConnectivityStatus, IpcSocketFrontend, LocalBriefcaseProps,\r\n NativeAppFunctions, nativeAppIpcStrings, NativeAppNotifications, OverriddenBy,\r\n RemoveFunction, RequestNewBriefcaseProps, StorageValue, SyncMode,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { IpcApp, IpcAppOptions, NotificationHandler } from \"./IpcApp\";\r\nimport { NativeAppLogger } from \"./NativeAppLogger\";\r\nimport { OnDownloadProgress } from \"./BriefcaseConnection\";\r\nimport { _callIpcChannel } from \"./common/internal/Symbols\";\r\n\r\n/** Properties for specifying the BriefcaseId for downloading. May either specify a BriefcaseId directly (preferable) or, for\r\n * backwards compatibility, a [SyncMode]($common). If [SyncMode.PullAndPush]($common) is supplied, a new briefcaseId will be acquired.\r\n * @public\r\n */\r\nexport type DownloadBriefcaseId =\r\n { syncMode?: SyncMode, briefcaseId?: never } |\r\n { briefcaseId: number, syncMode?: never };\r\n\r\n/**\r\n* Options to download a briefcase\r\n* @public\r\n*/\r\nexport type DownloadBriefcaseOptions = DownloadBriefcaseId & {\r\n /** the full path for the briefcase file */\r\n fileName?: string;\r\n /** Function called regularly to report progress of download. */\r\n progressCallback?: OnDownloadProgress;\r\n /** interval for calling progress function, in milliseconds */\r\n progressInterval?: number;\r\n};\r\n\r\n/** NativeApp notifications from backend */\r\nclass NativeAppNotifyHandler extends NotificationHandler implements NativeAppNotifications {\r\n public get channelName() { return nativeAppIpcStrings.notifyChannel; }\r\n public notifyInternetConnectivityChanged(status: InternetConnectivityStatus) {\r\n Logger.logInfo(FrontendLoggerCategory.NativeApp, \"Internet connectivity changed\");\r\n NativeApp.onInternetConnectivityChanged.raiseEvent(status);\r\n }\r\n}\r\n\r\n/**\r\n * Options for [[NativeApp.startup]]\r\n * @public\r\n */\r\nexport interface NativeAppOpts extends IpcAppOptions {\r\n nativeApp?: object;\r\n}\r\n\r\n/**\r\n * The frontend of a native application\r\n * @see [Native Applications]($docs/learning/NativeApps.md)\r\n * @public\r\n */\r\nexport class NativeApp {\r\n private static _removeAppNotify?: RemoveFunction;\r\n\r\n /** A Proxy to call one of the [NativeAppFunctions]($common) functions via IPC. */\r\n public static nativeAppIpc = IpcApp.makeIpcProxy<NativeAppFunctions>(nativeAppIpcStrings.channelName);\r\n public static catalogIpc = IpcApp.makeIpcProxy<CatalogIModel.IpcMethods, CatalogIModel.IpcChannel>(\"catalogIModel/ipc\");\r\n\r\n private static _storages = new Map<string, Storage>();\r\n private static _onOnline = async () => {\r\n await NativeApp.setConnectivity(OverriddenBy.Browser, InternetConnectivityStatus.Online);\r\n };\r\n private static _onOffline = async () => {\r\n await NativeApp.setConnectivity(OverriddenBy.Browser, InternetConnectivityStatus.Offline);\r\n };\r\n private static async setConnectivity(by: OverriddenBy, status: InternetConnectivityStatus) {\r\n await this.nativeAppIpc.overrideInternetConnectivity(by, status);\r\n }\r\n private static hookBrowserConnectivityEvents() {\r\n if (typeof window === \"object\" && window.ononline && window.onoffline) {\r\n window.addEventListener(\"online\", this._onOnline);\r\n window.addEventListener(\"offline\", this._onOffline);\r\n }\r\n }\r\n private static unhookBrowserConnectivityEvents() {\r\n if (typeof window === \"object\" && window.ononline && window.onoffline) {\r\n window.removeEventListener(\"online\", this._onOnline);\r\n window.removeEventListener(\"offline\", this._onOffline);\r\n }\r\n }\r\n /** event called when internet connectivity changes, if known */\r\n public static onInternetConnectivityChanged = new BeEvent<(status: InternetConnectivityStatus) => void>();\r\n\r\n /** determine whether the app currently has internet connectivity, if known */\r\n public static async checkInternetConnectivity(): Promise<InternetConnectivityStatus> {\r\n return this.nativeAppIpc.checkInternetConnectivity();\r\n }\r\n /** @internal */\r\n public static async overrideInternetConnectivity(status: InternetConnectivityStatus): Promise<void> {\r\n return this.nativeAppIpc.overrideInternetConnectivity(OverriddenBy.User, status);\r\n }\r\n private static _isValid = false;\r\n public static get isValid(): boolean { return this._isValid; }\r\n\r\n /**\r\n * This is called by either ElectronApp.startup or MobileApp.startup - it should not be called directly\r\n * @internal\r\n */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: NativeAppOpts) {\r\n await IpcApp.startup(ipc, opts);\r\n if (this._isValid)\r\n return;\r\n this._isValid = true;\r\n\r\n this._removeAppNotify = NativeAppNotifyHandler.register(); // receives notifications from backend\r\n NativeApp.hookBrowserConnectivityEvents();\r\n\r\n // initialize current online state.\r\n if (window.navigator.onLine) {\r\n await this.setConnectivity(OverriddenBy.Browser, window.navigator.onLine ? InternetConnectivityStatus.Online : InternetConnectivityStatus.Offline);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._removeAppNotify?.();\r\n NativeApp.unhookBrowserConnectivityEvents();\r\n await NativeAppLogger.flush();\r\n await IpcApp.shutdown();\r\n this._isValid = false;\r\n }\r\n\r\n public static async requestDownloadBriefcase(iTwinId: string, iModelId: string, downloadOptions: DownloadBriefcaseOptions,\r\n asOf?: IModelVersion): Promise<BriefcaseDownloader>;\r\n\r\n public static async requestDownloadBriefcase(\r\n iTwinId: string,\r\n iModelId: string,\r\n downloadOptions: DownloadBriefcaseOptions,\r\n asOf: IModelVersion = IModelVersion.latest()\r\n ): Promise<BriefcaseDownloader> {\r\n const shouldReportProgress = !!downloadOptions.progressCallback;\r\n\r\n let stopProgressEvents = () => { };\r\n if (shouldReportProgress) {\r\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\r\n downloadOptions.progressCallback?.(data);\r\n };\r\n\r\n stopProgressEvents = IpcApp.addListener(`nativeApp.progress-${iModelId}`, handleProgress);\r\n }\r\n\r\n const briefcaseId = (undefined !== downloadOptions.briefcaseId) ? downloadOptions.briefcaseId :\r\n (downloadOptions.syncMode === SyncMode.PullOnly ? 0 : await this.nativeAppIpc.acquireNewBriefcaseId(iModelId));\r\n\r\n const fileName = downloadOptions.fileName ?? await this.getBriefcaseFileName({ briefcaseId, iModelId });\r\n const requestProps: RequestNewBriefcaseProps = { iModelId, briefcaseId, iTwinId, asOf: asOf.toJSON(), fileName };\r\n\r\n const doDownload = async (): Promise<void> => {\r\n try {\r\n await this.nativeAppIpc.downloadBriefcase(requestProps, shouldReportProgress, downloadOptions.progressInterval);\r\n } finally {\r\n stopProgressEvents();\r\n }\r\n };\r\n\r\n const requestCancel = async (): Promise<boolean> => {\r\n const status = await this.nativeAppIpc.requestCancelDownloadBriefcase(fileName);\r\n if (status)\r\n stopProgressEvents();\r\n return status;\r\n };\r\n\r\n return { briefcaseId, fileName, downloadPromise: doDownload(), requestCancel };\r\n }\r\n\r\n /** Get the full path filename for a briefcase within the briefcase cache */\r\n public static async getBriefcaseFileName(props: BriefcaseProps): Promise<string> {\r\n return this.nativeAppIpc.getBriefcaseFileName(props);\r\n }\r\n\r\n /** Delete an existing briefcase\r\n * @param fileName the briefcase fileName\r\n */\r\n public static async deleteBriefcase(fileName: string): Promise<void> {\r\n await this.nativeAppIpc.deleteBriefcaseFiles(fileName);\r\n }\r\n\r\n /** Get a list of all briefcase files held in the local briefcase cache directory */\r\n public static async getCachedBriefcases(iModelId?: GuidString): Promise<LocalBriefcaseProps[]> {\r\n return this.nativeAppIpc.getCachedBriefcases(iModelId);\r\n }\r\n\r\n /**\r\n * Open a [[Storage]]. Creates a new Storage with that name if it does not already exist.\r\n * @param name Should be a local filename without an extension.\r\n * @returns a Promise for the [[Storage]].\r\n */\r\n public static async openStorage(name: string): Promise<Storage> {\r\n let storage = this._storages.get(name);\r\n if (!storage) {\r\n storage = new Storage(await this.nativeAppIpc.storageMgrOpen(name));\r\n this._storages.set(storage.id, storage);\r\n }\r\n \r\n return storage;\r\n }\r\n\r\n /**\r\n * Close a Storage and optionally delete it.\r\n * @param storage normally not call directly instead use Storage.close()\r\n * @param deleteStorage if true, delete the storage from disk after closing it.\r\n */\r\n public static async closeStorage(storage: Storage, deleteStorage: boolean = false): Promise<void> {\r\n if (!this._storages.has(storage.id))\r\n throw new Error(`Storage [Id=${storage.id}] not open`);\r\n\r\n await this.nativeAppIpc.storageMgrClose(storage.id, deleteStorage);\r\n this._storages.delete(storage.id);\r\n }\r\n\r\n /** Get the list of existing Storages on the local disk. */\r\n public static async getStorageNames(): Promise<string[]> {\r\n return NativeApp.nativeAppIpc.storageMgrNames();\r\n }\r\n}\r\n\r\n/**\r\n * A local disk-based cache for key value pairs for NativeApps.\r\n * @note This should be used only for local caching, since its not guaranteed to exist permanently.\r\n * @public\r\n */\r\nexport class Storage {\r\n constructor(public readonly id: string) { }\r\n\r\n /** get the type of a value for a key, or undefined if not present. */\r\n public async getValueType(key: string): Promise<\"number\" | \"string\" | \"boolean\" | \"Uint8Array\" | \"null\" | undefined> {\r\n return NativeApp.nativeAppIpc.storageGetValueType(this.id, key);\r\n }\r\n\r\n /** Get the value for a key */\r\n public async getData(key: string): Promise<StorageValue> {\r\n return NativeApp.nativeAppIpc.storageGet(this.id, key);\r\n }\r\n\r\n /** Set value for a key */\r\n public async setData(key: string, value: StorageValue): Promise<void> {\r\n return NativeApp.nativeAppIpc.storageSet(this.id, key, value);\r\n }\r\n\r\n /**\r\n * Return an array of all keys in this Storage.\r\n * @note This can be expensive, depending on the number of keys present.\r\n */\r\n public async getKeys(): Promise<string[]> {\r\n return NativeApp.nativeAppIpc.storageKeys(this.id);\r\n }\r\n\r\n /** Remove a key and its data. */\r\n public async removeData(key: string): Promise<void> {\r\n return NativeApp.nativeAppIpc.storageRemove(this.id, key);\r\n }\r\n\r\n /** Remove all keys and their data. */\r\n public async removeAll(): Promise<void> {\r\n return NativeApp.nativeAppIpc.storageRemoveAll(this.id);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"NativeApp.js","sourceRoot":"","sources":["../../src/NativeApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAC+C,aAAa,EAAE,0BAA0B,EACzE,mBAAmB,EAA0B,YAAY,EACrB,QAAQ,GACjE,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAyBpD,2CAA2C;AAC3C,MAAM,sBAAuB,SAAQ,mBAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/D,iCAAiC,CAAC,MAAkC;QACzE,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,SAAS,EAA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AAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC;IAED,0BAA0B;IACnB,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,KAAmB;QACnD,OAAO,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iCAAiC;IAC1B,KAAK,CAAC,UAAU,CAAC,GAAW;QACjC,OAAO,SAAS,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED,sCAAsC;IAC/B,KAAK,CAAC,SAAS;QACpB,OAAO,SAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1D,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 NativeApp\r\n */\r\n\r\nimport { BeEvent, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseDownloader, BriefcaseProps, CatalogIModel, IModelVersion, InternetConnectivityStatus, IpcSocketFrontend, LocalBriefcaseProps,\r\n NativeAppFunctions, nativeAppIpcStrings, NativeAppNotifications, OverriddenBy,\r\n RemoveFunction, RequestNewBriefcaseProps, StorageValue, SyncMode,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { IpcApp, IpcAppOptions, NotificationHandler } from \"./IpcApp\";\r\nimport { NativeAppLogger } from \"./NativeAppLogger\";\r\nimport { OnDownloadProgress } from \"./BriefcaseConnection\";\r\nimport { _callIpcChannel } from \"./common/internal/Symbols\";\r\n\r\n/** Properties for specifying the BriefcaseId for downloading. May either specify a BriefcaseId directly (preferable) or, for\r\n * backwards compatibility, a [SyncMode]($common). If [SyncMode.PullAndPush]($common) is supplied, a new briefcaseId will be acquired.\r\n * @public\r\n */\r\nexport type DownloadBriefcaseId =\r\n { syncMode?: SyncMode, briefcaseId?: never } |\r\n { briefcaseId: number, syncMode?: never };\r\n\r\n/**\r\n* Options to download a briefcase\r\n* @public\r\n*/\r\nexport type DownloadBriefcaseOptions = DownloadBriefcaseId & {\r\n /** the full path for the briefcase file */\r\n fileName?: string;\r\n /** Function called regularly to report progress of download. */\r\n progressCallback?: OnDownloadProgress;\r\n /** interval for calling progress function, in milliseconds */\r\n progressInterval?: number;\r\n};\r\n\r\n/** NativeApp notifications from backend */\r\nclass NativeAppNotifyHandler extends NotificationHandler implements NativeAppNotifications {\r\n public get channelName() { return nativeAppIpcStrings.notifyChannel; }\r\n public notifyInternetConnectivityChanged(status: InternetConnectivityStatus) {\r\n Logger.logInfo(FrontendLoggerCategory.NativeApp, \"Internet connectivity changed\");\r\n NativeApp.onInternetConnectivityChanged.raiseEvent(status);\r\n }\r\n}\r\n\r\n/**\r\n * Options for [[NativeApp.startup]]\r\n * @public\r\n */\r\nexport interface NativeAppOpts extends IpcAppOptions {\r\n nativeApp?: object;\r\n}\r\n\r\n/**\r\n * The frontend of a native application\r\n * @see [Native Applications]($docs/learning/NativeApps.md)\r\n * @public\r\n */\r\nexport class NativeApp {\r\n private static _removeAppNotify?: RemoveFunction;\r\n\r\n /** A Proxy to call one of the [NativeAppFunctions]($common) functions via IPC. */\r\n public static nativeAppIpc = IpcApp.makeIpcProxy<NativeAppFunctions>(nativeAppIpcStrings.channelName);\r\n public static catalogIpc = IpcApp.makeIpcProxy<CatalogIModel.IpcMethods, CatalogIModel.IpcChannel>(\"catalogIModel/ipc\");\r\n\r\n private static _storages = new Map<string, Storage>();\r\n private static _onOnline = async () => {\r\n await NativeApp.setConnectivity(OverriddenBy.Browser, InternetConnectivityStatus.Online);\r\n };\r\n private static _onOffline = async () => {\r\n await NativeApp.setConnectivity(OverriddenBy.Browser, InternetConnectivityStatus.Offline);\r\n };\r\n private static async setConnectivity(by: OverriddenBy, status: InternetConnectivityStatus) {\r\n await this.nativeAppIpc.overrideInternetConnectivity(by, status);\r\n }\r\n private static hookBrowserConnectivityEvents() {\r\n if (typeof window === \"object\" && window.ononline && window.onoffline) {\r\n window.addEventListener(\"online\", this._onOnline);\r\n window.addEventListener(\"offline\", this._onOffline);\r\n }\r\n }\r\n private static unhookBrowserConnectivityEvents() {\r\n if (typeof window === \"object\" && window.ononline && window.onoffline) {\r\n window.removeEventListener(\"online\", this._onOnline);\r\n window.removeEventListener(\"offline\", this._onOffline);\r\n }\r\n }\r\n /** event called when internet connectivity changes, if known */\r\n public static onInternetConnectivityChanged = new BeEvent<(status: InternetConnectivityStatus) => void>();\r\n\r\n /** determine whether the app currently has internet connectivity, if known */\r\n public static async checkInternetConnectivity(): Promise<InternetConnectivityStatus> {\r\n return this.nativeAppIpc.checkInternetConnectivity();\r\n }\r\n /** @internal */\r\n public static async overrideInternetConnectivity(status: InternetConnectivityStatus): Promise<void> {\r\n return this.nativeAppIpc.overrideInternetConnectivity(OverriddenBy.User, status);\r\n }\r\n private static _isValid = false;\r\n public static get isValid(): boolean { return this._isValid; }\r\n\r\n /**\r\n * This is called by either ElectronApp.startup or MobileApp.startup - it should not be called directly\r\n * @internal\r\n */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: NativeAppOpts) {\r\n await IpcApp.startup(ipc, opts);\r\n if (this._isValid)\r\n return;\r\n this._isValid = true;\r\n\r\n this._removeAppNotify = NativeAppNotifyHandler.register(); // receives notifications from backend\r\n NativeApp.hookBrowserConnectivityEvents();\r\n\r\n // initialize current online state.\r\n await this.setConnectivity(OverriddenBy.Browser, window.navigator.onLine ? InternetConnectivityStatus.Online : InternetConnectivityStatus.Offline);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._removeAppNotify?.();\r\n NativeApp.unhookBrowserConnectivityEvents();\r\n await NativeAppLogger.flush();\r\n await IpcApp.shutdown();\r\n this._isValid = false;\r\n }\r\n\r\n public static async requestDownloadBriefcase(iTwinId: string, iModelId: string, downloadOptions: DownloadBriefcaseOptions,\r\n asOf?: IModelVersion): Promise<BriefcaseDownloader>;\r\n\r\n public static async requestDownloadBriefcase(\r\n iTwinId: string,\r\n iModelId: string,\r\n downloadOptions: DownloadBriefcaseOptions,\r\n asOf: IModelVersion = IModelVersion.latest()\r\n ): Promise<BriefcaseDownloader> {\r\n const shouldReportProgress = !!downloadOptions.progressCallback;\r\n\r\n let stopProgressEvents = () => { };\r\n if (shouldReportProgress) {\r\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\r\n downloadOptions.progressCallback?.(data);\r\n };\r\n\r\n stopProgressEvents = IpcApp.addListener(`nativeApp.progress-${iModelId}`, handleProgress);\r\n }\r\n\r\n const briefcaseId = (undefined !== downloadOptions.briefcaseId) ? downloadOptions.briefcaseId :\r\n (downloadOptions.syncMode === SyncMode.PullOnly ? 0 : await this.nativeAppIpc.acquireNewBriefcaseId(iModelId));\r\n\r\n const fileName = downloadOptions.fileName ?? await this.getBriefcaseFileName({ briefcaseId, iModelId });\r\n const requestProps: RequestNewBriefcaseProps = { iModelId, briefcaseId, iTwinId, asOf: asOf.toJSON(), fileName };\r\n\r\n const doDownload = async (): Promise<void> => {\r\n try {\r\n await this.nativeAppIpc.downloadBriefcase(requestProps, shouldReportProgress, downloadOptions.progressInterval);\r\n } finally {\r\n stopProgressEvents();\r\n }\r\n };\r\n\r\n const requestCancel = async (): Promise<boolean> => {\r\n const status = await this.nativeAppIpc.requestCancelDownloadBriefcase(fileName);\r\n if (status)\r\n stopProgressEvents();\r\n return status;\r\n };\r\n\r\n return { briefcaseId, fileName, downloadPromise: doDownload(), requestCancel };\r\n }\r\n\r\n /** Get the full path filename for a briefcase within the briefcase cache */\r\n public static async getBriefcaseFileName(props: BriefcaseProps): Promise<string> {\r\n return this.nativeAppIpc.getBriefcaseFileName(props);\r\n }\r\n\r\n /** Delete an existing briefcase\r\n * @param fileName the briefcase fileName\r\n */\r\n public static async deleteBriefcase(fileName: string): Promise<void> {\r\n await this.nativeAppIpc.deleteBriefcaseFiles(fileName);\r\n }\r\n\r\n /** Get a list of all briefcase files held in the local briefcase cache directory */\r\n public static async getCachedBriefcases(iModelId?: GuidString): Promise<LocalBriefcaseProps[]> {\r\n return this.nativeAppIpc.getCachedBriefcases(iModelId);\r\n }\r\n\r\n /**\r\n * Open a [[Storage]]. Creates a new Storage with that name if it does not already exist.\r\n * @param name Should be a local filename without an extension.\r\n * @returns a Promise for the [[Storage]].\r\n */\r\n public static async openStorage(name: string): Promise<Storage> {\r\n let storage = this._storages.get(name);\r\n if (!storage) {\r\n storage = new Storage(await this.nativeAppIpc.storageMgrOpen(name));\r\n this._storages.set(storage.id, storage);\r\n }\r\n\r\n return storage;\r\n }\r\n\r\n /**\r\n * Close a Storage and optionally delete it.\r\n * @param storage normally not call directly instead use Storage.close()\r\n * @param deleteStorage if true, delete the storage from disk after closing it.\r\n */\r\n public static async closeStorage(storage: Storage, deleteStorage: boolean = false): Promise<void> {\r\n if (!this._storages.has(storage.id))\r\n throw new Error(`Storage [Id=${storage.id}] not open`);\r\n\r\n await this.nativeAppIpc.storageMgrClose(storage.id, deleteStorage);\r\n this._storages.delete(storage.id);\r\n }\r\n\r\n /** Get the list of existing Storages on the local disk. */\r\n public static async getStorageNames(): Promise<string[]> {\r\n return NativeApp.nativeAppIpc.storageMgrNames();\r\n }\r\n}\r\n\r\n/**\r\n * A local disk-based cache for key value pairs for NativeApps.\r\n * @note This should be used only for local caching, since its not guaranteed to exist permanently.\r\n * @public\r\n */\r\nexport class Storage {\r\n constructor(public readonly id: string) { }\r\n\r\n /** get the type of a value for a key, or undefined if not present. */\r\n public async getValueType(key: string): Promise<\"number\" | \"string\" | \"boolean\" | \"Uint8Array\" | \"null\" | undefined> {\r\n return NativeApp.nativeAppIpc.storageGetValueType(this.id, key);\r\n }\r\n\r\n /** Get the value for a key */\r\n public async getData(key: string): Promise<StorageValue> {\r\n return NativeApp.nativeAppIpc.storageGet(this.id, key);\r\n }\r\n\r\n /** Set value for a key */\r\n public async setData(key: string, value: StorageValue): Promise<void> {\r\n return NativeApp.nativeAppIpc.storageSet(this.id, key, value);\r\n }\r\n\r\n /**\r\n * Return an array of all keys in this Storage.\r\n * @note This can be expensive, depending on the number of keys present.\r\n */\r\n public async getKeys(): Promise<string[]> {\r\n return NativeApp.nativeAppIpc.storageKeys(this.id);\r\n }\r\n\r\n /** Remove a key and its data. */\r\n public async removeData(key: string): Promise<void> {\r\n return NativeApp.nativeAppIpc.storageRemove(this.id, key);\r\n }\r\n\r\n /** Remove all keys and their data. */\r\n public async removeAll(): Promise<void> {\r\n return NativeApp.nativeAppIpc.storageRemoveAll(this.id);\r\n }\r\n}\r\n"]}
@@ -2,7 +2,7 @@ import { GuidString } from "@itwin/core-bentley";
2
2
  import { RealityData, RealityDataSourceKey, RealityDataSourceProps } from "@itwin/core-common";
3
3
  import { PublisherProductInfo, RealityDataSource, SpatialLocationAndExtents } from "./RealityDataSource";
4
4
  /** This class provides access to the reality data provider services.
5
- * It encapsulates access to a reality data weiter it be from local access, http or ProjectWise Context Share.
5
+ * It encapsulates access to a reality data whether it be from local access, http or ProjectWise Context Share.
6
6
  * The key provided at the creation determines if this is ProjectWise Context Share reference.
7
7
  * If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
8
8
  * There is a one to one relationship between a reality data and the instances of present class.
@@ -1 +1 @@
1
- {"version":3,"file":"RealityDataSourceCesiumIonAssetImpl.d.ts","sourceRoot":"","sources":["../../src/RealityDataSourceCesiumIonAssetImpl.ts"],"names":[],"mappings":"AAQA,OAAO,EAAyB,UAAU,EAAE,MAAM,qBAAqB,CAAC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,GAAG,SAAS,CAAC;IAe5E,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAuC3E;;OAEG;IACU,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAO/D;;OAEG;IACU,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAO7C,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI1D;;;;OAIG;IACU,4BAA4B,IAAI,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC;IAK3F;;;;;OAKG;IACU,uBAAuB,IAAI,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;CAIlF"}
@@ -8,9 +8,9 @@
8
8
  import { request } from "./request/Request";
9
9
  import { assert, BentleyStatus } from "@itwin/core-bentley";
10
10
  import { IModelError, RealityDataProvider } from "@itwin/core-common";
11
- import { CesiumIonAssetProvider, getCesiumAccessTokenAndEndpointUrl, getCesiumAssetUrl, getCesiumOSMBuildingsUrl } from "./tile/internal";
11
+ import { CesiumIonAssetProvider, getCesiumAccessClient, getCesiumAccessTokenAndEndpointUrl, getCesiumAssetUrl, getCesiumOSMBuildingsUrl } from "./tile/internal";
12
12
  /** This class provides access to the reality data provider services.
13
- * It encapsulates access to a reality data weiter it be from local access, http or ProjectWise Context Share.
13
+ * It encapsulates access to a reality data whether it be from local access, http or ProjectWise Context Share.
14
14
  * The key provided at the creation determines if this is ProjectWise Context Share reference.
15
15
  * If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
16
16
  * There is a one to one relationship between a reality data and the instances of present class.
@@ -101,10 +101,28 @@ export class RealityDataSourceCesiumIonAssetImpl {
101
101
  // The following is only if the reality data is not stored on PW Context Share.
102
102
  const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(url);
103
103
  if (cesiumAsset) {
104
- const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(`${cesiumAsset.id}`, cesiumAsset.key);
105
- if (tokenAndUrl.url && tokenAndUrl.token) {
106
- url = tokenAndUrl.url;
107
- this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;
104
+ let resolvedToken;
105
+ let resolvedUrl;
106
+ if (cesiumAsset.key) {
107
+ // Legacy key-bearing URL (e.g. persisted saved view) - authenticate directly with the embedded Ion key.
108
+ // Such URLs are intentionally exempt from the cesiumAccess-over-cesiumIonKey precedence rule and are not
109
+ // routed through a registered CesiumAccessClient; see [[CesiumAccessClient]].
110
+ const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(`${cesiumAsset.id}`, cesiumAsset.key);
111
+ resolvedToken = tokenAndUrl.token;
112
+ resolvedUrl = tokenAndUrl.url;
113
+ }
114
+ else {
115
+ // delegate to the registered CesiumAccessClient
116
+ const client = getCesiumAccessClient();
117
+ const endpoint = await client.getAssetEndpoint(`${cesiumAsset.id}`, iTwinId);
118
+ if (endpoint) {
119
+ resolvedToken = endpoint.accessToken;
120
+ resolvedUrl = endpoint.url;
121
+ }
122
+ }
123
+ if (resolvedUrl && resolvedToken) {
124
+ url = resolvedUrl;
125
+ this._requestAuthorization = `Bearer ${resolvedToken}`;
108
126
  }
109
127
  }
110
128
  // The following is only if the reality data is not stored on PW Context Share.
@@ -1 +1 @@
1
- {"version":3,"file":"RealityDataSourceCesiumIonAssetImpl.js","sourceRoot":"","sources":["../../src/RealityDataSourceCesiumIonAssetImpl.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAc,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAe,mBAAmB,EAAgD,MAAM,oBAAoB,CAAC;AACjI,OAAO,EAAE,sBAAsB,EAAE,kCAAkC,EAAE,iBAAiB,EAAE,wBAAwB,EAAE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ACvC,sEAAsE;QACtE,MAAM,eAAe,GAA0C,SAAS,CAAC;QACzE,OAAO,eAAe,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,IAAI,aAA+C,CAAC;QACpD,OAAO,aAAa,CAAC;IACvB,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 Tiles\r\n */\r\nimport { request } from \"./request/Request\";\r\nimport { assert, BentleyStatus, GuidString } from \"@itwin/core-bentley\";\r\nimport { IModelError, RealityData, RealityDataProvider, RealityDataSourceKey, RealityDataSourceProps } from \"@itwin/core-common\";\r\nimport { CesiumIonAssetProvider, getCesiumAccessTokenAndEndpointUrl, getCesiumAssetUrl, getCesiumOSMBuildingsUrl } from \"./tile/internal\";\r\nimport { PublisherProductInfo, RealityDataSource, SpatialLocationAndExtents } from \"./RealityDataSource\";\r\n\r\n/** This class provides access to the reality data provider services.\r\n * It encapsulates access to a reality data weiter it be from local access, http or ProjectWise Context Share.\r\n * The key provided at the creation determines if this is ProjectWise Context Share reference.\r\n * If not then it is considered local (ex: C:\\temp\\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)\r\n * There is a one to one relationship between a reality data and the instances of present class.\r\n* @internal\r\n*/\r\nexport class RealityDataSourceCesiumIonAssetImpl implements RealityDataSource {\r\n public readonly key: RealityDataSourceKey;\r\n /** The URL that supplies the 3d tiles for displaying the reality model. */\r\n private _tilesetUrl: string | undefined;\r\n /** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/\r\n private _baseUrl: string = \"\";\r\n /** Request authorization for non PW ContextShare requests.*/\r\n private _requestAuthorization?: string;\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n protected constructor(props: RealityDataSourceProps) {\r\n assert(props.sourceKey.provider === RealityDataProvider.CesiumIonAsset);\r\n this.key = props.sourceKey;\r\n }\r\n\r\n /**\r\n * Create an instance of this class from a source key and iTwin context/\r\n */\r\n public static async createFromKey(sourceKey: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n if (sourceKey.provider !== RealityDataProvider.CesiumIonAsset)\r\n return undefined;\r\n const rdSource = new RealityDataSourceCesiumIonAssetImpl({ sourceKey });\r\n let tilesetUrl: string | undefined;\r\n try {\r\n tilesetUrl = await rdSource.getServiceUrl(iTwinId);\r\n } catch { }\r\n\r\n return (tilesetUrl !== undefined) ? rdSource : undefined;\r\n }\r\n\r\n public get isContextShare(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Returns Reality Data if available\r\n */\r\n public get realityData(): RealityData | undefined {\r\n return undefined;\r\n }\r\n public get realityDataId(): string | undefined {\r\n return undefined;\r\n }\r\n /**\r\n * Returns Reality Data type if available\r\n */\r\n public get realityDataType(): string | undefined {\r\n return undefined;\r\n }\r\n\r\n // This is to set the root url from the provided root document path.\r\n // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,\r\n // otherwise the full path to root document is given.\r\n // The base URL contains the base URL from which tile relative path are constructed.\r\n // The tile's path root will need to be reinserted for child tiles to return a 200\r\n private setBaseUrl(url: string): void {\r\n const urlParts = url.split(\"/\");\r\n urlParts.pop();\r\n if (urlParts.length === 0)\r\n this._baseUrl = \"\";\r\n else\r\n this._baseUrl = `${urlParts.join(\"/\")}/`;\r\n }\r\n\r\n /**\r\n * This method returns the URL to access the actual 3d tiles from the service provider.\r\n * @returns string containing the URL to reality data.\r\n */\r\n public async getServiceUrl(_iTwinId: GuidString | undefined): Promise<string | undefined> {\r\n // If url was not resolved - resolve it\r\n this._tilesetUrl = this.key.id;\r\n if (this.key.id === CesiumIonAssetProvider.osmBuildingId) {\r\n this._tilesetUrl = getCesiumOSMBuildingsUrl();\r\n } else {\r\n const parsedId = CesiumIonAssetProvider.parseCesiumUrl(this.key.id);\r\n if (parsedId) {\r\n this._tilesetUrl = getCesiumAssetUrl(parsedId.id, parsedId.key);\r\n }\r\n }\r\n\r\n return this._tilesetUrl;\r\n }\r\n\r\n public async getRootDocument(iTwinId: GuidString | undefined): Promise<any> {\r\n let url = await this.getServiceUrl(iTwinId);\r\n if (!url)\r\n throw new IModelError(BentleyStatus.ERROR, \"Unable to get service url\");\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(url);\r\n if (cesiumAsset) {\r\n const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(`${cesiumAsset.id}`, cesiumAsset.key);\r\n if (tokenAndUrl.url && tokenAndUrl.token) {\r\n url = tokenAndUrl.url;\r\n this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;\r\n }\r\n }\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n this.setBaseUrl(url);\r\n const headers = { authorization: this._requestAuthorization };\r\n\r\n return request(url, \"json\", { headers });\r\n }\r\n\r\n /**\r\n * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileContent(name: string): Promise<ArrayBuffer> {\r\n const tileUrl = this._baseUrl + name;\r\n const headers = { authorization: this._requestAuthorization };\r\n\r\n return request(tileUrl, \"arraybuffer\", { headers });\r\n }\r\n\r\n /**\r\n * Returns the tile content in json format. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileJson(name: string): Promise<any> {\r\n const tileUrl = this._baseUrl + name;\r\n const headers = { authorization: this._requestAuthorization };\r\n\r\n return request(tileUrl, \"json\", { headers });\r\n }\r\n\r\n public getTileContentType(url: string): \"tile\" | \"tileset\" {\r\n return url.endsWith(\"json\") ? \"tileset\" : \"tile\";\r\n }\r\n\r\n /**\r\n * Gets spatial location and extents of this reality data source\r\n * @returns spatial location and extents\r\n * @internal\r\n */\r\n public async getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined> {\r\n // Cesium Ion asset we currenlty support are unbound (cover all earth)\r\n const spatialLocation: SpatialLocationAndExtents | undefined = undefined;\r\n return spatialLocation;\r\n }\r\n /**\r\n * Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n public async getPublisherProductInfo(): Promise<PublisherProductInfo | undefined> {\r\n let publisherInfo: PublisherProductInfo | undefined;\r\n return publisherInfo;\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"RealityDataSourceCesiumIonAssetImpl.js","sourceRoot":"","sources":["../../src/RealityDataSourceCesiumIonAssetImpl.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAc,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAe,mBAAmB,EAAgD,MAAM,oBAAoB,CAAC;AACjI,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kCAAkC,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAGjK;;;;;;EAME;AACF,MAAM,OAAO,mCAAmC;IAC9B,GAAG,CAAuB;IAC1C,2EAA2E;IACnE,WAAW,CAAqB;IACxC,sIAAsI;IAC9H,QAAQ,GAAW,EAAE,CAAC;IAC9B,6DAA6D;IACrD,qBAAqB,CAAU;IAEvC;;OAEG;IACH,YAAsB,KAA6B;QACjD,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,mBAAmB,CAAC,cAAc,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,SAA+B,EAAE,OAA+B;QAChG,IAAI,SAAS,CAAC,Q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OAIG;IACI,KAAK,CAAC,4BAA4B;QACvC,sEAAsE;QACtE,MAAM,eAAe,GAA0C,SAAS,CAAC;QACzE,OAAO,eAAe,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,IAAI,aAA+C,CAAC;QACpD,OAAO,aAAa,CAAC;IACvB,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 Tiles\r\n */\r\nimport { request } from \"./request/Request\";\r\nimport { assert, BentleyStatus, GuidString } from \"@itwin/core-bentley\";\r\nimport { IModelError, RealityData, RealityDataProvider, RealityDataSourceKey, RealityDataSourceProps } from \"@itwin/core-common\";\r\nimport { CesiumIonAssetProvider, getCesiumAccessClient, getCesiumAccessTokenAndEndpointUrl, getCesiumAssetUrl, getCesiumOSMBuildingsUrl } from \"./tile/internal\";\r\nimport { PublisherProductInfo, RealityDataSource, SpatialLocationAndExtents } from \"./RealityDataSource\";\r\n\r\n/** This class provides access to the reality data provider services.\r\n * It encapsulates access to a reality data whether it be from local access, http or ProjectWise Context Share.\r\n * The key provided at the creation determines if this is ProjectWise Context Share reference.\r\n * If not then it is considered local (ex: C:\\temp\\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)\r\n * There is a one to one relationship between a reality data and the instances of present class.\r\n* @internal\r\n*/\r\nexport class RealityDataSourceCesiumIonAssetImpl implements RealityDataSource {\r\n public readonly key: RealityDataSourceKey;\r\n /** The URL that supplies the 3d tiles for displaying the reality model. */\r\n private _tilesetUrl: string | undefined;\r\n /** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/\r\n private _baseUrl: string = \"\";\r\n /** Request authorization for non PW ContextShare requests.*/\r\n private _requestAuthorization?: string;\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n protected constructor(props: RealityDataSourceProps) {\r\n assert(props.sourceKey.provider === RealityDataProvider.CesiumIonAsset);\r\n this.key = props.sourceKey;\r\n }\r\n\r\n /**\r\n * Create an instance of this class from a source key and iTwin context/\r\n */\r\n public static async createFromKey(sourceKey: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n if (sourceKey.provider !== RealityDataProvider.CesiumIonAsset)\r\n return undefined;\r\n const rdSource = new RealityDataSourceCesiumIonAssetImpl({ sourceKey });\r\n let tilesetUrl: string | undefined;\r\n try {\r\n tilesetUrl = await rdSource.getServiceUrl(iTwinId);\r\n } catch { }\r\n\r\n return (tilesetUrl !== undefined) ? rdSource : undefined;\r\n }\r\n\r\n public get isContextShare(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Returns Reality Data if available\r\n */\r\n public get realityData(): RealityData | undefined {\r\n return undefined;\r\n }\r\n public get realityDataId(): string | undefined {\r\n return undefined;\r\n }\r\n /**\r\n * Returns Reality Data type if available\r\n */\r\n public get realityDataType(): string | undefined {\r\n return undefined;\r\n }\r\n\r\n // This is to set the root url from the provided root document path.\r\n // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,\r\n // otherwise the full path to root document is given.\r\n // The base URL contains the base URL from which tile relative path are constructed.\r\n // The tile's path root will need to be reinserted for child tiles to return a 200\r\n private setBaseUrl(url: string): void {\r\n const urlParts = url.split(\"/\");\r\n urlParts.pop();\r\n if (urlParts.length === 0)\r\n this._baseUrl = \"\";\r\n else\r\n this._baseUrl = `${urlParts.join(\"/\")}/`;\r\n }\r\n\r\n /**\r\n * This method returns the URL to access the actual 3d tiles from the service provider.\r\n * @returns string containing the URL to reality data.\r\n */\r\n public async getServiceUrl(_iTwinId: GuidString | undefined): Promise<string | undefined> {\r\n // If url was not resolved - resolve it\r\n this._tilesetUrl = this.key.id;\r\n if (this.key.id === CesiumIonAssetProvider.osmBuildingId) {\r\n this._tilesetUrl = getCesiumOSMBuildingsUrl();\r\n } else {\r\n const parsedId = CesiumIonAssetProvider.parseCesiumUrl(this.key.id);\r\n if (parsedId) {\r\n this._tilesetUrl = getCesiumAssetUrl(parsedId.id, parsedId.key);\r\n }\r\n }\r\n\r\n return this._tilesetUrl;\r\n }\r\n\r\n public async getRootDocument(iTwinId: GuidString | undefined): Promise<any> {\r\n let url = await this.getServiceUrl(iTwinId);\r\n if (!url)\r\n throw new IModelError(BentleyStatus.ERROR, \"Unable to get service url\");\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(url);\r\n if (cesiumAsset) {\r\n let resolvedToken: string | undefined;\r\n let resolvedUrl: string | undefined;\r\n if (cesiumAsset.key) {\r\n // Legacy key-bearing URL (e.g. persisted saved view) - authenticate directly with the embedded Ion key.\r\n // Such URLs are intentionally exempt from the cesiumAccess-over-cesiumIonKey precedence rule and are not\r\n // routed through a registered CesiumAccessClient; see [[CesiumAccessClient]].\r\n const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(`${cesiumAsset.id}`, cesiumAsset.key);\r\n resolvedToken = tokenAndUrl.token;\r\n resolvedUrl = tokenAndUrl.url;\r\n } else {\r\n // delegate to the registered CesiumAccessClient\r\n const client = getCesiumAccessClient();\r\n const endpoint = await client.getAssetEndpoint(`${cesiumAsset.id}`, iTwinId);\r\n if (endpoint) {\r\n resolvedToken = endpoint.accessToken;\r\n resolvedUrl = endpoint.url;\r\n }\r\n }\r\n if (resolvedUrl && resolvedToken) {\r\n url = resolvedUrl;\r\n this._requestAuthorization = `Bearer ${resolvedToken}`;\r\n }\r\n }\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n this.setBaseUrl(url);\r\n const headers = { authorization: this._requestAuthorization };\r\n\r\n return request(url, \"json\", { headers });\r\n }\r\n\r\n /**\r\n * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileContent(name: string): Promise<ArrayBuffer> {\r\n const tileUrl = this._baseUrl + name;\r\n const headers = { authorization: this._requestAuthorization };\r\n\r\n return request(tileUrl, \"arraybuffer\", { headers });\r\n }\r\n\r\n /**\r\n * Returns the tile content in json format. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileJson(name: string): Promise<any> {\r\n const tileUrl = this._baseUrl + name;\r\n const headers = { authorization: this._requestAuthorization };\r\n\r\n return request(tileUrl, \"json\", { headers });\r\n }\r\n\r\n public getTileContentType(url: string): \"tile\" | \"tileset\" {\r\n return url.endsWith(\"json\") ? \"tileset\" : \"tile\";\r\n }\r\n\r\n /**\r\n * Gets spatial location and extents of this reality data source\r\n * @returns spatial location and extents\r\n * @internal\r\n */\r\n public async getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined> {\r\n // Cesium Ion asset we currenlty support are unbound (cover all earth)\r\n const spatialLocation: SpatialLocationAndExtents | undefined = undefined;\r\n return spatialLocation;\r\n }\r\n /**\r\n * Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n public async getPublisherProductInfo(): Promise<PublisherProductInfo | undefined> {\r\n let publisherInfo: PublisherProductInfo | undefined;\r\n return publisherInfo;\r\n }\r\n}\r\n\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Id64Arg, Id64Set, Id64String } from "@itwin/core-bentley";
2
2
  import { SubCategoryAppearance, SubCategoryResultRow } from "@itwin/core-common";
3
- import { IModelConnection } from "./IModelConnection";
3
+ import type { IModelConnection } from "./IModelConnection";
4
4
  /** A cancelable paginated request for subcategory information.
5
5
  * @see SubCategoriesCache
6
6
  * @internal
@@ -9,7 +9,7 @@ export interface SubCategoriesRequest {
9
9
  /** The Ids of any categories which were requested but were not yet loaded. */
10
10
  readonly missingCategoryIds: Id64Set;
11
11
  /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.
12
- * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.
12
+ * Categories may fail to load if the request is explicitly canceled, if the IModelConnection is closed before all categories are loaded, or if the query fails.
13
13
  */
14
14
  readonly promise: Promise<boolean>;
15
15
  /** Cancels the request. */
@@ -21,10 +21,16 @@ export interface SubCategoriesRequest {
21
21
  export declare class SubCategoriesCache {
22
22
  private readonly _byCategoryId;
23
23
  private readonly _appearances;
24
+ private readonly _staleCategoryIds;
24
25
  private readonly _imodel;
25
- private _missingAtTimeOfPreload;
26
+ private _invalidationGeneration;
27
+ private readonly _onChanged;
26
28
  constructor(imodel: IModelConnection);
27
29
  attachToBriefcase(imodel: IModelConnection): void;
30
+ /** Register a listener to be notified when transaction changes invalidate cached subcategory information.
31
+ * @internal
32
+ */
33
+ addChangedListener(listener: () => void): () => void;
28
34
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
29
35
  getSubCategories(categoryId: string): Id64Set | undefined;
30
36
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -47,6 +53,12 @@ export declare class SubCategoriesCache {
47
53
  * @internal
48
54
  */
49
55
  add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean): void;
56
+ private isCategoryStale;
57
+ private markCategoryFresh;
58
+ private markAllCategoriesStale;
59
+ private markCategoriesStale;
60
+ private hasStaleCategories;
61
+ private deleteCategory;
50
62
  getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>>;
51
63
  getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>>;
52
64
  private mapSubCategoryInfos;
@@ -1 +1 @@
1
- {"version":3,"file":"SubCategoriesCache.d.ts","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAuB,MAAM,qB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;KAgBjB;CACF"}
@@ -2,17 +2,18 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { assert, CompressedId64Set, Id64, OrderedId64Iterable } from "@itwin/core-bentley";
5
+ import { assert, BeEvent, CompressedId64Set, Id64, OrderedId64Iterable } from "@itwin/core-bentley";
6
6
  import { SubCategoryAppearance } from "@itwin/core-common";
7
- const invalidCategoryIdEntry = new Set();
8
7
  /** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.
9
8
  * @internal
10
9
  */
11
10
  export class SubCategoriesCache {
12
11
  _byCategoryId = new Map();
13
12
  _appearances = new Map();
13
+ _staleCategoryIds = new Set();
14
14
  _imodel;
15
- _missingAtTimeOfPreload;
15
+ _invalidationGeneration = 0;
16
+ _onChanged = new BeEvent();
16
17
  constructor(imodel) {
17
18
  this._imodel = imodel;
18
19
  }
@@ -23,36 +24,58 @@ export class SubCategoriesCache {
23
24
  assert(imodel.isBriefcaseConnection());
24
25
  imodel.txns.onElementsChanged.addListener((changes) => {
25
26
  const affectedSubCategories = new Set();
27
+ const affectedCategories = new Set();
28
+ let invalidateAllCategories = false;
29
+ let changed = false;
26
30
  for (const change of changes) {
27
31
  if (change.metadata.is("BisCore:Category")) {
28
32
  if (change.type === "deleted") {
29
- this._byCategoryId.delete(change.id);
33
+ this.deleteCategory(change.id);
34
+ changed = true;
30
35
  }
31
36
  }
32
37
  else if (change.metadata.is("BisCore:SubCategory")) {
33
38
  if (change.type === "inserted") {
34
- // We don't know to which category the subcategory belongs. Blow away the entire cache.
35
- this._byCategoryId.clear();
36
- this._appearances.clear();
37
- return;
39
+ // We don't know to which category the subcategory belongs, so every cached category may be stale.
40
+ invalidateAllCategories = true;
41
+ changed = true;
42
+ continue;
38
43
  }
39
- this._appearances.delete(change.id);
40
44
  affectedSubCategories.add(change.id);
41
45
  }
42
46
  }
43
- if (affectedSubCategories.size > 0) {
47
+ if (invalidateAllCategories) {
48
+ this.markAllCategoriesStale();
49
+ }
50
+ else if (affectedSubCategories.size > 0) {
44
51
  for (const [catId, subCatIds] of this._byCategoryId) {
45
52
  for (const subCatId of affectedSubCategories) {
46
53
  if (subCatIds.has(subCatId)) {
47
- this._byCategoryId.delete(catId);
54
+ affectedCategories.add(catId);
55
+ changed = true;
48
56
  affectedSubCategories.delete(subCatId);
49
57
  break;
50
58
  }
51
59
  }
52
60
  }
61
+ if (affectedCategories.size > 0)
62
+ this.markCategoriesStale(affectedCategories);
63
+ // If any affected subcategories were NOT found in cache and categories are currently stale,
64
+ // bump generation to invalidate in-flight reload queries that may return stale data.
65
+ if (affectedSubCategories.size > 0 && this.hasStaleCategories()) {
66
+ changed = true;
67
+ }
68
+ }
69
+ if (changed) {
70
+ this._invalidationGeneration++;
71
+ this._onChanged.raiseEvent();
53
72
  }
54
73
  });
55
74
  }
75
+ /** Register a listener to be notified when transaction changes invalidate cached subcategory information.
76
+ * @internal
77
+ */
78
+ addChangedListener(listener) { return this._onChanged.addListener(listener); }
56
79
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
57
80
  getSubCategories(categoryId) { return this._byCategoryId.get(categoryId); }
58
81
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -67,10 +90,14 @@ export class SubCategoriesCache {
67
90
  if (undefined === missing)
68
91
  return undefined;
69
92
  const request = new SubCategoriesCache.Request(missing, this._imodel);
93
+ const generation = this._invalidationGeneration;
70
94
  const promise = request.dispatch().then((result) => {
71
- if (undefined !== result)
95
+ const completed = undefined !== result && !request.wasCanceled && generation === this._invalidationGeneration;
96
+ if (completed)
72
97
  this.processResults(result, missing);
73
- return !request.wasCanceled;
98
+ // On failure (result undefined due to query error), do NOT cache empty sets for uncached categories.
99
+ // Leave them absent so getMissing() will include them in subsequent load() retries.
100
+ return completed;
74
101
  });
75
102
  return {
76
103
  missingCategoryIds: missing,
@@ -81,9 +108,16 @@ export class SubCategoriesCache {
81
108
  /** Load all subcategories that come from used spatial categories of the iModel into the cache. */
82
109
  async loadAllUsedSpatialSubCategories() {
83
110
  try {
111
+ const generation = this._invalidationGeneration;
84
112
  const results = await this._imodel.queryAllUsedSpatialSubCategories();
85
- if (undefined !== results) {
86
- this.processResults(results, new Set(), false);
113
+ if (generation === this._invalidationGeneration && undefined !== results) {
114
+ const staleCategories = new Set(this._staleCategoryIds);
115
+ // This preload can return partial results on very large iModels, so keep stale categories additive and
116
+ // preserve their stale state until a targeted reload can fully reconcile them.
117
+ for (const row of results)
118
+ this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), staleCategories.has(row.parentId));
119
+ if (staleCategories.size > 0)
120
+ this.markCategoriesStale(staleCategories);
87
121
  }
88
122
  }
89
123
  catch {
@@ -94,7 +128,7 @@ export class SubCategoriesCache {
94
128
  getMissing(categoryIds) {
95
129
  let missing;
96
130
  for (const catId of Id64.iterable(categoryIds)) {
97
- if (undefined === this._byCategoryId.get(catId)) {
131
+ if (undefined === this._byCategoryId.get(catId) || this.isCategoryStale(catId)) {
98
132
  if (undefined === missing)
99
133
  missing = new Set();
100
134
  missing.add(catId);
@@ -105,6 +139,8 @@ export class SubCategoriesCache {
105
139
  clear() {
106
140
  this._byCategoryId.clear();
107
141
  this._appearances.clear();
142
+ this._staleCategoryIds.clear();
143
+ this._invalidationGeneration++;
108
144
  }
109
145
  onIModelConnectionClose() {
110
146
  this.clear();
@@ -115,14 +151,25 @@ export class SubCategoriesCache {
115
151
  props = JSON.parse(json);
116
152
  return new SubCategoryAppearance(props);
117
153
  }
118
- processResults(result, missing, override = true) {
154
+ processResults(result, refreshedCategoryIds, override = true) {
155
+ const previousSubCategoryIds = new Map();
156
+ for (const id of refreshedCategoryIds) {
157
+ const previous = this._byCategoryId.get(id);
158
+ if (undefined !== previous)
159
+ previousSubCategoryIds.set(id, previous);
160
+ this._byCategoryId.set(id, new Set());
161
+ this.markCategoryFresh(id);
162
+ }
119
163
  for (const row of result) {
120
164
  this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);
121
165
  }
122
- // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested
123
- for (const id of missing)
124
- if (undefined === this._byCategoryId.get(id))
125
- this._byCategoryId.set(id, invalidCategoryIdEntry);
166
+ for (const [categoryId, previous] of previousSubCategoryIds) {
167
+ const current = this._byCategoryId.get(categoryId);
168
+ for (const subCategoryId of previous) {
169
+ if (!current?.has(subCategoryId))
170
+ this._appearances.delete(subCategoryId);
171
+ }
172
+ }
126
173
  }
127
174
  /** Exposed strictly for tests.
128
175
  * @internal
@@ -132,9 +179,38 @@ export class SubCategoriesCache {
132
179
  if (undefined === set)
133
180
  this._byCategoryId.set(categoryId, set = new Set());
134
181
  set.add(subCategoryId);
182
+ this.markCategoryFresh(categoryId);
135
183
  if (override || !this._appearances.has(subCategoryId))
136
184
  this._appearances.set(subCategoryId, appearance);
137
185
  }
186
+ isCategoryStale(categoryId) {
187
+ return this._staleCategoryIds.has(categoryId);
188
+ }
189
+ markCategoryFresh(categoryId) {
190
+ this._staleCategoryIds.delete(categoryId);
191
+ }
192
+ markAllCategoriesStale() {
193
+ // We don't know which cached category the inserted subcategory belongs to, so every currently-cached
194
+ // category may now be missing a subcategory. Mark them all stale so they are re-requested on next load.
195
+ // Categories cached after this point are loaded fresh and are intentionally left out.
196
+ for (const categoryId of this._byCategoryId.keys())
197
+ this._staleCategoryIds.add(categoryId);
198
+ }
199
+ markCategoriesStale(categoryIds) {
200
+ for (const categoryId of categoryIds)
201
+ this._staleCategoryIds.add(categoryId);
202
+ }
203
+ hasStaleCategories() {
204
+ return this._staleCategoryIds.size > 0;
205
+ }
206
+ deleteCategory(categoryId) {
207
+ const subCategoryIds = this._byCategoryId.get(categoryId);
208
+ if (undefined !== subCategoryIds)
209
+ for (const subCategoryId of subCategoryIds)
210
+ this._appearances.delete(subCategoryId);
211
+ this._byCategoryId.delete(categoryId);
212
+ this._staleCategoryIds.delete(categoryId);
213
+ }
138
214
  async getCategoryInfo(inputCategoryIds) {
139
215
  // Eliminate duplicates...
140
216
  const categoryIds = new Set(typeof inputCategoryIds === "string" ? [inputCategoryIds] : inputCategoryIds);
@@ -144,9 +220,7 @@ export class SubCategoriesCache {
144
220
  const map = new Map();
145
221
  for (const categoryId of categoryIds) {
146
222
  const subCategoryIds = this._byCategoryId.get(categoryId);
147
- if (!subCategoryIds)
148
- continue;
149
- const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);
223
+ const subCategories = undefined !== subCategoryIds ? this.mapSubCategoryInfos(categoryId, subCategoryIds) : new Map();
150
224
  map.set(categoryId, { id: categoryId, subCategories });
151
225
  }
152
226
  return map;
@@ -202,9 +276,7 @@ export class SubCategoriesCache {
202
276
  return undefined;
203
277
  }
204
278
  catch {
205
- // ###TODO: detect cases in which retry is warranted
206
- // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the
207
- // incomplete results. Since we're not retrying, that's the best we can do.
279
+ return undefined;
208
280
  }
209
281
  // Finished with current batch of categoryIds. Dispatch the next batch if one exists.
210
282
  if (++this._curCategoryIdsIndex < this._categoryIds.length) {