@itwin/presentation-frontend 5.0.0-dev.10 → 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 +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/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 +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/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 +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
|
@@ -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
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.
|
|
368
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
297
369
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe((0, rxjs_1.mergeMap)(({ level, changedSelection }) => {
|
|
298
|
-
const imodel = this._knownIModels.
|
|
299
|
-
|
|
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,12 +390,37 @@ class SelectionManager {
|
|
|
318
390
|
}
|
|
319
391
|
}
|
|
320
392
|
exports.SelectionManager = SelectionManager;
|
|
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
|
+
}
|
|
321
401
|
/** @internal */
|
|
322
402
|
class ToolSelectionSyncHandler {
|
|
403
|
+
_selectionSourceName = "Tool";
|
|
404
|
+
_logicalSelection;
|
|
405
|
+
_imodel;
|
|
406
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
407
|
+
_asyncsTracker = new internal_1.AsyncTasksTracker();
|
|
408
|
+
isSuspended;
|
|
323
409
|
constructor(imodel, logicalSelection) {
|
|
324
|
-
this.
|
|
325
|
-
this.
|
|
326
|
-
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 {
|
|
327
424
|
// ignore selection change event if the handler is suspended
|
|
328
425
|
if (this.isSuspended) {
|
|
329
426
|
return;
|
|
@@ -339,54 +436,47 @@ class ToolSelectionSyncHandler {
|
|
|
339
436
|
let ids;
|
|
340
437
|
switch (ev.type) {
|
|
341
438
|
case core_frontend_1.SelectionSetEventType.Add:
|
|
342
|
-
ids = ev.
|
|
439
|
+
ids = ev.additions;
|
|
343
440
|
break;
|
|
344
441
|
case core_frontend_1.SelectionSetEventType.Replace:
|
|
345
|
-
ids = ev.set.
|
|
442
|
+
ids = ev.set.active;
|
|
346
443
|
break;
|
|
347
444
|
default:
|
|
348
|
-
ids = ev.
|
|
445
|
+
ids = ev.removals;
|
|
349
446
|
break;
|
|
350
447
|
}
|
|
351
448
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
352
449
|
// makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
|
|
353
450
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
354
451
|
// concrete classes)
|
|
355
|
-
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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;
|
|
360
467
|
}
|
|
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
|
-
}
|
|
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
|
+
};
|
|
387
477
|
}
|
|
388
478
|
exports.ToolSelectionSyncHandler = ToolSelectionSyncHandler;
|
|
389
|
-
const
|
|
479
|
+
const parseElementIds = (ids) => {
|
|
390
480
|
let allPersistent = true;
|
|
391
481
|
let allTransient = true;
|
|
392
482
|
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
@@ -421,13 +511,16 @@ const parseIds = (ids) => {
|
|
|
421
511
|
}
|
|
422
512
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
423
513
|
};
|
|
424
|
-
function
|
|
425
|
-
for (const id of core_bentley_1.Id64.iterable(
|
|
426
|
-
|
|
514
|
+
function addKeys(target, className, ids) {
|
|
515
|
+
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
516
|
+
target.add({ className, id });
|
|
427
517
|
}
|
|
428
518
|
}
|
|
429
|
-
/** @internal */
|
|
430
519
|
class ScopedSelectionChanger {
|
|
520
|
+
name;
|
|
521
|
+
imodel;
|
|
522
|
+
manager;
|
|
523
|
+
scope;
|
|
431
524
|
constructor(name, imodel, manager, scope) {
|
|
432
525
|
this.name = name;
|
|
433
526
|
this.imodel = imodel;
|
|
@@ -437,27 +530,37 @@ class ScopedSelectionChanger {
|
|
|
437
530
|
async clear(level) {
|
|
438
531
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
439
532
|
}
|
|
440
|
-
async add(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
533
|
+
async add(ids, level) {
|
|
534
|
+
const keys = await this.#computeSelection(ids);
|
|
443
535
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
444
536
|
}
|
|
445
|
-
async remove(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
537
|
+
async remove(ids, level) {
|
|
538
|
+
const keys = await this.#computeSelection(ids);
|
|
448
539
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
449
540
|
}
|
|
450
|
-
async replace(
|
|
451
|
-
const keys = await this
|
|
452
|
-
addTransientKeys(transientIds, keys);
|
|
541
|
+
async replace(ids, level) {
|
|
542
|
+
const keys = await this.#computeSelection(ids);
|
|
453
543
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
454
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
|
+
}
|
|
455
560
|
}
|
|
456
561
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
457
562
|
class CurrentSelectionStorage {
|
|
458
|
-
|
|
459
|
-
this._currentSelection = new Map();
|
|
460
|
-
}
|
|
563
|
+
_currentSelection = new Map();
|
|
461
564
|
getCurrentSelectionStorage(imodelKey) {
|
|
462
565
|
let storage = this._currentSelection.get(imodelKey);
|
|
463
566
|
if (!storage) {
|
|
@@ -481,9 +584,7 @@ class CurrentSelectionStorage {
|
|
|
481
584
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
482
585
|
*/
|
|
483
586
|
class IModelSelectionStorage {
|
|
484
|
-
|
|
485
|
-
this._currentSelection = new Map();
|
|
486
|
-
}
|
|
587
|
+
_currentSelection = new Map();
|
|
487
588
|
getSelection(level) {
|
|
488
589
|
let entry = this._currentSelection.get(level);
|
|
489
590
|
if (!entry) {
|
|
@@ -501,7 +602,7 @@ class IModelSelectionStorage {
|
|
|
501
602
|
}
|
|
502
603
|
clearedLevels.forEach((storedLevel) => {
|
|
503
604
|
const entry = this._currentSelection.get(storedLevel);
|
|
504
|
-
|
|
605
|
+
/* c8 ignore next 3 */
|
|
505
606
|
if (!entry) {
|
|
506
607
|
return;
|
|
507
608
|
}
|
|
@@ -521,13 +622,12 @@ class IModelSelectionStorage {
|
|
|
521
622
|
}
|
|
522
623
|
setSelection(level, keys, disposer) {
|
|
523
624
|
const currEntry = this._currentSelection.get(level);
|
|
524
|
-
// istanbul ignore else
|
|
525
625
|
if (currEntry) {
|
|
526
626
|
currEntry.ongoingComputationDisposers.delete(disposer);
|
|
527
627
|
}
|
|
528
628
|
this._currentSelection.set(level, {
|
|
529
629
|
value: keys,
|
|
530
|
-
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /*
|
|
630
|
+
ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* c8 ignore next */ new Set(),
|
|
531
631
|
});
|
|
532
632
|
}
|
|
533
633
|
computeSelection(level, currSelectables, changedSelectables) {
|
|
@@ -606,7 +706,7 @@ async function* createInstanceKeysIterator(imodel, nodeKey) {
|
|
|
606
706
|
}
|
|
607
707
|
return;
|
|
608
708
|
}
|
|
609
|
-
const content = await
|
|
709
|
+
const content = await Presentation_js_1.Presentation.presentation.getContentInstanceKeys({
|
|
610
710
|
imodel,
|
|
611
711
|
keys: new presentation_common_1.KeySet([nodeKey]),
|
|
612
712
|
rulesetOrId: {
|
|
@@ -634,13 +734,13 @@ function isNodeKey(data) {
|
|
|
634
734
|
function getChangeType(type) {
|
|
635
735
|
switch (type) {
|
|
636
736
|
case "add":
|
|
637
|
-
return
|
|
737
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Add;
|
|
638
738
|
case "remove":
|
|
639
|
-
return
|
|
739
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Remove;
|
|
640
740
|
case "replace":
|
|
641
|
-
return
|
|
741
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Replace;
|
|
642
742
|
case "clear":
|
|
643
|
-
return
|
|
743
|
+
return SelectionChangeEvent_js_1.SelectionChangeType.Clear;
|
|
644
744
|
}
|
|
645
745
|
}
|
|
646
746
|
//# sourceMappingURL=SelectionManager.js.map
|