@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
|
@@ -3,63 +3,137 @@
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
6
7
|
/** @packageDocumentation
|
|
7
8
|
* @module UnifiedSelection
|
|
8
9
|
*/
|
|
10
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
11
|
+
if (value !== null && value !== void 0) {
|
|
12
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
13
|
+
var dispose, inner;
|
|
14
|
+
if (async) {
|
|
15
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.asyncDispose];
|
|
17
|
+
}
|
|
18
|
+
if (dispose === void 0) {
|
|
19
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
20
|
+
dispose = value[Symbol.dispose];
|
|
21
|
+
if (async) inner = dispose;
|
|
22
|
+
}
|
|
23
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
24
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
25
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
26
|
+
}
|
|
27
|
+
else if (async) {
|
|
28
|
+
env.stack.push({ async: true });
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
33
|
+
return function (env) {
|
|
34
|
+
function fail(e) {
|
|
35
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
36
|
+
env.hasError = true;
|
|
37
|
+
}
|
|
38
|
+
var r, s = 0;
|
|
39
|
+
function next() {
|
|
40
|
+
while (r = env.stack.pop()) {
|
|
41
|
+
try {
|
|
42
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
43
|
+
if (r.dispose) {
|
|
44
|
+
var result = r.dispose.call(r.value);
|
|
45
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
46
|
+
}
|
|
47
|
+
else s |= 1;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
fail(e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
54
|
+
if (env.hasError) throw env.error;
|
|
55
|
+
}
|
|
56
|
+
return next();
|
|
57
|
+
};
|
|
58
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
59
|
+
var e = new Error(message);
|
|
60
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
61
|
+
});
|
|
9
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
63
|
exports.ToolSelectionSyncHandler = exports.SelectionManager = void 0;
|
|
11
64
|
const rxjs_1 = require("rxjs");
|
|
12
65
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
66
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
14
67
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
68
|
+
const internal_1 = require("@itwin/presentation-common/internal");
|
|
15
69
|
const unified_selection_1 = require("@itwin/unified-selection");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
70
|
+
const Presentation_js_1 = require("../Presentation.js");
|
|
71
|
+
const HiliteSetProvider_js_1 = require("./HiliteSetProvider.js");
|
|
72
|
+
const SelectionChangeEvent_js_1 = require("./SelectionChangeEvent.js");
|
|
73
|
+
const SelectionScopesManager_js_1 = require("./SelectionScopesManager.js");
|
|
20
74
|
/**
|
|
21
75
|
* The selection manager which stores the overall selection.
|
|
22
76
|
* @public
|
|
77
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
23
78
|
*/
|
|
24
79
|
class SelectionManager {
|
|
80
|
+
_imodelKeyFactory;
|
|
81
|
+
_imodelToolSelectionSyncHandlers = new Map();
|
|
82
|
+
_hiliteSetProviders = new Map();
|
|
83
|
+
_ownsStorage;
|
|
84
|
+
_knownIModels = new Set();
|
|
85
|
+
_currentSelection = new CurrentSelectionStorage();
|
|
86
|
+
_selectionChanges = new rxjs_1.Subject();
|
|
87
|
+
_selectionEventsSubscription;
|
|
88
|
+
_listeners = [];
|
|
89
|
+
/**
|
|
90
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
91
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
92
|
+
*/
|
|
93
|
+
selectionStorage;
|
|
94
|
+
/** An event which gets broadcasted on selection changes */
|
|
95
|
+
selectionChange;
|
|
96
|
+
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
97
|
+
scopes;
|
|
25
98
|
/**
|
|
26
99
|
* Creates an instance of SelectionManager.
|
|
27
100
|
*/
|
|
28
101
|
constructor(props) {
|
|
29
|
-
this.
|
|
30
|
-
this._hiliteSetProviders = new Map();
|
|
31
|
-
this._knownIModels = new Map();
|
|
32
|
-
this._currentSelection = new CurrentSelectionStorage();
|
|
33
|
-
this._selectionChanges = new rxjs_1.Subject();
|
|
34
|
-
this._listeners = [];
|
|
35
|
-
this.selectionChange = new SelectionChangeEvent_1.SelectionChangeEvent();
|
|
102
|
+
this.selectionChange = new SelectionChangeEvent_js_1.SelectionChangeEvent();
|
|
36
103
|
this.scopes = props.scopes;
|
|
37
|
-
this.
|
|
104
|
+
this.selectionStorage = props.selectionStorage ?? (0, unified_selection_1.createStorage)();
|
|
105
|
+
this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
|
|
38
106
|
this._ownsStorage = props.selectionStorage === undefined;
|
|
39
|
-
this.
|
|
107
|
+
this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
|
|
40
108
|
this._selectionEventsSubscription = this.streamSelectionEvents();
|
|
41
109
|
this._listeners.push(core_frontend_1.IModelConnection.onOpen.addListener((imodel) => {
|
|
42
|
-
this._knownIModels.
|
|
110
|
+
this._knownIModels.add(imodel);
|
|
43
111
|
}));
|
|
44
112
|
this._listeners.push(core_frontend_1.IModelConnection.onClose.addListener((imodel) => {
|
|
45
113
|
this.onConnectionClose(imodel);
|
|
46
114
|
}));
|
|
47
115
|
}
|
|
48
|
-
dispose() {
|
|
116
|
+
[Symbol.dispose]() {
|
|
49
117
|
this._selectionEventsSubscription.unsubscribe();
|
|
50
118
|
this._listeners.forEach((dispose) => dispose());
|
|
51
119
|
}
|
|
120
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
121
|
+
/* c8 ignore next 3 */
|
|
122
|
+
dispose() {
|
|
123
|
+
this[Symbol.dispose]();
|
|
124
|
+
}
|
|
52
125
|
onConnectionClose(imodel) {
|
|
126
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
53
127
|
this._hiliteSetProviders.delete(imodel);
|
|
54
|
-
this._knownIModels.delete(imodel
|
|
55
|
-
this._currentSelection.clear(
|
|
128
|
+
this._knownIModels.delete(imodel);
|
|
129
|
+
this._currentSelection.clear(imodelKey);
|
|
56
130
|
if (this._ownsStorage) {
|
|
57
131
|
this.clearSelection("Connection Close Event", imodel);
|
|
58
|
-
this.
|
|
132
|
+
this.selectionStorage.clearStorage({ imodelKey });
|
|
59
133
|
}
|
|
60
134
|
}
|
|
61
135
|
/** @internal */
|
|
62
|
-
|
|
136
|
+
/* c8 ignore next 3 */
|
|
63
137
|
getToolSelectionSyncHandler(imodel) {
|
|
64
138
|
return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;
|
|
65
139
|
}
|
|
@@ -84,27 +158,30 @@ class SelectionManager {
|
|
|
84
158
|
}
|
|
85
159
|
else {
|
|
86
160
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
87
|
-
registration.handler.dispose();
|
|
161
|
+
registration.handler[Symbol.dispose]();
|
|
88
162
|
}
|
|
89
163
|
}
|
|
90
164
|
}
|
|
91
165
|
}
|
|
92
166
|
/**
|
|
93
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
167
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
94
168
|
* is disposed.
|
|
95
169
|
*/
|
|
96
170
|
suspendIModelToolSelectionSync(imodel) {
|
|
97
171
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
98
172
|
if (!registration) {
|
|
99
|
-
|
|
173
|
+
const noop = () => { };
|
|
174
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
100
175
|
}
|
|
101
176
|
const wasSuspended = registration.handler.isSuspended;
|
|
102
177
|
registration.handler.isSuspended = true;
|
|
103
|
-
|
|
178
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
179
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
104
180
|
}
|
|
105
181
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
106
182
|
getSelectionLevels(imodel) {
|
|
107
|
-
|
|
183
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
184
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
108
185
|
}
|
|
109
186
|
/**
|
|
110
187
|
* Get the selection currently stored in this manager
|
|
@@ -114,39 +191,39 @@ class SelectionManager {
|
|
|
114
191
|
* latest selection after changes.
|
|
115
192
|
*/
|
|
116
193
|
getSelection(imodel, level = 0) {
|
|
117
|
-
|
|
194
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
195
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
118
196
|
}
|
|
119
197
|
handleEvent(evt) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
198
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
199
|
+
this._knownIModels.add(evt.imodel);
|
|
123
200
|
switch (evt.changeType) {
|
|
124
|
-
case
|
|
125
|
-
this.
|
|
126
|
-
|
|
201
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Add:
|
|
202
|
+
this.selectionStorage.addToSelection({
|
|
203
|
+
imodelKey,
|
|
127
204
|
source: evt.source,
|
|
128
205
|
level: evt.level,
|
|
129
206
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
130
207
|
});
|
|
131
208
|
break;
|
|
132
|
-
case
|
|
133
|
-
this.
|
|
134
|
-
|
|
209
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Remove:
|
|
210
|
+
this.selectionStorage.removeFromSelection({
|
|
211
|
+
imodelKey,
|
|
135
212
|
source: evt.source,
|
|
136
213
|
level: evt.level,
|
|
137
214
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
138
215
|
});
|
|
139
216
|
break;
|
|
140
|
-
case
|
|
141
|
-
this.
|
|
142
|
-
|
|
217
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Replace:
|
|
218
|
+
this.selectionStorage.replaceSelection({
|
|
219
|
+
imodelKey,
|
|
143
220
|
source: evt.source,
|
|
144
221
|
level: evt.level,
|
|
145
222
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
146
223
|
});
|
|
147
224
|
break;
|
|
148
|
-
case
|
|
149
|
-
this.
|
|
225
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Clear:
|
|
226
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
150
227
|
break;
|
|
151
228
|
}
|
|
152
229
|
}
|
|
@@ -163,7 +240,7 @@ class SelectionManager {
|
|
|
163
240
|
source,
|
|
164
241
|
level,
|
|
165
242
|
imodel,
|
|
166
|
-
changeType:
|
|
243
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Add,
|
|
167
244
|
keys: new presentation_common_1.KeySet(keys),
|
|
168
245
|
timestamp: new Date(),
|
|
169
246
|
rulesetId,
|
|
@@ -183,7 +260,7 @@ class SelectionManager {
|
|
|
183
260
|
source,
|
|
184
261
|
level,
|
|
185
262
|
imodel,
|
|
186
|
-
changeType:
|
|
263
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Remove,
|
|
187
264
|
keys: new presentation_common_1.KeySet(keys),
|
|
188
265
|
timestamp: new Date(),
|
|
189
266
|
rulesetId,
|
|
@@ -203,7 +280,7 @@ class SelectionManager {
|
|
|
203
280
|
source,
|
|
204
281
|
level,
|
|
205
282
|
imodel,
|
|
206
|
-
changeType:
|
|
283
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Replace,
|
|
207
284
|
keys: new presentation_common_1.KeySet(keys),
|
|
208
285
|
timestamp: new Date(),
|
|
209
286
|
rulesetId,
|
|
@@ -222,7 +299,7 @@ class SelectionManager {
|
|
|
222
299
|
source,
|
|
223
300
|
level,
|
|
224
301
|
imodel,
|
|
225
|
-
changeType:
|
|
302
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Clear,
|
|
226
303
|
keys: new presentation_common_1.KeySet(),
|
|
227
304
|
timestamp: new Date(),
|
|
228
305
|
rulesetId,
|
|
@@ -285,7 +362,7 @@ class SelectionManager {
|
|
|
285
362
|
getHiliteSetProvider(imodel) {
|
|
286
363
|
let provider = this._hiliteSetProviders.get(imodel);
|
|
287
364
|
if (!provider) {
|
|
288
|
-
provider =
|
|
365
|
+
provider = HiliteSetProvider_js_1.HiliteSetProvider.create({ imodel });
|
|
289
366
|
this._hiliteSetProviders.set(imodel, provider);
|
|
290
367
|
}
|
|
291
368
|
return provider;
|
|
@@ -293,10 +370,10 @@ class SelectionManager {
|
|
|
293
370
|
streamSelectionEvents() {
|
|
294
371
|
return this._selectionChanges
|
|
295
372
|
.pipe((0, rxjs_1.mergeMap)((args) => {
|
|
296
|
-
const currentSelectables = this.
|
|
373
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
297
374
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe((0, rxjs_1.mergeMap)(({ level, changedSelection }) => {
|
|
298
|
-
const imodel = this._knownIModels.
|
|
299
|
-
|
|
375
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
376
|
+
/* c8 ignore next 3 */
|
|
300
377
|
if (!imodel) {
|
|
301
378
|
return rxjs_1.EMPTY;
|
|
302
379
|
}
|
|
@@ -318,12 +395,37 @@ class SelectionManager {
|
|
|
318
395
|
}
|
|
319
396
|
}
|
|
320
397
|
exports.SelectionManager = SelectionManager;
|
|
398
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
399
|
+
for (const imodel of set) {
|
|
400
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
401
|
+
return imodel;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
321
406
|
/** @internal */
|
|
322
407
|
class ToolSelectionSyncHandler {
|
|
408
|
+
_selectionSourceName = "Tool";
|
|
409
|
+
_logicalSelection;
|
|
410
|
+
_imodel;
|
|
411
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
412
|
+
_asyncsTracker = new internal_1.AsyncTasksTracker();
|
|
413
|
+
isSuspended;
|
|
323
414
|
constructor(imodel, logicalSelection) {
|
|
324
|
-
this.
|
|
325
|
-
this.
|
|
326
|
-
this.
|
|
415
|
+
this._imodel = imodel;
|
|
416
|
+
this._logicalSelection = logicalSelection;
|
|
417
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
418
|
+
}
|
|
419
|
+
[Symbol.dispose]() {
|
|
420
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
421
|
+
}
|
|
422
|
+
/** note: used only it tests */
|
|
423
|
+
get pendingAsyncs() {
|
|
424
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
425
|
+
}
|
|
426
|
+
onToolSelectionChanged = async (ev) => {
|
|
427
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
428
|
+
try {
|
|
327
429
|
// ignore selection change event if the handler is suspended
|
|
328
430
|
if (this.isSuspended) {
|
|
329
431
|
return;
|
|
@@ -339,54 +441,47 @@ class ToolSelectionSyncHandler {
|
|
|
339
441
|
let ids;
|
|
340
442
|
switch (ev.type) {
|
|
341
443
|
case core_frontend_1.SelectionSetEventType.Add:
|
|
342
|
-
ids = ev.
|
|
444
|
+
ids = ev.additions;
|
|
343
445
|
break;
|
|
344
446
|
case core_frontend_1.SelectionSetEventType.Replace:
|
|
345
|
-
ids = ev.set.
|
|
447
|
+
ids = ev.set.active;
|
|
346
448
|
break;
|
|
347
449
|
default:
|
|
348
|
-
ids = ev.
|
|
450
|
+
ids = ev.removals;
|
|
349
451
|
break;
|
|
350
452
|
}
|
|
351
453
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
352
454
|
// makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
|
|
353
455
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
354
456
|
// concrete classes)
|
|
355
|
-
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
457
|
+
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0, SelectionScopesManager_js_1.createSelectionScopeProps)(this._logicalSelection.scopes.activeScope));
|
|
458
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
459
|
+
switch (ev.type) {
|
|
460
|
+
case core_frontend_1.SelectionSetEventType.Add:
|
|
461
|
+
await changer.add(ids, selectionLevel);
|
|
462
|
+
break;
|
|
463
|
+
case core_frontend_1.SelectionSetEventType.Replace:
|
|
464
|
+
await changer.replace(ids, selectionLevel);
|
|
465
|
+
break;
|
|
466
|
+
case core_frontend_1.SelectionSetEventType.Remove:
|
|
467
|
+
await changer.remove(ids, selectionLevel);
|
|
468
|
+
break;
|
|
469
|
+
case core_frontend_1.SelectionSetEventType.Clear:
|
|
470
|
+
await changer.clear(selectionLevel);
|
|
471
|
+
break;
|
|
360
472
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
case core_frontend_1.SelectionSetEventType.Remove:
|
|
371
|
-
await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
};
|
|
376
|
-
this._imodel = imodel;
|
|
377
|
-
this._logicalSelection = logicalSelection;
|
|
378
|
-
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
379
|
-
}
|
|
380
|
-
dispose() {
|
|
381
|
-
this._imodelToolSelectionListenerDisposeFunc();
|
|
382
|
-
}
|
|
383
|
-
/** note: used only it tests */
|
|
384
|
-
get pendingAsyncs() {
|
|
385
|
-
return this._asyncsTracker.pendingAsyncs;
|
|
386
|
-
}
|
|
473
|
+
}
|
|
474
|
+
catch (e_1) {
|
|
475
|
+
env_1.error = e_1;
|
|
476
|
+
env_1.hasError = true;
|
|
477
|
+
}
|
|
478
|
+
finally {
|
|
479
|
+
__disposeResources(env_1);
|
|
480
|
+
}
|
|
481
|
+
};
|
|
387
482
|
}
|
|
388
483
|
exports.ToolSelectionSyncHandler = ToolSelectionSyncHandler;
|
|
389
|
-
const
|
|
484
|
+
const parseElementIds = (ids) => {
|
|
390
485
|
let allPersistent = true;
|
|
391
486
|
let allTransient = true;
|
|
392
487
|
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
@@ -421,13 +516,16 @@ const parseIds = (ids) => {
|
|
|
421
516
|
}
|
|
422
517
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
423
518
|
};
|
|
424
|
-
function
|
|
425
|
-
for (const id of core_bentley_1.Id64.iterable(
|
|
426
|
-
|
|
519
|
+
function addKeys(target, className, ids) {
|
|
520
|
+
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
521
|
+
target.add({ className, id });
|
|
427
522
|
}
|
|
428
523
|
}
|
|
429
|
-
/** @internal */
|
|
430
524
|
class ScopedSelectionChanger {
|
|
525
|
+
name;
|
|
526
|
+
imodel;
|
|
527
|
+
manager;
|
|
528
|
+
scope;
|
|
431
529
|
constructor(name, imodel, manager, scope) {
|
|
432
530
|
this.name = name;
|
|
433
531
|
this.imodel = imodel;
|
|
@@ -437,27 +535,37 @@ class ScopedSelectionChanger {
|
|
|
437
535
|
async clear(level) {
|
|
438
536
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
439
537
|
}
|
|
440
|
-
async add(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
538
|
+
async add(ids, level) {
|
|
539
|
+
const keys = await this.#computeSelection(ids);
|
|
443
540
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
444
541
|
}
|
|
445
|
-
async remove(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
542
|
+
async remove(ids, level) {
|
|
543
|
+
const keys = await this.#computeSelection(ids);
|
|
448
544
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
449
545
|
}
|
|
450
|
-
async replace(
|
|
451
|
-
const keys = await this
|
|
452
|
-
addTransientKeys(transientIds, keys);
|
|
546
|
+
async replace(ids, level) {
|
|
547
|
+
const keys = await this.#computeSelection(ids);
|
|
453
548
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
454
549
|
}
|
|
550
|
+
async #computeSelection(ids) {
|
|
551
|
+
let keys = new presentation_common_1.KeySet();
|
|
552
|
+
if (ids.elements) {
|
|
553
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
554
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
555
|
+
addKeys(keys, unified_selection_1.TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
556
|
+
}
|
|
557
|
+
if (ids.models) {
|
|
558
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
559
|
+
}
|
|
560
|
+
if (ids.subcategories) {
|
|
561
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
562
|
+
}
|
|
563
|
+
return keys;
|
|
564
|
+
}
|
|
455
565
|
}
|
|
456
566
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
457
567
|
class CurrentSelectionStorage {
|
|
458
|
-
|
|
459
|
-
this._currentSelection = new Map();
|
|
460
|
-
}
|
|
568
|
+
_currentSelection = new Map();
|
|
461
569
|
getCurrentSelectionStorage(imodelKey) {
|
|
462
570
|
let storage = this._currentSelection.get(imodelKey);
|
|
463
571
|
if (!storage) {
|
|
@@ -481,9 +589,7 @@ class CurrentSelectionStorage {
|
|
|
481
589
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
482
590
|
*/
|
|
483
591
|
class IModelSelectionStorage {
|
|
484
|
-
|
|
485
|
-
this._currentSelection = new Map();
|
|
486
|
-
}
|
|
592
|
+
_currentSelection = new Map();
|
|
487
593
|
getSelection(level) {
|
|
488
594
|
let entry = this._currentSelection.get(level);
|
|
489
595
|
if (!entry) {
|
|
@@ -501,7 +607,7 @@ class IModelSelectionStorage {
|
|
|
501
607
|
}
|
|
502
608
|
clearedLevels.forEach((storedLevel) => {
|
|
503
609
|
const entry = this._currentSelection.get(storedLevel);
|
|
504
|
-
|
|
610
|
+
/* c8 ignore next 3 */
|
|
505
611
|
if (!entry) {
|
|
506
612
|
return;
|
|
507
613
|
}
|
|
@@ -521,13 +627,12 @@ class IModelSelectionStorage {
|
|
|
521
627
|
}
|
|
522
628
|
setSelection(level, keys, disposer) {
|
|
523
629
|
const currEntry = this._currentSelection.get(level);
|
|
524
|
-
// istanbul ignore else
|
|
525
630
|
if (currEntry) {
|
|
526
631
|
currEntry.ongoingComputationDisposers.delete(disposer);
|
|
527
632
|
}
|
|
528
633
|
this._currentSelection.set(level, {
|
|
529
634
|
value: keys,
|
|
530
|
-
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /*
|
|
635
|
+
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* c8 ignore next */ new Set(),
|
|
531
636
|
});
|
|
532
637
|
}
|
|
533
638
|
computeSelection(level, currSelectables, changedSelectables) {
|
|
@@ -606,7 +711,7 @@ async function* createInstanceKeysIterator(imodel, nodeKey) {
|
|
|
606
711
|
}
|
|
607
712
|
return;
|
|
608
713
|
}
|
|
609
|
-
const content = await
|
|
714
|
+
const content = await Presentation_js_1.Presentation.presentation.getContentInstanceKeys({
|
|
610
715
|
imodel,
|
|
611
716
|
keys: new presentation_common_1.KeySet([nodeKey]),
|
|
612
717
|
rulesetOrId: {
|
|
@@ -634,13 +739,13 @@ function isNodeKey(data) {
|
|
|
634
739
|
function getChangeType(type) {
|
|
635
740
|
switch (type) {
|
|
636
741
|
case "add":
|
|
637
|
-
return
|
|
742
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Add;
|
|
638
743
|
case "remove":
|
|
639
|
-
return
|
|
744
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Remove;
|
|
640
745
|
case "replace":
|
|
641
|
-
return
|
|
746
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Replace;
|
|
642
747
|
case "clear":
|
|
643
|
-
return
|
|
748
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Clear;
|
|
644
749
|
}
|
|
645
750
|
}
|
|
646
751
|
//# sourceMappingURL=SelectionManager.js.map
|