@itwin/tree-widget-react 4.0.0-alpha.25 → 4.0.0-alpha.26
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.
- package/CHANGELOG.md +35 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +2 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +36 -47
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +75 -38
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +38 -23
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +11 -21
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +16 -168
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.d.ts +65 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.js +22 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js +4 -4
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +180 -88
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.d.ts +14 -5
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +43 -24
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js +78 -17
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +91 -114
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.d.ts +1 -3
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js +2 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +13 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +62 -32
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.d.ts +12 -9
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js +42 -38
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +15 -38
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +59 -242
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.d.ts +29 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.js +19 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +4 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +154 -78
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js +20 -6
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js +104 -63
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.d.ts +7 -0
- package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.js +14 -0
- package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +7 -5
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +5 -5
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.d.ts +20 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.js +44 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.d.ts +4 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.d.ts +12 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +17 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +58 -29
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +8 -14
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +22 -26
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/{AlwaysAndNeverDrawnElementInfo.d.ts → caches/AlwaysAndNeverDrawnElementInfoCache.d.ts} +15 -21
- package/lib/esm/tree-widget-react/components/trees/common/internal/{AlwaysAndNeverDrawnElementInfo.js → caches/AlwaysAndNeverDrawnElementInfoCache.js} +40 -38
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/AlwaysAndNeverDrawnElementInfoCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.d.ts +68 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.js +148 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.d.ts +30 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.js +151 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.d.ts +32 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.js +106 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/{ModelCategoryElementsCountCache.d.ts → caches/ModelCategoryElementsCountCache.d.ts} +9 -2
- package/lib/esm/tree-widget-react/components/trees/common/internal/{ModelCategoryElementsCountCache.js → caches/ModelCategoryElementsCountCache.js} +17 -21
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModelCategoryElementsCountCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.d.ts +27 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.js +106 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.d.ts +23 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.js +56 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +6 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +27 -17
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +7 -13
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +36 -35
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.d.ts +18 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js +14 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +46 -70
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +229 -361
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +32 -19
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/index.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.d.ts +7 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +36 -35
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +3 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +56 -26
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +5 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +25 -12
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +11 -23
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +56 -189
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.d.ts +52 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.js +22 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js +8 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +179 -72
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js +20 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js +73 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react-internal.d.ts +1 -0
- package/lib/esm/tree-widget-react-internal.js +1 -0
- package/lib/esm/tree-widget-react-internal.js.map +1 -1
- package/package.json +77 -82
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.d.ts +0 -20
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js +0 -53
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +0 -1
|
@@ -2,15 +2,16 @@
|
|
|
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 { BehaviorSubject, bufferCount, debounceTime, defer, EMPTY, filter, first, forkJoin, from, fromEventPattern, map, mergeMap, of, reduce, scan, share, shareReplay, startWith, Subject, switchMap, take, takeUntil, tap, } from "rxjs";
|
|
5
|
+
import { BehaviorSubject, bufferCount, debounceTime, defer, EMPTY, filter, first, forkJoin, from, fromEventPattern, map, mergeMap, of, race, reduce, scan, share, shareReplay, startWith, Subject, switchMap, take, takeUntil, tap, } from "rxjs";
|
|
6
6
|
import { Guid, Id64 } from "@itwin/core-bentley";
|
|
7
7
|
import { createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
8
|
-
import { catchBeSQLiteInterrupts } from "
|
|
9
|
-
import { getClassesByView, getIdsFromChildrenTree, getOptimalBatchSize, releaseMainThreadOnItemsCount, setDifference, updateChildrenTree } from "
|
|
8
|
+
import { catchBeSQLiteInterrupts } from "../UseErrorState.js";
|
|
9
|
+
import { getClassesByView, getIdsFromChildrenTree, getOptimalBatchSize, releaseMainThreadOnItemsCount, setDifference, updateChildrenTree } from "../Utils.js";
|
|
10
10
|
/** @internal */
|
|
11
11
|
export const SET_CHANGE_DEBOUNCE_TIME = 20;
|
|
12
|
+
const ALWAYS_NEVER_BUFFER_THRESHOLD = 5000;
|
|
12
13
|
/** @internal */
|
|
13
|
-
export class
|
|
14
|
+
export class AlwaysAndNeverDrawnElementInfoCache {
|
|
14
15
|
#subscriptions;
|
|
15
16
|
#alwaysDrawn;
|
|
16
17
|
#neverDrawn;
|
|
@@ -22,7 +23,6 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
22
23
|
#suppressors;
|
|
23
24
|
#suppress = new Subject();
|
|
24
25
|
constructor(props) {
|
|
25
|
-
this.#elementClassName = props.elementClassName;
|
|
26
26
|
this.#viewport = props.viewport;
|
|
27
27
|
this.#alwaysDrawn = { cacheEntryObs: this.createCacheEntryObservable("always") };
|
|
28
28
|
this.#neverDrawn = { cacheEntryObs: this.createCacheEntryObservable("never") };
|
|
@@ -30,6 +30,7 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
30
30
|
this.#subscriptions = [this.#alwaysDrawn.cacheEntryObs.subscribe(), this.#neverDrawn.cacheEntryObs.subscribe()];
|
|
31
31
|
this.#componentId = props.componentId ?? Guid.createValue();
|
|
32
32
|
this.#componentName = "AlwaysAndNeverDrawnElementInfo";
|
|
33
|
+
this.#elementClassName = props.elementClassName ? props.elementClassName : getClassesByView(this.#viewport.viewType === "2d" ? "2d" : "3d").elementClass;
|
|
33
34
|
}
|
|
34
35
|
suppressChangeEvents() {
|
|
35
36
|
this.#suppress.next(true);
|
|
@@ -37,13 +38,13 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
37
38
|
resumeChangeEvents() {
|
|
38
39
|
this.#suppress.next(false);
|
|
39
40
|
}
|
|
40
|
-
getElementsTree({ setType,
|
|
41
|
+
getElementsTree({ setType, modelId, ...props }) {
|
|
41
42
|
const cache = setType === "always" ? this.#alwaysDrawn : this.#neverDrawn;
|
|
42
43
|
const getElements = (rootTreeNodes) => {
|
|
43
44
|
if (!rootTreeNodes) {
|
|
44
45
|
return new Map();
|
|
45
46
|
}
|
|
46
|
-
const pathToElements = [
|
|
47
|
+
const pathToElements = [modelId];
|
|
47
48
|
if ("categoryIds" in props && props.categoryIds) {
|
|
48
49
|
pathToElements.push(props.categoryIds);
|
|
49
50
|
if ("parentElementIdsPath" in props && props.parentElementIdsPath) {
|
|
@@ -62,20 +63,6 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
62
63
|
}
|
|
63
64
|
const result = new Map();
|
|
64
65
|
const currentParentIds = pathToElements[currentIdsIndex];
|
|
65
|
-
// currentParentIds is undefined - it means that we are getting children for categories that don't have model as parent
|
|
66
|
-
if (!currentParentIds) {
|
|
67
|
-
for (const entry of currentChildrenTree.values()) {
|
|
68
|
-
if (entry.children) {
|
|
69
|
-
const childrenTreeOfChildren = this.getChildrenTree({
|
|
70
|
-
currentChildrenTree: entry.children,
|
|
71
|
-
pathToElements,
|
|
72
|
-
currentIdsIndex: currentIdsIndex + 1,
|
|
73
|
-
});
|
|
74
|
-
childrenTreeOfChildren.forEach((val, childId) => result.set(childId, val));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
66
|
for (const parentId of Id64.iterable(currentParentIds)) {
|
|
80
67
|
const entry = currentChildrenTree.get(parentId);
|
|
81
68
|
if (entry?.children) {
|
|
@@ -84,7 +71,9 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
84
71
|
pathToElements,
|
|
85
72
|
currentIdsIndex: currentIdsIndex + 1,
|
|
86
73
|
});
|
|
87
|
-
|
|
74
|
+
for (const [childId, childEntry] of childrenTreeOfChildren) {
|
|
75
|
+
result.set(childId, childEntry);
|
|
76
|
+
}
|
|
88
77
|
}
|
|
89
78
|
}
|
|
90
79
|
return result;
|
|
@@ -93,7 +82,11 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
93
82
|
const event = setType === "always" ? this.#viewport.onAlwaysDrawnChanged : this.#viewport.onNeverDrawnChanged;
|
|
94
83
|
const getIds = setType === "always" ? () => this.#viewport.alwaysDrawn : () => this.#viewport.neverDrawn;
|
|
95
84
|
const resultSubject = new BehaviorSubject(undefined);
|
|
96
|
-
|
|
85
|
+
// Observable listens to viewport always/never drawn set change events.
|
|
86
|
+
const sharedObs = fromEventPattern((handler) => event.addListener(handler), (handler) => event.removeListener(handler)).pipe(
|
|
87
|
+
// Return undefined when event is raised.
|
|
88
|
+
map(() => undefined), share());
|
|
89
|
+
const obs = sharedObs.pipe(
|
|
97
90
|
// Fire the observable once at the beginning
|
|
98
91
|
startWith(undefined),
|
|
99
92
|
// Reset result subject as soon as a new event is emitted.
|
|
@@ -105,9 +98,14 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
105
98
|
// Cancel pending request if dispose() is called.
|
|
106
99
|
takeUntil(this.#disposeSubject),
|
|
107
100
|
// If multiple requests are sent at once, preserve only the result of the newest.
|
|
108
|
-
switchMap(() =>
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
switchMap(() =>
|
|
102
|
+
// Race between the event and the query.
|
|
103
|
+
// In cases where event is raised before query returns, the query result is discarded.
|
|
104
|
+
race(sharedObs, defer(() => this.queryAlwaysOrNeverDrawnElementInfo(getIds(), setType)))), tap((cacheEntry) => {
|
|
105
|
+
if (cacheEntry !== undefined) {
|
|
106
|
+
const value = setType === "always" ? this.#alwaysDrawn : this.#neverDrawn;
|
|
107
|
+
value.latestCacheEntryValue = cacheEntry;
|
|
108
|
+
}
|
|
111
109
|
}),
|
|
112
110
|
// Share the result by using a subject which always emits the saved result.
|
|
113
111
|
share({
|
|
@@ -115,7 +113,7 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
115
113
|
resetOnRefCountZero: false,
|
|
116
114
|
}),
|
|
117
115
|
// Wait until the result is available.
|
|
118
|
-
first((x) => !!x
|
|
116
|
+
first((x) => !!x));
|
|
119
117
|
return obs;
|
|
120
118
|
}
|
|
121
119
|
[Symbol.dispose]() {
|
|
@@ -123,9 +121,12 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
123
121
|
this.#subscriptions = [];
|
|
124
122
|
this.#disposeSubject.next();
|
|
125
123
|
}
|
|
126
|
-
queryAlwaysOrNeverDrawnElementInfo(set,
|
|
124
|
+
queryAlwaysOrNeverDrawnElementInfo(set, setType) {
|
|
127
125
|
const elementInfo = set?.size
|
|
128
|
-
?
|
|
126
|
+
? set.size > ALWAYS_NEVER_BUFFER_THRESHOLD
|
|
127
|
+
? // When set is larger, buffer helps to not block main thread for long periods of time
|
|
128
|
+
from(set).pipe(bufferCount(getOptimalBatchSize({ totalSize: set.size, maximumBatchSize: ALWAYS_NEVER_BUFFER_THRESHOLD })), releaseMainThreadOnItemsCount(2), mergeMap((block, index) => this.queryElementInfo(block, `${setType}-${index}`), 10))
|
|
129
|
+
: this.queryElementInfo([...set], `${setType}-0`)
|
|
129
130
|
: EMPTY;
|
|
130
131
|
return elementInfo.pipe(releaseMainThreadOnItemsCount(500), reduce((acc, { categoryId, rootCategoryId, modelId, elementsPath }) => {
|
|
131
132
|
const elementIdInList = elementsPath[elementsPath.length - 1];
|
|
@@ -139,14 +140,11 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
139
140
|
};
|
|
140
141
|
updateChildrenTree({ tree: acc, idsToAdd: [modelId, rootCategoryId, ...elementsPath], additionalPropsGetter });
|
|
141
142
|
return acc;
|
|
142
|
-
},
|
|
143
|
+
}, new Map()));
|
|
143
144
|
}
|
|
144
145
|
queryElementInfo(elementIds, requestId) {
|
|
145
146
|
return defer(() => {
|
|
146
147
|
const executor = createECSqlQueryExecutor(this.#viewport.iModel);
|
|
147
|
-
const { elementClass } = this.#elementClassName
|
|
148
|
-
? { elementClass: this.#elementClassName }
|
|
149
|
-
: getClassesByView(this.#viewport.viewType === "2d" ? "2d" : "3d");
|
|
150
148
|
return executor.createQueryReader({
|
|
151
149
|
ctes: [
|
|
152
150
|
`
|
|
@@ -157,7 +155,7 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
157
155
|
Category.Id categoryId,
|
|
158
156
|
Parent.Id parentId,
|
|
159
157
|
CAST(IdToHex(ECInstanceId) AS TEXT) elementsPath
|
|
160
|
-
FROM ${
|
|
158
|
+
FROM ${this.#elementClassName}
|
|
161
159
|
WHERE InVirtualSet(?, ECInstanceId)
|
|
162
160
|
|
|
163
161
|
UNION ALL
|
|
@@ -168,7 +166,7 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
168
166
|
e.categoryId categoryId,
|
|
169
167
|
p.Parent.Id parentId,
|
|
170
168
|
CAST(IdToHex(p.ECInstanceId) AS TEXT) || ';' || e.elementsPath
|
|
171
|
-
FROM ${
|
|
169
|
+
FROM ${this.#elementClassName} p
|
|
172
170
|
JOIN ElementInfo e ON p.ECInstanceId = e.parentId
|
|
173
171
|
)
|
|
174
172
|
`,
|
|
@@ -192,8 +190,12 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
192
190
|
}
|
|
193
191
|
clearAlwaysAndNeverDrawnElements(props) {
|
|
194
192
|
return forkJoin({
|
|
195
|
-
alwaysDrawn: this.
|
|
196
|
-
|
|
193
|
+
alwaysDrawn: this.#viewport.alwaysDrawn?.size
|
|
194
|
+
? this.getAlwaysOrNeverDrawnElements({ modelId: props.modelId, categoryIds: props.categoryIds, setType: "always" })
|
|
195
|
+
: of(new Set()),
|
|
196
|
+
neverDrawn: this.#viewport.neverDrawn?.size
|
|
197
|
+
? this.getAlwaysOrNeverDrawnElements({ modelId: props.modelId, categoryIds: props.categoryIds, setType: "never" })
|
|
198
|
+
: of(new Set()),
|
|
197
199
|
}).pipe(map(({ alwaysDrawn, neverDrawn }) => {
|
|
198
200
|
const viewport = this.#viewport;
|
|
199
201
|
if (viewport.alwaysDrawn?.size && alwaysDrawn.size) {
|
|
@@ -205,4 +207,4 @@ export class AlwaysAndNeverDrawnElementInfo {
|
|
|
205
207
|
}));
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
|
-
//# sourceMappingURL=
|
|
210
|
+
//# sourceMappingURL=AlwaysAndNeverDrawnElementInfoCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlwaysAndNeverDrawnElementInfoCache.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/common/internal/caches/AlwaysAndNeverDrawnElementInfoCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,GAAG,EACH,QAAQ,EACR,EAAE,EACF,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,SAAS,EACT,IAAI,EACJ,SAAS,EACT,GAAG,GACJ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAO9J,gBAAgB;AAChB,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,6BAA6B,GAAG,IAAI,CAAC;AA8C3C,gBAAgB;AAChB,MAAM,OAAO,mCAAmC;IAC9C,cAAc,CAAiB;IAC/B,YAAY,CAAwF;IACpG,WAAW,CAAwF;IACnG,eAAe,GAAG,IAAI,OAAO,EAAQ,CAAC;IAC7B,SAAS,CAAqB;IAC9B,iBAAiB,CAAS;IACnC,YA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AE,CAAC;gBACnH,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,EAAc,CAAC;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI;gBACzC,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;gBAClH,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,EAAc,CAAC;SAC9B,CAAC,CAAC,IAAI,CACL,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;YAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;YAChC,IAAI,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;gBACnD,QAAQ,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;YAC5F,CAAC;YACD,IAAI,QAAQ,CAAC,UAAU,EAAE,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;gBACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;YACzF,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport {\n BehaviorSubject,\n bufferCount,\n debounceTime,\n defer,\n EMPTY,\n filter,\n first,\n forkJoin,\n from,\n fromEventPattern,\n map,\n mergeMap,\n of,\n race,\n reduce,\n scan,\n share,\n shareReplay,\n startWith,\n Subject,\n switchMap,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { catchBeSQLiteInterrupts } from \"../UseErrorState.js\";\nimport { getClassesByView, getIdsFromChildrenTree, getOptimalBatchSize, releaseMainThreadOnItemsCount, setDifference, updateChildrenTree } from \"../Utils.js\";\n\nimport type { Observable, Subscription } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { TreeWidgetViewport } from \"../../TreeWidgetViewport.js\";\nimport type { ChildrenTree } from \"../Utils.js\";\n\n/** @internal */\nexport const SET_CHANGE_DEBOUNCE_TIME = 20;\nconst ALWAYS_NEVER_BUFFER_THRESHOLD = 5000;\n\ntype SetType = \"always\" | \"never\";\n\ninterface GetElementsTreeByModelProps {\n /** Only always/never drawn elements that have the specified model will be returned. */\n modelId: Id64String;\n /**\n * The type of set from which tree should be retrieved.\n * `always` - ChildrenTree will be created from `alwaysDrawn` set.\n * `never` - ChildrenTree will be created from `neverDrawn` set.\n */\n setType: SetType;\n}\ninterface GetElementsTreeByCategoryProps extends GetElementsTreeByModelProps {\n /**\n * Categories of root elements.\n *\n * Elements are filtered by given categories. Children of those elements are also included, no matter their category.\n */\n categoryIds: Id64Arg;\n}\n\ninterface GetElementsTreeByElementProps extends GetElementsTreeByCategoryProps {\n /** Path to element for which to get its' child always/never drawn elements. When undefined, models and categories will be used to get the always/never drawn elements. */\n parentElementIdsPath: Array<Id64Arg>;\n}\n\n/** @internal */\nexport type GetElementsTreeProps = GetElementsTreeByModelProps | GetElementsTreeByCategoryProps | GetElementsTreeByElementProps;\n\n/**\n * - `categoryId` is assigned only to the elements in always/never drawn set.\n * - `isInAlwaysOrNeverDrawnSet` flag determines if key (ECInstanceId) is in always/never set.\n * @internal\n */\nexport type MapEntry = { isInAlwaysOrNeverDrawnSet: true; categoryId: Id64String } | { isInAlwaysOrNeverDrawnSet: false };\n\ntype CachedNodesMap = ChildrenTree<MapEntry>;\n\ninterface AlwaysAndNeverDrawnElementInfoCacheProps {\n viewport: TreeWidgetViewport;\n elementClassName?: string;\n componentId?: GuidString;\n}\n\n/** @internal */\nexport class AlwaysAndNeverDrawnElementInfoCache implements Disposable {\n #subscriptions: Subscription[];\n #alwaysDrawn: { cacheEntryObs: Observable<CachedNodesMap>; latestCacheEntryValue?: CachedNodesMap };\n #neverDrawn: { cacheEntryObs: Observable<CachedNodesMap>; latestCacheEntryValue?: CachedNodesMap };\n #disposeSubject = new Subject<void>();\n readonly #viewport: TreeWidgetViewport;\n readonly #elementClassName: string;\n #componentId: GuidString;\n #componentName: string;\n\n #suppressors: Observable<number>;\n #suppress = new Subject<boolean>();\n\n constructor(props: AlwaysAndNeverDrawnElementInfoCacheProps) {\n this.#viewport = props.viewport;\n this.#alwaysDrawn = { cacheEntryObs: this.createCacheEntryObservable(\"always\") };\n this.#neverDrawn = { cacheEntryObs: this.createCacheEntryObservable(\"never\") };\n this.#suppressors = this.#suppress.pipe(\n scan((acc, suppress) => acc + (suppress ? 1 : -1), 0),\n startWith(0),\n shareReplay(1),\n );\n this.#subscriptions = [this.#alwaysDrawn.cacheEntryObs.subscribe(), this.#neverDrawn.cacheEntryObs.subscribe()];\n this.#componentId = props.componentId ?? Guid.createValue();\n this.#componentName = \"AlwaysAndNeverDrawnElementInfo\";\n this.#elementClassName = props.elementClassName ? props.elementClassName : getClassesByView(this.#viewport.viewType === \"2d\" ? \"2d\" : \"3d\").elementClass;\n }\n\n public suppressChangeEvents() {\n this.#suppress.next(true);\n }\n\n public resumeChangeEvents() {\n this.#suppress.next(false);\n }\n\n public getElementsTree({ setType, modelId, ...props }: GetElementsTreeProps): Observable<CachedNodesMap> {\n const cache = setType === \"always\" ? this.#alwaysDrawn : this.#neverDrawn;\n const getElements = (rootTreeNodes: CachedNodesMap | undefined): CachedNodesMap => {\n if (!rootTreeNodes) {\n return new Map();\n }\n const pathToElements: Array<Id64Arg> = [modelId];\n if (\"categoryIds\" in props && props.categoryIds) {\n pathToElements.push(props.categoryIds);\n if (\"parentElementIdsPath\" in props && props.parentElementIdsPath) {\n props.parentElementIdsPath.forEach((parentElementIds) => pathToElements.push(parentElementIds));\n }\n }\n return this.getChildrenTree({ currentChildrenTree: rootTreeNodes, pathToElements, currentIdsIndex: 0 });\n };\n\n return !cache.latestCacheEntryValue\n ? cache.cacheEntryObs.pipe(map(getElements))\n : this.#suppressors.pipe(\n take(1),\n mergeMap((suppressionCount) =>\n suppressionCount > 0 ? of(cache.latestCacheEntryValue).pipe(map(getElements)) : cache.cacheEntryObs.pipe(map(getElements)),\n ),\n );\n }\n\n private getChildrenTree({\n currentChildrenTree,\n pathToElements,\n currentIdsIndex,\n }: {\n currentChildrenTree: ChildrenTree<MapEntry>;\n pathToElements: Array<Id64Arg>;\n currentIdsIndex: number;\n }): ChildrenTree<MapEntry> {\n if (currentIdsIndex >= pathToElements.length) {\n return currentChildrenTree;\n }\n const result: ChildrenTree<MapEntry> = new Map();\n const currentParentIds = pathToElements[currentIdsIndex];\n for (const parentId of Id64.iterable(currentParentIds)) {\n const entry = currentChildrenTree.get(parentId);\n if (entry?.children) {\n const childrenTreeOfChildren = this.getChildrenTree({\n currentChildrenTree: entry.children,\n pathToElements,\n currentIdsIndex: currentIdsIndex + 1,\n });\n for (const [childId, childEntry] of childrenTreeOfChildren) {\n result.set(childId, childEntry);\n }\n }\n }\n return result;\n }\n\n private createCacheEntryObservable(setType: SetType): Observable<CachedNodesMap> {\n const event = setType === \"always\" ? this.#viewport.onAlwaysDrawnChanged : this.#viewport.onNeverDrawnChanged;\n const getIds = setType === \"always\" ? () => this.#viewport.alwaysDrawn : () => this.#viewport.neverDrawn;\n\n const resultSubject = new BehaviorSubject<CachedNodesMap | undefined>(undefined);\n // Observable listens to viewport always/never drawn set change events.\n const sharedObs = fromEventPattern(\n (handler) => event.addListener(handler),\n (handler) => event.removeListener(handler),\n ).pipe(\n // Return undefined when event is raised.\n map(() => undefined),\n share(),\n );\n const obs = sharedObs.pipe(\n // Fire the observable once at the beginning\n startWith(undefined),\n // Reset result subject as soon as a new event is emitted.\n // This will make newly subscribed observers wait for the debounce period to pass\n // instead of consuming the cached value which at this point becomes invalid.\n tap(() => resultSubject.next(undefined)),\n // Check if cache updates are not suppressed.\n switchMap(() =>\n this.#suppressors.pipe(\n filter((suppressors) => suppressors === 0),\n take(1),\n ),\n ),\n debounceTime(SET_CHANGE_DEBOUNCE_TIME),\n // Cancel pending request if dispose() is called.\n takeUntil(this.#disposeSubject),\n // If multiple requests are sent at once, preserve only the result of the newest.\n switchMap(() =>\n // Race between the event and the query.\n // In cases where event is raised before query returns, the query result is discarded.\n race(\n sharedObs,\n defer(() => this.queryAlwaysOrNeverDrawnElementInfo(getIds(), setType)),\n ),\n ),\n tap((cacheEntry) => {\n if (cacheEntry !== undefined) {\n const value = setType === \"always\" ? this.#alwaysDrawn : this.#neverDrawn;\n value.latestCacheEntryValue = cacheEntry;\n }\n }),\n // Share the result by using a subject which always emits the saved result.\n share({\n connector: () => resultSubject,\n resetOnRefCountZero: false,\n }),\n // Wait until the result is available.\n first((x): x is CachedNodesMap => !!x),\n );\n return obs;\n }\n\n public [Symbol.dispose](): void {\n this.#subscriptions.forEach((x) => x.unsubscribe());\n this.#subscriptions = [];\n this.#disposeSubject.next();\n }\n\n private queryAlwaysOrNeverDrawnElementInfo(set: ReadonlySet<Id64String> | undefined, setType: SetType): Observable<CachedNodesMap> {\n const elementInfo = set?.size\n ? set.size > ALWAYS_NEVER_BUFFER_THRESHOLD\n ? // When set is larger, buffer helps to not block main thread for long periods of time\n from(set).pipe(\n bufferCount(getOptimalBatchSize({ totalSize: set.size, maximumBatchSize: ALWAYS_NEVER_BUFFER_THRESHOLD })),\n releaseMainThreadOnItemsCount(2),\n mergeMap((block, index) => this.queryElementInfo(block, `${setType}-${index}`), 10),\n )\n : this.queryElementInfo([...set], `${setType}-0`)\n : EMPTY;\n return elementInfo.pipe(\n releaseMainThreadOnItemsCount(500),\n reduce((acc: CachedNodesMap, { categoryId, rootCategoryId, modelId, elementsPath }) => {\n const elementIdInList = elementsPath[elementsPath.length - 1];\n const additionalPropsGetter = (id: Id64String, additionalProps?: MapEntry): MapEntry => {\n if (id === elementIdInList) {\n // Last element in elementsPath is in always/never drawn set. We want to mark, that it is in the set, and save it's categoryId.\n return { isInAlwaysOrNeverDrawnSet: true, categoryId };\n }\n // Existing entries can keep their value, if it's a new entry it's not in the list.\n return additionalProps ?? { isInAlwaysOrNeverDrawnSet: false };\n };\n updateChildrenTree({ tree: acc, idsToAdd: [modelId, rootCategoryId, ...elementsPath], additionalPropsGetter });\n return acc;\n }, new Map()),\n );\n }\n\n private queryElementInfo(\n elementIds: Id64Array,\n requestId: string,\n ): Observable<{\n rootCategoryId: Id64String;\n modelId: Id64String;\n categoryId: Id64String;\n elementsPath: Id64Array;\n }> {\n return defer(() => {\n const executor = createECSqlQueryExecutor(this.#viewport.iModel);\n return executor.createQueryReader(\n {\n ctes: [\n `\n ElementInfo(modelId, rootCategoryId, categoryId, parentId, elementsPath) AS (\n SELECT\n Model.Id modelId,\n Category.Id rootCategoryId,\n Category.Id categoryId,\n Parent.Id parentId,\n CAST(IdToHex(ECInstanceId) AS TEXT) elementsPath\n FROM ${this.#elementClassName}\n WHERE InVirtualSet(?, ECInstanceId)\n\n UNION ALL\n\n SELECT\n e.modelId modelId,\n p.Category.Id rootCategoryId,\n e.categoryId categoryId,\n p.Parent.Id parentId,\n CAST(IdToHex(p.ECInstanceId) AS TEXT) || ';' || e.elementsPath\n FROM ${this.#elementClassName} p\n JOIN ElementInfo e ON p.ECInstanceId = e.parentId\n )\n `,\n ],\n ecsql: `\n SELECT elementsPath elementsPath, modelId modelId, categoryId categoryId, rootCategoryId rootCategoryId\n FROM ElementInfo\n WHERE parentId IS NULL\n `,\n bindings: [{ type: \"idset\", value: elementIds }],\n },\n {\n rowFormat: \"ECSqlPropertyNames\",\n restartToken: `${this.#componentName}/${this.#componentId}/${requestId}`,\n },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return { elementsPath: row.elementsPath.split(\";\"), modelId: row.modelId, categoryId: row.categoryId, rootCategoryId: row.rootCategoryId };\n }),\n );\n }\n\n public getAlwaysOrNeverDrawnElements(props: GetElementsTreeProps) {\n return this.getElementsTree(props).pipe(\n map((childrenTree) => getIdsFromChildrenTree({ tree: childrenTree, predicate: ({ treeEntry }) => treeEntry.isInAlwaysOrNeverDrawnSet })),\n );\n }\n\n public clearAlwaysAndNeverDrawnElements(props: { categoryIds: Id64Arg; modelId: Id64String }) {\n return forkJoin({\n alwaysDrawn: this.#viewport.alwaysDrawn?.size\n ? this.getAlwaysOrNeverDrawnElements({ modelId: props.modelId, categoryIds: props.categoryIds, setType: \"always\" })\n : of(new Set<Id64String>()),\n neverDrawn: this.#viewport.neverDrawn?.size\n ? this.getAlwaysOrNeverDrawnElements({ modelId: props.modelId, categoryIds: props.categoryIds, setType: \"never\" })\n : of(new Set<Id64String>()),\n }).pipe(\n map(({ alwaysDrawn, neverDrawn }) => {\n const viewport = this.#viewport;\n if (viewport.alwaysDrawn?.size && alwaysDrawn.size) {\n viewport.setAlwaysDrawn({ elementIds: setDifference(viewport.alwaysDrawn, alwaysDrawn) });\n }\n if (viewport.neverDrawn?.size && neverDrawn.size) {\n viewport.setNeverDrawn({ elementIds: setDifference(viewport.neverDrawn, neverDrawn) });\n }\n }),\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ElementChildrenCache } from "./ElementChildrenCache.js";
|
|
2
|
+
import { ElementModelCategoriesCache } from "./ElementModelCategoriesCache.js";
|
|
3
|
+
import { ModelCategoryElementsCountCache } from "./ModelCategoryElementsCountCache.js";
|
|
4
|
+
import { ModeledElementsCache } from "./ModeledElementsCache.js";
|
|
5
|
+
import { SubCategoriesCache } from "./SubCategoriesCache.js";
|
|
6
|
+
import type { Observable } from "rxjs";
|
|
7
|
+
import type { Id64Array, Id64String } from "@itwin/core-bentley";
|
|
8
|
+
import type { LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
9
|
+
import type { Props } from "@itwin/presentation-shared";
|
|
10
|
+
/** @internal */
|
|
11
|
+
export interface BaseIdsCacheProps {
|
|
12
|
+
queryExecutor: LimitingECSqlQueryExecutor;
|
|
13
|
+
elementClassName: string;
|
|
14
|
+
type: "2d" | "3d";
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
export declare class BaseIdsCache implements Disposable {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(props: BaseIdsCacheProps);
|
|
20
|
+
[Symbol.dispose](): void;
|
|
21
|
+
getSubModels(props: {
|
|
22
|
+
modelId: Id64String;
|
|
23
|
+
categoryId?: Id64String;
|
|
24
|
+
} | {
|
|
25
|
+
categoryId: Id64String;
|
|
26
|
+
modelId: Id64String | undefined;
|
|
27
|
+
}): Observable<Id64Array>;
|
|
28
|
+
getAllModels(): ReturnType<ElementModelCategoriesCache["getAllModels"]>;
|
|
29
|
+
getCategories(props: Props<ElementModelCategoriesCache["getModelCategoryIds"]>): ReturnType<ElementModelCategoriesCache["getModelCategoryIds"]>;
|
|
30
|
+
getAllCategoriesOfElements(): ReturnType<ElementModelCategoriesCache["getAllCategoriesOfElements"]>;
|
|
31
|
+
getModels(props: Props<ElementModelCategoriesCache["getCategoryElementModels"]>): ReturnType<ElementModelCategoriesCache["getCategoryElementModels"]>;
|
|
32
|
+
getCategoriesOfModelsTopMostElements(props: Props<ElementModelCategoriesCache["getCategoriesOfModelsTopMostElements"]>): ReturnType<ElementModelCategoriesCache["getCategoriesOfModelsTopMostElements"]>;
|
|
33
|
+
getElementsCount(props: Props<ModelCategoryElementsCountCache["getCategoryElementsCount"]>): ReturnType<ModelCategoryElementsCountCache["getCategoryElementsCount"]>;
|
|
34
|
+
getChildElementsTree(props: Props<ElementChildrenCache["getChildElementsTree"]>): ReturnType<ElementChildrenCache["getChildElementsTree"]>;
|
|
35
|
+
getAllChildElementsCount(props: Props<ElementChildrenCache["getAllChildElementsCount"]>): ReturnType<ElementChildrenCache["getAllChildElementsCount"]>;
|
|
36
|
+
getSubCategories(props: Props<SubCategoriesCache["getSubCategories"]>): ReturnType<SubCategoriesCache["getSubCategories"]>;
|
|
37
|
+
getSubCategoriesInfo(): ReturnType<SubCategoriesCache["getSubCategoriesInfo"]>;
|
|
38
|
+
getSubModelsUnderElement(props: Props<ModeledElementsCache["getSubModelsUnderElement"]>): ReturnType<ModeledElementsCache["getSubModelsUnderElement"]>;
|
|
39
|
+
getModeledElementsInfo(): ReturnType<ModeledElementsCache["getModeledElementsInfo"]>;
|
|
40
|
+
}
|
|
41
|
+
/** @internal */
|
|
42
|
+
export interface BaseIdsCacheImplProps {
|
|
43
|
+
baseIdsCache: BaseIdsCache;
|
|
44
|
+
}
|
|
45
|
+
/** @internal */
|
|
46
|
+
export declare class BaseIdsCacheImpl implements Disposable {
|
|
47
|
+
#private;
|
|
48
|
+
constructor(props: BaseIdsCacheImplProps);
|
|
49
|
+
[Symbol.dispose](): void;
|
|
50
|
+
getChildElementsTree(props: Props<ElementChildrenCache["getChildElementsTree"]>): ReturnType<ElementChildrenCache["getChildElementsTree"]>;
|
|
51
|
+
getAllChildElementsCount(props: Props<ElementChildrenCache["getAllChildElementsCount"]>): ReturnType<ElementChildrenCache["getAllChildElementsCount"]>;
|
|
52
|
+
getSubCategories(props: Props<SubCategoriesCache["getSubCategories"]>): ReturnType<SubCategoriesCache["getSubCategories"]>;
|
|
53
|
+
getSubModels(props: {
|
|
54
|
+
modelId: Id64String;
|
|
55
|
+
categoryId?: Id64String;
|
|
56
|
+
} | {
|
|
57
|
+
categoryId: Id64String;
|
|
58
|
+
modelId: Id64String | undefined;
|
|
59
|
+
}): Observable<Id64Array>;
|
|
60
|
+
getSubModelsUnderElement(props: Props<ModeledElementsCache["getSubModelsUnderElement"]>): ReturnType<ModeledElementsCache["getSubModelsUnderElement"]>;
|
|
61
|
+
getElementsCount(props: Props<ModelCategoryElementsCountCache["getCategoryElementsCount"]>): ReturnType<ModelCategoryElementsCountCache["getCategoryElementsCount"]>;
|
|
62
|
+
getCategories(props: Props<ElementModelCategoriesCache["getModelCategoryIds"]>): ReturnType<ElementModelCategoriesCache["getModelCategoryIds"]>;
|
|
63
|
+
getModels(props: Props<ElementModelCategoriesCache["getCategoryElementModels"]>): ReturnType<ElementModelCategoriesCache["getCategoryElementModels"]>;
|
|
64
|
+
getAllCategoriesOfElements(): ReturnType<ElementModelCategoriesCache["getAllCategoriesOfElements"]>;
|
|
65
|
+
getCategoriesOfModelsTopMostElements(props: Props<BaseIdsCache["getCategoriesOfModelsTopMostElements"]>): ReturnType<BaseIdsCache["getCategoriesOfModelsTopMostElements"]>;
|
|
66
|
+
getSubCategoriesInfo(): ReturnType<SubCategoriesCache["getSubCategoriesInfo"]>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=BaseIdsCache.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { mergeAll, mergeMap, toArray } from "rxjs";
|
|
6
|
+
import { Guid } from "@itwin/core-bentley";
|
|
7
|
+
import { ElementChildrenCache } from "./ElementChildrenCache.js";
|
|
8
|
+
import { ElementModelCategoriesCache } from "./ElementModelCategoriesCache.js";
|
|
9
|
+
import { ModelCategoryElementsCountCache } from "./ModelCategoryElementsCountCache.js";
|
|
10
|
+
import { ModeledElementsCache } from "./ModeledElementsCache.js";
|
|
11
|
+
import { SubCategoriesCache } from "./SubCategoriesCache.js";
|
|
12
|
+
/** @internal */
|
|
13
|
+
export class BaseIdsCache {
|
|
14
|
+
#queryExecutor;
|
|
15
|
+
#componentId;
|
|
16
|
+
#categoryElementCounts;
|
|
17
|
+
#elementChildrenCache;
|
|
18
|
+
#subCategoriesCache;
|
|
19
|
+
#modeledElementsCache;
|
|
20
|
+
#elementModelCategoriesCache;
|
|
21
|
+
constructor(props) {
|
|
22
|
+
this.#queryExecutor = props.queryExecutor;
|
|
23
|
+
this.#componentId = Guid.createValue();
|
|
24
|
+
this.#categoryElementCounts = new ModelCategoryElementsCountCache({
|
|
25
|
+
elementClassName: props.elementClassName,
|
|
26
|
+
componentId: this.#componentId,
|
|
27
|
+
queryExecutor: this.#queryExecutor,
|
|
28
|
+
});
|
|
29
|
+
this.#elementChildrenCache = new ElementChildrenCache({
|
|
30
|
+
queryExecutor: this.#queryExecutor,
|
|
31
|
+
elementClassName: props.elementClassName,
|
|
32
|
+
componentId: this.#componentId,
|
|
33
|
+
});
|
|
34
|
+
this.#subCategoriesCache = new SubCategoriesCache({
|
|
35
|
+
queryExecutor: this.#queryExecutor,
|
|
36
|
+
componentId: this.#componentId,
|
|
37
|
+
});
|
|
38
|
+
this.#modeledElementsCache = new ModeledElementsCache({
|
|
39
|
+
queryExecutor: this.#queryExecutor,
|
|
40
|
+
componentId: this.#componentId,
|
|
41
|
+
elementClassName: props.elementClassName,
|
|
42
|
+
});
|
|
43
|
+
this.#elementModelCategoriesCache = new ElementModelCategoriesCache({
|
|
44
|
+
queryExecutor: this.#queryExecutor,
|
|
45
|
+
componentId: this.#componentId,
|
|
46
|
+
elementClassName: props.elementClassName,
|
|
47
|
+
modeledElementsCache: this.#modeledElementsCache,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
[Symbol.dispose]() {
|
|
51
|
+
this.#categoryElementCounts[Symbol.dispose]();
|
|
52
|
+
}
|
|
53
|
+
// Implement get sub-models method
|
|
54
|
+
getSubModels(props) {
|
|
55
|
+
if (props.modelId) {
|
|
56
|
+
if (props.categoryId) {
|
|
57
|
+
return this.#modeledElementsCache.getCategoryModeledElements({ modelId: props.modelId, categoryId: props.categoryId }).pipe(toArray());
|
|
58
|
+
}
|
|
59
|
+
return this.#elementModelCategoriesCache.getModelCategoryIds({ modelId: props.modelId }).pipe(mergeAll(), mergeMap((modelCategoryId) => this.#modeledElementsCache.getCategoryModeledElements({ modelId: props.modelId, categoryId: modelCategoryId })), toArray());
|
|
60
|
+
}
|
|
61
|
+
return this.#elementModelCategoriesCache.getCategoryElementModels({ categoryId: props.categoryId }).pipe(mergeAll(), mergeMap((modelId) => this.#modeledElementsCache.getCategoryModeledElements({ modelId, categoryId: props.categoryId })), toArray());
|
|
62
|
+
}
|
|
63
|
+
// Re-export cache methods
|
|
64
|
+
// ElementModelCategoriesCache methods
|
|
65
|
+
getAllModels() {
|
|
66
|
+
return this.#elementModelCategoriesCache.getAllModels();
|
|
67
|
+
}
|
|
68
|
+
getCategories(props) {
|
|
69
|
+
return this.#elementModelCategoriesCache.getModelCategoryIds(props);
|
|
70
|
+
}
|
|
71
|
+
getAllCategoriesOfElements() {
|
|
72
|
+
return this.#elementModelCategoriesCache.getAllCategoriesOfElements();
|
|
73
|
+
}
|
|
74
|
+
getModels(props) {
|
|
75
|
+
return this.#elementModelCategoriesCache.getCategoryElementModels(props);
|
|
76
|
+
}
|
|
77
|
+
getCategoriesOfModelsTopMostElements(props) {
|
|
78
|
+
return this.#elementModelCategoriesCache.getCategoriesOfModelsTopMostElements(props);
|
|
79
|
+
}
|
|
80
|
+
// ModelCategoryElementsCountCache methods
|
|
81
|
+
getElementsCount(props) {
|
|
82
|
+
return this.#categoryElementCounts.getCategoryElementsCount(props);
|
|
83
|
+
}
|
|
84
|
+
// ElementChildrenCache methods
|
|
85
|
+
getChildElementsTree(props) {
|
|
86
|
+
return this.#elementChildrenCache.getChildElementsTree(props);
|
|
87
|
+
}
|
|
88
|
+
getAllChildElementsCount(props) {
|
|
89
|
+
return this.#elementChildrenCache.getAllChildElementsCount(props);
|
|
90
|
+
}
|
|
91
|
+
// SubCategoriesCache methods
|
|
92
|
+
getSubCategories(props) {
|
|
93
|
+
return this.#subCategoriesCache.getSubCategories(props);
|
|
94
|
+
}
|
|
95
|
+
getSubCategoriesInfo() {
|
|
96
|
+
return this.#subCategoriesCache.getSubCategoriesInfo();
|
|
97
|
+
}
|
|
98
|
+
// ModeledElementsCache methods
|
|
99
|
+
getSubModelsUnderElement(props) {
|
|
100
|
+
return this.#modeledElementsCache.getSubModelsUnderElement(props);
|
|
101
|
+
}
|
|
102
|
+
getModeledElementsInfo() {
|
|
103
|
+
return this.#modeledElementsCache.getModeledElementsInfo();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** @internal */
|
|
107
|
+
export class BaseIdsCacheImpl {
|
|
108
|
+
#baseIdsCache;
|
|
109
|
+
constructor(props) {
|
|
110
|
+
this.#baseIdsCache = props.baseIdsCache;
|
|
111
|
+
}
|
|
112
|
+
[Symbol.dispose]() { }
|
|
113
|
+
// Implement IBaseIdsCache by re-exporting BaseIdsCache methods
|
|
114
|
+
getChildElementsTree(props) {
|
|
115
|
+
return this.#baseIdsCache.getChildElementsTree(props);
|
|
116
|
+
}
|
|
117
|
+
getAllChildElementsCount(props) {
|
|
118
|
+
return this.#baseIdsCache.getAllChildElementsCount(props);
|
|
119
|
+
}
|
|
120
|
+
getSubCategories(props) {
|
|
121
|
+
return this.#baseIdsCache.getSubCategories(props);
|
|
122
|
+
}
|
|
123
|
+
getSubModels(props) {
|
|
124
|
+
return this.#baseIdsCache.getSubModels(props);
|
|
125
|
+
}
|
|
126
|
+
getSubModelsUnderElement(props) {
|
|
127
|
+
return this.#baseIdsCache.getSubModelsUnderElement(props);
|
|
128
|
+
}
|
|
129
|
+
getElementsCount(props) {
|
|
130
|
+
return this.#baseIdsCache.getElementsCount(props);
|
|
131
|
+
}
|
|
132
|
+
getCategories(props) {
|
|
133
|
+
return this.#baseIdsCache.getCategories(props);
|
|
134
|
+
}
|
|
135
|
+
getModels(props) {
|
|
136
|
+
return this.#baseIdsCache.getModels(props);
|
|
137
|
+
}
|
|
138
|
+
getAllCategoriesOfElements() {
|
|
139
|
+
return this.#baseIdsCache.getAllCategoriesOfElements();
|
|
140
|
+
}
|
|
141
|
+
getCategoriesOfModelsTopMostElements(props) {
|
|
142
|
+
return this.#baseIdsCache.getCategoriesOfModelsTopMostElements(props);
|
|
143
|
+
}
|
|
144
|
+
getSubCategoriesInfo() {
|
|
145
|
+
return this.#baseIdsCache.getSubCategoriesInfo();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=BaseIdsCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseIdsCache.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAc7D,gBAAgB;AAChB,MAAM,OAAO,YAAY;IACvB,cAAc,CAA6B;IAC3C,YAAY,CAAa;IAChB,sBAAsB,CAAkC;IACxD,qBAAqB,CAAuB;IAC5C,mBAAmB,CAAqB;IACxC,qBAAqB,CAAuB;IAC5C,4BAA4B,CAA8B;IAEnE,YAAY,KAAwB;QAClC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,sBAAsB,GAAG,IAAI,+BAA+B,CAAC;YAChE,gBAAgB,EA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CAAC,CAAC;IAC5D,CAAC;IAEM,gBAAgB,CAAC,KAAoD;QAC1E,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,YAAY,CACjB,KAAqH;QAErH,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,wBAAwB,CAC7B,KAA8D;QAE9D,OAAO,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAEM,gBAAgB,CACrB,KAAyE;QAEzE,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,aAAa,CAAC,KAAgE;QACnF,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAEM,SAAS,CAAC,KAAqE;QACpF,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAEM,0BAA0B;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAEM,oCAAoC,CACzC,KAAkE;QAElE,OAAO,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;IACM,oBAAoB;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,EAAE,CAAC;IACnD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { mergeAll, mergeMap, toArray } from \"rxjs\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { ElementChildrenCache } from \"./ElementChildrenCache.js\";\nimport { ElementModelCategoriesCache } from \"./ElementModelCategoriesCache.js\";\nimport { ModelCategoryElementsCountCache } from \"./ModelCategoryElementsCountCache.js\";\nimport { ModeledElementsCache } from \"./ModeledElementsCache.js\";\nimport { SubCategoriesCache } from \"./SubCategoriesCache.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { Props } from \"@itwin/presentation-shared\";\n\n/** @internal */\nexport interface BaseIdsCacheProps {\n queryExecutor: LimitingECSqlQueryExecutor;\n elementClassName: string;\n type: \"2d\" | \"3d\";\n}\n\n/** @internal */\nexport class BaseIdsCache implements Disposable {\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n readonly #categoryElementCounts: ModelCategoryElementsCountCache;\n readonly #elementChildrenCache: ElementChildrenCache;\n readonly #subCategoriesCache: SubCategoriesCache;\n readonly #modeledElementsCache: ModeledElementsCache;\n readonly #elementModelCategoriesCache: ElementModelCategoriesCache;\n\n constructor(props: BaseIdsCacheProps) {\n this.#queryExecutor = props.queryExecutor;\n this.#componentId = Guid.createValue();\n this.#categoryElementCounts = new ModelCategoryElementsCountCache({\n elementClassName: props.elementClassName,\n componentId: this.#componentId,\n queryExecutor: this.#queryExecutor,\n });\n this.#elementChildrenCache = new ElementChildrenCache({\n queryExecutor: this.#queryExecutor,\n elementClassName: props.elementClassName,\n componentId: this.#componentId,\n });\n this.#subCategoriesCache = new SubCategoriesCache({\n queryExecutor: this.#queryExecutor,\n componentId: this.#componentId,\n });\n this.#modeledElementsCache = new ModeledElementsCache({\n queryExecutor: this.#queryExecutor,\n componentId: this.#componentId,\n elementClassName: props.elementClassName,\n });\n this.#elementModelCategoriesCache = new ElementModelCategoriesCache({\n queryExecutor: this.#queryExecutor,\n componentId: this.#componentId,\n elementClassName: props.elementClassName,\n modeledElementsCache: this.#modeledElementsCache,\n });\n }\n\n public [Symbol.dispose]() {\n this.#categoryElementCounts[Symbol.dispose]();\n }\n\n // Implement get sub-models method\n\n public getSubModels(\n props: { modelId: Id64String; categoryId?: Id64String } | { categoryId: Id64String; modelId: Id64String | undefined },\n ): Observable<Id64Array> {\n if (props.modelId) {\n if (props.categoryId) {\n return this.#modeledElementsCache.getCategoryModeledElements({ modelId: props.modelId, categoryId: props.categoryId }).pipe(toArray());\n }\n\n return this.#elementModelCategoriesCache.getModelCategoryIds({ modelId: props.modelId }).pipe(\n mergeAll(),\n mergeMap((modelCategoryId) => this.#modeledElementsCache.getCategoryModeledElements({ modelId: props.modelId!, categoryId: modelCategoryId })),\n toArray(),\n );\n }\n\n return this.#elementModelCategoriesCache.getCategoryElementModels({ categoryId: props.categoryId! }).pipe(\n mergeAll(),\n mergeMap((modelId) => this.#modeledElementsCache.getCategoryModeledElements({ modelId, categoryId: props.categoryId! })),\n toArray(),\n );\n }\n\n // Re-export cache methods\n\n // ElementModelCategoriesCache methods\n\n public getAllModels(): ReturnType<ElementModelCategoriesCache[\"getAllModels\"]> {\n return this.#elementModelCategoriesCache.getAllModels();\n }\n\n public getCategories(props: Props<ElementModelCategoriesCache[\"getModelCategoryIds\"]>): ReturnType<ElementModelCategoriesCache[\"getModelCategoryIds\"]> {\n return this.#elementModelCategoriesCache.getModelCategoryIds(props);\n }\n\n public getAllCategoriesOfElements(): ReturnType<ElementModelCategoriesCache[\"getAllCategoriesOfElements\"]> {\n return this.#elementModelCategoriesCache.getAllCategoriesOfElements();\n }\n\n public getModels(props: Props<ElementModelCategoriesCache[\"getCategoryElementModels\"]>): ReturnType<ElementModelCategoriesCache[\"getCategoryElementModels\"]> {\n return this.#elementModelCategoriesCache.getCategoryElementModels(props);\n }\n\n public getCategoriesOfModelsTopMostElements(\n props: Props<ElementModelCategoriesCache[\"getCategoriesOfModelsTopMostElements\"]>,\n ): ReturnType<ElementModelCategoriesCache[\"getCategoriesOfModelsTopMostElements\"]> {\n return this.#elementModelCategoriesCache.getCategoriesOfModelsTopMostElements(props);\n }\n\n // ModelCategoryElementsCountCache methods\n\n public getElementsCount(\n props: Props<ModelCategoryElementsCountCache[\"getCategoryElementsCount\"]>,\n ): ReturnType<ModelCategoryElementsCountCache[\"getCategoryElementsCount\"]> {\n return this.#categoryElementCounts.getCategoryElementsCount(props);\n }\n\n // ElementChildrenCache methods\n\n public getChildElementsTree(props: Props<ElementChildrenCache[\"getChildElementsTree\"]>): ReturnType<ElementChildrenCache[\"getChildElementsTree\"]> {\n return this.#elementChildrenCache.getChildElementsTree(props);\n }\n\n public getAllChildElementsCount(\n props: Props<ElementChildrenCache[\"getAllChildElementsCount\"]>,\n ): ReturnType<ElementChildrenCache[\"getAllChildElementsCount\"]> {\n return this.#elementChildrenCache.getAllChildElementsCount(props);\n }\n\n // SubCategoriesCache methods\n\n public getSubCategories(props: Props<SubCategoriesCache[\"getSubCategories\"]>): ReturnType<SubCategoriesCache[\"getSubCategories\"]> {\n return this.#subCategoriesCache.getSubCategories(props);\n }\n\n public getSubCategoriesInfo(): ReturnType<SubCategoriesCache[\"getSubCategoriesInfo\"]> {\n return this.#subCategoriesCache.getSubCategoriesInfo();\n }\n\n // ModeledElementsCache methods\n\n public getSubModelsUnderElement(\n props: Props<ModeledElementsCache[\"getSubModelsUnderElement\"]>,\n ): ReturnType<ModeledElementsCache[\"getSubModelsUnderElement\"]> {\n return this.#modeledElementsCache.getSubModelsUnderElement(props);\n }\n\n public getModeledElementsInfo(): ReturnType<ModeledElementsCache[\"getModeledElementsInfo\"]> {\n return this.#modeledElementsCache.getModeledElementsInfo();\n }\n}\n\n/** @internal */\nexport interface BaseIdsCacheImplProps {\n baseIdsCache: BaseIdsCache;\n}\n\n/** @internal */\nexport class BaseIdsCacheImpl implements Disposable {\n #baseIdsCache: BaseIdsCache;\n constructor(props: BaseIdsCacheImplProps) {\n this.#baseIdsCache = props.baseIdsCache;\n }\n\n public [Symbol.dispose]() {}\n // Implement IBaseIdsCache by re-exporting BaseIdsCache methods\n\n public getChildElementsTree(props: Props<ElementChildrenCache[\"getChildElementsTree\"]>): ReturnType<ElementChildrenCache[\"getChildElementsTree\"]> {\n return this.#baseIdsCache.getChildElementsTree(props);\n }\n\n public getAllChildElementsCount(\n props: Props<ElementChildrenCache[\"getAllChildElementsCount\"]>,\n ): ReturnType<ElementChildrenCache[\"getAllChildElementsCount\"]> {\n return this.#baseIdsCache.getAllChildElementsCount(props);\n }\n\n public getSubCategories(props: Props<SubCategoriesCache[\"getSubCategories\"]>): ReturnType<SubCategoriesCache[\"getSubCategories\"]> {\n return this.#baseIdsCache.getSubCategories(props);\n }\n\n public getSubModels(\n props: { modelId: Id64String; categoryId?: Id64String } | { categoryId: Id64String; modelId: Id64String | undefined },\n ): Observable<Id64Array> {\n return this.#baseIdsCache.getSubModels(props);\n }\n\n public getSubModelsUnderElement(\n props: Props<ModeledElementsCache[\"getSubModelsUnderElement\"]>,\n ): ReturnType<ModeledElementsCache[\"getSubModelsUnderElement\"]> {\n return this.#baseIdsCache.getSubModelsUnderElement(props);\n }\n\n public getElementsCount(\n props: Props<ModelCategoryElementsCountCache[\"getCategoryElementsCount\"]>,\n ): ReturnType<ModelCategoryElementsCountCache[\"getCategoryElementsCount\"]> {\n return this.#baseIdsCache.getElementsCount(props);\n }\n\n public getCategories(props: Props<ElementModelCategoriesCache[\"getModelCategoryIds\"]>): ReturnType<ElementModelCategoriesCache[\"getModelCategoryIds\"]> {\n return this.#baseIdsCache.getCategories(props);\n }\n\n public getModels(props: Props<ElementModelCategoriesCache[\"getCategoryElementModels\"]>): ReturnType<ElementModelCategoriesCache[\"getCategoryElementModels\"]> {\n return this.#baseIdsCache.getModels(props);\n }\n\n public getAllCategoriesOfElements(): ReturnType<ElementModelCategoriesCache[\"getAllCategoriesOfElements\"]> {\n return this.#baseIdsCache.getAllCategoriesOfElements();\n }\n\n public getCategoriesOfModelsTopMostElements(\n props: Props<BaseIdsCache[\"getCategoriesOfModelsTopMostElements\"]>,\n ): ReturnType<BaseIdsCache[\"getCategoriesOfModelsTopMostElements\"]> {\n return this.#baseIdsCache.getCategoriesOfModelsTopMostElements(props);\n }\n public getSubCategoriesInfo(): ReturnType<SubCategoriesCache[\"getSubCategoriesInfo\"]> {\n return this.#baseIdsCache.getSubCategoriesInfo();\n }\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Observable } from "rxjs";
|
|
2
|
+
import type { GuidString, Id64Arg, Id64String } from "@itwin/core-bentley";
|
|
3
|
+
import type { LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
4
|
+
import type { ChildrenTree } from "../Utils.js";
|
|
5
|
+
interface ElementChildrenCacheProps {
|
|
6
|
+
queryExecutor: LimitingECSqlQueryExecutor;
|
|
7
|
+
elementClassName: string;
|
|
8
|
+
componentId: GuidString;
|
|
9
|
+
}
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare class ElementChildrenCache {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(props: ElementChildrenCacheProps);
|
|
14
|
+
private queryChildren;
|
|
15
|
+
private getChildElementsTreeFromMap;
|
|
16
|
+
private getChildElementsCountMap;
|
|
17
|
+
/**
|
|
18
|
+
* Populates #childElementsLoadingMap with promises. When these promises resolve, they will populate #childElementsMap with values and delete entries from #childElementsLoadingMap.
|
|
19
|
+
*/
|
|
20
|
+
private createChildElementsLoadingMapEntries;
|
|
21
|
+
private createChildElementsMapEntries;
|
|
22
|
+
getChildElementsTree({ elementIds }: {
|
|
23
|
+
elementIds: Id64Arg;
|
|
24
|
+
}): Observable<ChildrenTree>;
|
|
25
|
+
getAllChildElementsCount({ elementIds }: {
|
|
26
|
+
elementIds: Id64Arg;
|
|
27
|
+
}): Observable<Map<Id64String, number>>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=ElementChildrenCache.d.ts.map
|