@itwin/presentation-frontend 4.4.0 → 4.5.0-dev.10
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 +1 -1
- package/README.md +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +10 -6
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js +18 -13
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +3 -3
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +3 -3
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +3 -3
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +24 -14
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +57 -30
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +11 -7
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +53 -31
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +111 -66
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +54 -25
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +16 -10
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +3 -3
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -3
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +15 -9
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +7 -5
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +31 -16
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +25 -14
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.js +3 -3
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +10 -6
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js +18 -13
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +3 -3
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +3 -3
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +3 -3
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +24 -14
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +57 -30
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +11 -7
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +53 -31
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +111 -66
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +54 -25
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +17 -11
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +3 -3
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -3
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +15 -9
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +7 -5
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +31 -16
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +25 -14
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js +3 -3
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +19 -16
package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesStorage.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiD,WAAW,EAAoC,MAAM,qBAAqB,CAAC;AAInI,OAAO,EAAmC,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACvH,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE5F,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,0BAA0B,CAAC;AAC/E,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,eAAe,CAAC;AACpE,gBAAgB;AAChB,eAAO,MAAM,gCAAgC,uBAAuB,CAAC;AACrE,gBAAgB;AAChB,eAAO,MAAM,2CAA2C,gCAAgC,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,CAAC;IAChG;;;;OAIG;IACH,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtG;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,EAAE,GAAG,SAAS,CAAC,CAAC;IACvH;;;;;OAKG;IACH,mBAAmB,CAAC,UAAU,EAAE,2BAA2B,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9H;AAED;;;GAGG;AACH,oBAAY,qCAAqC;IAC/C,qIAAqI;IACrI,IAAI,IAAA;IACJ,wFAAwF;IACxF,mBAAmB,IAAA;IACnB,mHAAmH;IACnH,sBAAsB,IAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,qCAAqC,GAAG,0BAA0B,
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesStorage.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiD,WAAW,EAAoC,MAAM,qBAAqB,CAAC;AAInI,OAAO,EAAmC,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACvH,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE5F,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,0BAA0B,CAAC;AAC/E,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,eAAe,CAAC;AACpE,gBAAgB;AAChB,eAAO,MAAM,gCAAgC,uBAAuB,CAAC;AACrE,gBAAgB;AAChB,eAAO,MAAM,2CAA2C,gCAAgC,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,CAAC;IAChG;;;;OAIG;IACH,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,Q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E,2BAA2B,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC7I;AAED,gBAAgB;AAChB,qBAAa,qCAAsC,YAAW,0BAA0B;IACtF,OAAO,CAAC,aAAa,CAAU;gBAEZ,KAAK,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE;IAK9C,6BAA6B,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAG1E,yBAAyB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAIhE,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAU/F,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAIrF,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,EAAE,GAAG,SAAS,CAAC;IAatH,mBAAmB,CAAC,UAAU,EAAE,2BAA2B,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1I"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Core
|
|
7
7
|
*/
|
|
@@ -37,9 +37,12 @@ export var DefaultFavoritePropertiesStorageTypes;
|
|
|
37
37
|
*/
|
|
38
38
|
export function createFavoritePropertiesStorage(type) {
|
|
39
39
|
switch (type) {
|
|
40
|
-
case DefaultFavoritePropertiesStorageTypes.Noop:
|
|
41
|
-
|
|
42
|
-
case DefaultFavoritePropertiesStorageTypes.
|
|
40
|
+
case DefaultFavoritePropertiesStorageTypes.Noop:
|
|
41
|
+
return new NoopFavoritePropertiesStorage();
|
|
42
|
+
case DefaultFavoritePropertiesStorageTypes.BrowserLocalStorage:
|
|
43
|
+
return new BrowserLocalFavoritePropertiesStorage();
|
|
44
|
+
case DefaultFavoritePropertiesStorageTypes.UserPreferencesStorage:
|
|
45
|
+
return new OfflineCachingFavoritePropertiesStorage({ impl: new IModelAppFavoritePropertiesStorage() });
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
@@ -48,13 +51,15 @@ export function createFavoritePropertiesStorage(type) {
|
|
|
48
51
|
export class IModelAppFavoritePropertiesStorage {
|
|
49
52
|
async ensureIsSignedIn() {
|
|
50
53
|
const accessToken = IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : "";
|
|
51
|
-
if (accessToken)
|
|
54
|
+
if (accessToken) {
|
|
52
55
|
return { accessToken };
|
|
56
|
+
}
|
|
53
57
|
throw new PresentationError(PresentationStatus.Error, "Current user is not authorized to use the settings service");
|
|
54
58
|
}
|
|
55
59
|
async loadProperties(iTwinId, imodelId) {
|
|
56
|
-
if (!IModelApp.userPreferences)
|
|
60
|
+
if (!IModelApp.userPreferences) {
|
|
57
61
|
throw new PresentationError(PresentationStatus.Error, "User preferences service is not set up");
|
|
62
|
+
}
|
|
58
63
|
const { accessToken } = await this.ensureIsSignedIn();
|
|
59
64
|
let setting = await IModelApp.userPreferences.get({
|
|
60
65
|
accessToken,
|
|
@@ -63,8 +68,9 @@ export class IModelAppFavoritePropertiesStorage {
|
|
|
63
68
|
namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,
|
|
64
69
|
key: FAVORITE_PROPERTIES_SETTING_NAME,
|
|
65
70
|
});
|
|
66
|
-
if (setting !== undefined)
|
|
71
|
+
if (setting !== undefined) {
|
|
67
72
|
return new Set(setting);
|
|
73
|
+
}
|
|
68
74
|
// try to check the old namespace
|
|
69
75
|
setting = await IModelApp.userPreferences.get({
|
|
70
76
|
accessToken,
|
|
@@ -73,13 +79,18 @@ export class IModelAppFavoritePropertiesStorage {
|
|
|
73
79
|
namespace: DEPRECATED_PROPERTIES_SETTING_NAMESPACE,
|
|
74
80
|
key: FAVORITE_PROPERTIES_SETTING_NAME,
|
|
75
81
|
});
|
|
76
|
-
if (setting !== undefined &&
|
|
82
|
+
if (setting !== undefined &&
|
|
83
|
+
setting.hasOwnProperty("nestedContentInfos") &&
|
|
84
|
+
setting.hasOwnProperty("propertyInfos") &&
|
|
85
|
+
setting.hasOwnProperty("baseFieldInfos")) {
|
|
77
86
|
return new Set([...setting.nestedContentInfos, ...setting.propertyInfos, ...setting.baseFieldInfos]);
|
|
87
|
+
}
|
|
78
88
|
return undefined;
|
|
79
89
|
}
|
|
80
90
|
async saveProperties(properties, iTwinId, imodelId) {
|
|
81
|
-
if (!IModelApp.userPreferences)
|
|
91
|
+
if (!IModelApp.userPreferences) {
|
|
82
92
|
throw new PresentationError(PresentationStatus.Error, "User preferences service is not set up");
|
|
93
|
+
}
|
|
83
94
|
const { accessToken } = await this.ensureIsSignedIn();
|
|
84
95
|
await IModelApp.userPreferences.save({
|
|
85
96
|
accessToken,
|
|
@@ -91,8 +102,9 @@ export class IModelAppFavoritePropertiesStorage {
|
|
|
91
102
|
});
|
|
92
103
|
}
|
|
93
104
|
async loadPropertiesOrder(iTwinId, imodelId) {
|
|
94
|
-
if (!IModelApp.userPreferences)
|
|
105
|
+
if (!IModelApp.userPreferences) {
|
|
95
106
|
throw new PresentationError(PresentationStatus.Error, "User preferences service is not set up");
|
|
107
|
+
}
|
|
96
108
|
const { accessToken } = await this.ensureIsSignedIn();
|
|
97
109
|
const setting = await IModelApp.userPreferences.get({
|
|
98
110
|
accessToken,
|
|
@@ -104,8 +116,9 @@ export class IModelAppFavoritePropertiesStorage {
|
|
|
104
116
|
return setting;
|
|
105
117
|
}
|
|
106
118
|
async savePropertiesOrder(orderInfos, iTwinId, imodelId) {
|
|
107
|
-
if (!IModelApp.userPreferences)
|
|
119
|
+
if (!IModelApp.userPreferences) {
|
|
108
120
|
throw new PresentationError(PresentationStatus.Error, "User preferences service is not set up");
|
|
121
|
+
}
|
|
109
122
|
const { accessToken } = await this.ensureIsSignedIn();
|
|
110
123
|
await IModelApp.userPreferences.save({
|
|
111
124
|
accessToken,
|
|
@@ -142,10 +155,13 @@ export class OfflineCachingFavoritePropertiesStorage {
|
|
|
142
155
|
this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);
|
|
143
156
|
}
|
|
144
157
|
dispose() {
|
|
145
|
-
if (isIDisposable(this._connectivityInfo))
|
|
158
|
+
if (isIDisposable(this._connectivityInfo)) {
|
|
146
159
|
this._connectivityInfo.dispose();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
get impl() {
|
|
163
|
+
return this._impl;
|
|
147
164
|
}
|
|
148
|
-
get impl() { return this._impl; }
|
|
149
165
|
async loadProperties(iTwinId, imodelId) {
|
|
150
166
|
if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {
|
|
151
167
|
try {
|
|
@@ -203,12 +219,15 @@ class DictionaryWithReservations {
|
|
|
203
219
|
constructor(compareKeys) {
|
|
204
220
|
this._impl = new Dictionary(compareKeys);
|
|
205
221
|
}
|
|
206
|
-
get(key) {
|
|
222
|
+
get(key) {
|
|
223
|
+
return this._impl.get(key)?.value;
|
|
224
|
+
}
|
|
207
225
|
forEach(func) {
|
|
208
226
|
this._impl.forEach((key, entry) => {
|
|
209
227
|
// istanbul ignore else
|
|
210
|
-
if (entry.value)
|
|
228
|
+
if (entry.value) {
|
|
211
229
|
func(key, entry.value);
|
|
230
|
+
}
|
|
212
231
|
});
|
|
213
232
|
}
|
|
214
233
|
reserve(key) {
|
|
@@ -216,31 +235,39 @@ class DictionaryWithReservations {
|
|
|
216
235
|
this._impl.set(key, { lastReservationId: reservationId });
|
|
217
236
|
return reservationId;
|
|
218
237
|
}
|
|
219
|
-
set(key, value) {
|
|
238
|
+
set(key, value) {
|
|
239
|
+
return this._impl.set(key, { value });
|
|
240
|
+
}
|
|
220
241
|
reservedSet(key, value, reservationId) {
|
|
221
242
|
const entry = this._impl.get(key);
|
|
222
|
-
if (entry && entry.lastReservationId === reservationId)
|
|
243
|
+
if (entry && entry.lastReservationId === reservationId) {
|
|
223
244
|
this._impl.set(key, { value });
|
|
245
|
+
}
|
|
224
246
|
}
|
|
225
247
|
reservedDelete(key, reservationId) {
|
|
226
248
|
const entry = this._impl.get(key);
|
|
227
|
-
if (entry && entry.lastReservationId === reservationId)
|
|
249
|
+
if (entry && entry.lastReservationId === reservationId) {
|
|
228
250
|
this._impl.delete(key);
|
|
251
|
+
}
|
|
229
252
|
}
|
|
230
253
|
}
|
|
231
254
|
// istanbul ignore next
|
|
232
255
|
function iTwinAndIModelIdsKeyComparer(lhs, rhs) {
|
|
233
256
|
const iTwinIdCompare = compareStrings(lhs[0] ?? "", rhs[0] ?? "");
|
|
234
|
-
return
|
|
257
|
+
return iTwinIdCompare !== 0 ? iTwinIdCompare : compareStrings(lhs[1] ?? "", rhs[1] ?? "");
|
|
235
258
|
}
|
|
236
259
|
/** @internal */
|
|
237
260
|
export class NoopFavoritePropertiesStorage {
|
|
238
261
|
// istanbul ignore next
|
|
239
|
-
async loadProperties(_iTwinId, _imodelId) {
|
|
262
|
+
async loadProperties(_iTwinId, _imodelId) {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
240
265
|
// istanbul ignore next
|
|
241
266
|
async saveProperties(_properties, _iTwinId, _imodelId) { }
|
|
242
267
|
// istanbul ignore next
|
|
243
|
-
async loadPropertiesOrder(_iTwinId, _imodelId) {
|
|
268
|
+
async loadPropertiesOrder(_iTwinId, _imodelId) {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
244
271
|
// istanbul ignore next
|
|
245
272
|
async savePropertiesOrder(_orderInfos, _iTwinId, _imodelId) { }
|
|
246
273
|
}
|
|
@@ -258,8 +285,9 @@ export class BrowserLocalFavoritePropertiesStorage {
|
|
|
258
285
|
}
|
|
259
286
|
async loadProperties(iTwinId, imodelId) {
|
|
260
287
|
const value = this._localStorage.getItem(this.createFavoritesSettingItemKey(iTwinId, imodelId));
|
|
261
|
-
if (!value)
|
|
288
|
+
if (!value) {
|
|
262
289
|
return undefined;
|
|
290
|
+
}
|
|
263
291
|
const properties = JSON.parse(value);
|
|
264
292
|
return new Set(properties);
|
|
265
293
|
}
|
|
@@ -268,8 +296,9 @@ export class BrowserLocalFavoritePropertiesStorage {
|
|
|
268
296
|
}
|
|
269
297
|
async loadPropertiesOrder(iTwinId, imodelId) {
|
|
270
298
|
const value = this._localStorage.getItem(this.createOrderSettingItemKey(iTwinId, imodelId));
|
|
271
|
-
if (!value)
|
|
299
|
+
if (!value) {
|
|
272
300
|
return undefined;
|
|
301
|
+
}
|
|
273
302
|
const orderInfos = JSON.parse(value).map((json) => ({
|
|
274
303
|
...json,
|
|
275
304
|
orderedTimestamp: new Date(json.orderedTimestamp),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertiesStorage.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAe,cAAc,EAAE,UAAU,EAAE,IAAI,EAAe,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AACnI,OAAO,EAAE,0BAA0B,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AAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK;YACR,OAAO,SAAS,CAAC;QAEnB,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","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, IDisposable, isIDisposable, 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: return new NoopFavoritePropertiesStorage();\n case DefaultFavoritePropertiesStorageTypes.BrowserLocalStorage: return new BrowserLocalFavoritePropertiesStorage();\n case DefaultFavoritePropertiesStorageTypes.UserPreferencesStorage: return new OfflineCachingFavoritePropertiesStorage({ impl: new IModelAppFavoritePropertiesStorage() });\n }\n}\n\n/**\n * @internal\n */\nexport class IModelAppFavoritePropertiesStorage implements IFavoritePropertiesStorage {\n\n private async ensureIsSignedIn(): Promise<{ accessToken: AccessToken }> {\n const accessToken = IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : \"\";\n if (accessToken)\n return { accessToken };\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 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 // 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 (setting !== undefined && setting.hasOwnProperty(\"nestedContentInfos\") && setting.hasOwnProperty(\"propertyInfos\") && setting.hasOwnProperty(\"baseFieldInfos\"))\n return new Set<PropertyFullName>([...setting.nestedContentInfos, ...setting.propertyInfos, ...setting.baseFieldInfos]);\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 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 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 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, IDisposable {\n\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 dispose() {\n if (isIDisposable(this._connectivityInfo))\n this._connectivityInfo.dispose();\n }\n\n public get impl() { return this._impl; }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\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}\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) { return this._impl.get(key)?.value; }\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 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) { return this._impl.set(key, { value }); }\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 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}\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> { return undefined; }\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> { return undefined; }\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 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 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"]}
|
|
1
|
+
{"version":3,"file":"FavoritePropertiesStorage.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAe,cAAc,EAAE,UAAU,EAAE,IAAI,EAAe,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AACnI,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACnF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AAC,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;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","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 // eslint-disable-next-line @typescript-eslint/naming-convention\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"]}
|