@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"}
@@ -77,9 +77,7 @@ class NativeApp {
77
77
  this._removeAppNotify = NativeAppNotifyHandler.register(); // receives notifications from backend
78
78
  NativeApp.hookBrowserConnectivityEvents();
79
79
  // initialize current online state.
80
- if (window.navigator.onLine) {
81
- await this.setConnectivity(core_common_1.OverriddenBy.Browser, window.navigator.onLine ? core_common_1.InternetConnectivityStatus.Online : core_common_1.InternetConnectivityStatus.Offline);
82
- }
80
+ await this.setConnectivity(core_common_1.OverriddenBy.Browser, window.navigator.onLine ? core_common_1.InternetConnectivityStatus.Online : core_common_1.InternetConnectivityStatus.Offline);
83
81
  }
84
82
  /** @internal */
85
83
  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,sDAAkE;AAClE,oDAI4B;AAC5B,4EAAyE;AACzE,qCAAsE;AACtE,uDAAoD;AAyBpD,2CAA2C;AAC3C,MAAM,sBAAuB,SAAQ,4BAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,iCAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/D,iCAAiC,CAAC,MAAkC;QACzE,qBAAM,CAAC,OAAO,CAAC,+CAAsB,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC;QAClF,SAAS,CAAC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACF;AAUD;;;;GAIG;AACH,MAAa,SAAS;IACZ,MAAM,CAAC,gBAAgB,CAAkB;IAEjD,kFAAkF;IAC3E,MAAM,CAAC,YAAY,GAAG,eAAM,CAAC,YAAY,CAAqB,iCAAmB,CAAC,WAAW,CAAC,CAAC;IAC/F,MAAM,CAAC,UAAU,GAAG,eAAM,CAAC,YAAY,CAAqD,mBAAmB,CAAC,CAAC;IAEhH,M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O,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;AAnCD,0BAmCC","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,sDAAkE;AAClE,oDAI4B;AAC5B,4EAAyE;AACzE,qCAAsE;AACtE,uDAAoD;AAyBpD,2CAA2C;AAC3C,MAAM,sBAAuB,SAAQ,4BAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,iCAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/D,iCAAiC,CAAC,MAAkC;QACzE,qBAAM,CAAC,OAAO,CAAC,+CAAsB,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC;QAClF,SAAS,CAAC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACF;AAUD;;;;GAIG;AACH,MAAa,SAAS;IACZ,MAAM,CAAC,gBAAgB,CAAkB;IAEjD,kFAAkF;IAC3E,MAAM,CAAC,YAAY,GAAG,eAAM,CAAC,YAAY,CAAqB,iCAAmB,CAAC,WAAW,CAAC,CAAC;IAC/F,MAAM,CAAC,UAAU,GAAG,eAAM,CAAC,YAAY,CAAqD,mBAAmB,CAAC,CAAC;IAEhH,MAAM,CAAC,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,MAAM,CAAC,SAAS,GAAG,KAAK,IAAI,E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Y,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;AAnCD,0BAmCC","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;AACxE,OAAO,EAAe,WAAW,EAAuB,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjI,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEzG;;;;;;EAME;AACF,qBAAa,mCAAoC,YAAW,iBAAiB;IAC3E,SAAgB,GAAG,EAAE,oBAAoB,CAAC;IAC1C,2EAA2E;IAC3E,OAAO,CAAC,WAAW,CAAqB;IACxC,sIAAsI;IACtI,OAAO,CAAC,QAAQ,CAAc;IAC9B,6DAA6D;IAC7D,OAAO,CAAC,qBAAqB,CAAC,CAAS;IAEvC;;OAEG;IAC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uB,IAAI,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;CAIlF"}
@@ -13,7 +13,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
13
13
  const core_common_1 = require("@itwin/core-common");
14
14
  const internal_1 = require("./tile/internal");
