@itwin/presentation-frontend 5.0.0-dev.1 → 5.0.0-dev.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -1
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.d.ts +13 -0
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.d.ts.map +1 -0
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.js +22 -0
- package/lib/cjs/presentation-frontend/IModelConnectionInitialization.js.map +1 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.d.ts +6 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.d.ts.map +1 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.js +17 -0
- package/lib/cjs/presentation-frontend/InternalSymbols.js.map +1 -0
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +12 -3
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +7 -7
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +7 -6
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +15 -14
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +31 -45
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +12 -23
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +81 -78
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +2 -4
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +2 -4
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +6 -4
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +9 -19
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +163 -153
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +4 -5
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +27 -29
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +10 -4
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +2 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +5 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +8 -5
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +3 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +31 -15
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +218 -120
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +11 -9
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +6 -11
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.d.ts +15 -15
- package/lib/cjs/presentation-frontend.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend.js +30 -29
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.d.ts +13 -0
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.d.ts.map +1 -0
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.js +17 -0
- package/lib/esm/presentation-frontend/IModelConnectionInitialization.js.map +1 -0
- package/lib/esm/presentation-frontend/InternalSymbols.d.ts +6 -0
- package/lib/esm/presentation-frontend/InternalSymbols.d.ts.map +1 -0
- package/lib/esm/presentation-frontend/InternalSymbols.js +14 -0
- package/lib/esm/presentation-frontend/InternalSymbols.js.map +1 -0
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +12 -3
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +8 -8
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +3 -2
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +15 -14
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +24 -38
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +12 -23
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +67 -64
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +2 -4
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +2 -4
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +6 -4
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +1 -0
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +9 -19
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +164 -154
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +4 -5
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +27 -29
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +9 -3
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +2 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +5 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +8 -5
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +3 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +31 -15
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +204 -106
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +11 -9
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +7 -11
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.d.ts +15 -15
- package/lib/esm/presentation-frontend.d.ts.map +1 -1
- package/lib/esm/presentation-frontend.js +12 -15
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +43 -43
|
@@ -3,66 +3,135 @@
|
|
|
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
|
-
exports.ToolSelectionSyncHandler = exports.
|
|
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
|
-
/** @internal */
|
|
62
|
-
// istanbul ignore next
|
|
63
|
-
getToolSelectionSyncHandler(imodel) {
|
|
64
|
-
return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;
|
|
65
|
-
}
|
|
66
135
|
/**
|
|
67
136
|
* Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).
|
|
68
137
|
*/
|
|
@@ -84,27 +153,30 @@ class SelectionManager {
|
|
|
84
153
|
}
|
|
85
154
|
else {
|
|
86
155
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
87
|
-
registration.handler.dispose();
|
|
156
|
+
registration.handler[Symbol.dispose]();
|
|
88
157
|
}
|
|
89
158
|
}
|
|
90
159
|
}
|
|
91
160
|
}
|
|
92
161
|
/**
|
|
93
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
162
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
94
163
|
* is disposed.
|
|
95
164
|
*/
|
|
96
165
|
suspendIModelToolSelectionSync(imodel) {
|
|
97
166
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
98
167
|
if (!registration) {
|
|
99
|
-
|
|
168
|
+
const noop = () => { };
|
|
169
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
100
170
|
}
|
|
101
171
|
const wasSuspended = registration.handler.isSuspended;
|
|
102
172
|
registration.handler.isSuspended = true;
|
|
103
|
-
|
|
173
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
174
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
104
175
|
}
|
|
105
176
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
106
177
|
getSelectionLevels(imodel) {
|
|
107
|
-
|
|
178
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
179
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
108
180
|
}
|
|
109
181
|
/**
|
|
110
182
|
* Get the selection currently stored in this manager
|
|
@@ -114,39 +186,39 @@ class SelectionManager {
|
|
|
114
186
|
* latest selection after changes.
|
|
115
187
|
*/
|
|
116
188
|
getSelection(imodel, level = 0) {
|
|
117
|
-
|
|
189
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
190
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
118
191
|
}
|
|
119
192
|
handleEvent(evt) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
193
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
194
|
+
this._knownIModels.add(evt.imodel);
|
|
123
195
|
switch (evt.changeType) {
|
|
124
|
-
case
|
|
125
|
-
this.
|
|
126
|
-
|
|
196
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Add:
|
|
197
|
+
this.selectionStorage.addToSelection({
|
|
198
|
+
imodelKey,
|
|
127
199
|
source: evt.source,
|
|
128
200
|
level: evt.level,
|
|
129
201
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
130
202
|
});
|
|
131
203
|
break;
|
|
132
|
-
case
|
|
133
|
-
this.
|
|
134
|
-
|
|
204
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Remove:
|
|
205
|
+
this.selectionStorage.removeFromSelection({
|
|
206
|
+
imodelKey,
|
|
135
207
|
source: evt.source,
|
|
136
208
|
level: evt.level,
|
|
137
209
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
138
210
|
});
|
|
139
211
|
break;
|
|
140
|
-
case
|
|
141
|
-
this.
|
|
142
|
-
|
|
212
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Replace:
|
|
213
|
+
this.selectionStorage.replaceSelection({
|
|
214
|
+
imodelKey,
|
|
143
215
|
source: evt.source,
|
|
144
216
|
level: evt.level,
|
|
145
217
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
146
218
|
});
|
|
147
219
|
break;
|
|
148
|
-
case
|
|
149
|
-
this.
|
|
220
|
+
case SelectionChangeEvent_js_1.SelectionChangeType.Clear:
|
|
221
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
150
222
|
break;
|
|
151
223
|
}
|
|
152
224
|
}
|
|
@@ -163,7 +235,7 @@ class SelectionManager {
|
|
|
163
235
|
source,
|
|
164
236
|
level,
|
|
165
237
|
imodel,
|
|
166
|
-
changeType:
|
|
238
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Add,
|
|
167
239
|
keys: new presentation_common_1.KeySet(keys),
|
|
168
240
|
timestamp: new Date(),
|
|
169
241
|
rulesetId,
|
|
@@ -183,7 +255,7 @@ class SelectionManager {
|
|
|
183
255
|
source,
|
|
184
256
|
level,
|
|
185
257
|
imodel,
|
|
186
|
-
changeType:
|
|
258
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Remove,
|
|
187
259
|
keys: new presentation_common_1.KeySet(keys),
|
|
188
260
|
timestamp: new Date(),
|
|
189
261
|
rulesetId,
|
|
@@ -203,7 +275,7 @@ class SelectionManager {
|
|
|
203
275
|
source,
|
|
204
276
|
level,
|
|
205
277
|
imodel,
|
|
206
|
-
changeType:
|
|
278
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Replace,
|
|
207
279
|
keys: new presentation_common_1.KeySet(keys),
|
|
208
280
|
timestamp: new Date(),
|
|
209
281
|
rulesetId,
|
|
@@ -222,7 +294,7 @@ class SelectionManager {
|
|
|
222
294
|
source,
|
|
223
295
|
level,
|
|
224
296
|
imodel,
|
|
225
|
-
changeType:
|
|
297
|
+
changeType: SelectionChangeEvent_js_1.SelectionChangeType.Clear,
|
|
226
298
|
keys: new presentation_common_1.KeySet(),
|
|
227
299
|
timestamp: new Date(),
|
|
228
300
|
rulesetId,
|
|
@@ -285,7 +357,7 @@ class SelectionManager {
|
|
|
285
357
|
getHiliteSetProvider(imodel) {
|
|
286
358
|
let provider = this._hiliteSetProviders.get(imodel);
|
|
287
359
|
if (!provider) {
|
|
288
|
-
provider =
|
|
360
|
+
provider = HiliteSetProvider_js_1.HiliteSetProvider.create({ imodel });
|
|
289
361
|
this._hiliteSetProviders.set(imodel, provider);
|
|
290
362
|
}
|
|
291
363
|
return provider;
|
|
@@ -293,10 +365,10 @@ class SelectionManager {
|
|
|
293
365
|
streamSelectionEvents() {
|
|
294
366
|
return this._selectionChanges
|
|
295
367
|
.pipe((0, rxjs_1.mergeMap)((args) => {
|
|
296
|
-
const currentSelectables = this.
|
|
297
|
-
return this._currentSelection.computeSelection(args.
|
|
298
|
-
const imodel = this._knownIModels.
|
|
299
|
-
|
|
368
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
369
|
+
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe((0, rxjs_1.mergeMap)(({ level, changedSelection }) => {
|
|
370
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
371
|
+
/* c8 ignore next 3 */
|
|
300
372
|
if (!imodel) {
|
|
301
373
|
return rxjs_1.EMPTY;
|
|
302
374
|
}
|
|
@@ -318,14 +390,37 @@ class SelectionManager {
|
|
|
318
390
|
}
|
|
319
391
|
}
|
|
320
392
|
exports.SelectionManager = SelectionManager;
|
|
321
|
-
|
|
322
|
-
|
|
393
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
394
|
+
for (const imodel of set) {
|
|
395
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
396
|
+
return imodel;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return undefined;
|
|
400
|
+
}
|
|
323
401
|
/** @internal */
|
|
324
402
|
class ToolSelectionSyncHandler {
|
|
403
|
+
_selectionSourceName = "Tool";
|
|
404
|
+
_logicalSelection;
|
|
405
|
+
_imodel;
|
|
406
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
407
|
+
_asyncsTracker = new internal_1.AsyncTasksTracker();
|
|
408
|
+
isSuspended;
|
|
325
409
|
constructor(imodel, logicalSelection) {
|
|
326
|
-
this.
|
|
327
|
-
this.
|
|
328
|
-
this.
|
|
410
|
+
this._imodel = imodel;
|
|
411
|
+
this._logicalSelection = logicalSelection;
|
|
412
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
413
|
+
}
|
|
414
|
+
[Symbol.dispose]() {
|
|
415
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
416
|
+
}
|
|
417
|
+
/** note: used only it tests */
|
|
418
|
+
get pendingAsyncs() {
|
|
419
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
420
|
+
}
|
|
421
|
+
onToolSelectionChanged = async (ev) => {
|
|
422
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
423
|
+
try {
|
|
329
424
|
// ignore selection change event if the handler is suspended
|
|
330
425
|
if (this.isSuspended) {
|
|
331
426
|
return;
|
|
@@ -341,54 +436,47 @@ class ToolSelectionSyncHandler {
|
|
|
341
436
|
let ids;
|
|
342
437
|
switch (ev.type) {
|
|
343
438
|
case core_frontend_1.SelectionSetEventType.Add:
|
|
344
|
-
ids = ev.
|
|
439
|
+
ids = ev.additions;
|
|
345
440
|
break;
|
|
346
441
|
case core_frontend_1.SelectionSetEventType.Replace:
|
|
347
|
-
ids = ev.set.
|
|
442
|
+
ids = ev.set.active;
|
|
348
443
|
break;
|
|
349
444
|
default:
|
|
350
|
-
ids = ev.
|
|
445
|
+
ids = ev.removals;
|
|
351
446
|
break;
|
|
352
447
|
}
|
|
353
448
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
354
449
|
// makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
|
|
355
450
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
356
451
|
// concrete classes)
|
|
357
|
-
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
452
|
+
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0, SelectionScopesManager_js_1.createSelectionScopeProps)(this._logicalSelection.scopes.activeScope));
|
|
453
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
454
|
+
switch (ev.type) {
|
|
455
|
+
case core_frontend_1.SelectionSetEventType.Add:
|
|
456
|
+
await changer.add(ids, selectionLevel);
|
|
457
|
+
break;
|
|
458
|
+
case core_frontend_1.SelectionSetEventType.Replace:
|
|
459
|
+
await changer.replace(ids, selectionLevel);
|
|
460
|
+
break;
|
|
461
|
+
case core_frontend_1.SelectionSetEventType.Remove:
|
|
462
|
+
await changer.remove(ids, selectionLevel);
|
|
463
|
+
break;
|
|
464
|
+
case core_frontend_1.SelectionSetEventType.Clear:
|
|
465
|
+
await changer.clear(selectionLevel);
|
|
466
|
+
break;
|
|
362
467
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
case core_frontend_1.SelectionSetEventType.Remove:
|
|
373
|
-
await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
this._imodel = imodel;
|
|
379
|
-
this._logicalSelection = logicalSelection;
|
|
380
|
-
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
381
|
-
}
|
|
382
|
-
dispose() {
|
|
383
|
-
this._imodelToolSelectionListenerDisposeFunc();
|
|
384
|
-
}
|
|
385
|
-
/** note: used only it tests */
|
|
386
|
-
get pendingAsyncs() {
|
|
387
|
-
return this._asyncsTracker.pendingAsyncs;
|
|
388
|
-
}
|
|
468
|
+
}
|
|
469
|
+
catch (e_1) {
|
|
470
|
+
env_1.error = e_1;
|
|
471
|
+
env_1.hasError = true;
|
|
472
|
+
}
|
|
473
|
+
finally {
|
|
474
|
+
__disposeResources(env_1);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
389
477
|
}
|
|
390
478
|
exports.ToolSelectionSyncHandler = ToolSelectionSyncHandler;
|
|
391
|
-
const
|
|
479
|
+
const parseElementIds = (ids) => {
|
|
392
480
|
let allPersistent = true;
|
|
393
481
|
let allTransient = true;
|
|
394
482
|
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
@@ -423,13 +511,16 @@ const parseIds = (ids) => {
|
|
|
423
511
|
}
|
|
424
512
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
425
513
|
};
|
|
426
|
-
function
|
|
427
|
-
for (const id of core_bentley_1.Id64.iterable(
|
|
428
|
-
|
|
514
|
+
function addKeys(target, className, ids) {
|
|
515
|
+
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
516
|
+
target.add({ className, id });
|
|
429
517
|
}
|
|
430
518
|
}
|
|
431
|
-
/** @internal */
|
|
432
519
|
class ScopedSelectionChanger {
|
|
520
|
+
name;
|
|
521
|
+
imodel;
|
|
522
|
+
manager;
|
|
523
|
+
scope;
|
|
433
524
|
constructor(name, imodel, manager, scope) {
|
|
434
525
|
this.name = name;
|
|
435
526
|
this.imodel = imodel;
|
|
@@ -439,27 +530,37 @@ class ScopedSelectionChanger {
|
|
|
439
530
|
async clear(level) {
|
|
440
531
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
441
532
|
}
|
|
442
|
-
async add(
|
|
443
|
-
const keys = await this
|
|
444
|
-
addTransientKeys(transientIds, keys);
|
|
533
|
+
async add(ids, level) {
|
|
534
|
+
const keys = await this.#computeSelection(ids);
|
|
445
535
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
446
536
|
}
|
|
447
|
-
async remove(
|
|
448
|
-
const keys = await this
|
|
449
|
-
addTransientKeys(transientIds, keys);
|
|
537
|
+
async remove(ids, level) {
|
|
538
|
+
const keys = await this.#computeSelection(ids);
|
|
450
539
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
451
540
|
}
|
|
452
|
-
async replace(
|
|
453
|
-
const keys = await this
|
|
454
|
-
addTransientKeys(transientIds, keys);
|
|
541
|
+
async replace(ids, level) {
|
|
542
|
+
const keys = await this.#computeSelection(ids);
|
|
455
543
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
456
544
|
}
|
|
545
|
+
async #computeSelection(ids) {
|
|
546
|
+
let keys = new presentation_common_1.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, unified_selection_1.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
|
+
}
|
|
457
560
|
}
|
|
458
561
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
459
562
|
class CurrentSelectionStorage {
|
|
460
|
-
|
|
461
|
-
this._currentSelection = new Map();
|
|
462
|
-
}
|
|
563
|
+
_currentSelection = new Map();
|
|
463
564
|
getCurrentSelectionStorage(imodelKey) {
|
|
464
565
|
let storage = this._currentSelection.get(imodelKey);
|
|
465
566
|
if (!storage) {
|
|
@@ -483,9 +584,7 @@ class CurrentSelectionStorage {
|
|
|
483
584
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
484
585
|
*/
|
|
485
586
|
class IModelSelectionStorage {
|
|
486
|
-
|
|
487
|
-
this._currentSelection = new Map();
|
|
488
|
-
}
|
|
587
|
+
_currentSelection = new Map();
|
|
489
588
|
getSelection(level) {
|
|
490
589
|
let entry = this._currentSelection.get(level);
|
|
491
590
|
if (!entry) {
|
|
@@ -503,7 +602,7 @@ class IModelSelectionStorage {
|
|
|
503
602
|
}
|
|
504
603
|
clearedLevels.forEach((storedLevel) => {
|
|
505
604
|
const entry = this._currentSelection.get(storedLevel);
|
|
506
|
-
|
|
605
|
+
/* c8 ignore next 3 */
|
|
507
606
|
if (!entry) {
|
|
508
607
|
return;
|
|
509
608
|
}
|
|
@@ -523,13 +622,12 @@ class IModelSelectionStorage {
|
|
|
523
622
|
}
|
|
524
623
|
setSelection(level, keys, disposer) {
|
|
525
624
|
const currEntry = this._currentSelection.get(level);
|
|
526
|
-
// istanbul ignore else
|
|
527
625
|
if (currEntry) {
|
|
528
626
|
currEntry.ongoingComputationDisposers.delete(disposer);
|
|
529
627
|
}
|
|
530
628
|
this._currentSelection.set(level, {
|
|
531
629
|
value: keys,
|
|
532
|
-
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /*
|
|
630
|
+
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* c8 ignore next */ new Set(),
|
|
533
631
|
});
|
|
534
632
|
}
|
|
535
633
|
computeSelection(level, currSelectables, changedSelectables) {
|
|
@@ -608,7 +706,7 @@ async function* createInstanceKeysIterator(imodel, nodeKey) {
|
|
|
608
706
|
}
|
|
609
707
|
return;
|
|
610
708
|
}
|
|
611
|
-
const content = await
|
|
709
|
+
const content = await Presentation_js_1.Presentation.presentation.getContentInstanceKeys({
|
|
612
710
|
imodel,
|
|
613
711
|
keys: new presentation_common_1.KeySet([nodeKey]),
|
|
614
712
|
rulesetOrId: {
|
|
@@ -636,13 +734,13 @@ function isNodeKey(data) {
|
|
|
636
734
|
function getChangeType(type) {
|
|
637
735
|
switch (type) {
|
|
638
736
|
case "add":
|
|
639
|
-
return
|
|
737
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Add;
|
|
640
738
|
case "remove":
|
|
641
|
-
return
|
|
739
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Remove;
|
|
642
740
|
case "replace":
|
|
643
|
-
return
|
|
741
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Replace;
|
|
644
742
|
case "clear":
|
|
645
|
-
return
|
|
743
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Clear;
|
|
646
744
|
}
|
|
647
745
|
}
|
|
648
746
|
//# sourceMappingURL=SelectionManager.js.map
|