@itwin/presentation-frontend 5.0.0-dev.1 → 5.0.0-dev.100
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 +75 -1
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.d.ts +13 -0
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.d.ts.map +1 -0
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.js +22 -0
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.js.map +1 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.d.ts +6 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.d.ts.map +1 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.js +17 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.js.map +1 -0
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +12 -3
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +7 -7
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +7 -6
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +15 -14
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +31 -45
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +12 -23
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +81 -78
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +2 -4
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +2 -4
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +6 -4
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +9 -19
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +163 -153
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +4 -5
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +27 -29
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +10 -4
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +2 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +5 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +8 -5
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +3 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +31 -15
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +218 -120
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +11 -9
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +6 -11
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.d.ts +15 -15
- package/lib/cjs/presentation-frontend.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend.js +30 -29
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.d.ts +13 -0
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.d.ts.map +1 -0
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.js +17 -0
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.js.map +1 -0
- package/lib/esm/presentation-frontend/InternalSymbols.d.ts +6 -0
- package/lib/esm/presentation-frontend/InternalSymbols.d.ts.map +1 -0
- package/lib/esm/presentation-frontend/InternalSymbols.js +14 -0
- package/lib/esm/presentation-frontend/InternalSymbols.js.map +1 -0
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +12 -3
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +8 -8
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +3 -2
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +15 -14
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +24 -38
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +12 -23
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +67 -64
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +2 -4
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +2 -4
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +6 -4
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +9 -19
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +164 -154
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +4 -5
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +27 -29
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +9 -3
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +2 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +5 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +8 -5
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +3 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +31 -15
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +204 -106
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +11 -9
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +7 -11
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.d.ts +15 -15
- package/lib/esm/presentation-frontend.d.ts.map +1 -1
- package/lib/esm/presentation-frontend.js +12 -15
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +43 -43
|
@@ -2,64 +2,133 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
5
6
|
/** @packageDocumentation
|
|
6
7
|
* @module UnifiedSelection
|
|
7
8
|
*/
|
|
9
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
10
|
+
if (value !== null && value !== void 0) {
|
|
11
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
12
|
+
var dispose, inner;
|
|
13
|
+
if (async) {
|
|
14
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
15
|
+
dispose = value[Symbol.asyncDispose];
|
|
16
|
+
}
|
|
17
|
+
if (dispose === void 0) {
|
|
18
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
19
|
+
dispose = value[Symbol.dispose];
|
|
20
|
+
if (async) inner = dispose;
|
|
21
|
+
}
|
|
22
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
23
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
24
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
25
|
+
}
|
|
26
|
+
else if (async) {
|
|
27
|
+
env.stack.push({ async: true });
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
32
|
+
return function (env) {
|
|
33
|
+
function fail(e) {
|
|
34
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
35
|
+
env.hasError = true;
|
|
36
|
+
}
|
|
37
|
+
var r, s = 0;
|
|
38
|
+
function next() {
|
|
39
|
+
while (r = env.stack.pop()) {
|
|
40
|
+
try {
|
|
41
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
42
|
+
if (r.dispose) {
|
|
43
|
+
var result = r.dispose.call(r.value);
|
|
44
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
45
|
+
}
|
|
46
|
+
else s |= 1;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
fail(e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
53
|
+
if (env.hasError) throw env.error;
|
|
54
|
+
}
|
|
55
|
+
return next();
|
|
56
|
+
};
|
|
57
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
58
|
+
var e = new Error(message);
|
|
59
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
60
|
+
});
|
|
8
61
|
import { defer, EMPTY, mergeMap, of, Subject, takeUntil, tap } from "rxjs";
|
|
9
|
-
import { Id64
|
|
62
|
+
import { Id64 } from "@itwin/core-bentley";
|
|
10
63
|
import { IModelConnection, SelectionSetEventType } from "@itwin/core-frontend";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
64
|
+
import { KeySet, NodeKey } from "@itwin/presentation-common";
|
|
65
|
+
import { AsyncTasksTracker } from "@itwin/presentation-common/internal";
|
|
66
|
+
import { createStorage, TRANSIENT_ELEMENT_CLASSNAME, } from "@itwin/unified-selection";
|
|
67
|
+
import { Presentation } from "../Presentation.js";
|
|
68
|
+
import { HiliteSetProvider } from "./HiliteSetProvider.js";
|
|
69
|
+
import { SelectionChangeEvent, SelectionChangeType } from "./SelectionChangeEvent.js";
|
|
70
|
+
import { createSelectionScopeProps } from "./SelectionScopesManager.js";
|
|
17
71
|
/**
|
|
18
72
|
* The selection manager which stores the overall selection.
|
|
19
73
|
* @public
|
|
74
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
20
75
|
*/
|
|
21
76
|
export class SelectionManager {
|
|
77
|
+
_imodelKeyFactory;
|
|
78
|
+
_imodelToolSelectionSyncHandlers = new Map();
|
|
79
|
+
_hiliteSetProviders = new Map();
|
|
80
|
+
_ownsStorage;
|
|
81
|
+
_knownIModels = new Set();
|
|
82
|
+
_currentSelection = new CurrentSelectionStorage();
|
|
83
|
+
_selectionChanges = new Subject();
|
|
84
|
+
_selectionEventsSubscription;
|
|
85
|
+
_listeners = [];
|
|
86
|
+
/**
|
|
87
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
88
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
89
|
+
*/
|
|
90
|
+
selectionStorage;
|
|
91
|
+
/** An event which gets broadcasted on selection changes */
|
|
92
|
+
selectionChange;
|
|
93
|
+
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
94
|
+
scopes;
|
|
22
95
|
/**
|
|
23
96
|
* Creates an instance of SelectionManager.
|
|
24
97
|
*/
|
|
25
98
|
constructor(props) {
|
|
26
|
-
this._imodelToolSelectionSyncHandlers = new Map();
|
|
27
|
-
this._hiliteSetProviders = new Map();
|
|
28
|
-
this._knownIModels = new Map();
|
|
29
|
-
this._currentSelection = new CurrentSelectionStorage();
|
|
30
|
-
this._selectionChanges = new Subject();
|
|
31
|
-
this._listeners = [];
|
|
32
99
|
this.selectionChange = new SelectionChangeEvent();
|
|
33
100
|
this.scopes = props.scopes;
|
|
34
|
-
this.
|
|
101
|
+
this.selectionStorage = props.selectionStorage ?? createStorage();
|
|
102
|
+
this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
|
|
35
103
|
this._ownsStorage = props.selectionStorage === undefined;
|
|
36
|
-
this.
|
|
104
|
+
this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
|
|
37
105
|
this._selectionEventsSubscription = this.streamSelectionEvents();
|
|
38
106
|
this._listeners.push(IModelConnection.onOpen.addListener((imodel) => {
|
|
39
|
-
this._knownIModels.
|
|
107
|
+
this._knownIModels.add(imodel);
|
|
40
108
|
}));
|
|
41
109
|
this._listeners.push(IModelConnection.onClose.addListener((imodel) => {
|
|
42
110
|
this.onConnectionClose(imodel);
|
|
43
111
|
}));
|
|
44
112
|
}
|
|
45
|
-
dispose() {
|
|
113
|
+
[Symbol.dispose]() {
|
|
46
114
|
this._selectionEventsSubscription.unsubscribe();
|
|
47
115
|
this._listeners.forEach((dispose) => dispose());
|
|
48
116
|
}
|
|
117
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
118
|
+
/* c8 ignore next 3 */
|
|
119
|
+
dispose() {
|
|
120
|
+
this[Symbol.dispose]();
|
|
121
|
+
}
|
|
49
122
|
onConnectionClose(imodel) {
|
|
123
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
50
124
|
this._hiliteSetProviders.delete(imodel);
|
|
51
|
-
this._knownIModels.delete(imodel
|
|
52
|
-
this._currentSelection.clear(
|
|
125
|
+
this._knownIModels.delete(imodel);
|
|
126
|
+
this._currentSelection.clear(imodelKey);
|
|
53
127
|
if (this._ownsStorage) {
|
|
54
128
|
this.clearSelection("Connection Close Event", imodel);
|
|
55
|
-
this.
|
|
129
|
+
this.selectionStorage.clearStorage({ imodelKey });
|
|
56
130
|
}
|
|
57
131
|
}
|
|
58
|
-
/** @internal */
|
|
59
|
-
// istanbul ignore next
|
|
60
|
-
getToolSelectionSyncHandler(imodel) {
|
|
61
|
-
return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;
|
|
62
|
-
}
|
|
63
132
|
/**
|
|
64
133
|
* Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).
|
|
65
134
|
*/
|
|
@@ -81,27 +150,30 @@ export class SelectionManager {
|
|
|
81
150
|
}
|
|
82
151
|
else {
|
|
83
152
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
84
|
-
registration.handler.dispose();
|
|
153
|
+
registration.handler[Symbol.dispose]();
|
|
85
154
|
}
|
|
86
155
|
}
|
|
87
156
|
}
|
|
88
157
|
}
|
|
89
158
|
/**
|
|
90
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
159
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
91
160
|
* is disposed.
|
|
92
161
|
*/
|
|
93
162
|
suspendIModelToolSelectionSync(imodel) {
|
|
94
163
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
95
164
|
if (!registration) {
|
|
96
|
-
|
|
165
|
+
const noop = () => { };
|
|
166
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
97
167
|
}
|
|
98
168
|
const wasSuspended = registration.handler.isSuspended;
|
|
99
169
|
registration.handler.isSuspended = true;
|
|
100
|
-
|
|
170
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
171
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
101
172
|
}
|
|
102
173
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
103
174
|
getSelectionLevels(imodel) {
|
|
104
|
-
|
|
175
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
176
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
105
177
|
}
|
|
106
178
|
/**
|
|
107
179
|
* Get the selection currently stored in this manager
|
|
@@ -111,39 +183,39 @@ export class SelectionManager {
|
|
|
111
183
|
* latest selection after changes.
|
|
112
184
|
*/
|
|
113
185
|
getSelection(imodel, level = 0) {
|
|
114
|
-
|
|
186
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
187
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
115
188
|
}
|
|
116
189
|
handleEvent(evt) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
190
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
191
|
+
this._knownIModels.add(evt.imodel);
|
|
120
192
|
switch (evt.changeType) {
|
|
121
193
|
case SelectionChangeType.Add:
|
|
122
|
-
this.
|
|
123
|
-
|
|
194
|
+
this.selectionStorage.addToSelection({
|
|
195
|
+
imodelKey,
|
|
124
196
|
source: evt.source,
|
|
125
197
|
level: evt.level,
|
|
126
198
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
127
199
|
});
|
|
128
200
|
break;
|
|
129
201
|
case SelectionChangeType.Remove:
|
|
130
|
-
this.
|
|
131
|
-
|
|
202
|
+
this.selectionStorage.removeFromSelection({
|
|
203
|
+
imodelKey,
|
|
132
204
|
source: evt.source,
|
|
133
205
|
level: evt.level,
|
|
134
206
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
135
207
|
});
|
|
136
208
|
break;
|
|
137
209
|
case SelectionChangeType.Replace:
|
|
138
|
-
this.
|
|
139
|
-
|
|
210
|
+
this.selectionStorage.replaceSelection({
|
|
211
|
+
imodelKey,
|
|
140
212
|
source: evt.source,
|
|
141
213
|
level: evt.level,
|
|
142
214
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
143
215
|
});
|
|
144
216
|
break;
|
|
145
217
|
case SelectionChangeType.Clear:
|
|
146
|
-
this.
|
|
218
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
147
219
|
break;
|
|
148
220
|
}
|
|
149
221
|
}
|
|
@@ -290,10 +362,10 @@ export class SelectionManager {
|
|
|
290
362
|
streamSelectionEvents() {
|
|
291
363
|
return this._selectionChanges
|
|
292
364
|
.pipe(mergeMap((args) => {
|
|
293
|
-
const currentSelectables = this.
|
|
294
|
-
return this._currentSelection.computeSelection(args.
|
|
295
|
-
const imodel = this._knownIModels.
|
|
296
|
-
|
|
365
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
366
|
+
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
|
|
367
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
368
|
+
/* c8 ignore next 3 */
|
|
297
369
|
if (!imodel) {
|
|
298
370
|
return EMPTY;
|
|
299
371
|
}
|
|
@@ -314,14 +386,37 @@ export class SelectionManager {
|
|
|
314
386
|
});
|
|
315
387
|
}
|
|
316
388
|
}
|
|
317
|
-
|
|
318
|
-
|
|
389
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
390
|
+
for (const imodel of set) {
|
|
391
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
392
|
+
return imodel;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
319
397
|
/** @internal */
|
|
320
398
|
export class ToolSelectionSyncHandler {
|
|
399
|
+
_selectionSourceName = "Tool";
|
|
400
|
+
_logicalSelection;
|
|
401
|
+
_imodel;
|
|
402
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
403
|
+
_asyncsTracker = new AsyncTasksTracker();
|
|
404
|
+
isSuspended;
|
|
321
405
|
constructor(imodel, logicalSelection) {
|
|
322
|
-
this.
|
|
323
|
-
this.
|
|
324
|
-
this.
|
|
406
|
+
this._imodel = imodel;
|
|
407
|
+
this._logicalSelection = logicalSelection;
|
|
408
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
409
|
+
}
|
|
410
|
+
[Symbol.dispose]() {
|
|
411
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
412
|
+
}
|
|
413
|
+
/** note: used only it tests */
|
|
414
|
+
get pendingAsyncs() {
|
|
415
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
416
|
+
}
|
|
417
|
+
onToolSelectionChanged = async (ev) => {
|
|
418
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
419
|
+
try {
|
|
325
420
|
// ignore selection change event if the handler is suspended
|
|
326
421
|
if (this.isSuspended) {
|
|
327
422
|
return;
|
|
@@ -337,13 +432,13 @@ export class ToolSelectionSyncHandler {
|
|
|
337
432
|
let ids;
|
|
338
433
|
switch (ev.type) {
|
|
339
434
|
case SelectionSetEventType.Add:
|
|
340
|
-
ids = ev.
|
|
435
|
+
ids = ev.additions;
|
|
341
436
|
break;
|
|
342
437
|
case SelectionSetEventType.Replace:
|
|
343
|
-
ids = ev.set.
|
|
438
|
+
ids = ev.set.active;
|
|
344
439
|
break;
|
|
345
440
|
default:
|
|
346
|
-
ids = ev.
|
|
441
|
+
ids = ev.removals;
|
|
347
442
|
break;
|
|
348
443
|
}
|
|
349
444
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
@@ -351,39 +446,32 @@ export class ToolSelectionSyncHandler {
|
|
|
351
446
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
352
447
|
// concrete classes)
|
|
353
448
|
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
449
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
450
|
+
switch (ev.type) {
|
|
451
|
+
case SelectionSetEventType.Add:
|
|
452
|
+
await changer.add(ids, selectionLevel);
|
|
453
|
+
break;
|
|
454
|
+
case SelectionSetEventType.Replace:
|
|
455
|
+
await changer.replace(ids, selectionLevel);
|
|
456
|
+
break;
|
|
457
|
+
case SelectionSetEventType.Remove:
|
|
458
|
+
await changer.remove(ids, selectionLevel);
|
|
459
|
+
break;
|
|
460
|
+
case SelectionSetEventType.Clear:
|
|
461
|
+
await changer.clear(selectionLevel);
|
|
462
|
+
break;
|
|
358
463
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
case SelectionSetEventType.Remove:
|
|
369
|
-
await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
};
|
|
374
|
-
this._imodel = imodel;
|
|
375
|
-
this._logicalSelection = logicalSelection;
|
|
376
|
-
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
377
|
-
}
|
|
378
|
-
dispose() {
|
|
379
|
-
this._imodelToolSelectionListenerDisposeFunc();
|
|
380
|
-
}
|
|
381
|
-
/** note: used only it tests */
|
|
382
|
-
get pendingAsyncs() {
|
|
383
|
-
return this._asyncsTracker.pendingAsyncs;
|
|
384
|
-
}
|
|
464
|
+
}
|
|
465
|
+
catch (e_1) {
|
|
466
|
+
env_1.error = e_1;
|
|
467
|
+
env_1.hasError = true;
|
|
468
|
+
}
|
|
469
|
+
finally {
|
|
470
|
+
__disposeResources(env_1);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
385
473
|
}
|
|
386
|
-
const
|
|
474
|
+
const parseElementIds = (ids) => {
|
|
387
475
|
let allPersistent = true;
|
|
388
476
|
let allTransient = true;
|
|
389
477
|
for (const id of Id64.iterable(ids)) {
|
|
@@ -418,13 +506,16 @@ const parseIds = (ids) => {
|
|
|
418
506
|
}
|
|
419
507
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
420
508
|
};
|
|
421
|
-
function
|
|
422
|
-
for (const id of Id64.iterable(
|
|
423
|
-
|
|
509
|
+
function addKeys(target, className, ids) {
|
|
510
|
+
for (const id of Id64.iterable(ids)) {
|
|
511
|
+
target.add({ className, id });
|
|
424
512
|
}
|
|
425
513
|
}
|
|
426
|
-
/** @internal */
|
|
427
514
|
class ScopedSelectionChanger {
|
|
515
|
+
name;
|
|
516
|
+
imodel;
|
|
517
|
+
manager;
|
|
518
|
+
scope;
|
|
428
519
|
constructor(name, imodel, manager, scope) {
|
|
429
520
|
this.name = name;
|
|
430
521
|
this.imodel = imodel;
|
|
@@ -434,27 +525,37 @@ class ScopedSelectionChanger {
|
|
|
434
525
|
async clear(level) {
|
|
435
526
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
436
527
|
}
|
|
437
|
-
async add(
|
|
438
|
-
const keys = await this
|
|
439
|
-
addTransientKeys(transientIds, keys);
|
|
528
|
+
async add(ids, level) {
|
|
529
|
+
const keys = await this.#computeSelection(ids);
|
|
440
530
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
441
531
|
}
|
|
442
|
-
async remove(
|
|
443
|
-
const keys = await this
|
|
444
|
-
addTransientKeys(transientIds, keys);
|
|
532
|
+
async remove(ids, level) {
|
|
533
|
+
const keys = await this.#computeSelection(ids);
|
|
445
534
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
446
535
|
}
|
|
447
|
-
async replace(
|
|
448
|
-
const keys = await this
|
|
449
|
-
addTransientKeys(transientIds, keys);
|
|
536
|
+
async replace(ids, level) {
|
|
537
|
+
const keys = await this.#computeSelection(ids);
|
|
450
538
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
451
539
|
}
|
|
540
|
+
async #computeSelection(ids) {
|
|
541
|
+
let keys = new KeySet();
|
|
542
|
+
if (ids.elements) {
|
|
543
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
544
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
545
|
+
addKeys(keys, TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
546
|
+
}
|
|
547
|
+
if (ids.models) {
|
|
548
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
549
|
+
}
|
|
550
|
+
if (ids.subcategories) {
|
|
551
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
552
|
+
}
|
|
553
|
+
return keys;
|
|
554
|
+
}
|
|
452
555
|
}
|
|
453
556
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
454
557
|
class CurrentSelectionStorage {
|
|
455
|
-
|
|
456
|
-
this._currentSelection = new Map();
|
|
457
|
-
}
|
|
558
|
+
_currentSelection = new Map();
|
|
458
559
|
getCurrentSelectionStorage(imodelKey) {
|
|
459
560
|
let storage = this._currentSelection.get(imodelKey);
|
|
460
561
|
if (!storage) {
|
|
@@ -478,9 +579,7 @@ class CurrentSelectionStorage {
|
|
|
478
579
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
479
580
|
*/
|
|
480
581
|
class IModelSelectionStorage {
|
|
481
|
-
|
|
482
|
-
this._currentSelection = new Map();
|
|
483
|
-
}
|
|
582
|
+
_currentSelection = new Map();
|
|
484
583
|
getSelection(level) {
|
|
485
584
|
let entry = this._currentSelection.get(level);
|
|
486
585
|
if (!entry) {
|
|
@@ -498,7 +597,7 @@ class IModelSelectionStorage {
|
|
|
498
597
|
}
|
|
499
598
|
clearedLevels.forEach((storedLevel) => {
|
|
500
599
|
const entry = this._currentSelection.get(storedLevel);
|
|
501
|
-
|
|
600
|
+
/* c8 ignore next 3 */
|
|
502
601
|
if (!entry) {
|
|
503
602
|
return;
|
|
504
603
|
}
|
|
@@ -518,13 +617,12 @@ class IModelSelectionStorage {
|
|
|
518
617
|
}
|
|
519
618
|
setSelection(level, keys, disposer) {
|
|
520
619
|
const currEntry = this._currentSelection.get(level);
|
|
521
|
-
// istanbul ignore else
|
|
522
620
|
if (currEntry) {
|
|
523
621
|
currEntry.ongoingComputationDisposers.delete(disposer);
|
|
524
622
|
}
|
|
525
623
|
this._currentSelection.set(level, {
|
|
526
624
|
value: keys,
|
|
527
|
-
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /*
|
|
625
|
+
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* c8 ignore next */ new Set(),
|
|
528
626
|
});
|
|
529
627
|
}
|
|
530
628
|
computeSelection(level, currSelectables, changedSelectables) {
|