15
15
  /** This class provides access to the reality data provider services.
16
- * It encapsulates access to a reality data weiter it be from local access, http or ProjectWise Context Share.
16
+ * It encapsulates access to a reality data whether it be from local access, http or ProjectWise Context Share.
17
17
  * The key provided at the creation determines if this is ProjectWise Context Share reference.
18
18
  * If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
19
19
  * There is a one to one relationship between a reality data and the instances of present class.
@@ -104,10 +104,28 @@ class RealityDataSourceCesiumIonAssetImpl {
104
104
  // The following is only if the reality data is not stored on PW Context Share.
105
105
  const cesiumAsset = internal_1.CesiumIonAssetProvider.parseCesiumUrl(url);
106
106
  if (cesiumAsset) {
107
- const tokenAndUrl = await (0, internal_1.getCesiumAccessTokenAndEndpointUrl)(`${cesiumAsset.id}`, cesiumAsset.key);
108
- if (tokenAndUrl.url && tokenAndUrl.token) {
109
- url = tokenAndUrl.url;
110
- this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;
107
+ let resolvedToken;
108
+ let resolvedUrl;
109
+ if (cesiumAsset.key) {
110
+ // Legacy key-bearing URL (e.g. persisted saved view) - authenticate directly with the embedded Ion key.
111
+ // Such URLs are intentionally exempt from the cesiumAccess-over-cesiumIonKey precedence rule and are not
112
+ // routed through a registered CesiumAccessClient; see [[CesiumAccessClient]].
113
+ const tokenAndUrl = await (0, internal_1.getCesiumAccessTokenAndEndpointUrl)(`${cesiumAsset.id}`, cesiumAsset.key);
114
+ resolvedToken = tokenAndUrl.token;
115
+ resolvedUrl = tokenAndUrl.url;
116
+ }
117
+ else {
118
+ // delegate to the registered CesiumAccessClient
119
+ const client = (0, internal_1.getCesiumAccessClient)();
120
+ const endpoint = await client.getAssetEndpoint(`${cesiumAsset.id}`, iTwinId);
121
+ if (endpoint) {
122
+ resolvedToken = endpoint.accessToken;
123
+ resolvedUrl = endpoint.url;
124
+ }
125
+ }
126
+ if (resolvedUrl && resolvedToken) {
127
+ url = resolvedUrl;
128
+ this._requestAuthorization = `Bearer ${resolvedToken}`;
111
129
  }
112
130
  }
113
131
  // 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,+CAA4C;AAC5C,sDAAwE;AACxE,oDAAiI;AACjI,8CAA0I;AAG1I;;;;;;EAME;AACF,MAAa,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,IAAA,qBAAM,EAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,iCAAmB,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,QAAQ,KAAK,iCAAmB,CAAC,cAAc;YAC3D,OAAO,SAAS,CAAC;QACnB,MAAM,QAAQ,GAAG,IAAI,mCAAmC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACxE,IAAI,UAA8B,CAAC;QACnC,IAAI,CAAC;YACH,UAAU,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC,CAAC,CAAC;QAEX,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,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G;IACI,KAAK,CAAC,WAAW,CAAC,IAAY;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrC,MAAM,OAAO,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAE9D,OAAO,IAAA,iBAAO,EAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;IAEM,kBAAkB,CAAC,GAAW;QACnC,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IAED;;;;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;AAvJD,kFAuJC","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,+CAA4C;AAC5C,sDAAwE;AACxE,oDAAiI;AACjI,8CAAiK;AAGjK;;;;;;EAME;AACF,MAAa,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,IAAA,qBAAM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a,EAAE,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAE9D,OAAO,IAAA,iBAAO,EAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;IAEM,kBAAkB,CAAC,GAAW;QACnC,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IAED;;;;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;AAxKD,kFAwKC","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,qBAAqB,CAAC;AACzH,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,2BAA2B;IAC3B,MAAM,IAAI,IAAI,CAAC;CAChB;AAID;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA8B;IAC5D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4C;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,uBAAuB,CAAsB;gBAElC,MAAM,EAAE,gBAAgB;IAIpC,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAsCxD,wIAAwI;IACjI,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAEhE,wHAAwH;IACjH,wBAAwB,CAAC,aAAa,EAAE,UAAU,GAAG,qBAAqB,GAAG,SAAS;IAE7F;;;;OAIG;IACI,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS;IAmBnE,kGAAkG;IACrF,+BAA+B,IAAI,OAAO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CAAC,SAAS,UAAS;QAE5B;;WAEG;QACI,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;QASnF,+CAA+C;QACxC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;QAW/B,IAAW,OAAO,IAAI,OAAO,CAE5B;QAED,OAAO,CAAC,WAAW;QAgBnB,OAAO,CAAC,cAAc;QAoCtB,OAAO,CAAC,QAAQ;KAgBjB;CACF"}
@@ -7,15 +7,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SubCategoriesCache = void 0;
8
8
  const core_bentley_1 = require("@itwin/core-bentley");
9
9
  const core_common_1 = require("@itwin/core-common");
10
- const invalidCategoryIdEntry = new Set();
11
10
  /** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.
12
11
  * @internal
13
12
  */
