@itwin/presentation-frontend 4.0.0-dev.52 → 4.0.0-dev.55
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/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +47 -47
- package/lib/cjs/presentation-frontend/Diagnostics.d.ts +14 -14
- package/lib/cjs/presentation-frontend/Diagnostics.js +61 -61
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +20 -20
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +10 -10
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +41 -41
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +10 -10
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +31 -31
- package/lib/cjs/presentation-frontend/Presentation.d.ts +73 -73
- package/lib/cjs/presentation-frontend/Presentation.js +159 -159
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +205 -205
- package/lib/cjs/presentation-frontend/PresentationManager.js +438 -438
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.d.ts +63 -63
- package/lib/cjs/presentation-frontend/RulesetManager.js +85 -85
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +195 -195
- package/lib/cjs/presentation-frontend/StateTracker.d.ts +38 -38
- package/lib/cjs/presentation-frontend/StateTracker.js +128 -128
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +519 -519
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +290 -290
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +97 -97
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +9 -9
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +33 -33
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +108 -108
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +17 -17
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +40 -40
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +139 -139
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +414 -414
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +91 -91
- package/lib/cjs/presentation-frontend.d.ts +34 -34
- package/lib/cjs/presentation-frontend.js +54 -50
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +43 -43
- package/lib/esm/presentation-frontend/Diagnostics.d.ts +14 -14
- package/lib/esm/presentation-frontend/Diagnostics.js +56 -56
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +17 -17
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +10 -10
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +37 -37
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +10 -10
- package/lib/esm/presentation-frontend/LocalizationHelper.js +27 -27
- package/lib/esm/presentation-frontend/Presentation.d.ts +73 -73
- package/lib/esm/presentation-frontend/Presentation.js +155 -155
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +205 -205
- package/lib/esm/presentation-frontend/PresentationManager.js +433 -433
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.d.ts +63 -63
- package/lib/esm/presentation-frontend/RulesetManager.js +81 -81
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +191 -191
- package/lib/esm/presentation-frontend/StateTracker.d.ts +38 -38
- package/lib/esm/presentation-frontend/StateTracker.js +124 -124
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +514 -513
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +282 -282
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +93 -93
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +8 -8
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +29 -29
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +104 -104
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +17 -17
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +36 -36
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +139 -139
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +409 -409
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +85 -85
- package/lib/esm/presentation-frontend.d.ts +34 -34
- package/lib/esm/presentation-frontend.js +38 -38
- package/package.json +15 -15
|
@@ -1,192 +1,192 @@
|
|
|
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module Core
|
|
7
|
-
*/
|
|
8
|
-
import { assert, BeEvent, Id64, OrderedId64Iterable } from "@itwin/core-bentley";
|
|
9
|
-
import { VariableValueTypes } from "@itwin/presentation-common";
|
|
10
|
-
/** @internal */
|
|
11
|
-
export class RulesetVariablesManagerImpl {
|
|
12
|
-
constructor(rulesetId, ipcHandler) {
|
|
13
|
-
this._clientValues = new Map();
|
|
14
|
-
this.onVariableChanged = new BeEvent();
|
|
15
|
-
this._rulesetId = rulesetId;
|
|
16
|
-
this._ipcHandler = ipcHandler;
|
|
17
|
-
}
|
|
18
|
-
getAllVariables() {
|
|
19
|
-
const variables = [];
|
|
20
|
-
for (const entry of this._clientValues)
|
|
21
|
-
variables.push(entry[1]);
|
|
22
|
-
return variables;
|
|
23
|
-
}
|
|
24
|
-
changeValueType(variable, toType) {
|
|
25
|
-
switch (toType) {
|
|
26
|
-
case VariableValueTypes.Bool:
|
|
27
|
-
switch (variable.type) {
|
|
28
|
-
case VariableValueTypes.Int: return (0 !== variable.value);
|
|
29
|
-
case VariableValueTypes.Id64: return Id64.isValidId64(variable.value);
|
|
30
|
-
default: return undefined;
|
|
31
|
-
}
|
|
32
|
-
case VariableValueTypes.Int:
|
|
33
|
-
switch (variable.type) {
|
|
34
|
-
case VariableValueTypes.Bool: return variable.value ? 1 : 0;
|
|
35
|
-
case VariableValueTypes.Id64: return Id64.getUpperUint32(variable.value);
|
|
36
|
-
default: return undefined;
|
|
37
|
-
}
|
|
38
|
-
case VariableValueTypes.IntArray:
|
|
39
|
-
switch (variable.type) {
|
|
40
|
-
case VariableValueTypes.Id64Array: return variable.value.map((id) => Id64.getUpperUint32(id));
|
|
41
|
-
default: return undefined;
|
|
42
|
-
}
|
|
43
|
-
case VariableValueTypes.Id64:
|
|
44
|
-
switch (variable.type) {
|
|
45
|
-
case VariableValueTypes.Bool: return Id64.fromLocalAndBriefcaseIds(variable.value ? 1 : 0, 0);
|
|
46
|
-
case VariableValueTypes.Int: return Id64.fromLocalAndBriefcaseIds(variable.value, 0);
|
|
47
|
-
default: return undefined;
|
|
48
|
-
}
|
|
49
|
-
case VariableValueTypes.Id64Array:
|
|
50
|
-
switch (variable.type) {
|
|
51
|
-
case VariableValueTypes.IntArray: return variable.value.map((int) => Id64.fromLocalAndBriefcaseIds(int, 0));
|
|
52
|
-
default: return undefined;
|
|
53
|
-
}
|
|
54
|
-
case VariableValueTypes.String:
|
|
55
|
-
switch (variable.type) {
|
|
56
|
-
case VariableValueTypes.IntArray:
|
|
57
|
-
case VariableValueTypes.Id64Array:
|
|
58
|
-
return undefined;
|
|
59
|
-
default: variable.value.toString();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
async getValue(id, type) {
|
|
65
|
-
const variable = this._clientValues.get(id);
|
|
66
|
-
if (!variable)
|
|
67
|
-
return undefined;
|
|
68
|
-
if (variable.type !== type)
|
|
69
|
-
return this.changeValueType(variable, type);
|
|
70
|
-
return variable.value;
|
|
71
|
-
}
|
|
72
|
-
async setValue(variable) {
|
|
73
|
-
const oldVariable = this._clientValues.get(variable.id);
|
|
74
|
-
if (oldVariable && variablesEqual(oldVariable, variable))
|
|
75
|
-
return;
|
|
76
|
-
this._clientValues.set(variable.id, variable);
|
|
77
|
-
if (this._ipcHandler) {
|
|
78
|
-
await this._ipcHandler.setRulesetVariable({ rulesetId: this._rulesetId, variable });
|
|
79
|
-
}
|
|
80
|
-
this.onVariableChanged.raiseEvent(variable.id, oldVariable?.value, variable.value);
|
|
81
|
-
}
|
|
82
|
-
async unset(variableId) {
|
|
83
|
-
const variable = this._clientValues.get(variableId);
|
|
84
|
-
if (variable === undefined)
|
|
85
|
-
return;
|
|
86
|
-
this._clientValues.delete(variable.id);
|
|
87
|
-
if (this._ipcHandler) {
|
|
88
|
-
await this._ipcHandler.unsetRulesetVariable({ rulesetId: this._rulesetId, variableId });
|
|
89
|
-
}
|
|
90
|
-
this.onVariableChanged.raiseEvent(variable.id, variable.value, undefined);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Retrieves `string` variable value.
|
|
94
|
-
* Returns empty string if variable does not exist or does not convert to string.
|
|
95
|
-
*/
|
|
96
|
-
async getString(variableId) {
|
|
97
|
-
return await this.getValue(variableId, VariableValueTypes.String) || "";
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Sets `string` variable value
|
|
101
|
-
*/
|
|
102
|
-
async setString(variableId, value) {
|
|
103
|
-
await this.setValue({ id: variableId, type: VariableValueTypes.String, value });
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Retrieves `boolean` variable value.
|
|
107
|
-
* Returns `false` if variable does not exist or does not convert to boolean.
|
|
108
|
-
*/
|
|
109
|
-
async getBool(variableId) {
|
|
110
|
-
return await this.getValue(variableId, VariableValueTypes.Bool) || false;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Sets `boolean` variable value
|
|
114
|
-
*/
|
|
115
|
-
async setBool(variableId, value) {
|
|
116
|
-
await this.setValue({ id: variableId, type: VariableValueTypes.Bool, value });
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Retrieves `number` variable value.
|
|
120
|
-
* Returns `0` if variable does not exist or does not convert to integer.
|
|
121
|
-
*/
|
|
122
|
-
async getInt(variableId) {
|
|
123
|
-
return await this.getValue(variableId, VariableValueTypes.Int) || 0;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Sets `number` variable value
|
|
127
|
-
*/
|
|
128
|
-
async setInt(variableId, value) {
|
|
129
|
-
await this.setValue({ id: variableId, type: VariableValueTypes.Int, value });
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Retrieves `number[]` variable value.
|
|
133
|
-
* Returns empty array if variable does not exist or does not convert to integer array.
|
|
134
|
-
*/
|
|
135
|
-
async getInts(variableId) {
|
|
136
|
-
return await this.getValue(variableId, VariableValueTypes.IntArray) || [];
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Sets `number[]` variable value
|
|
140
|
-
*/
|
|
141
|
-
async setInts(variableId, value) {
|
|
142
|
-
await this.setValue({ id: variableId, type: VariableValueTypes.IntArray, value: [...value] });
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Retrieves `Id64String` variable value.
|
|
146
|
-
* Returns invalid Id64String if variable does not exist or does not convert to Id64String.
|
|
147
|
-
*/
|
|
148
|
-
async getId64(variableId) {
|
|
149
|
-
return await this.getValue(variableId, VariableValueTypes.Id64) || Id64.invalid;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Sets `Id64String` variable value
|
|
153
|
-
*/
|
|
154
|
-
async setId64(variableId, value) {
|
|
155
|
-
await this.setValue({ id: variableId, type: VariableValueTypes.Id64, value });
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Retrieves `Id64String[]` variable value.
|
|
159
|
-
* Returns empty array if variable does not exist or does not convert to Id64String array.
|
|
160
|
-
*/
|
|
161
|
-
async getId64s(variableId) {
|
|
162
|
-
return await this.getValue(variableId, VariableValueTypes.Id64Array) || [];
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Sets `Id64String[]` variable value
|
|
166
|
-
*/
|
|
167
|
-
async setId64s(variableId, value) {
|
|
168
|
-
await this.setValue({ id: variableId, type: VariableValueTypes.Id64Array, value: [...OrderedId64Iterable.sortArray(value)] });
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function variablesEqual(lhs, rhs) {
|
|
172
|
-
if (lhs.type !== rhs.type)
|
|
173
|
-
return false;
|
|
174
|
-
switch (lhs.type) {
|
|
175
|
-
case VariableValueTypes.IntArray:
|
|
176
|
-
case VariableValueTypes.Id64Array:
|
|
177
|
-
assert(rhs.type === lhs.type);
|
|
178
|
-
return arraysEqual(lhs.value, rhs.value);
|
|
179
|
-
default:
|
|
180
|
-
return lhs.value === rhs.value;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function arraysEqual(lhs, rhs) {
|
|
184
|
-
if (lhs.length !== rhs.length)
|
|
185
|
-
return false;
|
|
186
|
-
for (let i = 0; i < lhs.length; ++i) {
|
|
187
|
-
if (lhs[i] !== rhs[i])
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
return true;
|
|
191
|
-
}
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Core
|
|
7
|
+
*/
|
|
8
|
+
import { assert, BeEvent, Id64, OrderedId64Iterable } from "@itwin/core-bentley";
|
|
9
|
+
import { VariableValueTypes } from "@itwin/presentation-common";
|
|
10
|
+
/** @internal */
|
|
11
|
+
export class RulesetVariablesManagerImpl {
|
|
12
|
+
constructor(rulesetId, ipcHandler) {
|
|
13
|
+
this._clientValues = new Map();
|
|
14
|
+
this.onVariableChanged = new BeEvent();
|
|
15
|
+
this._rulesetId = rulesetId;
|
|
16
|
+
this._ipcHandler = ipcHandler;
|
|
17
|
+
}
|
|
18
|
+
getAllVariables() {
|
|
19
|
+
const variables = [];
|
|
20
|
+
for (const entry of this._clientValues)
|
|
21
|
+
variables.push(entry[1]);
|
|
22
|
+
return variables;
|
|
23
|
+
}
|
|
24
|
+
changeValueType(variable, toType) {
|
|
25
|
+
switch (toType) {
|
|
26
|
+
case VariableValueTypes.Bool:
|
|
27
|
+
switch (variable.type) {
|
|
28
|
+
case VariableValueTypes.Int: return (0 !== variable.value);
|
|
29
|
+
case VariableValueTypes.Id64: return Id64.isValidId64(variable.value);
|
|
30
|
+
default: return undefined;
|
|
31
|
+
}
|
|
32
|
+
case VariableValueTypes.Int:
|
|
33
|
+
switch (variable.type) {
|
|
34
|
+
case VariableValueTypes.Bool: return variable.value ? 1 : 0;
|
|
35
|
+
case VariableValueTypes.Id64: return Id64.getUpperUint32(variable.value);
|
|
36
|
+
default: return undefined;
|
|
37
|
+
}
|
|
38
|
+
case VariableValueTypes.IntArray:
|
|
39
|
+
switch (variable.type) {
|
|
40
|
+
case VariableValueTypes.Id64Array: return variable.value.map((id) => Id64.getUpperUint32(id));
|
|
41
|
+
default: return undefined;
|
|
42
|
+
}
|
|
43
|
+
case VariableValueTypes.Id64:
|
|
44
|
+
switch (variable.type) {
|
|
45
|
+
case VariableValueTypes.Bool: return Id64.fromLocalAndBriefcaseIds(variable.value ? 1 : 0, 0);
|
|
46
|
+
case VariableValueTypes.Int: return Id64.fromLocalAndBriefcaseIds(variable.value, 0);
|
|
47
|
+
default: return undefined;
|
|
48
|
+
}
|
|
49
|
+
case VariableValueTypes.Id64Array:
|
|
50
|
+
switch (variable.type) {
|
|
51
|
+
case VariableValueTypes.IntArray: return variable.value.map((int) => Id64.fromLocalAndBriefcaseIds(int, 0));
|
|
52
|
+
default: return undefined;
|
|
53
|
+
}
|
|
54
|
+
case VariableValueTypes.String:
|
|
55
|
+
switch (variable.type) {
|
|
56
|
+
case VariableValueTypes.IntArray:
|
|
57
|
+
case VariableValueTypes.Id64Array:
|
|
58
|
+
return undefined;
|
|
59
|
+
default: variable.value.toString();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
async getValue(id, type) {
|
|
65
|
+
const variable = this._clientValues.get(id);
|
|
66
|
+
if (!variable)
|
|
67
|
+
return undefined;
|
|
68
|
+
if (variable.type !== type)
|
|
69
|
+
return this.changeValueType(variable, type);
|
|
70
|
+
return variable.value;
|
|
71
|
+
}
|
|
72
|
+
async setValue(variable) {
|
|
73
|
+
const oldVariable = this._clientValues.get(variable.id);
|
|
74
|
+
if (oldVariable && variablesEqual(oldVariable, variable))
|
|
75
|
+
return;
|
|
76
|
+
this._clientValues.set(variable.id, variable);
|
|
77
|
+
if (this._ipcHandler) {
|
|
78
|
+
await this._ipcHandler.setRulesetVariable({ rulesetId: this._rulesetId, variable });
|
|
79
|
+
}
|
|
80
|
+
this.onVariableChanged.raiseEvent(variable.id, oldVariable?.value, variable.value);
|
|
81
|
+
}
|
|
82
|
+
async unset(variableId) {
|
|
83
|
+
const variable = this._clientValues.get(variableId);
|
|
84
|
+
if (variable === undefined)
|
|
85
|
+
return;
|
|
86
|
+
this._clientValues.delete(variable.id);
|
|
87
|
+
if (this._ipcHandler) {
|
|
88
|
+
await this._ipcHandler.unsetRulesetVariable({ rulesetId: this._rulesetId, variableId });
|
|
89
|
+
}
|
|
90
|
+
this.onVariableChanged.raiseEvent(variable.id, variable.value, undefined);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves `string` variable value.
|
|
94
|
+
* Returns empty string if variable does not exist or does not convert to string.
|
|
95
|
+
*/
|
|
96
|
+
async getString(variableId) {
|
|
97
|
+
return await this.getValue(variableId, VariableValueTypes.String) || "";
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sets `string` variable value
|
|
101
|
+
*/
|
|
102
|
+
async setString(variableId, value) {
|
|
103
|
+
await this.setValue({ id: variableId, type: VariableValueTypes.String, value });
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Retrieves `boolean` variable value.
|
|
107
|
+
* Returns `false` if variable does not exist or does not convert to boolean.
|
|
108
|
+
*/
|
|
109
|
+
async getBool(variableId) {
|
|
110
|
+
return await this.getValue(variableId, VariableValueTypes.Bool) || false;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets `boolean` variable value
|
|
114
|
+
*/
|
|
115
|
+
async setBool(variableId, value) {
|
|
116
|
+
await this.setValue({ id: variableId, type: VariableValueTypes.Bool, value });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves `number` variable value.
|
|
120
|
+
* Returns `0` if variable does not exist or does not convert to integer.
|
|
121
|
+
*/
|
|
122
|
+
async getInt(variableId) {
|
|
123
|
+
return await this.getValue(variableId, VariableValueTypes.Int) || 0;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Sets `number` variable value
|
|
127
|
+
*/
|
|
128
|
+
async setInt(variableId, value) {
|
|
129
|
+
await this.setValue({ id: variableId, type: VariableValueTypes.Int, value });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves `number[]` variable value.
|
|
133
|
+
* Returns empty array if variable does not exist or does not convert to integer array.
|
|
134
|
+
*/
|
|
135
|
+
async getInts(variableId) {
|
|
136
|
+
return await this.getValue(variableId, VariableValueTypes.IntArray) || [];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sets `number[]` variable value
|
|
140
|
+
*/
|
|
141
|
+
async setInts(variableId, value) {
|
|
142
|
+
await this.setValue({ id: variableId, type: VariableValueTypes.IntArray, value: [...value] });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves `Id64String` variable value.
|
|
146
|
+
* Returns invalid Id64String if variable does not exist or does not convert to Id64String.
|
|
147
|
+
*/
|
|
148
|
+
async getId64(variableId) {
|
|
149
|
+
return await this.getValue(variableId, VariableValueTypes.Id64) || Id64.invalid;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Sets `Id64String` variable value
|
|
153
|
+
*/
|
|
154
|
+
async setId64(variableId, value) {
|
|
155
|
+
await this.setValue({ id: variableId, type: VariableValueTypes.Id64, value });
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves `Id64String[]` variable value.
|
|
159
|
+
* Returns empty array if variable does not exist or does not convert to Id64String array.
|
|
160
|
+
*/
|
|
161
|
+
async getId64s(variableId) {
|
|
162
|
+
return await this.getValue(variableId, VariableValueTypes.Id64Array) || [];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Sets `Id64String[]` variable value
|
|
166
|
+
*/
|
|
167
|
+
async setId64s(variableId, value) {
|
|
168
|
+
await this.setValue({ id: variableId, type: VariableValueTypes.Id64Array, value: [...OrderedId64Iterable.sortArray(value)] });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function variablesEqual(lhs, rhs) {
|
|
172
|
+
if (lhs.type !== rhs.type)
|
|
173
|
+
return false;
|
|
174
|
+
switch (lhs.type) {
|
|
175
|
+
case VariableValueTypes.IntArray:
|
|
176
|
+
case VariableValueTypes.Id64Array:
|
|
177
|
+
assert(rhs.type === lhs.type);
|
|
178
|
+
return arraysEqual(lhs.value, rhs.value);
|
|
179
|
+
default:
|
|
180
|
+
return lhs.value === rhs.value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function arraysEqual(lhs, rhs) {
|
|
184
|
+
if (lhs.length !== rhs.length)
|
|
185
|
+
return false;
|
|
186
|
+
for (let i = 0; i < lhs.length; ++i) {
|
|
187
|
+
if (lhs[i] !== rhs[i])
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
192
|
//# sourceMappingURL=RulesetVariablesManager.js.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Core
|
|
3
|
-
*/
|
|
4
|
-
import { IModelConnection } from "@itwin/core-frontend";
|
|
5
|
-
import { NodeKey } from "@itwin/presentation-common";
|
|
6
|
-
import { IpcRequestsHandler } from "./IpcRequestsHandler";
|
|
7
|
-
/**
|
|
8
|
-
* Data structure that describes information used by [[StateTracker]] to identify node.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export interface NodeIdentifier {
|
|
12
|
-
id: string;
|
|
13
|
-
key: NodeKey;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export interface NodeState {
|
|
19
|
-
isExpanded?: boolean;
|
|
20
|
-
instanceFilter?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
|
|
24
|
-
* just the state changes to the backend as soon as component sends in a new hierarchy state.
|
|
25
|
-
*
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare class StateTracker {
|
|
29
|
-
private _hierarchyStates;
|
|
30
|
-
private _ipcRequestsHandler;
|
|
31
|
-
constructor(ipcRequestsHandler: IpcRequestsHandler);
|
|
32
|
-
private updateHierarchyStateIfNeeded;
|
|
33
|
-
onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string): Promise<void>;
|
|
34
|
-
onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{
|
|
35
|
-
node: NodeIdentifier | undefined;
|
|
36
|
-
state: NodeState;
|
|
37
|
-
}>): Promise<void>;
|
|
38
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
5
|
+
import { NodeKey } from "@itwin/presentation-common";
|
|
6
|
+
import { IpcRequestsHandler } from "./IpcRequestsHandler";
|
|
7
|
+
/**
|
|
8
|
+
* Data structure that describes information used by [[StateTracker]] to identify node.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export interface NodeIdentifier {
|
|
12
|
+
id: string;
|
|
13
|
+
key: NodeKey;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export interface NodeState {
|
|
19
|
+
isExpanded?: boolean;
|
|
20
|
+
instanceFilter?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
|
|
24
|
+
* just the state changes to the backend as soon as component sends in a new hierarchy state.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare class StateTracker {
|
|
29
|
+
private _hierarchyStates;
|
|
30
|
+
private _ipcRequestsHandler;
|
|
31
|
+
constructor(ipcRequestsHandler: IpcRequestsHandler);
|
|
32
|
+
private updateHierarchyStateIfNeeded;
|
|
33
|
+
onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string): Promise<void>;
|
|
34
|
+
onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{
|
|
35
|
+
node: NodeIdentifier | undefined;
|
|
36
|
+
state: NodeState;
|
|
37
|
+
}>): Promise<void>;
|
|
38
|
+
}
|
|
39
39
|
//# sourceMappingURL=StateTracker.d.ts.map
|