@itwin/presentation-frontend 5.0.0-dev.10 → 5.0.0-dev.102
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 +58 -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/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 +77 -74
- 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 +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 -13
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +216 -116
- 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/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 +66 -63
- 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 +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 -13
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +202 -102
- 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 +42 -42
|
@@ -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 {
|
|
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
|
-
/** @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.
|
|
365
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
294
366
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
|
|
295
|
-
const imodel = this._knownIModels.
|
|
296
|
-
|
|
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,12 +386,37 @@ export class SelectionManager {
|
|
|
314
386
|
});
|
|
315
387
|
}
|
|
316
388
|
}
|
|
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
|
+
}
|
|
317
397
|
/** @internal */
|
|
318
398
|
export class ToolSelectionSyncHandler {
|
|
399
|
+
_selectionSourceName = "Tool";
|
|
400
|
+
_logicalSelection;
|
|
401
|
+
_imodel;
|
|
402
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
403
|
+
_asyncsTracker = new AsyncTasksTracker();
|
|
404
|
+
isSuspended;
|
|
319
405
|
constructor(imodel, logicalSelection) {
|
|
320
|
-
this.
|
|
321
|
-
this.
|
|
322
|
-
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 {
|
|
323
420
|
// ignore selection change event if the handler is suspended
|
|
324
421
|
if (this.isSuspended) {
|
|
325
422
|
return;
|
|
@@ -335,13 +432,13 @@ export class ToolSelectionSyncHandler {
|
|
|
335
432
|
let ids;
|
|
336
433
|
switch (ev.type) {
|
|
337
434
|
case SelectionSetEventType.Add:
|
|
338
|
-
ids = ev.
|
|
435
|
+
ids = ev.additions;
|
|
339
436
|
break;
|
|
340
437
|
case SelectionSetEventType.Replace:
|
|
341
|
-
ids = ev.set.
|
|
438
|
+
ids = ev.set.active;
|
|
342
439
|
break;
|
|
343
440
|
default:
|
|
344
|
-
ids = ev.
|
|
441
|
+
ids = ev.removals;
|
|
345
442
|
break;
|
|
346
443
|
}
|
|
347
444
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
@@ -349,39 +446,32 @@ export class ToolSelectionSyncHandler {
|
|
|
349
446
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
350
447
|
// concrete classes)
|
|
351
448
|
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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;
|
|
356
463
|
}
|
|
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
|
-
}
|
|
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
|
+
};
|
|
383
473
|
}
|
|
384
|
-
const
|
|
474
|
+
const parseElementIds = (ids) => {
|
|
385
475
|
let allPersistent = true;
|
|
386
476
|
let allTransient = true;
|
|
387
477
|
for (const id of Id64.iterable(ids)) {
|
|
@@ -416,13 +506,16 @@ const parseIds = (ids) => {
|
|
|
416
506
|
}
|
|
417
507
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
418
508
|
};
|
|
419
|
-
function
|
|
420
|
-
for (const id of Id64.iterable(
|
|
421
|
-
|
|
509
|
+
function addKeys(target, className, ids) {
|
|
510
|
+
for (const id of Id64.iterable(ids)) {
|
|
511
|
+
target.add({ className, id });
|
|
422
512
|
}
|
|
423
513
|
}
|
|
424
|
-
/** @internal */
|
|
425
514
|
class ScopedSelectionChanger {
|
|
515
|
+
name;
|
|
516
|
+
imodel;
|
|
517
|
+
manager;
|
|
518
|
+
scope;
|
|
426
519
|
constructor(name, imodel, manager, scope) {
|
|
427
520
|
this.name = name;
|
|
428
521
|
this.imodel = imodel;
|
|
@@ -432,27 +525,37 @@ class ScopedSelectionChanger {
|
|
|
432
525
|
async clear(level) {
|
|
433
526
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
434
527
|
}
|
|
435
|
-
async add(
|
|
436
|
-
const keys = await this
|
|
437
|
-
addTransientKeys(transientIds, keys);
|
|
528
|
+
async add(ids, level) {
|
|
529
|
+
const keys = await this.#computeSelection(ids);
|
|
438
530
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
439
531
|
}
|
|
440
|
-
async remove(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
532
|
+
async remove(ids, level) {
|
|
533
|
+
const keys = await this.#computeSelection(ids);
|
|
443
534
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
444
535
|
}
|
|
445
|
-
async replace(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
536
|
+
async replace(ids, level) {
|
|
537
|
+
const keys = await this.#computeSelection(ids);
|
|
448
538
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
449
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
|
+
}
|
|
450
555
|
}
|
|
451
556
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
452
557
|
class CurrentSelectionStorage {
|
|
453
|
-
|
|
454
|
-
this._currentSelection = new Map();
|
|
455
|
-
}
|
|
558
|
+
_currentSelection = new Map();
|
|
456
559
|
getCurrentSelectionStorage(imodelKey) {
|
|
457
560
|
let storage = this._currentSelection.get(imodelKey);
|
|
458
561
|
if (!storage) {
|
|
@@ -476,9 +579,7 @@ class CurrentSelectionStorage {
|
|
|
476
579
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
477
580
|
*/
|
|
478
581
|
class IModelSelectionStorage {
|
|
479
|
-
|
|
480
|
-
this._currentSelection = new Map();
|
|
481
|
-
}
|
|
582
|
+
_currentSelection = new Map();
|
|
482
583
|
getSelection(level) {
|
|
483
584
|
let entry = this._currentSelection.get(level);
|
|
484
585
|
if (!entry) {
|
|
@@ -496,7 +597,7 @@ class IModelSelectionStorage {
|
|
|
496
597
|
}
|
|
497
598
|
clearedLevels.forEach((storedLevel) => {
|
|
498
599
|
const entry = this._currentSelection.get(storedLevel);
|
|
499
|
-
|
|
600
|
+
/* c8 ignore next 3 */
|
|
500
601
|
if (!entry) {
|
|
501
602
|
return;
|
|
502
603
|
}
|
|
@@ -516,13 +617,12 @@ class IModelSelectionStorage {
|
|
|
516
617
|
}
|
|
517
618
|
setSelection(level, keys, disposer) {
|
|
518
619
|
const currEntry = this._currentSelection.get(level);
|
|
519
|
-
// istanbul ignore else
|
|
520
620
|
if (currEntry) {
|
|
521
621
|
currEntry.ongoingComputationDisposers.delete(disposer);
|
|
522
622
|
}
|
|
523
623
|
this._currentSelection.set(level, {
|
|
524
624
|
value: keys,
|
|
525
|
-
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /*
|
|
625
|
+
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* c8 ignore next */ new Set(),
|
|
526
626
|
});
|
|
527
627
|
}
|
|
528
628
|
computeSelection(level, currSelectables, changedSelectables) {
|