14
13
  class SubCategoriesCache {
15
14
  _byCategoryId = new Map();
16
15
  _appearances = new Map();
16
+ _staleCategoryIds = new Set();
17
17
  _imodel;
18
- _missingAtTimeOfPreload;
18
+ _invalidationGeneration = 0;
19
+ _onChanged = new core_bentley_1.BeEvent();
19
20
  constructor(imodel) {
20
21
  this._imodel = imodel;
21
22
  }
@@ -26,36 +27,58 @@ class SubCategoriesCache {
26
27
  (0, core_bentley_1.assert)(imodel.isBriefcaseConnection());
27
28
  imodel.txns.onElementsChanged.addListener((changes) => {
28
29
  const affectedSubCategories = new Set();
30
+ const affectedCategories = new Set();
31
+ let invalidateAllCategories = false;
32
+ let changed = false;
29
33
  for (const change of changes) {
30
34
  if (change.metadata.is("BisCore:Category")) {
31
35
  if (change.type === "deleted") {
32
- this._byCategoryId.delete(change.id);
36
+ this.deleteCategory(change.id);
37
+ changed = true;
33
38
  }
34
39
  }
35
40
  else if (change.metadata.is("BisCore:SubCategory")) {
36
41
  if (change.type === "inserted") {
37
- // We don't know to which category the subcategory belongs. Blow away the entire cache.
38
- this._byCategoryId.clear();
39
- this._appearances.clear();
40
- return;
42
+ // We don't know to which category the subcategory belongs, so every cached category may be stale.
43
+ invalidateAllCategories = true;
44
+ changed = true;
45
+ continue;
41
46
  }
42
- this._appearances.delete(change.id);
43
47
  affectedSubCategories.add(change.id);
44
48
  }
45
49
  }
46
- if (affectedSubCategories.size > 0) {
50
+ if (invalidateAllCategories) {
51
+ this.markAllCategoriesStale();
52
+ }
53
+ else if (affectedSubCategories.size > 0) {
47
54
  for (const [catId, subCatIds] of this._byCategoryId) {
48
55
  for (const subCatId of affectedSubCategories) {
49
56
  if (subCatIds.has(subCatId)) {
50
- this._byCategoryId.delete(catId);
57
+ affectedCategories.add(catId);
58
+ changed = true;
51
59
  affectedSubCategories.delete(subCatId);
52
60
  break;
53
61
  }
54
62
  }
55
63
  }
64
+ if (affectedCategories.size > 0)
65
+ this.markCategoriesStale(affectedCategories);
66
+ // If any affected subcategories were NOT found in cache and categories are currently stale,
67
+ // bump generation to invalidate in-flight reload queries that may return stale data.
68
+ if (affectedSubCategories.size > 0 && this.hasStaleCategories()) {
69
+ changed = true;
70
+ }
71
+ }
72
+ if (changed) {
73
+ this._invalidationGeneration++;
74
+ this._onChanged.raiseEvent();
56
75
  }
57
76
  });
58
77
  }
78
+ /** Register a listener to be notified when transaction changes invalidate cached subcategory information.
79
+ * @internal
80
+ */
81
+ addChangedListener(listener) { return this._onChanged.addListener(listener); }
59
82
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
60
83
  getSubCategories(categoryId) { return this._byCategoryId.get(categoryId); }
61
84
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -70,10 +93,14 @@ class SubCategoriesCache {
70
93
  if (undefined === missing)
71
94
  return undefined;
72
95
  const request = new SubCategoriesCache.Request(missing, this._imodel);
96
+ const generation = this._invalidationGeneration;
73
97
  const promise = request.dispatch().then((result) => {
74
- if (undefined !== result)
98
+ const completed = undefined !== result && !request.wasCanceled && generation === this._invalidationGeneration;
99
+ if (completed)
75
100
  this.processResults(result, missing);
76
- return !request.wasCanceled;
101
+ // On failure (result undefined due to query error), do NOT cache empty sets for uncached categories.
102
+ // Leave them absent so getMissing() will include them in subsequent load() retries.
103
+ return completed;
77
104
  });
78
105
  return {
79
106
  missingCategoryIds: missing,
@@ -84,9 +111,16 @@ class SubCategoriesCache {
84
111
  /** Load all subcategories that come from used spatial categories of the iModel into the cache. */
85
112
  async loadAllUsedSpatialSubCategories() {
86
113
  try {
114
+ const generation = this._invalidationGeneration;
87
115
  const results = await this._imodel.queryAllUsedSpatialSubCategories();
88
- if (undefined !== results) {
89
- this.processResults(results, new Set(), false);
116
+ if (generation === this._invalidationGeneration && undefined !== results) {
117
+ const staleCategories = new Set(this._staleCategoryIds);
118
+ // This preload can return partial results on very large iModels, so keep stale categories additive and
119
+ // preserve their stale state until a targeted reload can fully reconcile them.
120
+ for (const row of results)
121
+ this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), staleCategories.has(row.parentId));
122
+ if (staleCategories.size > 0)
123
+ this.markCategoriesStale(staleCategories);
90
124
  }
91
125
  }
92
126
  catch {
@@ -97,7 +131,7 @@ class SubCategoriesCache {
97
131
  getMissing(categoryIds) {
98
132
  let missing;
99
133
  for (const catId of core_bentley_1.Id64.iterable(categoryIds)) {
100
- if (undefined === this._byCategoryId.get(catId)) {
134
+ if (undefined === this._byCategoryId.get(catId) || this.isCategoryStale(catId)) {
101
135
  if (undefined === missing)
102
136
  missing = new Set();
103
137
  missing.add(catId);
@@ -108,6 +142,8 @@ class SubCategoriesCache {
108
142
  clear() {
109
143
  this._byCategoryId.clear();
110
144
  this._appearances.clear();
145
+ this._staleCategoryIds.clear();
146
+ this._invalidationGeneration++;
111
147
  }
112
148
  onIModelConnectionClose() {
113
149
  this.clear();
@@ -118,14 +154,25 @@ class SubCategoriesCache {
118
154
  props = JSON.parse(json);
119
155
  return new core_common_1.SubCategoryAppearance(props);
120
156
  }
121
- processResults(result, missing, override = true) {
157
+ processResults(result, refreshedCategoryIds, override = true) {
158
+ const previousSubCategoryIds = new Map();
159
+ for (const id of refreshedCategoryIds) {
160
+ const previous = this._byCategoryId.get(id);
161
+ if (undefined !== previous)
162
+ previousSubCategoryIds.set(id, previous);
163
+ this._byCategoryId.set(id, new Set());
164
+ this.markCategoryFresh(id);
165
+ }
122
166
  for (const row of result) {
123
167
  this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);
124
168
  }
125
- // 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
126
- for (const id of missing)
127
- if (undefined === this._byCategoryId.get(id))
128
- this._byCategoryId.set(id, invalidCategoryIdEntry);
169
+ for (const [categoryId, previous] of previousSubCategoryIds) {
170
+ const current = this._byCategoryId.get(categoryId);
171
+ for (const subCategoryId of previous) {
172
+ if (!current?.has(subCategoryId))
173
+ this._appearances.delete(subCategoryId);
174
+ }
175
+ }
129
176
  }
130
177
  /** Exposed strictly for tests.
131
178
  * @internal
@@ -135,9 +182,38 @@ class SubCategoriesCache {
135
182
  if (undefined === set)
136
183
  this._byCategoryId.set(categoryId, set = new Set());
137
184
  set.add(subCategoryId);
185
+ this.markCategoryFresh(categoryId);
138
186
  if (override || !this._appearances.has(subCategoryId))
139
187
  this._appearances.set(subCategoryId, appearance);
140
188
  }
189
+ isCategoryStale(categoryId) {
190
+ return this._staleCategoryIds.has(categoryId);
191
+ }
192
+ markCategoryFresh(categoryId) {
193
+ this._staleCategoryIds.delete(categoryId);
194
+ }
195
+ markAllCategoriesStale() {
196
+ // We don't know which cached category the inserted subcategory belongs to, so every currently-cached
197
+ // category may now be missing a subcategory. Mark them all stale so they are re-requested on next load.
198
+ // Categories cached after this point are loaded fresh and are intentionally left out.
199
+ for (const categoryId of this._byCategoryId.keys())
200
+ this._staleCategoryIds.add(categoryId);
201
+ }
202
+ markCategoriesStale(categoryIds) {
203
+ for (const categoryId of categoryIds)
204
+ this._staleCategoryIds.add(categoryId);
205
+ }
206
+ hasStaleCategories() {
207
+ return this._staleCategoryIds.size > 0;
208
+ }
209
+ deleteCategory(categoryId) {
210
+ const subCategoryIds = this._byCategoryId.get(categoryId);
211
+ if (undefined !== subCategoryIds)
212
+ for (const subCategoryId of subCategoryIds)
213
+ this._appearances.delete(subCategoryId);
214
+ this._byCategoryId.delete(categoryId);
215
+ this._staleCategoryIds.delete(categoryId);
216
+ }
141
217
  async getCategoryInfo(inputCategoryIds) {
142
218
  // Eliminate duplicates...
143
219
  const categoryIds = new Set(typeof inputCategoryIds === "string" ? [inputCategoryIds] : inputCategoryIds);
@@ -147,9 +223,7 @@ class SubCategoriesCache {
147
223
  const map = new Map();
148
224
  for (const categoryId of categoryIds) {
149
225
  const subCategoryIds = this._byCategoryId.get(categoryId);
150
- if (!subCategoryIds)
151
- continue;
152
- const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);
226
+ const subCategories = undefined !== subCategoryIds ? this.mapSubCategoryInfos(categoryId, subCategoryIds) : new Map();
153
227
  map.set(categoryId, { id: categoryId, subCategories });
154
228
  }
155
229
  return map;
@@ -206,9 +280,7 @@ exports.SubCategoriesCache = SubCategoriesCache;
206
280
  return undefined;
207
281
  }
208
282
  catch {
209
- // ###TODO: detect cases in which retry is warranted
210
- // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the
211
- // incomplete results. Since we're not retrying, that's the best we can do.
283
+ return undefined;
212
284
  }
213
285
  // Finished with current batch of categoryIds. Dispatch the next batch if one exists.
214
286
  if (++this._curCategoryIdsIndex < this._categoryIds.length) {