@itwin/presentation-frontend 5.0.0-dev.9 → 5.0.0-dev.92
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 +53 -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/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 -5
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +30 -21
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +9 -6
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +55 -44
- 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 +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +4 -2
- 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 +6 -4
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +157 -142
- 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 +8 -2
- 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 -11
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +217 -112
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +5 -8
- 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/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 -5
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +23 -14
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +9 -6
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +43 -32
- 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 +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +4 -2
- 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 +6 -4
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +158 -143
- 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 +8 -2
- 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 -11
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +203 -98
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +5 -8
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +6 -10
- 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 +42 -42
|
@@ -2,61 +2,135 @@
|
|
|
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 {
|
|
64
|
+
import { KeySet, NodeKey } from "@itwin/presentation-common";
|
|
65
|
+
import { AsyncTasksTracker } from "@itwin/presentation-common/internal";
|
|
12
66
|
import { createStorage, TRANSIENT_ELEMENT_CLASSNAME, } from "@itwin/unified-selection";
|
|
13
|
-
import { Presentation } from "../Presentation";
|
|
14
|
-
import { HiliteSetProvider } from "./HiliteSetProvider";
|
|
15
|
-
import { SelectionChangeEvent, SelectionChangeType } from "./SelectionChangeEvent";
|
|
16
|
-
import { createSelectionScopeProps } from "./SelectionScopesManager";
|
|
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
132
|
/** @internal */
|
|
59
|
-
|
|
133
|
+
/* c8 ignore next 3 */
|
|
60
134
|
getToolSelectionSyncHandler(imodel) {
|
|
61
135
|
return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;
|
|
62
136
|
}
|
|
@@ -81,27 +155,30 @@ export class SelectionManager {
|
|
|
81
155
|
}
|
|
82
156
|
else {
|
|
83
157
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
84
|
-
registration.handler.dispose();
|
|
158
|
+
registration.handler[Symbol.dispose]();
|
|
85
159
|
}
|
|
86
160
|
}
|
|
87
161
|
}
|
|
88
162
|
}
|
|
89
163
|
/**
|
|
90
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
164
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
91
165
|
* is disposed.
|
|
92
166
|
*/
|
|
93
167
|
suspendIModelToolSelectionSync(imodel) {
|
|
94
168
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
95
169
|
if (!registration) {
|
|
96
|
-
|
|
170
|
+
const noop = () => { };
|
|
171
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
97
172
|
}
|
|
98
173
|
const wasSuspended = registration.handler.isSuspended;
|
|
99
174
|
registration.handler.isSuspended = true;
|
|
100
|
-
|
|
175
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
176
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
101
177
|
}
|
|
102
178
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
103
179
|
getSelectionLevels(imodel) {
|
|
104
|
-
|
|
180
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
181
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
105
182
|
}
|
|
106
183
|
/**
|
|
107
184
|
* Get the selection currently stored in this manager
|
|
@@ -111,39 +188,39 @@ export class SelectionManager {
|
|
|
111
188
|
* latest selection after changes.
|
|
112
189
|
*/
|
|
113
190
|
getSelection(imodel, level = 0) {
|
|
114
|
-
|
|
191
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
192
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
115
193
|
}
|
|
116
194
|
handleEvent(evt) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
195
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
196
|
+
this._knownIModels.add(evt.imodel);
|
|
120
197
|
switch (evt.changeType) {
|
|
121
198
|
case SelectionChangeType.Add:
|
|
122
|
-
this.
|
|
123
|
-
|
|
199
|
+
this.selectionStorage.addToSelection({
|
|
200
|
+
imodelKey,
|
|
124
201
|
source: evt.source,
|
|
125
202
|
level: evt.level,
|
|
126
203
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
127
204
|
});
|
|
128
205
|
break;
|
|
129
206
|
case SelectionChangeType.Remove:
|
|
130
|
-
this.
|
|
131
|
-
|
|
207
|
+
this.selectionStorage.removeFromSelection({
|
|
208
|
+
imodelKey,
|
|
132
209
|
source: evt.source,
|
|
133
210
|
level: evt.level,
|
|
134
211
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
135
212
|
});
|
|
136
213
|
break;
|
|
137
214
|
case SelectionChangeType.Replace:
|
|
138
|
-
this.
|
|
139
|
-
|
|
215
|
+
this.selectionStorage.replaceSelection({
|
|
216
|
+
imodelKey,
|
|
140
217
|
source: evt.source,
|
|
141
218
|
level: evt.level,
|
|
142
219
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
143
220
|
});
|
|
144
221
|
break;
|
|
145
222
|
case SelectionChangeType.Clear:
|
|
146
|
-
this.
|
|
223
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
147
224
|
break;
|
|
148
225
|
}
|
|
149
226
|
}
|
|
@@ -290,10 +367,10 @@ export class SelectionManager {
|
|
|
290
367
|
streamSelectionEvents() {
|
|
291
368
|
return this._selectionChanges
|
|
292
369
|
.pipe(mergeMap((args) => {
|
|
293
|
-
const currentSelectables = this.
|
|
370
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
294
371
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
|
|
295
|
-
const imodel = this._knownIModels.
|
|
296
|
-
|
|
372
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
373
|
+
/* c8 ignore next 3 */
|
|
297
374
|
if (!imodel) {
|
|
298
375
|
return EMPTY;
|
|
299
376
|
}
|
|
@@ -314,12 +391,37 @@ export class SelectionManager {
|
|
|
314
391
|
});
|
|
315
392
|
}
|
|
316
393
|
}
|
|
394
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
395
|
+
for (const imodel of set) {
|
|
396
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
397
|
+
return imodel;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
317
402
|
/** @internal */
|
|
318
403
|
export class ToolSelectionSyncHandler {
|
|
404
|
+
_selectionSourceName = "Tool";
|
|
405
|
+
_logicalSelection;
|
|
406
|
+
_imodel;
|
|
407
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
408
|
+
_asyncsTracker = new AsyncTasksTracker();
|
|
409
|
+
isSuspended;
|
|
319
410
|
constructor(imodel, logicalSelection) {
|
|
320
|
-
this.
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
411
|
+
this._imodel = imodel;
|
|
412
|
+
this._logicalSelection = logicalSelection;
|
|
413
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
414
|
+
}
|
|
415
|
+
[Symbol.dispose]() {
|
|
416
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
417
|
+
}
|
|
418
|
+
/** note: used only it tests */
|
|
419
|
+
get pendingAsyncs() {
|
|
420
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
421
|
+
}
|
|
422
|
+
onToolSelectionChanged = async (ev) => {
|
|
423
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
424
|
+
try {
|
|
323
425
|
// ignore selection change event if the handler is suspended
|
|
324
426
|
if (this.isSuspended) {
|
|
325
427
|
return;
|
|
@@ -335,13 +437,13 @@ export class ToolSelectionSyncHandler {
|
|
|
335
437
|
let ids;
|
|
336
438
|
switch (ev.type) {
|
|
337
439
|
case SelectionSetEventType.Add:
|
|
338
|
-
ids = ev.
|
|
440
|
+
ids = ev.additions;
|
|
339
441
|
break;
|
|
340
442
|
case SelectionSetEventType.Replace:
|
|
341
|
-
ids = ev.set.
|
|
443
|
+
ids = ev.set.active;
|
|
342
444
|
break;
|
|
343
445
|
default:
|
|
344
|
-
ids = ev.
|
|
446
|
+
ids = ev.removals;
|
|
345
447
|
break;
|
|
346
448
|
}
|
|
347
449
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
@@ -349,39 +451,32 @@ export class ToolSelectionSyncHandler {
|
|
|
349
451
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
350
452
|
// concrete classes)
|
|
351
453
|
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
454
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
455
|
+
switch (ev.type) {
|
|
456
|
+
case SelectionSetEventType.Add:
|
|
457
|
+
await changer.add(ids, selectionLevel);
|
|
458
|
+
break;
|
|
459
|
+
case SelectionSetEventType.Replace:
|
|
460
|
+
await changer.replace(ids, selectionLevel);
|
|
461
|
+
break;
|
|
462
|
+
case SelectionSetEventType.Remove:
|
|
463
|
+
await changer.remove(ids, selectionLevel);
|
|
464
|
+
break;
|
|
465
|
+
case SelectionSetEventType.Clear:
|
|
466
|
+
await changer.clear(selectionLevel);
|
|
467
|
+
break;
|
|
356
468
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
case SelectionSetEventType.Remove:
|
|
367
|
-
await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
this._imodel = imodel;
|
|
373
|
-
this._logicalSelection = logicalSelection;
|
|
374
|
-
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
375
|
-
}
|
|
376
|
-
dispose() {
|
|
377
|
-
this._imodelToolSelectionListenerDisposeFunc();
|
|
378
|
-
}
|
|
379
|
-
/** note: used only it tests */
|
|
380
|
-
get pendingAsyncs() {
|
|
381
|
-
return this._asyncsTracker.pendingAsyncs;
|
|
382
|
-
}
|
|
469
|
+
}
|
|
470
|
+
catch (e_1) {
|
|
471
|
+
env_1.error = e_1;
|
|
472
|
+
env_1.hasError = true;
|
|
473
|
+
}
|
|
474
|
+
finally {
|
|
475
|
+
__disposeResources(env_1);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
383
478
|
}
|
|
384
|
-
const
|
|
479
|
+
const parseElementIds = (ids) => {
|
|
385
480
|
let allPersistent = true;
|
|
386
481
|
let allTransient = true;
|
|
387
482
|
for (const id of Id64.iterable(ids)) {
|
|
@@ -416,13 +511,16 @@ const parseIds = (ids) => {
|
|
|
416
511
|
}
|
|
417
512
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
418
513
|
};
|
|
419
|
-
function
|
|
420
|
-
for (const id of Id64.iterable(
|
|
421
|
-
|
|
514
|
+
function addKeys(target, className, ids) {
|
|
515
|
+
for (const id of Id64.iterable(ids)) {
|
|
516
|
+
target.add({ className, id });
|
|
422
517
|
}
|
|
423
518
|
}
|
|
424
|
-
/** @internal */
|
|
425
519
|
class ScopedSelectionChanger {
|
|
520
|
+
name;
|
|
521
|
+
imodel;
|
|
522
|
+
manager;
|
|
523
|
+
scope;
|
|
426
524
|
constructor(name, imodel, manager, scope) {
|
|
427
525
|
this.name = name;
|
|
428
526
|
this.imodel = imodel;
|
|
@@ -432,27 +530,37 @@ class ScopedSelectionChanger {
|
|
|
432
530
|
async clear(level) {
|
|
433
531
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
434
532
|
}
|
|
435
|
-
async add(
|
|
436
|
-
const keys = await this
|
|
437
|
-
addTransientKeys(transientIds, keys);
|
|
533
|
+
async add(ids, level) {
|
|
534
|
+
const keys = await this.#computeSelection(ids);
|
|
438
535
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
439
536
|
}
|
|
440
|
-
async remove(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
537
|
+
async remove(ids, level) {
|
|
538
|
+
const keys = await this.#computeSelection(ids);
|
|
443
539
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
444
540
|
}
|
|
445
|
-
async replace(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
541
|
+
async replace(ids, level) {
|
|
542
|
+
const keys = await this.#computeSelection(ids);
|
|
448
543
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
449
544
|
}
|
|
545
|
+
async #computeSelection(ids) {
|
|
546
|
+
let keys = new KeySet();
|
|
547
|
+
if (ids.elements) {
|
|
548
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
549
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
550
|
+
addKeys(keys, TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
551
|
+
}
|
|
552
|
+
if (ids.models) {
|
|
553
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
554
|
+
}
|
|
555
|
+
if (ids.subcategories) {
|
|
556
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
557
|
+
}
|
|
558
|
+
return keys;
|
|
559
|
+
}
|
|
450
560
|
}
|
|
451
561
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
452
562
|
class CurrentSelectionStorage {
|
|
453
|
-
|
|
454
|
-
this._currentSelection = new Map();
|
|
455
|
-
}
|
|
563
|
+
_currentSelection = new Map();
|
|
456
564
|
getCurrentSelectionStorage(imodelKey) {
|
|
457
565
|
let storage = this._currentSelection.get(imodelKey);
|
|
458
566
|
if (!storage) {
|
|
@@ -476,9 +584,7 @@ class CurrentSelectionStorage {
|
|
|
476
584
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
477
585
|
*/
|
|
478
586
|
class IModelSelectionStorage {
|
|
479
|
-
|
|
480
|
-
this._currentSelection = new Map();
|
|
481
|
-
}
|
|
587
|
+
_currentSelection = new Map();
|
|
482
588
|
getSelection(level) {
|
|
483
589
|
let entry = this._currentSelection.get(level);
|
|
484
590
|
if (!entry) {
|
|
@@ -496,7 +602,7 @@ class IModelSelectionStorage {
|
|
|
496
602
|
}
|
|
497
603
|
clearedLevels.forEach((storedLevel) => {
|
|
498
604
|
const entry = this._currentSelection.get(storedLevel);
|
|
499
|
-
|
|
605
|
+
/* c8 ignore next 3 */
|
|
500
606
|
if (!entry) {
|
|
501
607
|
return;
|
|
502
608
|
}
|
|
@@ -516,13 +622,12 @@ class IModelSelectionStorage {
|
|
|
516
622
|
}
|
|
517
623
|
setSelection(level, keys, disposer) {
|
|
518
624
|
const currEntry = this._currentSelection.get(level);
|
|
519
|
-
// istanbul ignore else
|
|
520
625
|
if (currEntry) {
|
|
521
626
|
currEntry.ongoingComputationDisposers.delete(disposer);
|
|
522
627
|
}
|
|
523
628
|
this._currentSelection.set(level, {
|
|
524
629
|
value: keys,
|
|
525
|
-
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /*
|
|
630
|
+
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* c8 ignore next */ new Set(),
|
|
526
631
|
});
|
|
527
632
|
}
|
|
528
633
|
computeSelection(level, currSelectables, changedSelectables) {
|