@itwin/presentation-frontend 5.0.0-dev.9 → 5.0.0-dev.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +2 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +1 -0
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +12 -2
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +16 -7
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +4 -2
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +31 -21
- 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.js +4 -2
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.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 +4 -2
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +142 -126
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +21 -19
- 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 +4 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +1 -0
- 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 +4 -0
- 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 +5 -2
- 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 +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +27 -7
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +192 -87
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +3 -7
- 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.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +11 -9
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +2 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +1 -0
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +12 -2
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +16 -7
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +4 -2
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +32 -22
- 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.js +4 -2
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.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 +4 -2
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +143 -127
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +22 -20
- 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 +4 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +1 -0
- 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 +4 -0
- 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 +5 -2
- 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 +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +27 -7
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +193 -88
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +3 -7
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +6 -10
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +25 -26
|
@@ -137,35 +137,35 @@ class IModelAppFavoritePropertiesStorage {
|
|
|
137
137
|
exports.IModelAppFavoritePropertiesStorage = IModelAppFavoritePropertiesStorage;
|
|
138
138
|
/** @internal */
|
|
139
139
|
class OfflineCachingFavoritePropertiesStorage {
|
|
140
|
+
_connectivityInfo;
|
|
141
|
+
_impl;
|
|
142
|
+
_propertiesOfflineCache = new DictionaryWithReservations(iTwinAndIModelIdsKeyComparer);
|
|
143
|
+
_propertiesOrderOfflineCache = new DictionaryWithReservations(iTwinAndIModelIdsKeyComparer);
|
|
140
144
|
constructor(props) {
|
|
141
|
-
this._propertiesOfflineCache = new DictionaryWithReservations(iTwinAndIModelIdsKeyComparer);
|
|
142
|
-
this._propertiesOrderOfflineCache = new DictionaryWithReservations(iTwinAndIModelIdsKeyComparer);
|
|
143
|
-
this.onConnectivityStatusChanged = (args) => {
|
|
144
|
-
// istanbul ignore else
|
|
145
|
-
if (args.status === core_common_1.InternetConnectivityStatus.Online) {
|
|
146
|
-
// note: we're copying the cached values to temp arrays because `saveProperties` and `savePropertiesOrder` both
|
|
147
|
-
// attempt to modify cache dictionaries
|
|
148
|
-
const propertiesCache = new Array();
|
|
149
|
-
this._propertiesOfflineCache.forEach((key, value) => propertiesCache.push({ properties: value, iTwinId: key[0], imodelId: key[1] }));
|
|
150
|
-
propertiesCache.forEach(async (cached) => this.saveProperties(cached.properties, cached.iTwinId, cached.imodelId));
|
|
151
|
-
const ordersCache = new Array();
|
|
152
|
-
this._propertiesOrderOfflineCache.forEach((key, value) => ordersCache.push({ order: value, iTwinId: key[0], imodelId: key[1] }));
|
|
153
|
-
ordersCache.forEach(async (cached) => this.savePropertiesOrder(cached.order, cached.iTwinId, cached.imodelId));
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
145
|
this._impl = props.impl;
|
|
157
146
|
// istanbul ignore next
|
|
158
147
|
this._connectivityInfo = props.connectivityInfo ?? new ConnectivityInformationProvider_1.ConnectivityInformationProvider();
|
|
159
148
|
this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);
|
|
160
149
|
}
|
|
161
|
-
dispose() {
|
|
162
|
-
|
|
163
|
-
this._connectivityInfo.dispose();
|
|
164
|
-
}
|
|
150
|
+
[Symbol.dispose]() {
|
|
151
|
+
(0, core_bentley_1.isDisposable)(this._connectivityInfo) && this._connectivityInfo[Symbol.dispose]();
|
|
165
152
|
}
|
|
166
153
|
get impl() {
|
|
167
154
|
return this._impl;
|
|
168
155
|
}
|
|
156
|
+
onConnectivityStatusChanged = (args) => {
|
|
157
|
+
// istanbul ignore else
|
|
158
|
+
if (args.status === core_common_1.InternetConnectivityStatus.Online) {
|
|
159
|
+
// note: we're copying the cached values to temp arrays because `saveProperties` and `savePropertiesOrder` both
|
|
160
|
+
// attempt to modify cache dictionaries
|
|
161
|
+
const propertiesCache = new Array();
|
|
162
|
+
this._propertiesOfflineCache.forEach((key, value) => propertiesCache.push({ properties: value, iTwinId: key[0], imodelId: key[1] }));
|
|
163
|
+
propertiesCache.forEach(async (cached) => this.saveProperties(cached.properties, cached.iTwinId, cached.imodelId));
|
|
164
|
+
const ordersCache = new Array();
|
|
165
|
+
this._propertiesOrderOfflineCache.forEach((key, value) => ordersCache.push({ order: value, iTwinId: key[0], imodelId: key[1] }));
|
|
166
|
+
ordersCache.forEach(async (cached) => this.savePropertiesOrder(cached.order, cached.iTwinId, cached.imodelId));
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
169
|
async loadProperties(iTwinId, imodelId) {
|
|
170
170
|
if (this._connectivityInfo.status === core_common_1.InternetConnectivityStatus.Online) {
|
|
171
171
|
try {
|
|
@@ -221,6 +221,7 @@ class OfflineCachingFavoritePropertiesStorage {
|
|
|
221
221
|
}
|
|
222
222
|
exports.OfflineCachingFavoritePropertiesStorage = OfflineCachingFavoritePropertiesStorage;
|
|
223
223
|
class DictionaryWithReservations {
|
|
224
|
+
_impl;
|
|
224
225
|
constructor(compareKeys) {
|
|
225
226
|
this._impl = new core_bentley_1.Dictionary(compareKeys);
|
|
226
227
|
}
|
|
@@ -279,6 +280,7 @@ class NoopFavoritePropertiesStorage {
|
|
|
279
280
|
exports.NoopFavoritePropertiesStorage = NoopFavoritePropertiesStorage;
|
|
280
281
|
/** @internal */
|
|
281
282
|
class BrowserLocalFavoritePropertiesStorage {
|
|
283
|
+
_localStorage;
|
|
282
284
|
constructor(props) {
|
|
283
285
|
// istanbul ignore next
|
|
284
286
|
this._localStorage = props?.localStorage ?? window.localStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesStorage.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAkEH,0EASC;AAzED,sDAAmI;AACnI,oDAAgE;AAChE,wDAAiD;AACjD,oEAAmF;AACnF,wFAAuH;AAGvH,gBAAgB;AACH,QAAA,uCAAuC,GAAG,uBAAuB,CAAC;AAC/E,gBAAgB;AACH,QAAA,uCAAuC,GAAG,YAAY,CAAC;AACpE,gBAAgB;AACH,QAAA,gCAAgC,GAAG,oBAAoB,CAAC;AACrE,gBAAgB;AACH,QAAA,2CAA2C,GAAG,6BAA6B,CAAC;AAiCzF;;;GAGG;AACH,IAAY,qCAOX;AAPD,WAAY,qCAAqC;IAC/C,qIAAqI;IACrI,iGAAI,CAAA;IACJ,wFAAwF;IACxF,+HAAmB,CAAA;IACnB,mHAAmH;IACnH,qIAAsB,CAAA;AACxB,CAAC,EAPW,qCAAqC,qDAArC,qCAAqC,QAOhD;AAED;;;GAGG;AACH,SAAgB,+BAA+B,CAAC,IAA2C;IACzF,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,qCAAqC,CAAC,IAAI;YAC7C,OAAO,IAAI,6BAA6B,EAAE,CAAC;QAC7C,KAAK,qCAAqC,CAAC,mBAAmB;YAC5D,OAAO,IAAI,qCAAqC,EAAE,CAAC;QACrD,KAAK,qCAAqC,CAAC,sBAAsB;YAC/D,OAAO,IAAI,uCAAuC,CAAC,EAAE,IAAI,EAAE,IAAI,kCAAkC,EAAE,EAAE,CAAC,CAAC;IAC3G,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAa,kCAAkC;IACrC,KAAK,CAAC,gBAAgB;QAC5B,MAAM,WAAW,GAAG,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9G,IAAI,WAAW,EAAE,CAAC;Y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,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAiC,EAAE,OAAgB,EAAE,QAAiB;QAChG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACrH,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,OAA2B,EAAE,QAAgB;QAC5E,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,UAAU,GAAkC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YACtF,GAAG,IAAI;YACP,gBAAgB,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;SAClD,CAAC,CAAC,CAAC;QACJ,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAyC,EAAE,OAA2B,EAAE,QAAgB;QACvH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF;AA7CD,sFA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { AccessToken, compareStrings, Dictionary, Guid, IDisposable, isIDisposable, OrderedComparator } from \"@itwin/core-bentley\";\r\nimport { InternetConnectivityStatus } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { ConnectivityInformationProvider, IConnectivityInformationProvider } from \"../ConnectivityInformationProvider\";\r\nimport { FavoritePropertiesOrderInfo, PropertyFullName } from \"./FavoritePropertiesManager\";\r\n\r\n/** @internal */\r\nexport const IMODELJS_PRESENTATION_SETTING_NAMESPACE = \"imodeljs.presentation\";\r\n/** @internal */\r\nexport const DEPRECATED_PROPERTIES_SETTING_NAMESPACE = \"Properties\";\r\n/** @internal */\r\nexport const FAVORITE_PROPERTIES_SETTING_NAME = \"FavoriteProperties\";\r\n/** @internal */\r\nexport const FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME = \"FavoritePropertiesOrderInfo\";\r\n\r\n/**\r\n * Stores user preferences for favorite properties.\r\n * @public\r\n */\r\nexport interface IFavoritePropertiesStorage {\r\n /** Load Favorite properties from user-specific settings.\r\n * @param iTwinId ITwin Id, if the settings is specific to a iTwin, otherwise undefined.\r\n * @param imodelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\r\n */\r\n loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined>;\r\n /** Saves Favorite properties to user-specific settings.\r\n * @param properties Favorite properties to save.\r\n * @param iTwinId iTwin Id, if the settings is specific to a iTwin, otherwise undefined.\r\n * @param iModelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\r\n */\r\n saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void>;\r\n /** Load array of FavoritePropertiesOrderInfo from user-specific settings.\r\n * Setting is specific to an iModel.\r\n * @param iTwinId iTwin Id.\r\n * @param imodelId iModel Id.\r\n */\r\n loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined>;\r\n /** Saves FavoritePropertiesOrderInfo array to user-specific settings.\r\n * Setting is specific to an iModel.\r\n * @param orderInfo Array of FavoritePropertiesOrderInfo to save.\r\n * @param iTwinId iTwin Id.\r\n * @param imodelId iModel Id.\r\n */\r\n savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void>;\r\n}\r\n\r\n/**\r\n * Available implementations of [[IFavoritePropertiesStorage]].\r\n * @public\r\n */\r\nexport enum DefaultFavoritePropertiesStorageTypes {\r\n /** A no-op storage that doesn't store or return anything. Used for cases when favorite properties aren't used by the application. */\r\n Noop,\r\n /** A storage that stores favorite properties information in a browser local storage. */\r\n BrowserLocalStorage,\r\n /** A storage that stores favorite properties in a user preferences storage (see [[IModelApp.userPreferences]]). */\r\n UserPreferencesStorage,\r\n}\r\n\r\n/**\r\n * A factory method to create one of the available [[IFavoritePropertiesStorage]] implementations.\r\n * @public\r\n */\r\nexport function createFavoritePropertiesStorage(type: DefaultFavoritePropertiesStorageTypes): IFavoritePropertiesStorage {\r\n switch (type) {\r\n case DefaultFavoritePropertiesStorageTypes.Noop:\r\n return new NoopFavoritePropertiesStorage();\r\n case DefaultFavoritePropertiesStorageTypes.BrowserLocalStorage:\r\n return new BrowserLocalFavoritePropertiesStorage();\r\n case DefaultFavoritePropertiesStorageTypes.UserPreferencesStorage:\r\n return new OfflineCachingFavoritePropertiesStorage({ impl: new IModelAppFavoritePropertiesStorage() });\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class IModelAppFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n private async ensureIsSignedIn(): Promise<{ accessToken: AccessToken }> {\r\n const accessToken = IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : \"\";\r\n if (accessToken) {\r\n return { accessToken };\r\n }\r\n throw new PresentationError(PresentationStatus.Error, \"Current user is not authorized to use the settings service\");\r\n }\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n if (!IModelApp.userPreferences) {\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n }\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n let setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n });\r\n\r\n if (setting !== undefined) {\r\n return new Set<PropertyFullName>(setting);\r\n }\r\n\r\n // try to check the old namespace\r\n setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: DEPRECATED_PROPERTIES_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n });\r\n\r\n if (\r\n setting !== undefined &&\r\n setting.hasOwnProperty(\"nestedContentInfos\") &&\r\n setting.hasOwnProperty(\"propertyInfos\") &&\r\n setting.hasOwnProperty(\"baseFieldInfos\")\r\n ) {\r\n return new Set<PropertyFullName>([...setting.nestedContentInfos, ...setting.propertyInfos, ...setting.baseFieldInfos]);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void> {\r\n if (!IModelApp.userPreferences) {\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n }\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n await IModelApp.userPreferences.save({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n content: Array.from(properties),\r\n });\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n if (!IModelApp.userPreferences) {\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n }\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n const setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\r\n });\r\n return setting as FavoritePropertiesOrderInfo[];\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\r\n if (!IModelApp.userPreferences) {\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n }\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n await IModelApp.userPreferences.save({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\r\n content: orderInfos,\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface OfflineCachingFavoritePropertiesStorageProps {\r\n impl: IFavoritePropertiesStorage;\r\n connectivityInfo?: IConnectivityInformationProvider;\r\n}\r\n/** @internal */\r\nexport class OfflineCachingFavoritePropertiesStorage implements IFavoritePropertiesStorage, IDisposable {\r\n private _connectivityInfo: IConnectivityInformationProvider;\r\n private _impl: IFavoritePropertiesStorage;\r\n private _propertiesOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, Set<PropertyFullName>>(iTwinAndIModelIdsKeyComparer);\r\n private _propertiesOrderOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, FavoritePropertiesOrderInfo[]>(iTwinAndIModelIdsKeyComparer);\r\n\r\n public constructor(props: OfflineCachingFavoritePropertiesStorageProps) {\r\n this._impl = props.impl;\r\n // istanbul ignore next\r\n this._connectivityInfo = props.connectivityInfo ?? new ConnectivityInformationProvider();\r\n this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);\r\n }\r\n\r\n public dispose() {\r\n if (isIDisposable(this._connectivityInfo)) {\r\n this._connectivityInfo.dispose();\r\n }\r\n }\r\n\r\n public get impl() {\r\n return this._impl;\r\n }\r\n\r\n private onConnectivityStatusChanged = (args: { status: InternetConnectivityStatus }) => {\r\n // istanbul ignore else\r\n if (args.status === InternetConnectivityStatus.Online) {\r\n // note: we're copying the cached values to temp arrays because `saveProperties` and `savePropertiesOrder` both\r\n // attempt to modify cache dictionaries\r\n\r\n const propertiesCache = new Array<{ properties: Set<PropertyFullName>; iTwinId?: string; imodelId?: string }>();\r\n this._propertiesOfflineCache.forEach((key, value) => propertiesCache.push({ properties: value, iTwinId: key[0], imodelId: key[1] }));\r\n propertiesCache.forEach(async (cached) => this.saveProperties(cached.properties, cached.iTwinId, cached.imodelId));\r\n\r\n const ordersCache = new Array<{ order: FavoritePropertiesOrderInfo[]; iTwinId?: string; imodelId: string }>();\r\n this._propertiesOrderOfflineCache.forEach((key, value) => ordersCache.push({ order: value, iTwinId: key[0], imodelId: key[1]! }));\r\n ordersCache.forEach(async (cached) => this.savePropertiesOrder(cached.order, cached.iTwinId, cached.imodelId));\r\n }\r\n };\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string) {\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\r\n try {\r\n return await this._impl.loadProperties(iTwinId, imodelId);\r\n } catch {\r\n // return from offline cache if the above fails\r\n }\r\n }\r\n return this._propertiesOfflineCache.get([iTwinId, imodelId]);\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\r\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\r\n this._propertiesOfflineCache.set(key, properties);\r\n return;\r\n }\r\n const reservationId = this._propertiesOfflineCache.reserve(key);\r\n try {\r\n await this._impl.saveProperties(properties, iTwinId, imodelId);\r\n this._propertiesOfflineCache.reservedDelete(key, reservationId);\r\n } catch {\r\n this._propertiesOfflineCache.reservedSet(key, properties, reservationId);\r\n }\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string) {\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\r\n try {\r\n return await this._impl.loadPropertiesOrder(iTwinId, imodelId);\r\n } catch {\r\n // return from offline cache if the above fails\r\n }\r\n }\r\n return this._propertiesOrderOfflineCache.get([iTwinId, imodelId]);\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\r\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\r\n this._propertiesOrderOfflineCache.set(key, orderInfos);\r\n return;\r\n }\r\n const reservationId = this._propertiesOrderOfflineCache.reserve(key);\r\n try {\r\n await this._impl.savePropertiesOrder(orderInfos, iTwinId, imodelId);\r\n this._propertiesOrderOfflineCache.reservedDelete(key, reservationId);\r\n } catch {\r\n this._propertiesOrderOfflineCache.reservedSet(key, orderInfos, reservationId);\r\n }\r\n }\r\n}\r\n\r\nclass DictionaryWithReservations<TKey, TValue> {\r\n private _impl: Dictionary<TKey, { value?: TValue; lastReservationId?: string }>;\r\n public constructor(compareKeys: OrderedComparator<TKey>) {\r\n this._impl = new Dictionary(compareKeys);\r\n }\r\n public get(key: TKey) {\r\n return this._impl.get(key)?.value;\r\n }\r\n public forEach(func: (key: TKey, value: TValue) => void): void {\r\n this._impl.forEach((key, entry) => {\r\n // istanbul ignore else\r\n if (entry.value) {\r\n func(key, entry.value);\r\n }\r\n });\r\n }\r\n public reserve(key: TKey) {\r\n const reservationId = Guid.createValue();\r\n this._impl.set(key, { lastReservationId: reservationId });\r\n return reservationId;\r\n }\r\n public set(key: TKey, value: TValue) {\r\n return this._impl.set(key, { value });\r\n }\r\n public reservedSet(key: TKey, value: TValue, reservationId: string) {\r\n const entry = this._impl.get(key);\r\n if (entry && entry.lastReservationId === reservationId) {\r\n this._impl.set(key, { value });\r\n }\r\n }\r\n public reservedDelete(key: TKey, reservationId: string) {\r\n const entry = this._impl.get(key);\r\n if (entry && entry.lastReservationId === reservationId) {\r\n this._impl.delete(key);\r\n }\r\n }\r\n}\r\ntype ITwinAndIModelIdsKey = [string | undefined, string | undefined];\r\n\r\n// istanbul ignore next\r\nfunction iTwinAndIModelIdsKeyComparer(lhs: ITwinAndIModelIdsKey, rhs: ITwinAndIModelIdsKey) {\r\n const iTwinIdCompare = compareStrings(lhs[0] ?? \"\", rhs[0] ?? \"\");\r\n return iTwinIdCompare !== 0 ? iTwinIdCompare : compareStrings(lhs[1] ?? \"\", rhs[1] ?? \"\");\r\n}\r\n\r\n/** @internal */\r\nexport class NoopFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n // istanbul ignore next\r\n public async loadProperties(_iTwinId?: string, _imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n return undefined;\r\n }\r\n // istanbul ignore next\r\n public async saveProperties(_properties: Set<PropertyFullName>, _iTwinId?: string, _imodelId?: string) {}\r\n // istanbul ignore next\r\n public async loadPropertiesOrder(_iTwinId: string | undefined, _imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n return undefined;\r\n }\r\n // istanbul ignore next\r\n public async savePropertiesOrder(_orderInfos: FavoritePropertiesOrderInfo[], _iTwinId: string | undefined, _imodelId: string): Promise<void> {}\r\n}\r\n\r\n/** @internal */\r\nexport class BrowserLocalFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n private _localStorage: Storage;\r\n\r\n public constructor(props?: { localStorage?: Storage }) {\r\n // istanbul ignore next\r\n this._localStorage = props?.localStorage ?? window.localStorage;\r\n }\r\n\r\n public createFavoritesSettingItemKey(iTwinId?: string, imodelId?: string): string {\r\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\r\n }\r\n public createOrderSettingItemKey(iTwinId?: string, imodelId?: string): string {\r\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\r\n }\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n const value = this._localStorage.getItem(this.createFavoritesSettingItemKey(iTwinId, imodelId));\r\n if (!value) {\r\n return undefined;\r\n }\r\n\r\n const properties: PropertyFullName[] = JSON.parse(value);\r\n return new Set(properties);\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\r\n this._localStorage.setItem(this.createFavoritesSettingItemKey(iTwinId, imodelId), JSON.stringify([...properties]));\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n const value = this._localStorage.getItem(this.createOrderSettingItemKey(iTwinId, imodelId));\r\n if (!value) {\r\n return undefined;\r\n }\r\n\r\n const orderInfos: FavoritePropertiesOrderInfo[] = JSON.parse(value).map((json: any) => ({\r\n ...json,\r\n orderedTimestamp: new Date(json.orderedTimestamp),\r\n }));\r\n return orderInfos;\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void> {\r\n this._localStorage.setItem(this.createOrderSettingItemKey(iTwinId, imodelId), JSON.stringify(orderInfos));\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesStorage.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAkEH,0EASC;AAzED,sDAAqH;AACrH,oDAAgE;AAChE,wDAAiD;AACjD,oEAAmF;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I,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACrH,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,OAA2B,EAAE,QAAgB;QAC5E,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,UAAU,GAAkC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YACtF,GAAG,IAAI;YACP,gBAAgB,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;SAClD,CAAC,CAAC,CAAC;QACJ,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAyC,EAAE,OAA2B,EAAE,QAAgB;QACvH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF;AA7CD,sFA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { AccessToken, compareStrings, Dictionary, Guid, isDisposable, OrderedComparator } from \"@itwin/core-bentley\";\nimport { InternetConnectivityStatus } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\nimport { ConnectivityInformationProvider, IConnectivityInformationProvider } from \"../ConnectivityInformationProvider\";\nimport { FavoritePropertiesOrderInfo, PropertyFullName } from \"./FavoritePropertiesManager\";\n\n/** @internal */\nexport const IMODELJS_PRESENTATION_SETTING_NAMESPACE = \"imodeljs.presentation\";\n/** @internal */\nexport const DEPRECATED_PROPERTIES_SETTING_NAMESPACE = \"Properties\";\n/** @internal */\nexport const FAVORITE_PROPERTIES_SETTING_NAME = \"FavoriteProperties\";\n/** @internal */\nexport const FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME = \"FavoritePropertiesOrderInfo\";\n\n/**\n * Stores user preferences for favorite properties.\n * @public\n */\nexport interface IFavoritePropertiesStorage {\n /** Load Favorite properties from user-specific settings.\n * @param iTwinId ITwin Id, if the settings is specific to a iTwin, otherwise undefined.\n * @param imodelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\n */\n loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined>;\n /** Saves Favorite properties to user-specific settings.\n * @param properties Favorite properties to save.\n * @param iTwinId iTwin Id, if the settings is specific to a iTwin, otherwise undefined.\n * @param iModelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\n */\n saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void>;\n /** Load array of FavoritePropertiesOrderInfo from user-specific settings.\n * Setting is specific to an iModel.\n * @param iTwinId iTwin Id.\n * @param imodelId iModel Id.\n */\n loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined>;\n /** Saves FavoritePropertiesOrderInfo array to user-specific settings.\n * Setting is specific to an iModel.\n * @param orderInfo Array of FavoritePropertiesOrderInfo to save.\n * @param iTwinId iTwin Id.\n * @param imodelId iModel Id.\n */\n savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void>;\n}\n\n/**\n * Available implementations of [[IFavoritePropertiesStorage]].\n * @public\n */\nexport enum DefaultFavoritePropertiesStorageTypes {\n /** A no-op storage that doesn't store or return anything. Used for cases when favorite properties aren't used by the application. */\n Noop,\n /** A storage that stores favorite properties information in a browser local storage. */\n BrowserLocalStorage,\n /** A storage that stores favorite properties in a user preferences storage (see [[IModelApp.userPreferences]]). */\n UserPreferencesStorage,\n}\n\n/**\n * A factory method to create one of the available [[IFavoritePropertiesStorage]] implementations.\n * @public\n */\nexport function createFavoritePropertiesStorage(type: DefaultFavoritePropertiesStorageTypes): IFavoritePropertiesStorage {\n switch (type) {\n case DefaultFavoritePropertiesStorageTypes.Noop:\n return new NoopFavoritePropertiesStorage();\n case DefaultFavoritePropertiesStorageTypes.BrowserLocalStorage:\n return new BrowserLocalFavoritePropertiesStorage();\n case DefaultFavoritePropertiesStorageTypes.UserPreferencesStorage:\n return new OfflineCachingFavoritePropertiesStorage({ impl: new IModelAppFavoritePropertiesStorage() });\n }\n}\n\n/**\n * @internal\n */\nexport class IModelAppFavoritePropertiesStorage implements IFavoritePropertiesStorage {\n private async ensureIsSignedIn(): Promise<{ accessToken: AccessToken }> {\n const accessToken = IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : \"\";\n if (accessToken) {\n return { accessToken };\n }\n throw new PresentationError(PresentationStatus.Error, \"Current user is not authorized to use the settings service\");\n }\n\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\n if (!IModelApp.userPreferences) {\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\n }\n\n const { accessToken } = await this.ensureIsSignedIn();\n let setting = await IModelApp.userPreferences.get({\n accessToken,\n iTwinId,\n iModelId: imodelId,\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\n key: FAVORITE_PROPERTIES_SETTING_NAME,\n });\n\n if (setting !== undefined) {\n return new Set<PropertyFullName>(setting);\n }\n\n // try to check the old namespace\n setting = await IModelApp.userPreferences.get({\n accessToken,\n iTwinId,\n iModelId: imodelId,\n namespace: DEPRECATED_PROPERTIES_SETTING_NAMESPACE,\n key: FAVORITE_PROPERTIES_SETTING_NAME,\n });\n\n if (\n setting !== undefined &&\n setting.hasOwnProperty(\"nestedContentInfos\") &&\n setting.hasOwnProperty(\"propertyInfos\") &&\n setting.hasOwnProperty(\"baseFieldInfos\")\n ) {\n return new Set<PropertyFullName>([...setting.nestedContentInfos, ...setting.propertyInfos, ...setting.baseFieldInfos]);\n }\n\n return undefined;\n }\n\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void> {\n if (!IModelApp.userPreferences) {\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\n }\n\n const { accessToken } = await this.ensureIsSignedIn();\n await IModelApp.userPreferences.save({\n accessToken,\n iTwinId,\n iModelId: imodelId,\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\n key: FAVORITE_PROPERTIES_SETTING_NAME,\n content: Array.from(properties),\n });\n }\n\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\n if (!IModelApp.userPreferences) {\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\n }\n\n const { accessToken } = await this.ensureIsSignedIn();\n const setting = await IModelApp.userPreferences.get({\n accessToken,\n iTwinId,\n iModelId: imodelId,\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\n });\n return setting as FavoritePropertiesOrderInfo[];\n }\n\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\n if (!IModelApp.userPreferences) {\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\n }\n\n const { accessToken } = await this.ensureIsSignedIn();\n await IModelApp.userPreferences.save({\n accessToken,\n iTwinId,\n iModelId: imodelId,\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\n content: orderInfos,\n });\n }\n}\n\n/** @internal */\nexport interface OfflineCachingFavoritePropertiesStorageProps {\n impl: IFavoritePropertiesStorage;\n connectivityInfo?: IConnectivityInformationProvider;\n}\n/** @internal */\nexport class OfflineCachingFavoritePropertiesStorage implements IFavoritePropertiesStorage, Disposable {\n private _connectivityInfo: IConnectivityInformationProvider;\n private _impl: IFavoritePropertiesStorage;\n private _propertiesOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, Set<PropertyFullName>>(iTwinAndIModelIdsKeyComparer);\n private _propertiesOrderOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, FavoritePropertiesOrderInfo[]>(iTwinAndIModelIdsKeyComparer);\n\n public constructor(props: OfflineCachingFavoritePropertiesStorageProps) {\n this._impl = props.impl;\n // istanbul ignore next\n this._connectivityInfo = props.connectivityInfo ?? new ConnectivityInformationProvider();\n this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);\n }\n\n public [Symbol.dispose]() {\n isDisposable(this._connectivityInfo) && this._connectivityInfo[Symbol.dispose]();\n }\n\n public get impl() {\n return this._impl;\n }\n\n private onConnectivityStatusChanged = (args: { status: InternetConnectivityStatus }) => {\n // istanbul ignore else\n if (args.status === InternetConnectivityStatus.Online) {\n // note: we're copying the cached values to temp arrays because `saveProperties` and `savePropertiesOrder` both\n // attempt to modify cache dictionaries\n\n const propertiesCache = new Array<{ properties: Set<PropertyFullName>; iTwinId?: string; imodelId?: string }>();\n this._propertiesOfflineCache.forEach((key, value) => propertiesCache.push({ properties: value, iTwinId: key[0], imodelId: key[1] }));\n propertiesCache.forEach(async (cached) => this.saveProperties(cached.properties, cached.iTwinId, cached.imodelId));\n\n const ordersCache = new Array<{ order: FavoritePropertiesOrderInfo[]; iTwinId?: string; imodelId: string }>();\n this._propertiesOrderOfflineCache.forEach((key, value) => ordersCache.push({ order: value, iTwinId: key[0], imodelId: key[1]! }));\n ordersCache.forEach(async (cached) => this.savePropertiesOrder(cached.order, cached.iTwinId, cached.imodelId));\n }\n };\n\n public async loadProperties(iTwinId?: string, imodelId?: string) {\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\n try {\n return await this._impl.loadProperties(iTwinId, imodelId);\n } catch {\n // return from offline cache if the above fails\n }\n }\n return this._propertiesOfflineCache.get([iTwinId, imodelId]);\n }\n\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\n this._propertiesOfflineCache.set(key, properties);\n return;\n }\n const reservationId = this._propertiesOfflineCache.reserve(key);\n try {\n await this._impl.saveProperties(properties, iTwinId, imodelId);\n this._propertiesOfflineCache.reservedDelete(key, reservationId);\n } catch {\n this._propertiesOfflineCache.reservedSet(key, properties, reservationId);\n }\n }\n\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string) {\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\n try {\n return await this._impl.loadPropertiesOrder(iTwinId, imodelId);\n } catch {\n // return from offline cache if the above fails\n }\n }\n return this._propertiesOrderOfflineCache.get([iTwinId, imodelId]);\n }\n\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\n this._propertiesOrderOfflineCache.set(key, orderInfos);\n return;\n }\n const reservationId = this._propertiesOrderOfflineCache.reserve(key);\n try {\n await this._impl.savePropertiesOrder(orderInfos, iTwinId, imodelId);\n this._propertiesOrderOfflineCache.reservedDelete(key, reservationId);\n } catch {\n this._propertiesOrderOfflineCache.reservedSet(key, orderInfos, reservationId);\n }\n }\n}\n\nclass DictionaryWithReservations<TKey, TValue> {\n private _impl: Dictionary<TKey, { value?: TValue; lastReservationId?: string }>;\n public constructor(compareKeys: OrderedComparator<TKey>) {\n this._impl = new Dictionary(compareKeys);\n }\n public get(key: TKey) {\n return this._impl.get(key)?.value;\n }\n public forEach(func: (key: TKey, value: TValue) => void): void {\n this._impl.forEach((key, entry) => {\n // istanbul ignore else\n if (entry.value) {\n func(key, entry.value);\n }\n });\n }\n public reserve(key: TKey) {\n const reservationId = Guid.createValue();\n this._impl.set(key, { lastReservationId: reservationId });\n return reservationId;\n }\n public set(key: TKey, value: TValue) {\n return this._impl.set(key, { value });\n }\n public reservedSet(key: TKey, value: TValue, reservationId: string) {\n const entry = this._impl.get(key);\n if (entry && entry.lastReservationId === reservationId) {\n this._impl.set(key, { value });\n }\n }\n public reservedDelete(key: TKey, reservationId: string) {\n const entry = this._impl.get(key);\n if (entry && entry.lastReservationId === reservationId) {\n this._impl.delete(key);\n }\n }\n}\ntype ITwinAndIModelIdsKey = [string | undefined, string | undefined];\n\n// istanbul ignore next\nfunction iTwinAndIModelIdsKeyComparer(lhs: ITwinAndIModelIdsKey, rhs: ITwinAndIModelIdsKey) {\n const iTwinIdCompare = compareStrings(lhs[0] ?? \"\", rhs[0] ?? \"\");\n return iTwinIdCompare !== 0 ? iTwinIdCompare : compareStrings(lhs[1] ?? \"\", rhs[1] ?? \"\");\n}\n\n/** @internal */\nexport class NoopFavoritePropertiesStorage implements IFavoritePropertiesStorage {\n // istanbul ignore next\n public async loadProperties(_iTwinId?: string, _imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\n return undefined;\n }\n // istanbul ignore next\n public async saveProperties(_properties: Set<PropertyFullName>, _iTwinId?: string, _imodelId?: string) {}\n // istanbul ignore next\n public async loadPropertiesOrder(_iTwinId: string | undefined, _imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\n return undefined;\n }\n // istanbul ignore next\n public async savePropertiesOrder(_orderInfos: FavoritePropertiesOrderInfo[], _iTwinId: string | undefined, _imodelId: string): Promise<void> {}\n}\n\n/** @internal */\nexport class BrowserLocalFavoritePropertiesStorage implements IFavoritePropertiesStorage {\n private _localStorage: Storage;\n\n public constructor(props?: { localStorage?: Storage }) {\n // istanbul ignore next\n this._localStorage = props?.localStorage ?? window.localStorage;\n }\n\n public createFavoritesSettingItemKey(iTwinId?: string, imodelId?: string): string {\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\n }\n public createOrderSettingItemKey(iTwinId?: string, imodelId?: string): string {\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\n }\n\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\n const value = this._localStorage.getItem(this.createFavoritesSettingItemKey(iTwinId, imodelId));\n if (!value) {\n return undefined;\n }\n\n const properties: PropertyFullName[] = JSON.parse(value);\n return new Set(properties);\n }\n\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\n this._localStorage.setItem(this.createFavoritesSettingItemKey(iTwinId, imodelId), JSON.stringify([...properties]));\n }\n\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\n const value = this._localStorage.getItem(this.createOrderSettingItemKey(iTwinId, imodelId));\n if (!value) {\n return undefined;\n }\n\n const orderInfos: FavoritePropertiesOrderInfo[] = JSON.parse(value).map((json: any) => ({\n ...json,\n orderedTimestamp: new Date(json.orderedTimestamp),\n }));\n return orderInfos;\n }\n\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void> {\n this._localStorage.setItem(this.createOrderSettingItemKey(iTwinId, imodelId), JSON.stringify(orderInfos));\n }\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import { KeySet } from "@itwin/presentation-common";
|
|
|
9
9
|
* viewport hilite.
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
|
+
* @deprecated in 5.0. Use `HiliteSet` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.
|
|
12
13
|
*/
|
|
13
14
|
export interface HiliteSet {
|
|
14
15
|
models?: Id64String[];
|
|
@@ -18,6 +19,7 @@ export interface HiliteSet {
|
|
|
18
19
|
/**
|
|
19
20
|
* Properties for creating a `HiliteSetProvider` instance.
|
|
20
21
|
* @public
|
|
22
|
+
* @deprecated in 5.0. Use `HiliteSetProvider` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.
|
|
21
23
|
*/
|
|
22
24
|
export interface HiliteSetProviderProps {
|
|
23
25
|
imodel: IModelConnection;
|
|
@@ -28,6 +30,7 @@ export interface HiliteSetProviderProps {
|
|
|
28
30
|
* supplied `KeySet`.
|
|
29
31
|
*
|
|
30
32
|
* @public
|
|
33
|
+
* @deprecated in 5.0. Use `HiliteSetProvider` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.
|
|
31
34
|
*/
|
|
32
35
|
export declare class HiliteSetProvider {
|
|
33
36
|
private _imodel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/HiliteSetProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/HiliteSetProvider.ts"],"names":[],"mappings":"AAKA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAqG,MAAM,EAAW,MAAM,4BAA4B,CAAC;AAOhK;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,UAAU,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,MAAM,CAAsE;IAEpF,OAAO;IAIP;;OAEG;WACW,MAAM,CAAC,KAAK,EAAE,sBAAsB;IAIlD;;;;;;OAMG;IACU,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAmB1E;;;OAGG;IACI,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC;YAWxC,uBAAuB;IAmCtC,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,mBAAmB;CAgB5B"}
|
|
@@ -3,6 +3,7 @@
|
|
|
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
|
*/
|
|
@@ -24,8 +25,11 @@ const HILITE_RULESET = HiliteRules_json_1.default;
|
|
|
24
25
|
* supplied `KeySet`.
|
|
25
26
|
*
|
|
26
27
|
* @public
|
|
28
|
+
* @deprecated in 5.0. Use `HiliteSetProvider` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.
|
|
27
29
|
*/
|
|
28
30
|
class HiliteSetProvider {
|
|
31
|
+
_imodel;
|
|
32
|
+
_cache;
|
|
29
33
|
constructor(props) {
|
|
30
34
|
this._imodel = props.imodel;
|
|
31
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HiliteSetProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/HiliteSetProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;AAEH,+BAAqD;AACrD,mDAA+C;AAG/C,oEAAgK;AAChK,kDAA+C;AAC/C,0EAA+C;AAC/C,gEAAuE;AAEvE,MAAM,cAAc,GAAG,0BAAwB,CAAC;AAsBhD;;;;;;GAMG;AACH,MAAa,iBAAiB;IAI5B,YAAoB,KAA6B;QAC/C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAM,CAAC,KAA6B;QAChD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,CAAC,SAA2B;QACnD,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAc,CAAC;QACzC,MAAM,cAAc,GAAG,IAAI,KAAK,EAAc,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,KAAK,EAAc,CAAC;QAE3C,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;YACrC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC;YAClD,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC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O,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO;YACL,YAAY;YACZ,IAAI;SACL,CAAC;IACJ,CAAC;CACF;AA9ID,8CA8IC;AAED,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,aAAa,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC;AAElF,MAAM,mBAAmB,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { from, Observable, shareReplay } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { ContentFlags, DEFAULT_KEYS_BATCH_SIZE, DefaultContentDisplayTypes, DescriptorOverrides, Item, Key, KeySet, Ruleset } from \"@itwin/presentation-common\";\r\nimport { Presentation } from \"../Presentation\";\r\nimport hiliteRuleset from \"./HiliteRules.json\";\r\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"@itwin/unified-selection\";\r\n\r\nconst HILITE_RULESET = hiliteRuleset as Ruleset;\r\n\r\n/**\r\n * A set of model, subcategory and element ids that can be used for specifying\r\n * viewport hilite.\r\n *\r\n * @public\r\n */\r\nexport interface HiliteSet {\r\n models?: Id64String[];\r\n subCategories?: Id64String[];\r\n elements?: Id64String[];\r\n}\r\n\r\n/**\r\n * Properties for creating a `HiliteSetProvider` instance.\r\n * @public\r\n */\r\nexport interface HiliteSetProviderProps {\r\n imodel: IModelConnection;\r\n}\r\n\r\n/**\r\n * Presentation-based provider which uses presentation ruleset to determine\r\n * what `HiliteSet` should be hilited in the graphics viewport based on the\r\n * supplied `KeySet`.\r\n *\r\n * @public\r\n */\r\nexport class HiliteSetProvider {\r\n private _imodel: IModelConnection;\r\n private _cache: undefined | { keysGuid: string; observable: Observable<HiliteSet> };\r\n\r\n private constructor(props: HiliteSetProviderProps) {\r\n this._imodel = props.imodel;\r\n }\r\n\r\n /**\r\n * Create a hilite set provider for the specified iModel.\r\n */\r\n public static create(props: HiliteSetProviderProps) {\r\n return new HiliteSetProvider(props);\r\n }\r\n\r\n /**\r\n * Get hilite set for instances and/or nodes whose keys are specified in the\r\n * given KeySet.\r\n *\r\n * Note: The provider caches result of the last request, so subsequent requests\r\n * for the same input doesn't cost.\r\n */\r\n public async getHiliteSet(selection: Readonly<KeySet>): Promise<HiliteSet> {\r\n const modelIds = new Array<Id64String>();\r\n const subCategoryIds = new Array<Id64String>();\r\n const elementIds = new Array<Id64String>();\r\n\r\n const iterator = this.getHiliteSetIterator(selection);\r\n for await (const set of iterator) {\r\n modelIds.push(...(set.models ?? []));\r\n subCategoryIds.push(...(set.subCategories ?? []));\r\n elementIds.push(...(set.elements ?? []));\r\n }\r\n\r\n return {\r\n models: modelIds.length ? modelIds : undefined,\r\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\r\n elements: elementIds.length ? elementIds : undefined,\r\n };\r\n }\r\n\r\n /**\r\n * Get hilite set iterator for provided keys. It loads content in batches and\r\n * yields hilite set created from each batch after it is loaded.\r\n */\r\n public getHiliteSetIterator(selection: Readonly<KeySet>) {\r\n if (!this._cache || this._cache.keysGuid !== selection.guid) {\r\n this._cache = {\r\n keysGuid: selection.guid,\r\n observable: from(this.createHiliteSetIterator(selection)).pipe(shareReplay({ refCount: true })),\r\n };\r\n }\r\n\r\n return eachValueFrom(this._cache.observable);\r\n }\r\n\r\n private async *createHiliteSetIterator(selection: Readonly<KeySet>) {\r\n const { keys, transientIds } = this.handleTransientKeys(selection);\r\n const { options, keyBatches } = this.getContentOptions(keys);\r\n\r\n if (transientIds.length !== 0) {\r\n yield { elements: transientIds };\r\n }\r\n\r\n for (const batch of keyBatches) {\r\n let loadedItems = 0;\r\n while (true) {\r\n const content = await Presentation.presentation.getContentIterator({\r\n ...options,\r\n paging: { start: loadedItems, size: CONTENT_SET_PAGE_SIZE },\r\n keys: batch,\r\n });\r\n if (!content) {\r\n break;\r\n }\r\n\r\n const items = new Array<Item>();\r\n for await (const item of content.items) {\r\n items.push(item);\r\n }\r\n const result = this.createHiliteSet(items);\r\n yield result;\r\n\r\n loadedItems += items.length;\r\n if (loadedItems >= content.total) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n private createHiliteSet(records: Item[]): HiliteSet {\r\n const modelIds = new Array<Id64String>();\r\n const subCategoryIds = new Array<Id64String>();\r\n const elementIds = new Array<Id64String>();\r\n records.forEach((rec) => {\r\n const ids = isModelRecord(rec) ? modelIds : isSubCategoryRecord(rec) ? subCategoryIds : elementIds;\r\n rec.primaryKeys.forEach((pk) => ids.push(pk.id));\r\n });\r\n return {\r\n models: modelIds.length ? modelIds : undefined,\r\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\r\n elements: elementIds.length ? elementIds : undefined,\r\n };\r\n }\r\n\r\n private getContentOptions(keys: KeySet) {\r\n const descriptor: DescriptorOverrides = {\r\n displayType: DefaultContentDisplayTypes.Viewport,\r\n contentFlags: ContentFlags.KeysOnly,\r\n };\r\n const options = {\r\n imodel: this._imodel,\r\n rulesetOrId: HILITE_RULESET,\r\n descriptor,\r\n };\r\n const keyBatches = new Array<KeySet>();\r\n keys.forEachBatch(DEFAULT_KEYS_BATCH_SIZE, (batch: KeySet) => {\r\n keyBatches.push(batch);\r\n });\r\n return {\r\n options,\r\n keyBatches,\r\n };\r\n }\r\n\r\n private handleTransientKeys(selection: Readonly<KeySet>) {\r\n // need to create a new set without transients\r\n const transientIds = new Array<Id64String>();\r\n const keys = new KeySet();\r\n keys.add(selection, (key: Key) => {\r\n if (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) {\r\n transientIds.push(key.id);\r\n return false;\r\n }\r\n return true;\r\n });\r\n return {\r\n transientIds,\r\n keys,\r\n };\r\n }\r\n}\r\n\r\nconst CONTENT_SET_PAGE_SIZE = 1000;\r\n\r\nconst isModelRecord = (rec: Item) => rec.extendedData && rec.extendedData.isModel;\r\n\r\nconst isSubCategoryRecord = (rec: Item) => rec.extendedData && rec.extendedData.isSubCategory;\r\n"]}
|
|
1
|
+
{"version":3,"file":"HiliteSetProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/HiliteSetProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;;;;AAEH,+BAAqD;AACrD,mDAA+C;AAG/C,oEAAgK;AAChK,kDAA+C;AAC/C,0EAA+C;AAC/C,gEAAuE;AAEvE,MAAM,cAAc,GAAG,0BAAwB,CAAC;AAwBhD;;;;;;;GAOG;AACH,MAAa,iBAAiB;IACpB,OAAO,CAAmB;IAC1B,MAAM,CAAsE;IAEpF,YAAoB,KAA6B;QAC/C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAM,CAAC,KAA6B;QAChD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,CAAC,SAA2B;QACnD,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAc,CAAC;QACzC,MAAM,cAAc,GAAG,IAAI,KAAK,EAAc,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,KAAK,EAAc,CAAC;QAE3C,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,KAAK,EAAE,MAAM,GAAG,IA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,MAAM,IAAI,GAAG,IAAI,4BAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAQ,EAAE,EAAE;YAC/B,IAAI,yBAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,+CAA2B,EAAE,CAAC;gBAC5E,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO;YACL,YAAY;YACZ,IAAI;SACL,CAAC;IACJ,CAAC;CACF;AA9ID,8CA8IC;AAED,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,aAAa,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC;AAElF,MAAM,mBAAmB,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { ContentFlags, DEFAULT_KEYS_BATCH_SIZE, DefaultContentDisplayTypes, DescriptorOverrides, Item, Key, KeySet, Ruleset } from \"@itwin/presentation-common\";\nimport { Presentation } from \"../Presentation\";\nimport hiliteRuleset from \"./HiliteRules.json\";\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"@itwin/unified-selection\";\n\nconst HILITE_RULESET = hiliteRuleset as Ruleset;\n\n/**\n * A set of model, subcategory and element ids that can be used for specifying\n * viewport hilite.\n *\n * @public\n * @deprecated in 5.0. Use `HiliteSet` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.\n */\nexport interface HiliteSet {\n models?: Id64String[];\n subCategories?: Id64String[];\n elements?: Id64String[];\n}\n\n/**\n * Properties for creating a `HiliteSetProvider` instance.\n * @public\n * @deprecated in 5.0. Use `HiliteSetProvider` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.\n */\nexport interface HiliteSetProviderProps {\n imodel: IModelConnection;\n}\n\n/**\n * Presentation-based provider which uses presentation ruleset to determine\n * what `HiliteSet` should be hilited in the graphics viewport based on the\n * supplied `KeySet`.\n *\n * @public\n * @deprecated in 5.0. Use `HiliteSetProvider` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#hilite-sets) package instead.\n */\nexport class HiliteSetProvider {\n private _imodel: IModelConnection;\n private _cache: undefined | { keysGuid: string; observable: Observable<HiliteSet> };\n\n private constructor(props: HiliteSetProviderProps) {\n this._imodel = props.imodel;\n }\n\n /**\n * Create a hilite set provider for the specified iModel.\n */\n public static create(props: HiliteSetProviderProps) {\n return new HiliteSetProvider(props);\n }\n\n /**\n * Get hilite set for instances and/or nodes whose keys are specified in the\n * given KeySet.\n *\n * Note: The provider caches result of the last request, so subsequent requests\n * for the same input doesn't cost.\n */\n public async getHiliteSet(selection: Readonly<KeySet>): Promise<HiliteSet> {\n const modelIds = new Array<Id64String>();\n const subCategoryIds = new Array<Id64String>();\n const elementIds = new Array<Id64String>();\n\n const iterator = this.getHiliteSetIterator(selection);\n for await (const set of iterator) {\n modelIds.push(...(set.models ?? []));\n subCategoryIds.push(...(set.subCategories ?? []));\n elementIds.push(...(set.elements ?? []));\n }\n\n return {\n models: modelIds.length ? modelIds : undefined,\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\n elements: elementIds.length ? elementIds : undefined,\n };\n }\n\n /**\n * Get hilite set iterator for provided keys. It loads content in batches and\n * yields hilite set created from each batch after it is loaded.\n */\n public getHiliteSetIterator(selection: Readonly<KeySet>) {\n if (!this._cache || this._cache.keysGuid !== selection.guid) {\n this._cache = {\n keysGuid: selection.guid,\n observable: from(this.createHiliteSetIterator(selection)).pipe(shareReplay({ refCount: true })),\n };\n }\n\n return eachValueFrom(this._cache.observable);\n }\n\n private async *createHiliteSetIterator(selection: Readonly<KeySet>) {\n const { keys, transientIds } = this.handleTransientKeys(selection);\n const { options, keyBatches } = this.getContentOptions(keys);\n\n if (transientIds.length !== 0) {\n yield { elements: transientIds };\n }\n\n for (const batch of keyBatches) {\n let loadedItems = 0;\n while (true) {\n const content = await Presentation.presentation.getContentIterator({\n ...options,\n paging: { start: loadedItems, size: CONTENT_SET_PAGE_SIZE },\n keys: batch,\n });\n if (!content) {\n break;\n }\n\n const items = new Array<Item>();\n for await (const item of content.items) {\n items.push(item);\n }\n const result = this.createHiliteSet(items);\n yield result;\n\n loadedItems += items.length;\n if (loadedItems >= content.total) {\n break;\n }\n }\n }\n }\n\n private createHiliteSet(records: Item[]): HiliteSet {\n const modelIds = new Array<Id64String>();\n const subCategoryIds = new Array<Id64String>();\n const elementIds = new Array<Id64String>();\n records.forEach((rec) => {\n const ids = isModelRecord(rec) ? modelIds : isSubCategoryRecord(rec) ? subCategoryIds : elementIds;\n rec.primaryKeys.forEach((pk) => ids.push(pk.id));\n });\n return {\n models: modelIds.length ? modelIds : undefined,\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\n elements: elementIds.length ? elementIds : undefined,\n };\n }\n\n private getContentOptions(keys: KeySet) {\n const descriptor: DescriptorOverrides = {\n displayType: DefaultContentDisplayTypes.Viewport,\n contentFlags: ContentFlags.KeysOnly,\n };\n const options = {\n imodel: this._imodel,\n rulesetOrId: HILITE_RULESET,\n descriptor,\n };\n const keyBatches = new Array<KeySet>();\n keys.forEachBatch(DEFAULT_KEYS_BATCH_SIZE, (batch: KeySet) => {\n keyBatches.push(batch);\n });\n return {\n options,\n keyBatches,\n };\n }\n\n private handleTransientKeys(selection: Readonly<KeySet>) {\n // need to create a new set without transients\n const transientIds = new Array<Id64String>();\n const keys = new KeySet();\n keys.add(selection, (key: Key) => {\n if (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) {\n transientIds.push(key.id);\n return false;\n }\n return true;\n });\n return {\n transientIds,\n keys,\n };\n }\n}\n\nconst CONTENT_SET_PAGE_SIZE = 1000;\n\nconst isModelRecord = (rec: Item) => rec.extendedData && rec.extendedData.isModel;\n\nconst isSubCategoryRecord = (rec: Item) => rec.extendedData && rec.extendedData.isSubCategory;\n"]}
|
|
@@ -7,6 +7,7 @@ import { SelectionChangeEvent } from "./SelectionChangeEvent";
|
|
|
7
7
|
/**
|
|
8
8
|
* Selection provider interface which provides main selection and sub-selection.
|
|
9
9
|
* @public
|
|
10
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
10
11
|
*/
|
|
11
12
|
export interface ISelectionProvider {
|
|
12
13
|
/** An event that's fired when selection changes */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISelectionProvider.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/ISelectionProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ISelectionProvider.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/ISelectionProvider.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,eAAe,EAAE,oBAAoB,CAAC;IAEtC;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;CACzE"}
|
|
@@ -3,6 +3,7 @@
|
|
|
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
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISelectionProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/ISelectionProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ISelectionProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/ISelectionProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { SelectionChangeEvent } from \"./SelectionChangeEvent\";\n\n/**\n * Selection provider interface which provides main selection and sub-selection.\n * @public\n * @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.\n */\nexport interface ISelectionProvider {\n /** An event that's fired when selection changes */\n selectionChange: SelectionChangeEvent;\n\n /** Get the selection stored in the provider.\n * @param imodel iModel connection which the selection is associated with.\n * @param level Level of the selection (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n */\n getSelection(imodel: IModelConnection, level: number): Readonly<KeySet>;\n}\n"]}
|
|
@@ -8,17 +8,20 @@ import { ISelectionProvider } from "./ISelectionProvider";
|
|
|
8
8
|
/**
|
|
9
9
|
* An interface for selection change listeners.
|
|
10
10
|
* @public
|
|
11
|
+
* @deprecated in 5.0. Use `StorageSelectionChangesListener` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
11
12
|
*/
|
|
12
13
|
export declare type SelectionChangesListener = (args: SelectionChangeEventArgs, provider: ISelectionProvider) => void;
|
|
13
14
|
/**
|
|
14
15
|
* An event broadcasted on selection changes
|
|
15
16
|
* @public
|
|
17
|
+
* @deprecated in 5.0. Use `Event<StorageSelectionChangesListener>` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
16
18
|
*/
|
|
17
19
|
export declare class SelectionChangeEvent extends BeEvent<SelectionChangesListener> {
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* The type of selection change
|
|
21
23
|
* @public
|
|
24
|
+
* @deprecated in 5.0. Use `StorageSelectionChangeType` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
22
25
|
*/
|
|
23
26
|
export declare enum SelectionChangeType {
|
|
24
27
|
/** Added to selection. */
|
|
@@ -33,6 +36,7 @@ export declare enum SelectionChangeType {
|
|
|
33
36
|
/**
|
|
34
37
|
* The event object that's sent when the selection changes.
|
|
35
38
|
* @public
|
|
39
|
+
* @deprecated in 5.0. Use `StorageSelectionChangeEventArgs` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
36
40
|
*/
|
|
37
41
|
export interface SelectionChangeEventArgs {
|
|
38
42
|
/** The name of the selection source which caused the selection change. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionChangeEvent.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionChangeEvent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectionChangeEvent.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,OAAO,MAAM,wBAAwB,GAAG,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAEtH;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,OAAO,CAAC,wBAAwB,CAAC;CAAG;AAE9E;;;;GAIG;AACH,oBAAY,mBAAmB;IAC7B,0BAA0B;IAC1B,GAAG,IAAA;IAEH,8BAA8B;IAC9B,MAAM,IAAA;IAEN,8BAA8B;IAC9B,OAAO,IAAA;IAEP,6BAA6B;IAC7B,KAAK,IAAA;CACN;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IAEf,yIAAyI;IACzI,KAAK,EAAE,MAAM,CAAC;IAEd,iCAAiC;IACjC,UAAU,EAAE,mBAAmB,CAAC;IAEhC,2DAA2D;IAC3D,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEvB,qEAAqE;IACrE,MAAM,EAAE,gBAAgB,CAAC;IAEzB,0DAA0D;IAC1D,SAAS,EAAE,IAAI,CAAC;IAEhB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
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
|
*/
|
|
@@ -12,6 +13,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
|
|
|
12
13
|
/**
|
|
13
14
|
* An event broadcasted on selection changes
|
|
14
15
|
* @public
|
|
16
|
+
* @deprecated in 5.0. Use `Event<StorageSelectionChangesListener>` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
15
17
|
*/
|
|
16
18
|
class SelectionChangeEvent extends core_bentley_1.BeEvent {
|
|
17
19
|
}
|
|
@@ -19,6 +21,7 @@ exports.SelectionChangeEvent = SelectionChangeEvent;
|
|
|
19
21
|
/**
|
|
20
22
|
* The type of selection change
|
|
21
23
|
* @public
|
|
24
|
+
* @deprecated in 5.0. Use `StorageSelectionChangeType` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
22
25
|
*/
|
|
23
26
|
var SelectionChangeType;
|
|
24
27
|
(function (SelectionChangeType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA8C;
|
|
1
|
+
{"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;AAEH,sDAA8C;AAY9C;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,sBAAiC;CAAG;AAA9E,oDAA8E;AAE9E;;;;GAIG;AACH,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B,0BAA0B;IAC1B,2DAAG,CAAA;IAEH,8BAA8B;IAC9B,iEAAM,CAAA;IAEN,8BAA8B;IAC9B,mEAAO,CAAA;IAEP,6BAA6B;IAC7B,+DAAK,CAAA;AACP,CAAC,EAZW,mBAAmB,mCAAnB,mBAAmB,QAY9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { ISelectionProvider } from \"./ISelectionProvider\";\n\n/**\n * An interface for selection change listeners.\n * @public\n * @deprecated in 5.0. Use `StorageSelectionChangesListener` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.\n */\nexport declare type SelectionChangesListener = (args: SelectionChangeEventArgs, provider: ISelectionProvider) => void;\n\n/**\n * An event broadcasted on selection changes\n * @public\n * @deprecated in 5.0. Use `Event<StorageSelectionChangesListener>` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.\n */\nexport class SelectionChangeEvent extends BeEvent<SelectionChangesListener> {}\n\n/**\n * The type of selection change\n * @public\n * @deprecated in 5.0. Use `StorageSelectionChangeType` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.\n */\nexport enum SelectionChangeType {\n /** Added to selection. */\n Add,\n\n /** Removed from selection. */\n Remove,\n\n /** Selection was replaced. */\n Replace,\n\n /** Selection was cleared. */\n Clear,\n}\n\n/**\n * The event object that's sent when the selection changes.\n * @public\n * @deprecated in 5.0. Use `StorageSelectionChangeEventArgs` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.\n */\nexport interface SelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n\n /** Level of the selection. See [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels). */\n level: number;\n\n /** The selection change type. */\n changeType: SelectionChangeType;\n\n /** Set of keys affected by this selection change event. */\n keys: Readonly<KeySet>;\n\n /** iModel connection with which the selection is associated with. */\n imodel: IModelConnection;\n\n /** The timestamp of when the selection change happened */\n timestamp: Date;\n\n /** Id of the ruleset associated with the selection change. */\n rulesetId?: string;\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module UnifiedSelection
|
|
3
3
|
*/
|
|
4
|
-
import { IDisposable } from "@itwin/core-bentley";
|
|
5
4
|
import { IModelConnection } from "@itwin/core-frontend";
|
|
6
5
|
import { Keys, KeySet } from "@itwin/presentation-common";
|
|
7
6
|
import { ISelectionProvider } from "./ISelectionProvider";
|
|
@@ -10,6 +9,7 @@ import { SelectionManager } from "./SelectionManager";
|
|
|
10
9
|
/**
|
|
11
10
|
* Properties for creating a `SelectionHandler` instance.
|
|
12
11
|
* @public
|
|
12
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#basic-usage) package instead.
|
|
13
13
|
*/
|
|
14
14
|
export interface SelectionHandlerProps {
|
|
15
15
|
/** SelectionManager used to store overall selection. */
|
|
@@ -37,8 +37,9 @@ export interface SelectionHandlerProps {
|
|
|
37
37
|
* internal the selection state.
|
|
38
38
|
*
|
|
39
39
|
* @public
|
|
40
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#basic-usage) package instead.
|
|
40
41
|
*/
|
|
41
|
-
export declare class SelectionHandler implements
|
|
42
|
+
export declare class SelectionHandler implements Disposable {
|
|
42
43
|
private _inSelect;
|
|
43
44
|
private _disposables;
|
|
44
45
|
/** Selection manager used by this handler to manage selection */
|
|
@@ -62,6 +63,8 @@ export declare class SelectionHandler implements IDisposable {
|
|
|
62
63
|
* Destructor. Must be called before disposing this object to make sure it cleans
|
|
63
64
|
* up correctly.
|
|
64
65
|
*/
|
|
66
|
+
[Symbol.dispose](): void;
|
|
67
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
65
68
|
dispose(): void;
|
|
66
69
|
/**
|
|
67
70
|
* Called when the selection changes. Handles this callback by first checking whether
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionHandler.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectionHandler.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAKA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,wDAAwD;IACxD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,uEAAuE;IACvE,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;I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AG,IAAI;CAO/C"}
|
|
@@ -3,6 +3,7 @@
|
|
|
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
|
*/
|
|
@@ -14,24 +15,28 @@ const core_bentley_1 = require("@itwin/core-bentley");
|
|
|
14
15
|
* internal the selection state.
|
|
15
16
|
*
|
|
16
17
|
* @public
|
|
18
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#basic-usage) package instead.
|
|
17
19
|
*/
|
|
18
20
|
class SelectionHandler {
|
|
21
|
+
_inSelect;
|
|
22
|
+
_disposables;
|
|
23
|
+
/** Selection manager used by this handler to manage selection */
|
|
24
|
+
manager;
|
|
25
|
+
/** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */
|
|
26
|
+
name;
|
|
27
|
+
/** iModel whose selection is being handled */
|
|
28
|
+
imodel;
|
|
29
|
+
/**
|
|
30
|
+
* Id of a ruleset selection changes will be associated with.
|
|
31
|
+
* @see `SelectionHandlerProps.rulesetId`
|
|
32
|
+
*/
|
|
33
|
+
rulesetId;
|
|
34
|
+
/** Callback function called when selection changes */
|
|
35
|
+
onSelect;
|
|
19
36
|
/**
|
|
20
37
|
* Constructor.
|
|
21
38
|
*/
|
|
22
39
|
constructor(props) {
|
|
23
|
-
/**
|
|
24
|
-
* Called when the selection changes. Handles this callback by first checking whether
|
|
25
|
-
* the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`
|
|
26
|
-
*/
|
|
27
|
-
this.onSelectionChanged = (evt, provider) => {
|
|
28
|
-
if (!this.onSelect || !this.shouldHandle(evt)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
this._inSelect = true;
|
|
32
|
-
this.onSelect(evt, provider);
|
|
33
|
-
this._inSelect = false;
|
|
34
|
-
};
|
|
35
40
|
this._inSelect = false;
|
|
36
41
|
this.manager = props.manager;
|
|
37
42
|
this._disposables = new core_bentley_1.DisposableList();
|
|
@@ -45,9 +50,26 @@ class SelectionHandler {
|
|
|
45
50
|
* Destructor. Must be called before disposing this object to make sure it cleans
|
|
46
51
|
* up correctly.
|
|
47
52
|
*/
|
|
48
|
-
dispose() {
|
|
53
|
+
[Symbol.dispose]() {
|
|
49
54
|
this._disposables.dispose();
|
|
50
55
|
}
|
|
56
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
57
|
+
// istanbul ignore next
|
|
58
|
+
dispose() {
|
|
59
|
+
this[Symbol.dispose]();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Called when the selection changes. Handles this callback by first checking whether
|
|
63
|
+
* the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`
|
|
64
|
+
*/
|
|
65
|
+
onSelectionChanged = (evt, provider) => {
|
|
66
|
+
if (!this.onSelect || !this.shouldHandle(evt)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this._inSelect = true;
|
|
70
|
+
this.onSelect(evt, provider);
|
|
71
|
+
this._inSelect = false;
|
|
72
|
+
};
|
|
51
73
|
/** Called to check whether the event should be handled by this handler */
|
|
52
74
|
shouldHandle(evt) {
|
|
53
75
|
if (this.name === evt.source) {
|